@latte-macchiat-io/latte-vanilla-components 0.0.202 → 0.0.204
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 +1 -1
- package/src/components/Button/index.tsx +0 -1
- package/src/components/Carousel/export.tsx +2 -4
- package/src/components/Carousel/index.tsx +159 -191
- package/src/components/Carousel/theme.ts +102 -0
- package/src/components/Columns/export.tsx +2 -5
- package/src/components/Columns/index.tsx +9 -15
- package/src/components/Columns/styles.css.ts +3 -1
- package/src/components/Columns/theme.ts +24 -0
- package/src/components/ConsentCookie/export.tsx +2 -4
- package/src/components/ConsentCookie/index.tsx +104 -0
- package/src/components/Footer/export.tsx +1 -4
- package/src/components/Footer/index.tsx +1 -9
- package/src/components/Footer/theme.ts +51 -0
- package/src/components/Form/Form.tsx +0 -3
- package/src/components/Form/Row/Row.tsx +0 -3
- package/src/components/Form/TextField/Input/Input.tsx +0 -3
- package/src/components/Form/TextField/Label/Label.tsx +0 -3
- package/src/components/Form/TextField/TextField.tsx +0 -3
- package/src/components/Form/TextField/Textarea/Textarea.tsx +0 -3
- package/src/components/Form/export.tsx +17 -3
- package/src/components/Header/export.tsx +1 -4
- package/src/components/Header/index.tsx +19 -35
- package/src/components/Header/styles.css.ts +2 -2
- package/src/components/Header/theme.ts +51 -0
- package/src/components/Heading/export.tsx +1 -0
- package/src/components/Heading/index.tsx +3 -9
- package/src/components/Icon/export.tsx +1 -4
- package/src/components/Icon/index.tsx +4 -5
- package/src/components/Icon/theme.ts +17 -0
- package/src/components/KeyNumber/export.tsx +2 -4
- package/src/components/KeyNumber/index.tsx +3 -3
- package/src/components/KeyNumber/theme.ts +22 -0
- package/src/components/LanguageSwitcher/export.tsx +2 -4
- package/src/components/LanguageSwitcher/index.tsx +37 -63
- package/src/components/Logo/export.tsx +1 -4
- package/src/components/Logo/index.tsx +2 -5
- package/src/components/Logo/styles.css.ts +2 -2
- package/src/components/Main/export.tsx +1 -4
- package/src/components/Main/index.tsx +1 -9
- package/src/components/Main/theme.ts +19 -0
- package/src/components/Modal/export.tsx +2 -4
- package/src/components/Modal/index.tsx +4 -5
- package/src/components/Modal/theme.ts +31 -0
- package/src/components/Nav/export.tsx +1 -4
- package/src/components/Nav/index.tsx +6 -14
- package/src/components/Nav/styles.css.ts +3 -1
- package/src/components/Nav/theme.ts +24 -0
- package/src/components/NavLegal/export.tsx +1 -4
- package/src/components/NavLegal/index.tsx +1 -7
- package/src/components/NavLegal/theme.ts +24 -0
- package/src/components/NavSocial/export.tsx +2 -5
- package/src/components/NavSocial/index.tsx +14 -18
- package/src/components/NavSocial/theme.ts +34 -0
- package/src/components/Section/export.tsx +2 -6
- package/src/components/Section/index.tsx +4 -8
- package/src/components/Section/theme.ts +40 -0
- package/src/components/Video/export.tsx +2 -2
- package/src/components/Video/index.tsx +78 -84
- package/src/components/Video/theme.ts +104 -0
- package/src/index.ts +19 -49
- package/src/theme/baseThemeValues.ts +40 -712
- package/src/theme/contract.css.ts +0 -16
- package/src/utils/useWindowSize.ts +29 -0
- package/src/components/ConsentCookie/ConsentCookie.tsx +0 -200
- package/src/components/Header/HeaderOverlay/index.tsx +0 -32
- package/src/components/Header/HeaderOverlay/styles.css.ts +0 -33
- package/src/components/Header/ToggleNav/index.tsx +0 -29
- package/src/components/Header/ToggleNav/styles.css.ts +0 -40
- package/src/components/ThemeTest/ThemeTest.css.ts +0 -11
- package/src/components/ThemeTest/ThemeTest.tsx +0 -12
- /package/src/components/ConsentCookie/{ConsentCookie.css.ts → styles.css.ts} +0 -0
@@ -219,22 +219,6 @@ export const themeContract = createGlobalThemeContract({
|
|
219
219
|
xl: 'latte-columns-gap-xl',
|
220
220
|
'2xl': 'latte-columns-gap-2xl',
|
221
221
|
},
|
222
|
-
flex: {
|
223
|
-
mobile: 'latte-columns-flex-mobile',
|
224
|
-
sm: 'latte-columns-flex-sm',
|
225
|
-
md: 'latte-columns-flex-md',
|
226
|
-
lg: 'latte-columns-flex-lg',
|
227
|
-
xl: 'latte-columns-flex-xl',
|
228
|
-
'2xl': 'latte-columns-flex-2xl',
|
229
|
-
},
|
230
|
-
maxWidth: {
|
231
|
-
mobile: 'latte-columns-maxWidth-mobile',
|
232
|
-
sm: 'latte-columns-maxWidth-sm',
|
233
|
-
md: 'latte-columns-maxWidth-md',
|
234
|
-
lg: 'latte-columns-maxWidth-lg',
|
235
|
-
xl: 'latte-columns-maxWidth-xl',
|
236
|
-
'2xl': 'latte-columns-maxWidth-2xl',
|
237
|
-
},
|
238
222
|
},
|
239
223
|
|
240
224
|
actions: {
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
|
3
|
+
interface UseWindowSizeReturn {
|
4
|
+
width: number | undefined;
|
5
|
+
height: number | undefined;
|
6
|
+
}
|
7
|
+
|
8
|
+
export const useWindowSize = (): UseWindowSizeReturn => {
|
9
|
+
const [windowSize, setWindowSize] = useState<UseWindowSizeReturn>({
|
10
|
+
width: undefined,
|
11
|
+
height: undefined,
|
12
|
+
});
|
13
|
+
|
14
|
+
useEffect(() => {
|
15
|
+
const handleResize = () => {
|
16
|
+
setWindowSize({
|
17
|
+
width: window.innerWidth,
|
18
|
+
height: window.innerHeight,
|
19
|
+
});
|
20
|
+
};
|
21
|
+
|
22
|
+
window.addEventListener('resize', handleResize);
|
23
|
+
handleResize();
|
24
|
+
|
25
|
+
return () => window.removeEventListener('resize', handleResize);
|
26
|
+
}, []);
|
27
|
+
|
28
|
+
return windowSize;
|
29
|
+
};
|
@@ -1,200 +0,0 @@
|
|
1
|
-
import { clsx } from 'clsx';
|
2
|
-
import { forwardRef, useEffect, useState } from 'react';
|
3
|
-
import { consentActions, consentContent, type ConsentCookieVariants, consentRecipe } from './ConsentCookie.css';
|
4
|
-
import { getCookie, setCookie } from './cookie';
|
5
|
-
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
6
|
-
import { Button } from '../Button/';
|
7
|
-
|
8
|
-
// Declare window object including gtag to avoid TypeScript errors
|
9
|
-
declare const window: Window &
|
10
|
-
typeof globalThis & {
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
12
|
-
gtag: any;
|
13
|
-
};
|
14
|
-
|
15
|
-
export interface ConsentCookieProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Sprinkles, NonNullable<ConsentCookieVariants> {
|
16
|
-
css?: string;
|
17
|
-
cookieName?: string;
|
18
|
-
cookieExpirationDays?: number;
|
19
|
-
onAccept?: () => void;
|
20
|
-
onReject?: () => void;
|
21
|
-
translations?: {
|
22
|
-
actions: {
|
23
|
-
accept: string;
|
24
|
-
reject: string;
|
25
|
-
};
|
26
|
-
};
|
27
|
-
enableGoogleAnalytics?: boolean;
|
28
|
-
}
|
29
|
-
|
30
|
-
export const ConsentCookie = forwardRef<HTMLDivElement, ConsentCookieProps>(
|
31
|
-
(
|
32
|
-
{
|
33
|
-
children,
|
34
|
-
variant,
|
35
|
-
cookieName = 'consent',
|
36
|
-
cookieExpirationDays = 365,
|
37
|
-
onAccept,
|
38
|
-
onReject,
|
39
|
-
translations,
|
40
|
-
enableGoogleAnalytics = true,
|
41
|
-
css,
|
42
|
-
className,
|
43
|
-
// Extract sprinkles props
|
44
|
-
margin,
|
45
|
-
marginTop,
|
46
|
-
marginBottom,
|
47
|
-
marginLeft,
|
48
|
-
marginRight,
|
49
|
-
padding,
|
50
|
-
paddingTop,
|
51
|
-
paddingBottom,
|
52
|
-
paddingLeft,
|
53
|
-
paddingRight,
|
54
|
-
gap,
|
55
|
-
display,
|
56
|
-
flexDirection,
|
57
|
-
justifyContent,
|
58
|
-
flexWrap,
|
59
|
-
flex,
|
60
|
-
width,
|
61
|
-
height,
|
62
|
-
minWidth,
|
63
|
-
maxWidth,
|
64
|
-
minHeight,
|
65
|
-
zIndex,
|
66
|
-
fontSize,
|
67
|
-
fontFamily,
|
68
|
-
lineHeight,
|
69
|
-
textAlign,
|
70
|
-
fontWeight,
|
71
|
-
color,
|
72
|
-
backgroundColor,
|
73
|
-
borderRadius,
|
74
|
-
borderWidth,
|
75
|
-
borderStyle,
|
76
|
-
borderColor,
|
77
|
-
boxShadow,
|
78
|
-
opacity,
|
79
|
-
overflow,
|
80
|
-
overflowX,
|
81
|
-
overflowY,
|
82
|
-
...htmlProps
|
83
|
-
},
|
84
|
-
ref
|
85
|
-
) => {
|
86
|
-
const [showConsent, setShowConsent] = useState(false);
|
87
|
-
|
88
|
-
const handleAccept = () => {
|
89
|
-
setShowConsent(false);
|
90
|
-
setCookie(cookieName, 'true', cookieExpirationDays);
|
91
|
-
|
92
|
-
if (enableGoogleAnalytics && typeof window !== 'undefined' && typeof window.gtag !== 'undefined') {
|
93
|
-
window.gtag('consent', 'update', {
|
94
|
-
analytics_storage: 'granted',
|
95
|
-
});
|
96
|
-
}
|
97
|
-
|
98
|
-
onAccept?.();
|
99
|
-
};
|
100
|
-
|
101
|
-
const handleReject = () => {
|
102
|
-
setShowConsent(false);
|
103
|
-
setCookie(cookieName, 'false', cookieExpirationDays);
|
104
|
-
|
105
|
-
if (enableGoogleAnalytics && typeof window !== 'undefined' && typeof window.gtag !== 'undefined') {
|
106
|
-
window.gtag('consent', 'update', {
|
107
|
-
analytics_storage: 'denied',
|
108
|
-
});
|
109
|
-
}
|
110
|
-
|
111
|
-
onReject?.();
|
112
|
-
};
|
113
|
-
|
114
|
-
useEffect(() => {
|
115
|
-
const consentValue = getCookie(cookieName);
|
116
|
-
const shouldShowConsent = consentValue !== 'true' && consentValue !== 'false';
|
117
|
-
const areCookiesAccepted = consentValue === 'true';
|
118
|
-
|
119
|
-
if (shouldShowConsent) {
|
120
|
-
setShowConsent(true);
|
121
|
-
}
|
122
|
-
|
123
|
-
// Set initial Google Analytics consent
|
124
|
-
if (enableGoogleAnalytics && typeof window !== 'undefined' && typeof window.gtag !== 'undefined') {
|
125
|
-
const gAnalyticsConsent = areCookiesAccepted ? 'granted' : 'denied';
|
126
|
-
window.gtag('consent', 'update', {
|
127
|
-
analytics_storage: gAnalyticsConsent,
|
128
|
-
});
|
129
|
-
}
|
130
|
-
}, [cookieName, enableGoogleAnalytics]);
|
131
|
-
|
132
|
-
if (!showConsent) return null;
|
133
|
-
|
134
|
-
return (
|
135
|
-
<div
|
136
|
-
ref={ref}
|
137
|
-
className={clsx(
|
138
|
-
consentRecipe({ variant }),
|
139
|
-
sprinkles({
|
140
|
-
margin,
|
141
|
-
marginTop,
|
142
|
-
marginBottom,
|
143
|
-
marginLeft,
|
144
|
-
marginRight,
|
145
|
-
padding,
|
146
|
-
paddingTop,
|
147
|
-
paddingBottom,
|
148
|
-
paddingLeft,
|
149
|
-
paddingRight,
|
150
|
-
gap,
|
151
|
-
display,
|
152
|
-
flexDirection,
|
153
|
-
justifyContent,
|
154
|
-
flexWrap,
|
155
|
-
flex,
|
156
|
-
width,
|
157
|
-
height,
|
158
|
-
minWidth,
|
159
|
-
maxWidth,
|
160
|
-
minHeight,
|
161
|
-
zIndex,
|
162
|
-
fontSize,
|
163
|
-
fontFamily,
|
164
|
-
lineHeight,
|
165
|
-
textAlign,
|
166
|
-
fontWeight,
|
167
|
-
color,
|
168
|
-
backgroundColor,
|
169
|
-
borderRadius,
|
170
|
-
borderWidth,
|
171
|
-
borderStyle,
|
172
|
-
borderColor,
|
173
|
-
boxShadow,
|
174
|
-
opacity,
|
175
|
-
overflow,
|
176
|
-
overflowX,
|
177
|
-
overflowY,
|
178
|
-
}),
|
179
|
-
css,
|
180
|
-
className
|
181
|
-
)}
|
182
|
-
role="dialog"
|
183
|
-
aria-modal="true"
|
184
|
-
aria-labelledby="consent-title"
|
185
|
-
{...htmlProps}>
|
186
|
-
<div className={consentContent}>
|
187
|
-
{children}
|
188
|
-
<div className={consentActions}>
|
189
|
-
<Button size="sm" onClick={handleReject}>
|
190
|
-
{translations?.actions.reject || 'Reject'}
|
191
|
-
</Button>
|
192
|
-
<Button variant="primary" size="sm" onClick={handleAccept}>
|
193
|
-
{translations?.actions.accept || 'Accept'}
|
194
|
-
</Button>
|
195
|
-
</div>
|
196
|
-
</div>
|
197
|
-
</div>
|
198
|
-
);
|
199
|
-
}
|
200
|
-
);
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
2
|
-
import { useEffect } from 'react';
|
3
|
-
|
4
|
-
import { headerOverlayStyle, vars } from './styles.css';
|
5
|
-
|
6
|
-
export interface HeaderOverlayProps {
|
7
|
-
css?: string;
|
8
|
-
isOpen: boolean;
|
9
|
-
children: React.ReactNode;
|
10
|
-
}
|
11
|
-
|
12
|
-
const HeaderOverlay = ({ isOpen = false, children, css }: HeaderOverlayProps) => {
|
13
|
-
useEffect(() => {
|
14
|
-
const html = document.getElementsByTagName('html')[0];
|
15
|
-
html.style.overflow = '';
|
16
|
-
|
17
|
-
if (isOpen) html.style.overflow = 'hidden';
|
18
|
-
}, [isOpen]);
|
19
|
-
|
20
|
-
return (
|
21
|
-
<div
|
22
|
-
className={`${headerOverlayStyle} ${css}`}
|
23
|
-
style={assignInlineVars({
|
24
|
-
[vars.overlayBottom]: !isOpen ? '100%' : '-100vh',
|
25
|
-
[vars.overlayTransform]: isOpen ? 'translate(0, 0)' : 'translate(0, -100%)',
|
26
|
-
})}>
|
27
|
-
{children}
|
28
|
-
</div>
|
29
|
-
);
|
30
|
-
};
|
31
|
-
|
32
|
-
export default HeaderOverlay;
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { createVar, style } from '@vanilla-extract/css';
|
2
|
-
|
3
|
-
export const vars = {
|
4
|
-
overlayBottom: createVar(),
|
5
|
-
overlayTransform: createVar(),
|
6
|
-
};
|
7
|
-
|
8
|
-
export const headerOverlayStyle = style({
|
9
|
-
top: 0,
|
10
|
-
left: 0,
|
11
|
-
zIndex: 40,
|
12
|
-
width: '100vw',
|
13
|
-
display: 'flex',
|
14
|
-
height: '100vh',
|
15
|
-
position: 'fixed',
|
16
|
-
overflow: 'hidden',
|
17
|
-
textAlign: 'center',
|
18
|
-
alignItems: 'center',
|
19
|
-
flexDirection: 'column',
|
20
|
-
transformOrigin: '0% 0%',
|
21
|
-
justifyContent: 'center',
|
22
|
-
gap: 'var(--overlayGap, 20px)', // valeur par défaut, à remplacer via assignInlineVars si nécessaire
|
23
|
-
bottom: vars.overlayBottom,
|
24
|
-
transform: vars.overlayTransform,
|
25
|
-
transition: 'transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0)',
|
26
|
-
|
27
|
-
// TODO responsive with sprinkles
|
28
|
-
// '@media': {
|
29
|
-
// [mq[0]]: { gap: 'var(--overlayGap0, 20px)' },
|
30
|
-
// [mq[1]]: { gap: 'var(--overlayGap1, 30px)' },
|
31
|
-
// [mq[2]]: { gap: 'var(--overlayGap2, 40px)' },
|
32
|
-
// },
|
33
|
-
});
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
2
|
-
import { toggleNavBarStyle, toggleNavStyle, vars } from './styles.css';
|
3
|
-
|
4
|
-
export type ToggleNavProps = {
|
5
|
-
css?: string;
|
6
|
-
isNavOpen: boolean;
|
7
|
-
onToggleNav: () => void;
|
8
|
-
displayOnDesktop: boolean;
|
9
|
-
};
|
10
|
-
|
11
|
-
export const ToggleNav = ({ isNavOpen = false, onToggleNav, displayOnDesktop, css }: ToggleNavProps) => {
|
12
|
-
const handleClick = () => {
|
13
|
-
window.scrollTo({ top: 0, behavior: 'smooth' });
|
14
|
-
onToggleNav();
|
15
|
-
};
|
16
|
-
|
17
|
-
return (
|
18
|
-
<button
|
19
|
-
className={`${toggleNavStyle} ${css}`}
|
20
|
-
style={assignInlineVars({
|
21
|
-
[vars.displayOnDesktop]: displayOnDesktop ? 'block' : 'none',
|
22
|
-
})}
|
23
|
-
onClick={handleClick}
|
24
|
-
aria-label="Toggle nav">
|
25
|
-
<span className={toggleNavBarStyle} data-open={isNavOpen ? 'true' : 'false'} />
|
26
|
-
<span className={toggleNavBarStyle} data-open={isNavOpen ? 'true' : 'false'} />
|
27
|
-
</button>
|
28
|
-
);
|
29
|
-
};
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { createVar, globalStyle, style } from '@vanilla-extract/css';
|
2
|
-
|
3
|
-
export const vars = {
|
4
|
-
displayOnDesktop: createVar(),
|
5
|
-
};
|
6
|
-
|
7
|
-
export const toggleNavStyle = style({
|
8
|
-
border: 0,
|
9
|
-
width: '25px',
|
10
|
-
height: '12px',
|
11
|
-
zIndex: 60,
|
12
|
-
marginLeft: 0,
|
13
|
-
cursor: 'pointer',
|
14
|
-
position: 'relative',
|
15
|
-
|
16
|
-
'@media': {
|
17
|
-
'screen and (min-width: 1024px)': {
|
18
|
-
display: vars.displayOnDesktop,
|
19
|
-
},
|
20
|
-
},
|
21
|
-
});
|
22
|
-
|
23
|
-
export const toggleNavBarStyle = style({
|
24
|
-
height: '2px',
|
25
|
-
width: '25px',
|
26
|
-
marginBottom: '8px',
|
27
|
-
display: 'block',
|
28
|
-
position: 'relative',
|
29
|
-
transformOrigin: 'center center',
|
30
|
-
transition: 'all 0.5s ease-in-out',
|
31
|
-
});
|
32
|
-
|
33
|
-
// Style dynamique pour chaque ligne via data attribute
|
34
|
-
globalStyle(`${toggleNavBarStyle}[data-open="true"]:nth-of-type(1)`, {
|
35
|
-
transform: 'rotate(45deg) translate(4px, 3px)',
|
36
|
-
});
|
37
|
-
|
38
|
-
globalStyle(`${toggleNavBarStyle}[data-open="true"]:nth-of-type(2)`, {
|
39
|
-
transform: 'rotate(-45deg) translate(4px, -3px)',
|
40
|
-
});
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { style } from '@vanilla-extract/css';
|
2
|
-
import { themeContract } from '../../theme/contract.css';
|
3
|
-
|
4
|
-
export const testStyle = style({
|
5
|
-
padding: themeContract.space.lg,
|
6
|
-
backgroundColor: themeContract.colors.primary,
|
7
|
-
color: themeContract.colors.text,
|
8
|
-
borderRadius: themeContract.radii.md,
|
9
|
-
margin: themeContract.space.md,
|
10
|
-
border: `2px solid ${themeContract.colors.border}`,
|
11
|
-
});
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { testStyle } from './ThemeTest.css';
|
2
|
-
|
3
|
-
export function ThemeTest() {
|
4
|
-
return (
|
5
|
-
<div className={testStyle}>
|
6
|
-
<h3>Theme Test Component</h3>
|
7
|
-
<p>Background should be primary color</p>
|
8
|
-
<p>Text should be theme text color</p>
|
9
|
-
<p>This should change when you toggle the theme!</p>
|
10
|
-
</div>
|
11
|
-
);
|
12
|
-
}
|
File without changes
|