-
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.
EPMGCIP-125/feature/add-image-gallery (#4)
Co-authored-by: Siarhei Balonikau <[email protected]>
- Loading branch information
Showing
15 changed files
with
2,957 additions
and
218 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
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 +1,7 @@ | ||
|
||
window.matchMedia = jest.fn().mockImplementation((query: string) => ({ | ||
matches: false, | ||
media: query, | ||
onchange: null, | ||
addListener: jest.fn(), | ||
removeListener: jest.fn(), | ||
})) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,6 @@ | |
} | ||
|
||
.logo { | ||
width: 44px; | ||
width: 68px; | ||
padding-top: 4px; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/components/organisms/ImageGallery/ImageGallery.module.css
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,23 @@ | ||
.image { | ||
width: 100%; | ||
height: 380px; | ||
object-fit: cover; | ||
object-position: center; | ||
} | ||
|
||
.imageWrapper { | ||
margin: 0 8px; | ||
border-radius: 28px; | ||
overflow: hidden; | ||
} | ||
|
||
.lightboxButton { | ||
width: 100%; | ||
padding: 0; | ||
border: none; | ||
background-color: transparent; | ||
} | ||
|
||
.lightboxButton:focus { | ||
outline: none; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/components/organisms/ImageGallery/ImageGallery.test.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,22 @@ | ||
import { render } from '@testing-library/react' | ||
import ImageGallery from './ImageGallery.tsx' | ||
import '@testing-library/jest-dom' | ||
|
||
const images = [ | ||
{ | ||
url: './picture1.png', | ||
id: '1', | ||
}, | ||
{ | ||
url: './picture2.png', | ||
id: '2', | ||
}, | ||
] | ||
|
||
describe('ImageGallery', () => { | ||
it('renders without crashing', async () => { | ||
const { getByTestId } = render(<ImageGallery images={images} />) | ||
|
||
expect(getByTestId('image-gallery-image-0')).toBeInTheDocument() | ||
}) | ||
}) |
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,79 @@ | ||
import { useState } from 'react' | ||
import Slider from 'react-slick' | ||
import FsLightbox from 'fslightbox-react' | ||
import 'slick-carousel/slick/slick.css' | ||
import 'slick-carousel/slick/slick-theme.css' | ||
import styles from './ImageGallery.module.css' | ||
import BREAKPOINT_TABLE from '../../../constants/breakpoints.ts' | ||
|
||
interface Props { | ||
images: { | ||
url: string | ||
id: string | ||
}[] | ||
} | ||
|
||
function ImageGallery({ images }: Props) { | ||
const [lightboxController, setLightboxController] = useState({ | ||
toggler: false, | ||
slide: 1, | ||
}) | ||
const lighboxImages = images.map((i) => i.url) | ||
|
||
function openLightbox(number: number) { | ||
setLightboxController({ | ||
toggler: !lightboxController.toggler, | ||
slide: number, | ||
}) | ||
} | ||
|
||
const imagesList = images.map((image, index) => ( | ||
<div key={image.id}> | ||
<div className={styles.imageWrapper}> | ||
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */} | ||
<button | ||
className={styles.lightboxButton} | ||
type='button' | ||
onClick={() => openLightbox(index + 1)} | ||
> | ||
<img | ||
data-testid={`image-gallery-image-${index}`} | ||
className={styles.image} | ||
src={image.url} | ||
alt='' | ||
/> | ||
</button> | ||
</div> | ||
</div> | ||
)) | ||
|
||
return ( | ||
<> | ||
<Slider | ||
swipeToSlide | ||
infinite={false} | ||
centerPadding='28px' | ||
slidesToShow={3} | ||
responsive={[ | ||
{ | ||
breakpoint: BREAKPOINT_TABLE, | ||
settings: { | ||
slidesToShow: 1, | ||
centerMode: true, | ||
}, | ||
}, | ||
]} | ||
> | ||
{imagesList} | ||
</Slider> | ||
|
||
<FsLightbox | ||
toggler={lightboxController.toggler} | ||
sources={lighboxImages} | ||
slide={lightboxController.slide} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
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 |
---|---|---|
|
@@ -16,6 +16,14 @@ query GetExhibit($slug: String!) { | |
} | ||
} | ||
} | ||
imagesCollection(limit: 5) { | ||
items { | ||
url | ||
sys { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,33 +1,47 @@ | ||
@import '../../../variables.scss'; | ||
|
||
.exhibit { | ||
padding: 40px $indentMobilePageBorder; | ||
padding: 40px 0; | ||
font-size: $fontSizeDefault; | ||
|
||
@media (min-width: $breakpointTablet) { | ||
padding: 40px $indentTabletPageBorder; | ||
} | ||
} | ||
|
||
.title { | ||
margin: 0 0 12px 0; | ||
padding: 0 $indentMobilePageBorder; | ||
text-align: center; | ||
font-weight: bold; | ||
font-size: $fontSizeExtraLarge; | ||
|
||
@media (min-width: $breakpointTablet) { | ||
padding: 0 $indentTabletPageBorder; | ||
} | ||
} | ||
|
||
.author { | ||
padding-bottom: 24px; | ||
padding: 0 $indentMobilePageBorder 32px $indentMobilePageBorder; | ||
text-align: center; | ||
font-size: $fontSizeDefault; | ||
|
||
@media (min-width: $breakpointTablet) { | ||
padding: 0 $indentTabletPageBorder 32px $indentTabletPageBorder; | ||
} | ||
} | ||
|
||
.description { | ||
padding-bottom: 24px; | ||
padding: 0 $indentMobilePageBorder 24px $indentMobilePageBorder; | ||
|
||
@media (min-width: $breakpointTablet) { | ||
padding: 0 $indentTabletPageBorder 24px $indentTabletPageBorder; | ||
} | ||
} | ||
|
||
.descriptionName { | ||
padding-bottom: 8px; | ||
font-size: $fontSizeSmall; | ||
font-weight: bold; | ||
} | ||
|
||
.gallery { | ||
padding-bottom: 40px; | ||
overflow: hidden; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const BREAKPOINT_TABLE = 834 | ||
export default BREAKPOINT_TABLE |