Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Adds tokens to ImageGallery #143

Merged
merged 24 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f1c09ee
Removes unused icons file
hellofanny Jun 17, 2022
d9ed4b7
Removes unnecessary data-attr
hellofanny Jun 17, 2022
20be43f
Adds default stories mdx
hellofanny Jun 17, 2022
e430410
Renames data-store-image to data-fs-image
hellofanny Jun 17, 2022
be93644
Moves image styles to layout.scss
hellofanny Jun 17, 2022
52a3363
Adjusts tokens for image-gallery
hellofanny Jun 22, 2022
848d059
Renames `data-thumbnail-button` to `data-fs-image-gallery-selector-th…
hellofanny Jun 23, 2022
469cb8c
Adds `data-fs-image-gallery-selector-control-button` data-attr`
hellofanny Jun 23, 2022
91a26a0
Adds image-gallery-selector-elements tokens
hellofanny Jun 23, 2022
0720a67
Adds tokens data-fs-image-gallery-selector-thumbnail data-attr
hellofanny Jun 23, 2022
4234b17
Adds tokens documentation
hellofanny Jun 23, 2022
ee18f3c
Removes unused args paramenter
hellofanny Jun 23, 2022
86fb314
Convert px to rem
hellofanny Jun 23, 2022
9e0b6f9
Updates title
hellofanny Jun 23, 2022
9fdb11a
Adds `-mobile`
hellofanny Jun 23, 2022
4e16af5
Merge branch 'main' into theming-image-gallery-FSSS-282
hellofanny Jun 23, 2022
448c3b0
Updates description
hellofanny Jun 23, 2022
1f07277
Merge branch 'main' into theming-image-gallery-FSSS-282
hellofanny Jun 24, 2022
7437d41
Updates changelog
hellofanny Jun 24, 2022
7af7ff1
Merge branch 'main' into theming-image-gallery-FSSS-282
hellofanny Jun 27, 2022
9e7327c
Updates tokens variables with global tokens
hellofanny Jun 27, 2022
484547b
Renames thumbnail selected border color token
hellofanny Jun 27, 2022
c90c257
Adding Variants section
hellofanny Jun 27, 2022
dc1ca35
Reorders Variants section place
hellofanny Jun 27, 2022
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Applies new local tokens to `ImageGallery` ([#143](https://github.com/vtex-sites/nextjs.store/pull/143))
- Creates Doc page for `Regionalization` Feature ([#110](https://github.com/vtex-sites/nextjs.store/pull/110))
- Applies new local tokens to `RegionalizationBar` ([#104](https://github.com/vtex-sites/nextjs.store/pull/104))
- Applies new local tokens to `Modal` and `RegionalizationModal` ([#128](https://github.com/vtex-sites/nextjs.store/pull/128))
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Image = forwardRef<HTMLImageElement, Props>(
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
ref={ref}
data-store-image
data-fs-image
{...imgProps}
alt={imgProps.alt}
fetchpriority={fetchPriority}
Expand Down
5 changes: 0 additions & 5 deletions src/components/ui/Image/image.scss

This file was deleted.

41 changes: 0 additions & 41 deletions src/components/ui/ImageGallery/Icons.tsx

This file was deleted.

167 changes: 167 additions & 0 deletions src/components/ui/ImageGallery/ImageGallery.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'

import { ImageGallery } from '.'

import {
TokenTable,
TokenRow,
TokenDivider,
} from 'src/../.storybook/components'

<Meta title="Organisms/ImageGallery" />

export const Template = () => {
const productImages = [
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190902/unsplash-magic-mouse.jpg?v=637800136963870000',
alternateName: 'Magicwhite',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190923/lena-de-fanti-nQ_j5d-klVU-unsplash.jpg?v=637867501523500000',
alternateName: 'magicbox',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190924/anthony-choren-e7dG26YCrZU-unsplash.jpg?v=637867501835430000',
alternateName: 'magicblackwhite',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190925/maheshkumar-painam-GZdfLeL-MDk-unsplash.jpg?v=637867502064000000',
alternateName: 'magiccombo',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190926/math-0U9fBLGP3EY-unsplash.jpg?v=637867502325830000',
alternateName: 'magicback',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190927/marek-levak-YPeqMN_wfw0-unsplash.jpg?v=637867502641430000',
alternateName: 'magictable',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190928/mouse8.jpg?v=637867504048970000',
alternateName: 'magichand',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190929/harpal-singh-KuvEVL7lXYQ-unsplash.jpg?v=637867509459130000',
alternateName: 'magicstyle',
},
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190930/chris-hardy-182PzOtcmWc-unsplash.jpg?v=637867509778300000',
alternateName: 'magicscale',
},
]
return <ImageGallery images={productImages} />
}

export const TemplateWithoutSelector = () => {
const productImages = [
{
url: 'https://storeframework.vtexassets.com/arquivos/ids/190902/unsplash-magic-mouse.jpg?v=637800136963870000',
alternateName: 'Magicwhite',
},
]
return <ImageGallery images={productImages} />
}

<header>

# Image Gallery

An `ImageGallery` is used when you want to display a series of photos in a gallery on a post or page.

</header>

## Overview

According to the quantity of `Image` to be displayed, the `ImageGallerySelector` will be displayed.

---

## Usage

`import { ImageGallery } from 'src/components/ui/ImageGallery'`

<Canvas>
<Story name="default">{Template.bind({})}</Story>
</Canvas>

<TokenTable>
<TokenRow
token="--fs-image-gallery-width"
value="calc(100% + (2 * var(--fs-grid-padding)))"
/>
<TokenRow
token="--fs-image-gallery-image-border-radius"
value="var(--fs-border-radius)"
/>
<TokenDivider />
<TokenRow token="--fs-image-gallery-gap-mobile" value="var(--fs-spacing-2)" />
<TokenRow
token="--fs-image-gallery-gap-notebook"
value="var(--fs-spacing-3)"
/>
</TokenTable>

---

## Nested Elements

### Selector

<TokenTable>
<TokenRow token="--fs-image-gallery-selector-max-height" value="33.125rem" />
</TokenTable>

### Selector Elements

<TokenTable>
<TokenRow
token="--fs-image-gallery-selector-elements-gap"
value="var(--fs-spacing-1)"
/>
<TokenRow
token="--fs-image-gallery-selector-elements-gap-notebook"
value="var(--fs-spacing-2)"
/>
<TokenRow
token="--fs-image-gallery-selector-elements-padding"
value="var(--fs-spacing-0)"
/>
</TokenTable>

### Selector Thumbnail

<TokenTable>
<TokenRow
token="--fs-image-gallery-selector-thumbnail-width-mobile"
value="3.5rem"
/>
<TokenRow
token="--fs-image-gallery-selector-thumbnail-width-notebook"
value="4.5rem"
/>
<TokenRow
token="--fs-image-gallery-selector-thumbnail-border-radius"
value="var(--fs-border-radius)"
/>
<TokenRow
token="--fs-image-gallery-selector-thumbnail-selected-border-color"
value="var(--fs-border-color-active)"
isColor
/>
</TokenTable>

---

## Variants

### With Selector (More than 1 Image)

<Canvas>
<Story name="overview-default">{Template.bind({})}</Story>
</Canvas>

### Without Selector

<Canvas>
<Story name="overview-default-2">{TemplateWithoutSelector.bind({})}</Story>
</Canvas>
8 changes: 5 additions & 3 deletions src/components/ui/ImageGallery/ImageGallerySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function ImageGallerySelector({ images, onSelect, currentImageIdx }: Props) {
>
{elementHasScroll && !firstImageInView && (
<IconButton
data-fs-image-gallery-selector-control-button
aria-label="backward slide image selector"
icon={<Icon name="ArrowLeft" width={24} height={24} />}
onClick={() => moveScroll(elementsRef.current, -SCROLL_MARGIN_VALUE)}
Expand All @@ -79,13 +80,13 @@ function ImageGallerySelector({ images, onSelect, currentImageIdx }: Props) {
return (
<Button
key={idx}
data-thumbnail-button={
idx === currentImageIdx ? 'selected' : 'true'
}
aria-label={`${image.alternateName} - Image ${idx + 1} of ${
images.length
}`}
onClick={() => onSelect(idx)}
data-fs-image-gallery-selector-thumbnail={
idx === currentImageIdx ? 'selected' : 'true'
}
>
<Image
ref={ref}
Expand All @@ -102,6 +103,7 @@ function ImageGallerySelector({ images, onSelect, currentImageIdx }: Props) {
</div>
{elementHasScroll && !lastImageInView && (
<IconButton
data-fs-image-gallery-selector-control-button
aria-label="forward slide image selector"
icon={<Icon name="ArrowLeft" width={24} height={24} />}
onClick={() => moveScroll(elementsRef.current, +SCROLL_MARGIN_VALUE)}
Expand Down
Loading