-
Notifications
You must be signed in to change notification settings - Fork 0
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
206b4a4
commit aefe23b
Showing
10 changed files
with
204 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.dimmed { | ||
position: fixed; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
background-color: #000; | ||
z-index: 9999; | ||
|
||
.icon-close { | ||
width: 20px; | ||
height: 20px; | ||
fill: #fff; | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
z-index: 2; | ||
} | ||
} |
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,61 @@ | ||
import { Swiper, SwiperSlide } from 'swiper/react' | ||
import classNames from 'classnames/bind' | ||
|
||
import styles from './ImageViewer.module.scss' | ||
import 'swiper/css' | ||
import './swiper.css' | ||
|
||
const cx = classNames.bind(styles) | ||
|
||
function ImageViewer({ | ||
images, | ||
open = false, | ||
selectedIdx, | ||
onClose, | ||
}: { | ||
images: string[] | ||
open: boolean | ||
selectedIdx: number | ||
onClose: () => void | ||
}) { | ||
if (open === false) return null | ||
|
||
return ( | ||
<div className={cx('dimmed')}> | ||
<CloseButton className={cx('icon-close')} onClose={onClose} /> | ||
<Swiper | ||
spaceBetween={20} | ||
slidesPerView={1} | ||
loop | ||
initialSlide={selectedIdx} | ||
> | ||
{images.map((src, index) => ( | ||
<SwiperSlide key={index}> | ||
<img src={src} alt="이미지 뷰어" /> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
</div> | ||
) | ||
} | ||
|
||
function CloseButton({ | ||
onClose, | ||
className, | ||
}: { | ||
onClose: () => void | ||
className: string | ||
}) { | ||
return ( | ||
<svg | ||
className={className} | ||
onClick={onClose} | ||
viewBox="0 0 20 20" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm1.41-1.41A8 8 0 1 0 15.66 4.34 8 8 0 0 0 4.34 15.66zm9.9-8.49L11.41 10l2.83 2.83-1.41 1.41L10 11.41l-2.83 2.83-1.41-1.41L8.59 10 5.76 7.17l1.41-1.41L10 8.59l2.83-2.83 1.41 1.41z" /> | ||
</svg> | ||
) | ||
} | ||
|
||
export default ImageViewer |
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,15 @@ | ||
.swiper, | ||
.swiper-wrapper { | ||
height: 100% !important; | ||
} | ||
|
||
.swiper-slide { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
} | ||
|
||
.swiper-slide img { | ||
width: 100%; | ||
} |
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,26 @@ | ||
.wrap-images { | ||
display: grid; | ||
grid-template-columns: repeat(3, 1fr); | ||
gap: 6px; | ||
|
||
.wrap-image { | ||
|
||
width: 100%; | ||
position: relative; | ||
|
||
&::after { | ||
display: block; | ||
content: ""; | ||
padding-bottom: 100%; | ||
} | ||
|
||
img { | ||
width: 100%; | ||
height: 100%; | ||
left: 0; | ||
position: absolute; | ||
object-fit: cover; | ||
border-radius: 8px; | ||
} | ||
} | ||
} |
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,51 @@ | ||
import classNames from 'classnames/bind' | ||
import { useState } from 'react' | ||
import ImageViewer from '../imageViewer' | ||
import Section from '../shared/Section' | ||
import styles from './ImageGallery.module.scss' | ||
|
||
type Props = { | ||
images: string[] | ||
} | ||
|
||
const cx = classNames.bind(styles) | ||
|
||
function ImageGallery({ images }: Props) { | ||
const [selectedIdx, setSelectedIdx] = useState<number>(-1) | ||
|
||
const open = selectedIdx > -1 | ||
|
||
const handleSelectedImage = (idx: number) => { | ||
setSelectedIdx(idx) | ||
} | ||
|
||
const handleClose = () => { | ||
setSelectedIdx(-1) | ||
} | ||
|
||
return ( | ||
<> | ||
<Section title="사진첩"> | ||
<ul className={cx('wrap-images')}> | ||
{images.map((src, index) => ( | ||
<li | ||
key={index} | ||
className={cx('wrap-image')} | ||
onClick={() => handleSelectedImage(index)} | ||
> | ||
<img src={src} alt="사진첩 이미지" /> | ||
</li> | ||
))} | ||
</ul> | ||
</Section> | ||
<ImageViewer | ||
images={images} | ||
open={open} | ||
selectedIdx={selectedIdx} | ||
onClose={handleClose} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default ImageGallery |
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,5 @@ | ||
.container { | ||
video { | ||
width: 100%; | ||
} | ||
} |
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,9 +1,17 @@ | ||
import classNames from 'classnames/bind' | ||
import Section from '../shared/Section' | ||
import styles from './Video.module.scss' | ||
|
||
// const cx = classNames.bind(styles) | ||
const cx = classNames.bind(styles) | ||
|
||
function Video() { | ||
return <Section>Heading</Section> | ||
return ( | ||
<Section className={cx('container')}> | ||
<video autoPlay muted loop poster="/assets/poster.jpg"> | ||
<source src="/assets/main.mp4" type="video/mp4" /> | ||
</video> | ||
</Section> | ||
) | ||
} | ||
|
||
export default Video |
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,3 +1,9 @@ | ||
.container { | ||
padding: 24px; | ||
|
||
.txt-title { | ||
font-size: 18px; | ||
font-weight: bold; | ||
margin-bottom: 24px; | ||
} | ||
} |
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