-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61c050c
commit 8eca652
Showing
58 changed files
with
1,042 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 1 addition & 9 deletions
10
packages/embla-carousel-auto-height/src/components/Options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
import { CreateOptionsType } from 'embla-carousel/components/Options' | ||
|
||
export type OptionsType = CreateOptionsType<{ | ||
destroyHeight: CSSStyleDeclaration['height'] | ||
}> | ||
|
||
export const defaultOptions: OptionsType = { | ||
active: true, | ||
breakpoints: {}, | ||
destroyHeight: 'auto' | ||
} | ||
export type OptionsType = CreateOptionsType<{}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/embla-carousel-docs/src/components/Examples/Plugins/Fade.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react' | ||
import { EmblaOptionsType } from 'embla-carousel' | ||
import styled from 'styled-components' | ||
import { useInView } from 'react-intersection-observer' | ||
import CarouselFade from 'components/Sandbox/React/SandboxFilesSrc/Fade/EmblaCarousel' | ||
import { examplesDefaultWrapperStyles } from 'components/Examples/examplesWrapperStyles' | ||
import { examplesCarouselFadeStyles } from 'components/Examples/examplesCarouselStyles' | ||
import { arrayFromNumber } from 'utils/arrayFromNumber' | ||
import { SandboxSelection } from 'components/Sandbox/SandboxSelection' | ||
import { sandboxStaticSandboxes } from 'components/Sandbox/sandboxStatic' | ||
import { SandboxStaticSettingsType } from 'consts/sandbox' | ||
import { EXAMPLES_INTERSECTION_OPTIONS } from 'consts/examples' | ||
|
||
const ID = 'embla-carousel-fade' | ||
const SLIDES = arrayFromNumber(5) | ||
const OPTIONS: EmblaOptionsType = { loop: true, duration: 40 } | ||
const STYLES = examplesCarouselFadeStyles() | ||
|
||
const SANDBOX_CONFIG: SandboxStaticSettingsType = { | ||
id: ID, | ||
slides: SLIDES, | ||
options: OPTIONS, | ||
styles: STYLES | ||
} | ||
|
||
const SANDBOXES = sandboxStaticSandboxes(SANDBOX_CONFIG, 'Fade') | ||
|
||
const Wrapper = styled.div` | ||
${examplesDefaultWrapperStyles}; | ||
&.${ID} { | ||
${STYLES}; | ||
} | ||
` | ||
|
||
export const Fade = () => { | ||
const [inViewRef, inView] = useInView(EXAMPLES_INTERSECTION_OPTIONS) | ||
|
||
return ( | ||
<> | ||
<SandboxSelection sandboxes={SANDBOXES} /> | ||
<Wrapper className={ID} ref={inViewRef}> | ||
{inView ? <CarouselFade slides={SLIDES} options={OPTIONS} /> : null} | ||
</Wrapper> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...s/embla-carousel-docs/src/components/Sandbox/React/SandboxFilesSrc/Fade/EmblaCarousel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react' | ||
import { EmblaOptionsType } from 'embla-carousel' | ||
import useEmblaCarousel from 'embla-carousel-react' | ||
import Fade from 'embla-carousel-fade' | ||
import { | ||
NextButton, | ||
PrevButton, | ||
usePrevNextButtons | ||
} from '../EmblaCarouselArrowButtons' | ||
import { DotButton, useDotButton } from '../EmblaCarouselDotButton' | ||
import { sandboxImages } from 'components/Sandbox/sandboxImages' | ||
|
||
type PropType = { | ||
slides: number[] | ||
options?: EmblaOptionsType | ||
} | ||
|
||
const EmblaCarousel: React.FC<PropType> = (props) => { | ||
const { slides, options } = props | ||
const [emblaRef, emblaApi] = useEmblaCarousel(options, [Fade()]) | ||
|
||
const { selectedIndex, scrollSnaps, onDotButtonClick } = | ||
useDotButton(emblaApi) | ||
|
||
const { | ||
prevBtnDisabled, | ||
nextBtnDisabled, | ||
onPrevButtonClick, | ||
onNextButtonClick | ||
} = usePrevNextButtons(emblaApi) | ||
|
||
return ( | ||
<div className="embla"> | ||
<div className="embla__viewport" ref={emblaRef}> | ||
<div className="embla__container"> | ||
{slides.map((index) => ( | ||
<div className="embla__slide" key={index}> | ||
<img | ||
className="embla__slide__img" | ||
src={sandboxImages(index)} | ||
alt="Your alt text" | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
|
||
<div className="embla__controls"> | ||
<div className="embla__buttons"> | ||
<PrevButton onClick={onPrevButtonClick} disabled={prevBtnDisabled} /> | ||
<NextButton onClick={onNextButtonClick} disabled={nextBtnDisabled} /> | ||
</div> | ||
|
||
<div className="embla__dots"> | ||
{scrollSnaps.map((_, index) => ( | ||
<DotButton | ||
key={index} | ||
onClick={() => onDotButtonClick(index)} | ||
className={'embla__dot'.concat( | ||
index === selectedIndex ? ' embla__dot--selected' : '' | ||
)} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default EmblaCarousel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.