-
Notifications
You must be signed in to change notification settings - Fork 455
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: productSlider [SFUI2-1190] #2819
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f322fa8
feat: productSlider [SFUI2-1190]
FRSgit 59afe7d
chore: add changesets
FRSgit e6a74e4
chore: lint autofix
FRSgit 9c88065
fix: react eslint errors
FRSgit e2fca67
chore: update apps/docs/components/blocks/ProductSlider.md
FRSgit 6a06240
chore: remove minor version bump
FRSgit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@storefront-ui/vue': patch | ||
--- | ||
|
||
fix typings of SfScrollable drag prop |
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,6 @@ | ||
--- | ||
'@storefront-ui/vue': minor | ||
'@storefront-ui/react': minor | ||
--- | ||
|
||
add ProductSlider block | ||
Binary file added
BIN
+121 KB
apps/docs/components/.vuepress/public/thumbnails/blocks/ProductSlider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 @@ | ||
--- | ||
layout: DefaultLayout | ||
hideBreadcrumbs: true | ||
description: The ProductSlider allows for scrollable content with product cards, providing a visually appealing and interactive way to showcase products. | ||
hideToc: true | ||
|
||
FRSgit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--- | ||
# ProductSlider | ||
|
||
::: warning This is an experimental block | ||
This block has been built on top of experimental base component. The API and structure of it might change based on user feedback. | ||
::: | ||
|
||
The example allows for scrollable content with product cards, providing a visually appealing and interactive way to showcase products. | ||
|
||
## Basic | ||
|
||
Users can easily navigate through the cards by swiping or using navigation arrows, making it convenient to explore a collection of products within a limited space. The component is responsive and adapts to different devices, ensuring a consistent and enjoyable browsing experience. | ||
|
||
For further customization options, please refer to our documentation on the [Scrollable](/<!-- vue -->vue<!-- end vue --><!-- react -->react<!-- end react -->/components/scrollable.html) component and [Product Card](/<!-- vue -->vue<!-- end vue --><!-- react -->react<!-- end react -->/blocks/ProductCard.html) block pages. | ||
|
||
<Showcase showcase-name="ProductSlider/Basic" style="min-height:380px"> | ||
|
||
<!-- vue --> | ||
<<<../../preview/nuxt/pages/showcases/ProductSlider/Basic.vue | ||
<!-- end vue --> | ||
<!-- react --> | ||
<<<../../preview/next/pages/showcases/ProductSlider/Basic.tsx#source | ||
<!-- end react --> | ||
|
||
</Showcase> | ||
|
||
## Accessibility notes | ||
|
||
The ProductSlider supports the use of the keyboard (Tab/alt+Tab) to navigate through images. |
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
110 changes: 110 additions & 0 deletions
110
apps/preview/next/pages/showcases/ProductSlider/Basic.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,110 @@ | ||
/* eslint-disable react/no-array-index-key */ | ||
/* eslint-disable jsx-a11y/anchor-has-content */ | ||
import { ShowcasePageLayout } from '../../showcases'; | ||
|
||
// #region source | ||
import { | ||
SfLink, | ||
SfButton, | ||
SfIconFavorite, | ||
SfIconChevronLeft, | ||
SfIconChevronRight, | ||
SfScrollable, | ||
} from '@storefront-ui/react'; | ||
import classNames from 'classnames'; | ||
|
||
const products = Array.from(Array(10), (_, i) => ({ | ||
id: i.toString(), | ||
name: 'Athletic mens walking sneakers', | ||
price: '$2,345.99', | ||
img: { | ||
src: 'http://localhost:3100/@assets/sneakers.png', | ||
alt: 'White sneaker shoe', | ||
}, | ||
})); | ||
|
||
function ButtonPrev({ disabled, ...attributes }: { disabled?: boolean }) { | ||
return ( | ||
<SfButton | ||
className={classNames('absolute !rounded-full z-10 left-4 bg-white hidden md:block', { | ||
'!hidden': disabled, | ||
})} | ||
variant="secondary" | ||
size="lg" | ||
square | ||
{...attributes} | ||
> | ||
<SfIconChevronLeft /> | ||
</SfButton> | ||
); | ||
} | ||
|
||
ButtonPrev.defaultProps = { disabled: false }; | ||
|
||
function ButtonNext({ disabled, ...attributes }: { disabled?: boolean }) { | ||
return ( | ||
<SfButton | ||
className={classNames('absolute !rounded-full z-10 right-4 bg-white hidden md:block', { | ||
'!hidden': disabled, | ||
})} | ||
variant="secondary" | ||
size="lg" | ||
square | ||
{...attributes} | ||
> | ||
<SfIconChevronRight /> | ||
</SfButton> | ||
); | ||
} | ||
|
||
ButtonNext.defaultProps = { disabled: false }; | ||
|
||
export default function GalleryVertical() { | ||
return ( | ||
<SfScrollable | ||
className="m-auto items-center w-full [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]" | ||
buttons-placement="floating" | ||
drag | ||
slotPreviousButton={<ButtonPrev />} | ||
slotNextButton={<ButtonNext />} | ||
> | ||
{products.map(({ id, name, price, img }) => ( | ||
<div | ||
key={id} | ||
className="first:ms-auto last:me-auto border border-neutral-200 shrink-0 rounded-md hover:shadow-lg w-[148px] lg:w-[192px]" | ||
> | ||
<div className="relative"> | ||
<SfLink href="#"> | ||
<img | ||
src={img.src} | ||
alt={img.alt} | ||
className="block object-cover h-auto rounded-md aspect-square lg:w-[190px] lg:h-[190px]" | ||
width="146" | ||
height="146" | ||
/> | ||
</SfLink> | ||
<SfButton | ||
type="button" | ||
variant="tertiary" | ||
size="sm" | ||
square | ||
className="absolute bottom-0 right-0 mr-2 mb-2 bg-white border border-neutral-200 !rounded-full" | ||
aria-label="Add to wishlist" | ||
> | ||
<SfIconFavorite size="sm" /> | ||
</SfButton> | ||
</div> | ||
<div className="p-2 border-t border-neutral-200 typography-text-sm"> | ||
<SfLink href="#" variant="secondary" className="no-underline"> | ||
{name} | ||
</SfLink> | ||
<span className="block mt-2 font-bold">{price}</span> | ||
</div> | ||
</div> | ||
))} | ||
</SfScrollable> | ||
); | ||
} | ||
// #endregion source | ||
|
||
GalleryVertical.getLayout = ShowcasePageLayout; |
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,84 @@ | ||
<template> | ||
<SfScrollable | ||
class="m-auto items-center w-full [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]" | ||
buttons-placement="floating" | ||
drag | ||
> | ||
<template #previousButton="defaultProps"> | ||
<SfButton | ||
v-bind="defaultProps" | ||
class="absolute !rounded-full z-10 left-4 bg-white hidden md:block" | ||
:class="{ '!hidden': defaultProps.disabled }" | ||
variant="secondary" | ||
size="lg" | ||
square | ||
> | ||
<SfIconChevronLeft /> | ||
</SfButton> | ||
</template> | ||
<div | ||
v-for="{ id, name, price, img } in products" | ||
:key="id" | ||
class="first:ms-auto last:me-auto border border-neutral-200 shrink-0 rounded-md hover:shadow-lg w-[148px] lg:w-[192px]" | ||
> | ||
<div class="relative"> | ||
<SfLink href="#"> | ||
<img | ||
:src="img.src" | ||
:alt="img.alt" | ||
class="block object-cover h-auto rounded-md aspect-square lg:w-[190px] lg:h-[190px]" | ||
width="146" | ||
height="146" | ||
/> | ||
</SfLink> | ||
<SfButton | ||
type="button" | ||
variant="tertiary" | ||
size="sm" | ||
square | ||
class="absolute bottom-0 right-0 mr-2 mb-2 bg-white border border-neutral-200 !rounded-full" | ||
aria-label="Add to wishlist" | ||
> | ||
<SfIconFavorite size="sm" /> | ||
</SfButton> | ||
</div> | ||
<div class="p-2 border-t border-neutral-200 typography-text-sm"> | ||
<SfLink href="#" variant="secondary" class="no-underline">{{ name }}</SfLink> | ||
<span class="block mt-2 font-bold">{{ price }}</span> | ||
</div> | ||
</div> | ||
<template #nextButton="defaultProps"> | ||
<SfButton | ||
v-bind="defaultProps" | ||
class="absolute !rounded-full z-10 right-4 bg-white hidden md:block" | ||
:class="{ '!hidden': defaultProps.disabled }" | ||
variant="secondary" | ||
size="lg" | ||
square | ||
> | ||
<SfIconChevronRight /> | ||
</SfButton> | ||
</template> | ||
</SfScrollable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { | ||
SfLink, | ||
SfButton, | ||
SfIconFavorite, | ||
SfIconChevronLeft, | ||
SfIconChevronRight, | ||
SfScrollable, | ||
} from '@storefront-ui/vue'; | ||
|
||
const products = Array.from(Array(10), (_, i) => ({ | ||
id: i.toString(), | ||
name: 'Athletic mens walking sneakers', | ||
price: '$2,345.99', | ||
img: { | ||
src: 'http://localhost:3100/@assets/sneakers.png', | ||
alt: 'White sneaker shoe', | ||
}, | ||
})); | ||
</script> |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Block is not part of our packages that we release on npm, so it should not be mentioned in changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, was wondering about that - how will we raise the version number when there are no changes to the package? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure if I understand, you did changes in component from package in scrollable.vue so you should make patch change only for vue package and write something like
Prop typing change in SfScrollable
, wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I did it already yesterday: https://github.com/vuestorefront/storefront-ui/pull/2819/files#diff-d78d5a6ea45c0e27ea4974822b530c55251c860f32d1f9cb9435a4d09d575cc8R2-R5
But what I mean - we need to release the vue/react packages with
2.4
next week - how do we do that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've remove this changelog. But the issue of "how and when to set version at
2.4
" still persists 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With what I test today changesets bump version to 2.4 so at this point we need to only go with current new flow and at the end run yarn publish by hand and thats it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, but we need to make sure that we will always have a minor bump somewhere in our tasks 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats true, we have to be aware what kind of tickets we do, but so far its looking good, we have some breaking change tickets and one commit already land to different branch so i think we are good here