@latte-macchiat-io/latte-vanilla-components 0.0.310 → 0.0.312
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/package.json
CHANGED
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
carouselItem,
|
12
12
|
carouselNav,
|
13
13
|
carouselNavButton,
|
14
|
+
CarouselNavVariants,
|
14
15
|
carouselRecipe,
|
15
16
|
carouselSlide,
|
16
17
|
type CarouselVariants,
|
@@ -23,7 +24,8 @@ import { useWindowSize } from '../../utils/useWindowSize';
|
|
23
24
|
import { Icon } from '../Icon';
|
24
25
|
|
25
26
|
export type CarouselProps = React.HTMLAttributes<HTMLDivElement> &
|
26
|
-
CarouselVariants &
|
27
|
+
CarouselVariants &
|
28
|
+
CarouselNavVariants & {
|
27
29
|
gap?: number;
|
28
30
|
data: ReactNode[];
|
29
31
|
itemsPerView?: number;
|
@@ -44,6 +46,8 @@ export const Carousel = ({
|
|
44
46
|
gap = 16,
|
45
47
|
isFullWidth,
|
46
48
|
className,
|
49
|
+
navPositionVertical,
|
50
|
+
navPositionHorizontal,
|
47
51
|
}: CarouselProps) => {
|
48
52
|
const { width: windowWidth } = useWindowSize();
|
49
53
|
const [currentIndex, setCurrentIndex] = useState(0);
|
@@ -171,7 +175,7 @@ export const Carousel = ({
|
|
171
175
|
</div>
|
172
176
|
|
173
177
|
{showNavButtons && (
|
174
|
-
<div className={carouselNav}>
|
178
|
+
<div className={carouselNav({ navPositionHorizontal, navPositionVertical })}>
|
175
179
|
<button type="button" className={carouselNavButton} onClick={handlePrevious} disabled={currentIndex === 0} aria-label="Previous slide">
|
176
180
|
<Icon icon="arrowBack" />
|
177
181
|
</button>
|
@@ -12,7 +12,6 @@ export const carouselRecipe = recipe(
|
|
12
12
|
{
|
13
13
|
base: {
|
14
14
|
width: '100%',
|
15
|
-
overflow: 'hidden',
|
16
15
|
position: 'relative',
|
17
16
|
},
|
18
17
|
|
@@ -48,6 +47,7 @@ export const carouselRecipe = recipe(
|
|
48
47
|
},
|
49
48
|
},
|
50
49
|
},
|
50
|
+
navPosition: {},
|
51
51
|
},
|
52
52
|
|
53
53
|
defaultVariants: {
|
@@ -94,21 +94,56 @@ globalStyle(`${carouselItem} > div`, {
|
|
94
94
|
},
|
95
95
|
});
|
96
96
|
|
97
|
-
export const carouselNav =
|
97
|
+
export const carouselNav = recipe(
|
98
98
|
{
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
pointerEvents: 'none',
|
107
|
-
justifyContent: 'flex-end',
|
99
|
+
base: {
|
100
|
+
zIndex: 30,
|
101
|
+
width: '100%',
|
102
|
+
display: 'flex',
|
103
|
+
position: 'absolute',
|
104
|
+
pointerEvents: 'none',
|
105
|
+
justifyContent: 'flex-end',
|
108
106
|
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
gap: themeContract.space.sm,
|
108
|
+
padding: themeContract.space.md,
|
109
|
+
maxWidth: themeContract.maxWidth,
|
110
|
+
},
|
111
|
+
|
112
|
+
variants: {
|
113
|
+
navPositionHorizontal: {
|
114
|
+
left: {
|
115
|
+
left: 0,
|
116
|
+
},
|
117
|
+
right: {
|
118
|
+
right: 0,
|
119
|
+
},
|
120
|
+
spaceBetween: {
|
121
|
+
left: 0,
|
122
|
+
right: 0,
|
123
|
+
},
|
124
|
+
center: {
|
125
|
+
left: 'auto',
|
126
|
+
right: 'auto',
|
127
|
+
},
|
128
|
+
},
|
129
|
+
|
130
|
+
navPositionVertical: {
|
131
|
+
top: {
|
132
|
+
bottom: '100%',
|
133
|
+
},
|
134
|
+
center: {
|
135
|
+
top: '50%',
|
136
|
+
},
|
137
|
+
bottom: {
|
138
|
+
top: '100%',
|
139
|
+
},
|
140
|
+
},
|
141
|
+
},
|
142
|
+
|
143
|
+
defaultVariants: {
|
144
|
+
navPositionHorizontal: 'spaceBetween',
|
145
|
+
navPositionVertical: 'center',
|
146
|
+
},
|
112
147
|
},
|
113
148
|
'carousel-nav'
|
114
149
|
);
|
@@ -198,3 +233,4 @@ export const carouselBulletActive = style(
|
|
198
233
|
);
|
199
234
|
|
200
235
|
export type CarouselVariants = RecipeVariants<typeof carouselRecipe>;
|
236
|
+
export type CarouselNavVariants = RecipeVariants<typeof carouselNav>;
|