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: productSlider [SFUI2-1190] #2819

Merged
merged 6 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/beige-coins-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@storefront-ui/vue': patch
---

fix typings of SfScrollable drag prop
6 changes: 6 additions & 0 deletions .changeset/lucky-papayas-reflect.md
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
Copy link
Contributor

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

Copy link
Contributor Author

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? 😄

Copy link
Contributor

@Szymon-dziewonski Szymon-dziewonski Jun 14, 2023

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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 😄

Copy link
Contributor

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

Copy link
Contributor Author

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 😄

Copy link
Contributor

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions apps/docs/components/blocks/ProductSlider.md
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.
2 changes: 1 addition & 1 deletion apps/docs/components/blocks/Review.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hideToc: true

## With Avatar

Basic Review usage with avatar and [Rating](/vue/components/rating.html) base component.
Basic Review usage with avatar and [Rating](/<!-- vue -->vue<!-- end vue --><!-- react -->react<!-- end react -->/components/rating.html) base component.

<Showcase showcase-name="Review/WithAvatar" style="min-height:220px">

Expand Down
110 changes: 110 additions & 0 deletions apps/preview/next/pages/showcases/ProductSlider/Basic.tsx
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;
84 changes: 84 additions & 0 deletions apps/preview/nuxt/pages/showcases/ProductSlider/Basic.vue
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>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const props = defineProps({
default: undefined,
},
drag: {
type: [Object || Boolean] as PropType<ScrollableOptions['drag']>,
type: [Object, Boolean] as PropType<ScrollableOptions['drag']>,
default: undefined,
},
prevDisabled: {
Expand Down