@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.
@@ -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-arrow="left|right"] {}
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
- alt=""
18
+ height={480}
19
19
  width="100%"
20
- height={614}
21
- src="https://storecomponents.vtex.app/assets/fit-in/1280x613/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Fassets%2Fvtex.file-manager-graphql%2Fimages%2F331632a0-fa52-4f08-8e45-df762d97a289___167e4c8385c3129b1a2ddab9156510ba.jpg"
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
- alt=""
24
+ height={480}
25
25
  width="100%"
26
- height={614}
27
- src="https://storecomponents.vtex.app/assets/fit-in/1280x613/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Fassets%2Fvtex.file-manager-graphql%2Fimages%2Fedce348c-068c-4fb9-91f2-7d235d596e0f___b2822f893b14f87337d08f07f0e520ab.jpg"
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
  )