fix different carousels named the exact same thing
This commit is contained in:
		
							parent
							
								
									52098a3e50
								
							
						
					
					
						commit
						bf20cf8f56
					
				@ -2,7 +2,7 @@ import { useRouter } from 'next/router'
 | 
				
			|||||||
import DesktopHeader from './desktop/header'
 | 
					import DesktopHeader from './desktop/header'
 | 
				
			||||||
import MobileHeader from './mobile/header'
 | 
					import MobileHeader from './mobile/header'
 | 
				
			||||||
import StickyBar from './sticky-bar'
 | 
					import StickyBar from './sticky-bar'
 | 
				
			||||||
import { CarouselProvider } from './carousel'
 | 
					import { PriceCarouselProvider } from './price-carousel'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function Navigation ({ sub }) {
 | 
					export default function Navigation ({ sub }) {
 | 
				
			||||||
  const router = useRouter()
 | 
					  const router = useRouter()
 | 
				
			||||||
@ -17,10 +17,10 @@ export default function Navigation ({ sub }) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <CarouselProvider>
 | 
					    <PriceCarouselProvider>
 | 
				
			||||||
      <DesktopHeader {...props} />
 | 
					      <DesktopHeader {...props} />
 | 
				
			||||||
      <MobileHeader {...props} />
 | 
					      <MobileHeader {...props} />
 | 
				
			||||||
      <StickyBar {...props} />
 | 
					      <StickyBar {...props} />
 | 
				
			||||||
    </CarouselProvider>
 | 
					    </PriceCarouselProvider>
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -12,12 +12,12 @@ const carousel = [
 | 
				
			|||||||
  'halving'
 | 
					  'halving'
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const CarouselContext = createContext({
 | 
					export const PriceCarouselContext = createContext({
 | 
				
			||||||
  selection: undefined,
 | 
					  selection: undefined,
 | 
				
			||||||
  handleClick: () => {}
 | 
					  handleClick: () => {}
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function CarouselProvider ({ children }) {
 | 
					export function PriceCarouselProvider ({ children }) {
 | 
				
			||||||
  const [selection, setSelection] = useState(undefined)
 | 
					  const [selection, setSelection] = useState(undefined)
 | 
				
			||||||
  const [pos, setPos] = useState(0)
 | 
					  const [pos, setPos] = useState(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -35,12 +35,12 @@ export function CarouselProvider ({ children }) {
 | 
				
			|||||||
  }, [pos])
 | 
					  }, [pos])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <CarouselContext.Provider value={[selection, handleClick]}>
 | 
					    <PriceCarouselContext.Provider value={[selection, handleClick]}>
 | 
				
			||||||
      {children}
 | 
					      {children}
 | 
				
			||||||
    </CarouselContext.Provider>
 | 
					    </PriceCarouselContext.Provider>
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useCarousel () {
 | 
					export function usePriceCarousel () {
 | 
				
			||||||
  return useContext(CarouselContext)
 | 
					  return useContext(PriceCarouselContext)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1,11 +1,11 @@
 | 
				
			|||||||
import { Container, Nav, Navbar } from 'react-bootstrap'
 | 
					import { Container, Nav, Navbar } from 'react-bootstrap'
 | 
				
			||||||
import styles from '../header.module.css'
 | 
					import styles from '../header.module.css'
 | 
				
			||||||
import { BackOrBrand, NavPrice, SearchItem } from './common'
 | 
					import { BackOrBrand, NavPrice, SearchItem } from './common'
 | 
				
			||||||
import { CarouselProvider } from './carousel'
 | 
					import { PriceCarouselProvider } from './price-carousel'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function StaticHeader () {
 | 
					export default function StaticHeader () {
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <CarouselProvider>
 | 
					    <PriceCarouselProvider>
 | 
				
			||||||
      <Container as='header' className='px-sm-0'>
 | 
					      <Container as='header' className='px-sm-0'>
 | 
				
			||||||
        <Navbar>
 | 
					        <Navbar>
 | 
				
			||||||
          <Nav
 | 
					          <Nav
 | 
				
			||||||
@ -17,6 +17,6 @@ export default function StaticHeader () {
 | 
				
			|||||||
          </Nav>
 | 
					          </Nav>
 | 
				
			||||||
        </Navbar>
 | 
					        </Navbar>
 | 
				
			||||||
      </Container>
 | 
					      </Container>
 | 
				
			||||||
    </CarouselProvider>
 | 
					    </PriceCarouselProvider>
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,7 @@ import { NORMAL_POLL_INTERVAL, SSR } from '@/lib/constants'
 | 
				
			|||||||
import { useBlockHeight } from './block-height'
 | 
					import { useBlockHeight } from './block-height'
 | 
				
			||||||
import { useChainFee } from './chain-fee'
 | 
					import { useChainFee } from './chain-fee'
 | 
				
			||||||
import { CompactLongCountdown } from './countdown'
 | 
					import { CompactLongCountdown } from './countdown'
 | 
				
			||||||
import { useCarousel } from './nav/carousel'
 | 
					import { usePriceCarousel } from './nav/price-carousel'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const PriceContext = React.createContext({
 | 
					export const PriceContext = React.createContext({
 | 
				
			||||||
  price: null,
 | 
					  price: null,
 | 
				
			||||||
@ -45,7 +45,7 @@ export function PriceProvider ({ price, children }) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function Price ({ className }) {
 | 
					export default function Price ({ className }) {
 | 
				
			||||||
  const [selection, handleClick] = useCarousel()
 | 
					  const [selection, handleClick] = usePriceCarousel()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const { price, fiatSymbol } = usePrice()
 | 
					  const { price, fiatSymbol } = usePrice()
 | 
				
			||||||
  const { height: blockHeight, halving } = useBlockHeight()
 | 
					  const { height: blockHeight, halving } = useBlockHeight()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user