@faststore/ui 1.12.20 → 1.12.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/hooks/useSlider/useSlider.d.ts +3 -1
- package/dist/hooks/useSlider/useSlider.js +5 -10
- package/dist/hooks/useSlider/useSlider.js.map +1 -1
- package/dist/molecules/Bullets/Bullets.js +1 -1
- package/dist/molecules/Bullets/Bullets.js.map +1 -1
- package/dist/molecules/Carousel/Carousel.d.ts +40 -2
- package/dist/molecules/Carousel/Carousel.js +115 -56
- package/dist/molecules/Carousel/Carousel.js.map +1 -1
- package/dist/molecules/Carousel/CarouselItem.d.ts +11 -0
- package/dist/molecules/Carousel/CarouselItem.js +18 -0
- package/dist/molecules/Carousel/CarouselItem.js.map +1 -0
- package/package.json +4 -4
- package/src/hooks/useSlider/useSlider.ts +8 -9
- package/src/molecules/Bullets/Bullets.test.tsx +5 -5
- package/src/molecules/Bullets/Bullets.tsx +3 -3
- package/src/molecules/Bullets/stories/Bullets.mdx +2 -2
- package/src/molecules/Carousel/Carousel.test.tsx +55 -52
- package/src/molecules/Carousel/Carousel.tsx +217 -85
- package/src/molecules/Carousel/CarouselItem.tsx +54 -0
- package/src/molecules/Carousel/stories/Carousel.mdx +7 -7
- package/src/molecules/Carousel/stories/Carousel.stories.tsx +6 -6
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { CSSProperties, PropsWithChildren, HTMLAttributes } from 'react'
|
|
3
|
+
import type { SliderState } from '../../hooks/useSlider/useSlider'
|
|
4
|
+
|
|
5
|
+
import useSlideVisibility from './hooks/useSlideVisibility'
|
|
6
|
+
|
|
7
|
+
interface CarouselItemProps extends HTMLAttributes<HTMLLIElement> {
|
|
8
|
+
index: number
|
|
9
|
+
totalItems: number
|
|
10
|
+
state: SliderState
|
|
11
|
+
infiniteMode: boolean
|
|
12
|
+
isScrollCarousel: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function CarouselItem({
|
|
16
|
+
index,
|
|
17
|
+
state,
|
|
18
|
+
children,
|
|
19
|
+
totalItems,
|
|
20
|
+
infiniteMode,
|
|
21
|
+
isScrollCarousel,
|
|
22
|
+
}: PropsWithChildren<CarouselItemProps>) {
|
|
23
|
+
const { isItemVisible, shouldRenderItem } = useSlideVisibility({
|
|
24
|
+
totalItems,
|
|
25
|
+
currentSlide: state.currentItem,
|
|
26
|
+
itemsPerPage: state.itemsPerPage,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const style =
|
|
30
|
+
((!isScrollCarousel && { width: '100%' }) as CSSProperties) ||
|
|
31
|
+
((isScrollCarousel && {
|
|
32
|
+
maxWidth: '80%',
|
|
33
|
+
display: 'inline-block',
|
|
34
|
+
}) as CSSProperties)
|
|
35
|
+
|
|
36
|
+
const shouldDisplayItem =
|
|
37
|
+
isScrollCarousel || shouldRenderItem(index - Number(infiniteMode))
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<li
|
|
41
|
+
style={style}
|
|
42
|
+
data-fs-carousel-item
|
|
43
|
+
aria-roledescription="slide"
|
|
44
|
+
id={`carousel-item-${index}`}
|
|
45
|
+
data-fs-carousel-item-visible={
|
|
46
|
+
isItemVisible(index - Number(infiniteMode)) || undefined
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
{shouldDisplayItem ? children : null}
|
|
50
|
+
</li>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default CarouselItem
|
|
@@ -17,19 +17,19 @@ import Carousel from '../Carousel'
|
|
|
17
17
|
```css
|
|
18
18
|
[data-fs-carousel] {}
|
|
19
19
|
|
|
20
|
-
[data-carousel-track-container] {}
|
|
20
|
+
[data-fs-carousel-track-container] {}
|
|
21
21
|
|
|
22
|
-
[data-carousel-track] {}
|
|
22
|
+
[data-fs-carousel-track] {}
|
|
23
23
|
|
|
24
|
-
[data-carousel-item] {}
|
|
24
|
+
[data-fs-carousel-item] {}
|
|
25
25
|
|
|
26
|
-
[data-carousel-controls] {}
|
|
26
|
+
[data-fs-carousel-controls] {}
|
|
27
27
|
|
|
28
|
-
[data-
|
|
28
|
+
[data-fs-carousel-control="left|right"] {}
|
|
29
29
|
|
|
30
|
-
[data-carousel-bullets] {}
|
|
30
|
+
[data-fs-carousel-bullets] {}
|
|
31
31
|
|
|
32
|
-
[data-carousel-bullets] [data-fs-bullets] {}
|
|
32
|
+
[data-fs-carousel-bullets] [data-fs-bullets] {}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
This components inherits [IconButton](?path=/docs/molecules-iconbutton--default#css-selectors), [Bullets](?path=/docs/molecules-bullets--bullets#css-selectors) css selectors.
|
|
@@ -15,16 +15,16 @@ const CarouselTemplate: Story<
|
|
|
15
15
|
transition={{ property: 'transform', duration: transitionDuration }}
|
|
16
16
|
>
|
|
17
17
|
<img
|
|
18
|
-
|
|
18
|
+
height={480}
|
|
19
19
|
width="100%"
|
|
20
|
-
|
|
21
|
-
src="https://storecomponents.vtex.app/assets/fit-in/
|
|
20
|
+
alt="A vintage camera"
|
|
21
|
+
src="https://storecomponents.vtex.app/assets/fit-in/480x480/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Farquivos%2Fids%2F155481%2FFrame-3.jpg%3Fv%3D636793814536230000"
|
|
22
22
|
/>
|
|
23
23
|
<img
|
|
24
|
-
|
|
24
|
+
height={480}
|
|
25
25
|
width="100%"
|
|
26
|
-
|
|
27
|
-
src="https://storecomponents.vtex.app/assets/fit-in/
|
|
26
|
+
alt="A vintage camera"
|
|
27
|
+
src="https://storecomponents.vtex.app/assets/fit-in/480x480/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Farquivos%2Fids%2F155481%2FFrame-3.jpg%3Fv%3D636793814536230000"
|
|
28
28
|
/>
|
|
29
29
|
</Component>
|
|
30
30
|
)
|