Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"react-use": "^15.3.4",
"react-waypoint": "^9.0.3",
"react-youtube": "^7.12.0",
"react-youtube-background": "^1.0.0",
"slick-carousel": "^1.8.1",
"styled-components": "^5.2.0",
"styled-system": "^5.1.5",
Expand Down
1,067 changes: 1,066 additions & 1 deletion src/components/Icon/selection.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/components/Slider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Les propriétés de **`Slide`** :
| subtitle | La section subtitle du slide | `JSX Componant` | `null` |
| content | Le contneu du slide | `JSX Componant` | `null` |
| bgImage | Indique l'image du background du slide | `string` | `null` |
| bgVideo | Indique la video du background du slide | `string` | `null` |
| videoId | Indique la video du youtube integrer sur slide | `string` | `null` |
| bgVideoId | Indique la video youtube en background du slide | `string` | `null` |
| Box's props | | | |


Expand Down
44 changes: 42 additions & 2 deletions src/components/Slider/Slide.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useRef, useEffect } from 'react';
import { Box } from '../Box';
import YouTube from 'react-youtube';
import YoutubeBackground from 'react-youtube-background';
import { findParentByMatchedQuery } from '../../core';


Expand Down Expand Up @@ -62,8 +63,46 @@ const SlideVideo = ({ videoId, sx, variant, opt, ...rest }) => {
</Box>
}

const SlideBgVideo = ({ bgVideoId, sx, variant, opt, ...rest }) => {

export const Slide = ({ children, isActive = false, subtitle = null, content = null, bgImage = null, videoId = null, ...rest }) => {
const options = {
height: '100%',
width: '100%',
playerVars: {
autoplay: 1,
loop: 1,
controls: 0,
rel: 0,
showinfo: 0
},

...opt
}

return <Box __css={{
width: '100%',
height: '100%',
background: '0 0',
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
overflow: 'hidden',
'& > div:first-child, & iframe': {
height: '100%',
width: '100%'
},

}}
variant={variant}
sx={variant}
>
<YoutubeBackground {...rest} opt={options} videoId={bgVideoId} />
</Box>
}


export const Slide = ({ children, isActive = false, subtitle = null, content = null, bgImage = null, videoId = null, bgVideoId = null, ...rest }) => {

const ref = useRef(null);
const refVideo = useRef(null);
Expand Down Expand Up @@ -109,7 +148,8 @@ export const Slide = ({ children, isActive = false, subtitle = null, content = n
}
}} {...rest}>

{videoId && <SlideVideo videoId={videoId} onReady={onVideoReady} />}
{bgVideoId && <SlideBgVideo bgVideoId={bgVideoId} onReady={onVideoReady} />}
{(videoId && !bgVideoId) && <SlideVideo videoId={videoId} onReady={onVideoReady} />}
{subtitle && <SlideSubtitle subtitle={subtitle} />}
{bgImage && <SlideIamge imageSrc={bgImage} />}
{content && <Box sx={{
Expand Down
193 changes: 97 additions & 96 deletions src/components/Slider/stories/slider.stories.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useContext } from 'react';
import { Box, Flex } from '../../Box';
import { Icon } from '../../Icon';
import { useInterval } from 'react-use';
import { Tab, Tabs } from '../../Tabs';
import { Container } from '../../Grid';
import { MotionBox } from '../../Animation';
import { Slider, PrevArrow, NextArrow, appendDots } from '../Slider';
import { Slide } from '../Slide';
import React, {useContext} from 'react';
import {Box, Flex} from '../../Box';
import {Icon} from '../../Icon';
import {useInterval} from 'react-use';
import {Tab, Tabs} from '../../Tabs';
import {Container} from '../../Grid';
import {MotionBox} from '../../Animation';
import {Slider, PrevArrow, NextArrow, appendDots} from '../Slider';
import {Slide} from '../Slide';
import {theme} from '../../../theme'

// export const SlideWithTabs = () => {
Expand Down Expand Up @@ -58,102 +58,103 @@ import {theme} from '../../../theme'
// }




const SlideContent = ({isActive, ...rest}) => <Flex sx={{
alignItems: 'center',
justofyContent: 'center',
width: '100%',
height: '100%',
alignItems: 'center',
justofyContent: 'center',
width: '100%',
height: '100%',
}}>
<Container>
<MotionBox animate={isActive ? 'show' : 'hide'} initial='hide' transition={{ ease: "easeOut", duration: .5 }} variants={{show:{opacity:1, y:0}, hide:{opacity:0, y:100}}}>
<Box sx={{ textAlign: 'center', mx: ["3rem", '1.5rem']}}>
<Box as="span"
sx={{
color: 'white',
display: ['none', null, 'inline-block'],
position: 'relative',
textTransform: 'uppercase',
fontSize: '1.125rem',
lineHeight: '1.5rem',
marginBottom: '.3125rem',

}}>Offre du moment</Box>
<Box as="h2"
sx={{
color: 'white',
fontSize: ['2rem', null, '2.5rem'],
lineHeight: ['2.25rem', null, '2.375rem'],
marginBottom: ['1.5625rem', null, '.4375rem'],
fontWeight: 800,
}}>Restez chez vous, nous venons vers vous !</Box>
<Box as="p" sx={{
color: "white",
width: ['100%'],
fontSize: ['1.2 rem', null, '1.25rem'],
lineHeight: [null, null, '1.4375rem']
}}>
Car votre santé est notre priorité.
</Box>
</Box>
</MotionBox>
</Container>
<Container>
<MotionBox animate={isActive ? 'show' : 'hide'} initial='hide' transition={{ease: "easeOut", duration: .5}}
variants={{show: {opacity: 1, y: 0}, hide: {opacity: 0, y: 100}}}>
<Box sx={{textAlign: 'center', mx: ["3rem", '1.5rem']}}>
<Box as="span"
sx={{
color: 'white',
display: ['none', null, 'inline-block'],
position: 'relative',
textTransform: 'uppercase',
fontSize: '1.125rem',
lineHeight: '1.5rem',
marginBottom: '.3125rem',

}}>Offre du moment</Box>
<Box as="h2"
sx={{
color: 'white',
fontSize: ['2rem', null, '2.5rem'],
lineHeight: ['2.25rem', null, '2.375rem'],
marginBottom: ['1.5625rem', null, '.4375rem'],
fontWeight: 800,
}}>Restez chez vous, nous venons vers vous !</Box>
<Box as="p" sx={{
color: "white",
width: ['100%'],
fontSize: ['1.2 rem', null, '1.25rem'],
lineHeight: [null, null, '1.4375rem']
}}>
Car votre santé est notre priorité.
</Box>
</Box>
</MotionBox>
</Container>
</Flex>


export const RichSlider = () => {

const [activeSlide, setActiveSlide] = React.useState(0);

const settings = {
dots: false,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
centerPadding: '0px',
centerMode: false,
nextArrow: <NextArrow />,
prevArrow: <PrevArrow />,

responsive: [
{
breakpoint: theme.breakpoints.md,
settings: {
centerPadding: '40px',
centerMode: true,
arrows: false,
dots: true,
dotsClass: 'slick-dots',
appendDots: appendDots
},

}
]
}

return <Box>
<Slider {...settings} afterChange={index => setActiveSlide(index)}>
<Slide isActive={activeSlide === 0}
videoId="hwXhgwBbUO8"/>

<Slide isActive={activeSlide === 1}
bgImage="https://images.unsplash.com/photo-1588613254750-cf5d89a29b66?ixlib=rb-1.2.1&auto=format&fit=crop&w=1357&q=80"
content={<SlideContent isActive={activeSlide === 1}/>} />

<Slide isActive={activeSlide === 2}
bgImage="https://images.unsplash.com/photo-1588776844919-5ed4449a8fd7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3200&q=80"
content={<SlideContent isActive={activeSlide === 2}/>} />
</Slider>

</Box>
const [activeSlide, setActiveSlide] = React.useState(0);

const settings = {
dots: false,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
centerPadding: '0px',
centerMode: false,
nextArrow: <NextArrow/>,
prevArrow: <PrevArrow/>,

responsive: [
{
breakpoint: theme.breakpoints.md,
settings: {
centerPadding: '40px',
centerMode: true,
arrows: false,
dots: true,
dotsClass: 'slick-dots',
appendDots: appendDots
},

}
]
}

return <Box>
<Slider {...settings} afterChange={index => setActiveSlide(index)}>
<Slide isActive={activeSlide === 0}
bgVideoId="hwXhgwBbUO8"
content={<SlideContent isActive={activeSlide === 0}/>}/>

<Slide isActive={activeSlide === 1}
videoId="hwXhgwBbUO8"/>

<Slide isActive={activeSlide === 2}
bgImage="https://images.unsplash.com/photo-1588613254750-cf5d89a29b66?ixlib=rb-1.2.1&auto=format&fit=crop&w=1357&q=80"
content={<SlideContent isActive={activeSlide === 2}/>}/>

<Slide isActive={activeSlide === 3}
bgImage="https://images.unsplash.com/photo-1588776844919-5ed4449a8fd7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3200&q=80"
content={<SlideContent isActive={activeSlide === 3}/>}/>
</Slider>

</Box>
}




export default {
title: 'Components/Slider',
title: 'Components/Slider',
};
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13783,6 +13783,11 @@ react-waypoint@^9.0.3:
prop-types "^15.0.0"
react-is "^16.6.3"

react-youtube-background@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/react-youtube-background/-/react-youtube-background-1.0.0.tgz#b9bd4cbc425fdc74c80496f99b0a5b4fb7086814"
integrity sha512-EEnpEyPAjUIMi1QJM620r6NdBDHuC7Dg12/B3L8m0mA1hqYDCLOdEq0rjbk9demX7bVXQAU5zuRQ0MXpWoFY+w==

react-youtube@^7.12.0:
version "7.12.0"
resolved "https://registry.yarnpkg.com/react-youtube/-/react-youtube-7.12.0.tgz#632b770556fd415179093e4a6eeea36d109fb3d4"
Expand Down