-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(story-content): add story gallery and videos (#300)
* refactor(story-content): add styles for content images * refactor(story-content): add story gallery * refactor(story-content): add video component to stories * refactor(gallery): remove deprecated gallery component * refactor(story): remove unnecessary const
- Loading branch information
1 parent
a2f5a02
commit bfde718
Showing
8 changed files
with
137 additions
and
149 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
@require '../../../variables.styl' | ||
|
||
.content | ||
padding: emCalc(80px) emCalc(56px) | ||
color: $textWhite | ||
overflow-y: auto | ||
padding: emCalc(80px) emCalc(28px) 0 emCalc(56px) | ||
background-color: $black | ||
color: $textDefault | ||
line-height: emCalc(22px) | ||
|
||
h1 | ||
margin-top: 0 | ||
color: $textColor | ||
font-weight: bold | ||
font-size: emCalc(36px) | ||
font-family: NotesEsa | ||
line-height: emCalc(16px) | ||
|
||
p | ||
color: $textDefault | ||
line-height: emCalc(22px) | ||
img | ||
width: 50% | ||
|
||
.shortTextContent | ||
overflow-y: hidden | ||
padding-top: emCalc(30px) | ||
font-size: emCalc(32px) |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,92 @@ | ||
import React, {FunctionComponent} from 'react'; | ||
import React, {FunctionComponent, useState} from 'react'; | ||
import cx from 'classnames'; | ||
|
||
const StoryMedia: FunctionComponent = () => <div>media</div>; | ||
import {PreviousIcon} from '../icons/previous-icon'; | ||
import {NextIcon} from '../icons/next-icon'; | ||
import {FullscreenExitIcon} from '../icons/fullscreen-exit-icon'; | ||
import {FullscreenIcon} from '../icons/fullscreen-icon'; | ||
import {getStoryMediaUrl} from '../../libs/get-story-media-url'; | ||
|
||
import styles from './story-media.styl'; | ||
|
||
interface Props { | ||
images: string[]; | ||
storyId: string; | ||
} | ||
|
||
const StoryMedia: FunctionComponent<Props> = ({images, storyId}) => { | ||
const containerWidth = images.length * 100; | ||
const imageWidth = 100 / images.length; | ||
const [currentIndex, setCurrentIndex] = useState(0); | ||
const [showLightbox, setShowLightbox] = useState(false); | ||
const showPrevButton = currentIndex > 0; | ||
const showNextButton = currentIndex < images.length - 1; | ||
|
||
const onPrevClick = () => { | ||
if (currentIndex <= 0) { | ||
return; | ||
} | ||
setCurrentIndex(currentIndex - 1); | ||
}; | ||
|
||
const onNextClick = () => { | ||
if (currentIndex >= images.length - 1) { | ||
return; | ||
} | ||
setCurrentIndex(currentIndex + 1); | ||
}; | ||
|
||
const imgClasses = cx(styles.slider, images.length > 1 && styles.transition); | ||
const galleryClasses = cx( | ||
styles.storyGallery, | ||
showLightbox && styles.lightboxGallery | ||
); | ||
|
||
return ( | ||
<div className={styles.storyMedia}> | ||
<div className={galleryClasses}> | ||
<div className={styles.buttonContainer}> | ||
<div onClick={onPrevClick} className={styles.navIcon}> | ||
{showPrevButton ? <PreviousIcon /> : null} | ||
</div> | ||
<div onClick={onNextClick} className={styles.navIcon}> | ||
{showNextButton ? <NextIcon /> : null} | ||
</div> | ||
</div> | ||
{showLightbox ? ( | ||
<div | ||
className={styles.fullscreenIcon} | ||
onClick={() => setShowLightbox(false)}> | ||
<FullscreenExitIcon /> | ||
</div> | ||
) : ( | ||
<div | ||
className={styles.fullscreenIcon} | ||
onClick={() => setShowLightbox(true)}> | ||
<FullscreenIcon /> | ||
</div> | ||
)} | ||
<div | ||
className={imgClasses} | ||
style={{ | ||
width: `${containerWidth}%`, | ||
transform: `translateX(-${imageWidth * currentIndex}%)` | ||
}}> | ||
{images.map((image, index) => { | ||
const imageUrl = getStoryMediaUrl(storyId, image); | ||
return ( | ||
<img | ||
className={styles.sliderImage} | ||
src={imageUrl} | ||
key={index} | ||
style={{width: `${imageWidth}%`}} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default StoryMedia; |
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,4 +1,5 @@ | ||
@require '../../../variables.styl' | ||
|
||
.storyVideo | ||
flex-shrink: 0 | ||
width: 100% | ||
height: 300px | ||
padding: emCalc(80px) emCalc(56px) 0 emCalc(28px) | ||
height: emCalc(450px) |
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