@latte-macchiat-io/latte-vanilla-components 0.0.176 → 0.0.178
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 +9 -22
- package/src/assets/styles/mediaqueries.tsx +24 -0
- package/src/components/Actions/Actions.tsx +132 -0
- package/src/components/Actions/export.tsx +4 -0
- package/src/components/{Main/stories.ts → Actions/stories.tsx} +14 -13
- package/src/components/Button/Button.tsx +132 -0
- package/src/components/Button/export.tsx +5 -0
- package/src/components/Carousel/Carousel.tsx +328 -0
- package/src/components/Carousel/export.tsx +4 -0
- package/src/components/Columns/Columns.tsx +142 -0
- package/src/components/Columns/export.tsx +5 -0
- package/src/components/ConsentCookie/ConsentCookie.tsx +202 -0
- package/src/components/ConsentCookie/export.tsx +4 -0
- package/src/components/{Icon/stories.ts → ConsentCookie/stories.tsx} +7 -8
- package/src/components/Footer/Footer.tsx +130 -0
- package/src/components/Footer/export.tsx +4 -0
- package/src/components/Footer/stories.tsx +26 -0
- package/src/components/Form/Form.tsx +127 -0
- package/src/components/Form/Row/Row.tsx +137 -0
- package/src/components/Form/Row/stories.tsx +41 -0
- package/src/components/Form/TextField/Input/Input.tsx +139 -0
- package/src/components/Form/TextField/Input/export.tsx +6 -0
- package/src/components/Form/TextField/Label/Label.tsx +133 -0
- package/src/components/Form/TextField/Label/export.tsx +4 -0
- package/src/components/Form/TextField/TextField.tsx +200 -0
- package/src/components/Form/TextField/Textarea/Textarea.tsx +135 -0
- package/src/components/Form/TextField/Textarea/export.tsx +6 -0
- package/src/components/Form/TextField/Textarea/stories.tsx +44 -0
- package/src/components/Form/TextField/export.tsx +4 -0
- package/src/components/Form/export.tsx +4 -0
- package/src/components/Header/Header.tsx +158 -0
- package/src/components/Header/HeaderOverlay/index.tsx +32 -0
- package/src/components/Header/ToggleNav/index.tsx +32 -0
- package/src/components/Header/export.tsx +4 -0
- package/src/components/Header/stories.tsx +26 -0
- package/src/components/Icon/Icon.tsx +159 -0
- package/src/components/Icon/export.tsx +4 -0
- package/src/components/KeyNumber/KeyNumber.tsx +166 -0
- package/src/components/KeyNumber/export.tsx +4 -0
- package/src/components/LanguageSwitcher/LanguageSwitcher.tsx +168 -0
- package/src/components/LanguageSwitcher/export.tsx +4 -0
- package/src/components/Logo/Logo.tsx +137 -0
- package/src/components/Logo/export.tsx +4 -0
- package/src/components/Logo/stories.tsx +28 -0
- package/src/components/Main/Main.tsx +130 -0
- package/src/components/Main/export.tsx +4 -0
- package/src/components/Modal/Modal.tsx +194 -0
- package/src/components/Modal/export.tsx +4 -0
- package/src/components/Modal/types.tsx +5 -0
- package/src/components/Nav/Nav.tsx +129 -0
- package/src/components/Nav/export.tsx +4 -0
- package/src/components/Nav/stories.tsx +28 -0
- package/src/components/NavLegal/NavLegal.tsx +133 -0
- package/src/components/NavLegal/export.tsx +4 -0
- package/src/components/NavLegal/stories.tsx +28 -0
- package/src/components/NavSocial/NavSocial.tsx +169 -0
- package/src/components/NavSocial/export.tsx +5 -0
- package/src/components/{Columns/stories.ts → NavSocial/stories.tsx} +12 -14
- package/src/components/Section/Section.tsx +130 -0
- package/src/components/Section/export.tsx +6 -0
- package/src/components/ToRemove/ToRemove.tsx +3 -0
- package/src/components/Video/Video.tsx +243 -0
- package/src/components/Video/export.tsx +2 -0
- package/src/components/VideoFullWidth/VideoFullWidth.tsx +152 -0
- package/src/components/VideoFullWidth/export.tsx +2 -0
- package/dist/components/Actions/Actions.css.ts +0 -113
- package/dist/components/Button/Button.css.ts +0 -119
- package/dist/components/Carousel/Carousel.css.ts +0 -179
- package/dist/components/Columns/Columns.css.ts +0 -185
- package/dist/components/ConsentCookie/ConsentCookie.css.ts +0 -167
- package/dist/components/Footer/Footer.css.ts +0 -108
- package/dist/components/Form/Form.css.ts +0 -64
- package/dist/components/Form/Row/Row.css.ts +0 -70
- package/dist/components/Form/TextField/Input/Input.css.ts +0 -106
- package/dist/components/Form/TextField/Label/Label.css.ts +0 -58
- package/dist/components/Form/TextField/TextField.css.ts +0 -139
- package/dist/components/Form/TextField/Textarea/Textarea.css.ts +0 -121
- package/dist/components/Header/Header.css.ts +0 -111
- package/dist/components/Header/HeaderOverlay/styles.css.ts +0 -33
- package/dist/components/Header/ToggleNav/styles.css.ts +0 -40
- package/dist/components/Icon/Icon.css.ts +0 -102
- package/dist/components/KeyNumber/KeyNumber.css.ts +0 -158
- package/dist/components/LanguageSwitcher/LanguageSwitcher.css.ts +0 -120
- package/dist/components/Logo/Logo.css.ts +0 -98
- package/dist/components/Main/Main.css.ts +0 -62
- package/dist/components/Modal/Modal.css.ts +0 -203
- package/dist/components/Nav/Nav.css.ts +0 -123
- package/dist/components/NavLegal/NavLegal.css.ts +0 -121
- package/dist/components/NavSocial/NavSocial.css.ts +0 -121
- package/dist/components/Section/Section.css.ts +0 -101
- package/dist/components/Video/Video.css.ts +0 -210
- package/dist/components/VideoFullWidth/VideoFullWidth.css.ts +0 -50
- package/dist/css/index.cjs +0 -1
- package/dist/css/index.js +0 -34
- package/dist/index.cjs.js +0 -2
- package/dist/index.es.js +0 -3863
- package/dist/styles/sprinkles.css.ts +0 -84
- package/dist/theme/contract.css.ts +0 -83
- package/dist/theme.css-CNjMk-g_.cjs +0 -1
- package/dist/theme.css-Dj6kL9o0.js +0 -3020
- package/dist/types/components/Actions/Actions.css.d.ts +0 -74
- package/dist/types/components/Actions/Actions.d.ts +0 -7
- package/dist/types/components/Actions/stories.d.ts +0 -0
- package/dist/types/components/Button/Button.css.d.ts +0 -65
- package/dist/types/components/Button/Button.d.ts +0 -8
- package/dist/types/components/Button/export.d.ts +0 -0
- package/dist/types/components/Button/stories.d.ts +0 -0
- package/dist/types/components/Carousel/Carousel.css.d.ts +0 -33
- package/dist/types/components/Carousel/Carousel.d.ts +0 -15
- package/dist/types/components/Carousel/export.d.ts +0 -0
- package/dist/types/components/Columns/Columns.css.d.ts +0 -104
- package/dist/types/components/Columns/Columns.d.ts +0 -8
- package/dist/types/components/Columns/export.d.ts +0 -0
- package/dist/types/components/Columns/stories.d.ts +0 -0
- package/dist/types/components/ConsentCookie/ConsentCookie.css.d.ts +0 -15
- package/dist/types/components/ConsentCookie/ConsentCookie.d.ts +0 -17
- package/dist/types/components/ConsentCookie/export.d.ts +0 -0
- package/dist/types/components/ConsentCookie/stories.d.ts +0 -0
- package/dist/types/components/Footer/Footer.css.d.ts +0 -50
- package/dist/types/components/Footer/Footer.d.ts +0 -7
- package/dist/types/components/Footer/export.d.ts +0 -0
- package/dist/types/components/Footer/stories.d.ts +0 -6
- package/dist/types/components/Form/Form.css.d.ts +0 -46
- package/dist/types/components/Form/Form.d.ts +0 -7
- package/dist/types/components/Form/Row/Row.css.d.ts +0 -51
- package/dist/types/components/Form/Row/Row.d.ts +0 -9
- package/dist/types/components/Form/Row/index.d.ts +0 -0
- package/dist/types/components/Form/Row/stories.d.ts +0 -0
- package/dist/types/components/Form/TextField/Input/Input.css.d.ts +0 -32
- package/dist/types/components/Form/TextField/Input/Input.d.ts +0 -10
- package/dist/types/components/Form/TextField/Input/export.d.ts +0 -0
- package/dist/types/components/Form/TextField/Label/Label.css.d.ts +0 -23
- package/dist/types/components/Form/TextField/Label/Label.d.ts +0 -9
- package/dist/types/components/Form/TextField/Label/export.d.ts +0 -0
- package/dist/types/components/Form/TextField/TextField.css.d.ts +0 -19
- package/dist/types/components/Form/TextField/TextField.d.ts +0 -21
- package/dist/types/components/Form/TextField/Textarea/Textarea.css.d.ts +0 -56
- package/dist/types/components/Form/TextField/Textarea/Textarea.d.ts +0 -8
- package/dist/types/components/Form/TextField/Textarea/export.d.ts +0 -0
- package/dist/types/components/Form/TextField/Textarea/stories.d.ts +0 -0
- package/dist/types/components/Form/TextField/export.d.ts +0 -0
- package/dist/types/components/Form/export.d.ts +0 -0
- package/dist/types/components/Header/Header.css.d.ts +0 -36
- package/dist/types/components/Header/Header.d.ts +0 -11
- package/dist/types/components/Header/HeaderOverlay/index.d.ts +0 -7
- package/dist/types/components/Header/HeaderOverlay/styles.css.d.ts +0 -5
- package/dist/types/components/Header/ToggleNav/index.d.ts +0 -9
- package/dist/types/components/Header/ToggleNav/styles.css.d.ts +0 -5
- package/dist/types/components/Header/export.d.ts +0 -0
- package/dist/types/components/Header/stories.d.ts +0 -6
- package/dist/types/components/Icon/Icon.css.d.ts +0 -45
- package/dist/types/components/Icon/Icon.d.ts +0 -12
- package/dist/types/components/Icon/export.d.ts +0 -0
- package/dist/types/components/Icon/path.d.ts +0 -19
- package/dist/types/components/Icon/stories.d.ts +0 -0
- package/dist/types/components/KeyNumber/KeyNumber.css.d.ts +0 -40
- package/dist/types/components/KeyNumber/KeyNumber.d.ts +0 -15
- package/dist/types/components/KeyNumber/export.d.ts +0 -0
- package/dist/types/components/LanguageSwitcher/LanguageSwitcher.css.d.ts +0 -18
- package/dist/types/components/LanguageSwitcher/LanguageSwitcher.d.ts +0 -16
- package/dist/types/components/LanguageSwitcher/export.d.ts +0 -0
- package/dist/types/components/Logo/Logo.css.d.ts +0 -54
- package/dist/types/components/Logo/Logo.d.ts +0 -8
- package/dist/types/components/Logo/export.d.ts +0 -0
- package/dist/types/components/Logo/stories.d.ts +0 -6
- package/dist/types/components/Main/Main.css.d.ts +0 -32
- package/dist/types/components/Main/Main.d.ts +0 -7
- package/dist/types/components/Main/export.d.ts +0 -0
- package/dist/types/components/Main/stories.d.ts +0 -0
- package/dist/types/components/Modal/Modal.css.d.ts +0 -82
- package/dist/types/components/Modal/Modal.d.ts +0 -15
- package/dist/types/components/Modal/export.d.ts +0 -0
- package/dist/types/components/Modal/types.d.ts +0 -5
- package/dist/types/components/Nav/Nav.css.d.ts +0 -52
- package/dist/types/components/Nav/Nav.d.ts +0 -7
- package/dist/types/components/Nav/export.d.ts +0 -0
- package/dist/types/components/Nav/stories.d.ts +0 -6
- package/dist/types/components/NavLegal/NavLegal.css.d.ts +0 -57
- package/dist/types/components/NavLegal/NavLegal.d.ts +0 -7
- package/dist/types/components/NavLegal/export.d.ts +0 -0
- package/dist/types/components/NavLegal/stories.d.ts +0 -6
- package/dist/types/components/NavSocial/NavSocial.css.d.ts +0 -30
- package/dist/types/components/NavSocial/NavSocial.d.ts +0 -15
- package/dist/types/components/NavSocial/export.d.ts +0 -0
- package/dist/types/components/NavSocial/stories.d.ts +0 -0
- package/dist/types/components/Section/Section.css.d.ts +0 -60
- package/dist/types/components/Section/Section.d.ts +0 -7
- package/dist/types/components/Section/export.d.ts +0 -0
- package/dist/types/components/Section/stories.d.ts +0 -0
- package/dist/types/components/ToRemove/ToRemove.d.ts +0 -1
- package/dist/types/components/Video/Video.css.d.ts +0 -43
- package/dist/types/components/Video/Video.d.ts +0 -17
- package/dist/types/components/Video/export.d.ts +0 -0
- package/dist/types/components/VideoFullWidth/VideoFullWidth.css.d.ts +0 -18
- package/dist/types/components/VideoFullWidth/VideoFullWidth.d.ts +0 -14
- package/dist/types/components/VideoFullWidth/export.d.ts +0 -0
- package/dist/types/css/index.d.ts +0 -28
- package/dist/types/index.d.ts +0 -58
- package/dist/types/styles/mediaqueries.d.ts +0 -16
- package/dist/types/styles/sprinkles.css.d.ts +0 -3423
- package/dist/types/theme/baseThemeValues.d.ts +0 -158
- package/dist/types/theme/contract.css.d.ts +0 -79
- package/dist/types/theme/index.d.ts +0 -3
- package/dist/types/theme/utils.d.ts +0 -86
- package/dist/types/utils/cookie.d.ts +0 -2
- package/dist/types/utils/deep-merge-objects.d.ts +0 -2
- package/dist/types/utils/theme.css.d.ts +0 -173
- package/dist/types/utils/use-breakpoint-key.d.ts +0 -1
- package/dist/types/utils/use-window-size.d.ts +0 -5
- package/dist/utils/theme.css.ts +0 -129
- package/src/components/Button/stories.ts +0 -127
- package/src/components/Section/stories.ts +0 -64
- package/src/css/index.ts +0 -33
- package/src/themes/dark.ts +0 -3
- package/src/themes/index.ts +0 -5
- package/src/themes/light.ts +0 -3
- /package/{dist/types/components/Actions/export.d.ts → src/components/Form/Row/index.tsx} +0 -0
- /package/{dist/types/components/NavLegal/types.d.ts → src/components/NavLegal/types.tsx} +0 -0
- /package/{dist/types/components/NavSocial/types.d.ts → src/components/NavSocial/types.tsx} +0 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
2
|
+
import { useEffect } from 'react';
|
3
|
+
import { WithClassName } from '@/types/withClassName';
|
4
|
+
|
5
|
+
import { headerOverlayStyle, vars } from './styles.css';
|
6
|
+
|
7
|
+
export interface HeaderOverlayProps {
|
8
|
+
isOpen: boolean;
|
9
|
+
children: React.ReactNode;
|
10
|
+
}
|
11
|
+
|
12
|
+
const HeaderOverlay = ({ isOpen = false, children, className }: HeaderOverlayProps & WithClassName) => {
|
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} ${className}`}
|
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;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
2
|
+
import { Theme } from '@/types/theme';
|
3
|
+
import { WithClassName } from '@/types/withClassName';
|
4
|
+
import { toggleNavBarStyle, toggleNavStyle, vars } from './styles.css';
|
5
|
+
import { defaultTheme } from '../../../assets/styles/default-theme';
|
6
|
+
|
7
|
+
export type ToggleNavProps = {
|
8
|
+
theme?: Theme;
|
9
|
+
isNavOpen: boolean;
|
10
|
+
onToggleNav: () => void;
|
11
|
+
displayOnDesktop: boolean;
|
12
|
+
};
|
13
|
+
|
14
|
+
export const ToggleNav = ({ theme = defaultTheme, isNavOpen = false, onToggleNav, displayOnDesktop, className }: ToggleNavProps & WithClassName) => {
|
15
|
+
const handleClick = () => {
|
16
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
17
|
+
onToggleNav();
|
18
|
+
};
|
19
|
+
|
20
|
+
return (
|
21
|
+
<button
|
22
|
+
className={`${toggleNavStyle} ${className}`}
|
23
|
+
style={assignInlineVars({
|
24
|
+
[vars.displayOnDesktop]: displayOnDesktop ? 'block' : 'none',
|
25
|
+
})}
|
26
|
+
onClick={handleClick}
|
27
|
+
aria-label="Toggle nav">
|
28
|
+
<span className={toggleNavBarStyle} data-open={isNavOpen ? 'true' : 'false'} />
|
29
|
+
<span className={toggleNavBarStyle} data-open={isNavOpen ? 'true' : 'false'} />
|
30
|
+
</button>
|
31
|
+
);
|
32
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
|
3
|
+
import { Header } from '../../index';
|
4
|
+
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
6
|
+
const meta: Meta<typeof Header> = {
|
7
|
+
title: 'Latte Components / Layout / Header',
|
8
|
+
component: Header,
|
9
|
+
parameters: {
|
10
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
11
|
+
layout: 'centered',
|
12
|
+
},
|
13
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
14
|
+
tags: ['autodocs'],
|
15
|
+
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
16
|
+
argTypes: {},
|
17
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
18
|
+
};
|
19
|
+
|
20
|
+
export default meta;
|
21
|
+
type Story = StoryObj<typeof meta>;
|
22
|
+
|
23
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
24
|
+
export const Default: Story = {
|
25
|
+
args: {},
|
26
|
+
};
|
@@ -0,0 +1,159 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { iconRecipe, type IconVariants } from './Icon.css';
|
4
|
+
import iconPaths from './path';
|
5
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
6
|
+
|
7
|
+
export interface IconProps
|
8
|
+
extends Omit<
|
9
|
+
React.SVGProps<SVGSVGElement>,
|
10
|
+
'color' | 'size' | 'display' | 'fontFamily' | 'fontSize' | 'fontWeight' | 'height' | 'opacity' | 'overflow' | 'width'
|
11
|
+
>,
|
12
|
+
Sprinkles,
|
13
|
+
NonNullable<IconVariants> {
|
14
|
+
css?: string;
|
15
|
+
icon?: keyof typeof iconPaths;
|
16
|
+
iconPath?: string;
|
17
|
+
customSize?: number;
|
18
|
+
customColor?: string;
|
19
|
+
viewBox?: string;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const Icon = forwardRef<SVGSVGElement, IconProps>(
|
23
|
+
(
|
24
|
+
{
|
25
|
+
icon,
|
26
|
+
iconPath,
|
27
|
+
size,
|
28
|
+
color,
|
29
|
+
customSize,
|
30
|
+
customColor,
|
31
|
+
interactive,
|
32
|
+
viewBox = '0 0 24 24',
|
33
|
+
css,
|
34
|
+
className,
|
35
|
+
// Extract sprinkles props
|
36
|
+
margin,
|
37
|
+
marginTop,
|
38
|
+
marginBottom,
|
39
|
+
marginLeft,
|
40
|
+
marginRight,
|
41
|
+
padding,
|
42
|
+
paddingTop,
|
43
|
+
paddingBottom,
|
44
|
+
paddingLeft,
|
45
|
+
paddingRight,
|
46
|
+
gap,
|
47
|
+
display,
|
48
|
+
flexDirection,
|
49
|
+
justifyContent,
|
50
|
+
flexWrap,
|
51
|
+
flex,
|
52
|
+
width,
|
53
|
+
height,
|
54
|
+
minWidth,
|
55
|
+
maxWidth,
|
56
|
+
minHeight,
|
57
|
+
position,
|
58
|
+
top,
|
59
|
+
bottom,
|
60
|
+
left,
|
61
|
+
right,
|
62
|
+
zIndex,
|
63
|
+
fontSize,
|
64
|
+
fontFamily,
|
65
|
+
lineHeight,
|
66
|
+
textAlign,
|
67
|
+
fontWeight,
|
68
|
+
backgroundColor,
|
69
|
+
borderRadius,
|
70
|
+
borderWidth,
|
71
|
+
borderStyle,
|
72
|
+
borderColor,
|
73
|
+
boxShadow,
|
74
|
+
opacity,
|
75
|
+
overflow,
|
76
|
+
overflowX,
|
77
|
+
overflowY,
|
78
|
+
...svgProps
|
79
|
+
},
|
80
|
+
ref
|
81
|
+
) => {
|
82
|
+
const pathData = iconPath || (icon ? iconPaths[icon] : '');
|
83
|
+
|
84
|
+
const iconStyle = customSize
|
85
|
+
? {
|
86
|
+
width: `${customSize}px`,
|
87
|
+
height: `${customSize}px`,
|
88
|
+
}
|
89
|
+
: {};
|
90
|
+
|
91
|
+
const pathStyle = customColor
|
92
|
+
? {
|
93
|
+
fill: customColor,
|
94
|
+
}
|
95
|
+
: {};
|
96
|
+
|
97
|
+
return (
|
98
|
+
<svg
|
99
|
+
ref={ref}
|
100
|
+
viewBox={viewBox}
|
101
|
+
className={clsx(
|
102
|
+
iconRecipe({ size: customSize ? undefined : size, interactive }),
|
103
|
+
sprinkles({
|
104
|
+
margin,
|
105
|
+
marginTop,
|
106
|
+
marginBottom,
|
107
|
+
marginLeft,
|
108
|
+
marginRight,
|
109
|
+
padding,
|
110
|
+
paddingTop,
|
111
|
+
paddingBottom,
|
112
|
+
paddingLeft,
|
113
|
+
paddingRight,
|
114
|
+
gap,
|
115
|
+
display,
|
116
|
+
flexDirection,
|
117
|
+
justifyContent,
|
118
|
+
flexWrap,
|
119
|
+
flex,
|
120
|
+
width,
|
121
|
+
height,
|
122
|
+
minWidth,
|
123
|
+
maxWidth,
|
124
|
+
minHeight,
|
125
|
+
position,
|
126
|
+
top,
|
127
|
+
bottom,
|
128
|
+
left,
|
129
|
+
right,
|
130
|
+
zIndex,
|
131
|
+
fontSize,
|
132
|
+
fontFamily,
|
133
|
+
lineHeight,
|
134
|
+
textAlign,
|
135
|
+
fontWeight,
|
136
|
+
backgroundColor,
|
137
|
+
borderRadius,
|
138
|
+
borderWidth,
|
139
|
+
borderStyle,
|
140
|
+
borderColor,
|
141
|
+
boxShadow,
|
142
|
+
opacity,
|
143
|
+
overflow,
|
144
|
+
overflowX,
|
145
|
+
overflowY,
|
146
|
+
}),
|
147
|
+
css,
|
148
|
+
className
|
149
|
+
)}
|
150
|
+
style={iconStyle}
|
151
|
+
aria-hidden={!svgProps['aria-label'] && !svgProps['aria-labelledby']}
|
152
|
+
{...svgProps}>
|
153
|
+
<path className={iconPath} d={pathData} style={pathStyle} />
|
154
|
+
</svg>
|
155
|
+
);
|
156
|
+
}
|
157
|
+
);
|
158
|
+
|
159
|
+
Icon.displayName = 'Icon';
|
@@ -0,0 +1,166 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import CountUp from 'react-countup';
|
4
|
+
import { useInView } from 'react-intersection-observer';
|
5
|
+
import { keyNumberLabel, keyNumberRecipe, keyNumberValue, type KeyNumberVariants } from './KeyNumber.css';
|
6
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
7
|
+
|
8
|
+
export interface KeyNumberProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Sprinkles, NonNullable<KeyNumberVariants> {
|
9
|
+
css?: string;
|
10
|
+
value: number;
|
11
|
+
label: string;
|
12
|
+
suffix?: string;
|
13
|
+
prefix?: string;
|
14
|
+
duration?: number;
|
15
|
+
threshold?: number;
|
16
|
+
separator?: string;
|
17
|
+
decimals?: number;
|
18
|
+
as?: 'div' | 'section' | 'article';
|
19
|
+
}
|
20
|
+
|
21
|
+
export const KeyNumber = forwardRef<HTMLDivElement, KeyNumberProps>(
|
22
|
+
(
|
23
|
+
{
|
24
|
+
value,
|
25
|
+
label,
|
26
|
+
suffix = '',
|
27
|
+
prefix = '',
|
28
|
+
duration = 2,
|
29
|
+
threshold = 0.3,
|
30
|
+
separator = ',',
|
31
|
+
decimals = 0,
|
32
|
+
size,
|
33
|
+
variant,
|
34
|
+
align,
|
35
|
+
color,
|
36
|
+
as: Component = 'div',
|
37
|
+
css,
|
38
|
+
className,
|
39
|
+
// Extract sprinkles props
|
40
|
+
margin,
|
41
|
+
marginTop,
|
42
|
+
marginBottom,
|
43
|
+
marginLeft,
|
44
|
+
marginRight,
|
45
|
+
padding,
|
46
|
+
paddingTop,
|
47
|
+
paddingBottom,
|
48
|
+
paddingLeft,
|
49
|
+
paddingRight,
|
50
|
+
gap,
|
51
|
+
display,
|
52
|
+
flexDirection,
|
53
|
+
justifyContent,
|
54
|
+
flexWrap,
|
55
|
+
flex,
|
56
|
+
width,
|
57
|
+
height,
|
58
|
+
minWidth,
|
59
|
+
maxWidth,
|
60
|
+
minHeight,
|
61
|
+
position,
|
62
|
+
top,
|
63
|
+
bottom,
|
64
|
+
left,
|
65
|
+
right,
|
66
|
+
zIndex,
|
67
|
+
fontSize,
|
68
|
+
fontFamily,
|
69
|
+
lineHeight,
|
70
|
+
textAlign,
|
71
|
+
fontWeight,
|
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 [inViewRef, inView] = useInView({
|
87
|
+
threshold,
|
88
|
+
triggerOnce: true,
|
89
|
+
});
|
90
|
+
|
91
|
+
return (
|
92
|
+
<Component
|
93
|
+
ref={(node) => {
|
94
|
+
inViewRef(node);
|
95
|
+
if (ref) {
|
96
|
+
if (typeof ref === 'function') {
|
97
|
+
ref(node);
|
98
|
+
} else {
|
99
|
+
(ref as any).current = node;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}}
|
103
|
+
className={clsx(
|
104
|
+
keyNumberRecipe({ size, variant, align }),
|
105
|
+
sprinkles({
|
106
|
+
margin,
|
107
|
+
marginTop,
|
108
|
+
marginBottom,
|
109
|
+
marginLeft,
|
110
|
+
marginRight,
|
111
|
+
padding,
|
112
|
+
paddingTop,
|
113
|
+
paddingBottom,
|
114
|
+
paddingLeft,
|
115
|
+
paddingRight,
|
116
|
+
gap,
|
117
|
+
display,
|
118
|
+
flexDirection,
|
119
|
+
justifyContent,
|
120
|
+
flexWrap,
|
121
|
+
flex,
|
122
|
+
width,
|
123
|
+
height,
|
124
|
+
minWidth,
|
125
|
+
maxWidth,
|
126
|
+
minHeight,
|
127
|
+
position,
|
128
|
+
top,
|
129
|
+
bottom,
|
130
|
+
left,
|
131
|
+
right,
|
132
|
+
zIndex,
|
133
|
+
fontSize,
|
134
|
+
fontFamily,
|
135
|
+
lineHeight,
|
136
|
+
textAlign,
|
137
|
+
fontWeight,
|
138
|
+
backgroundColor,
|
139
|
+
borderRadius,
|
140
|
+
borderWidth,
|
141
|
+
borderStyle,
|
142
|
+
borderColor,
|
143
|
+
boxShadow,
|
144
|
+
opacity,
|
145
|
+
overflow,
|
146
|
+
overflowX,
|
147
|
+
overflowY,
|
148
|
+
}),
|
149
|
+
css,
|
150
|
+
className
|
151
|
+
)}
|
152
|
+
{...htmlProps}>
|
153
|
+
<div className={keyNumberValue}>
|
154
|
+
{prefix}
|
155
|
+
<span>
|
156
|
+
<CountUp end={inView ? value : 0} duration={duration} separator={separator} decimals={decimals} />
|
157
|
+
</span>
|
158
|
+
{suffix}
|
159
|
+
</div>
|
160
|
+
<p className={keyNumberLabel}>{label}</p>
|
161
|
+
</Component>
|
162
|
+
);
|
163
|
+
}
|
164
|
+
);
|
165
|
+
|
166
|
+
KeyNumber.displayName = 'KeyNumber';
|
@@ -0,0 +1,168 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { languageSwitcherIcon, languageSwitcherRecipe, languageSwitcherSelect, type LanguageSwitcherVariants } from './LanguageSwitcher.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
5
|
+
import { Icon } from '../Icon/Icon';
|
6
|
+
|
7
|
+
export interface Locale {
|
8
|
+
code: string;
|
9
|
+
name: string;
|
10
|
+
label?: string;
|
11
|
+
}
|
12
|
+
|
13
|
+
export interface LanguageSwitcherProps
|
14
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color' | 'onChange'>,
|
15
|
+
Sprinkles,
|
16
|
+
NonNullable<LanguageSwitcherVariants> {
|
17
|
+
css?: string;
|
18
|
+
locales: Locale[];
|
19
|
+
currentLocale: string;
|
20
|
+
onChange: (locale: string) => void;
|
21
|
+
disabled?: boolean;
|
22
|
+
placeholder?: string;
|
23
|
+
}
|
24
|
+
|
25
|
+
export const LanguageSwitcher = forwardRef<HTMLDivElement, LanguageSwitcherProps>(
|
26
|
+
(
|
27
|
+
{
|
28
|
+
locales,
|
29
|
+
currentLocale,
|
30
|
+
onChange,
|
31
|
+
disabled = false,
|
32
|
+
placeholder,
|
33
|
+
variant,
|
34
|
+
size,
|
35
|
+
css,
|
36
|
+
className,
|
37
|
+
// Extract sprinkles props
|
38
|
+
margin,
|
39
|
+
marginTop,
|
40
|
+
marginBottom,
|
41
|
+
marginLeft,
|
42
|
+
marginRight,
|
43
|
+
padding,
|
44
|
+
paddingTop,
|
45
|
+
paddingBottom,
|
46
|
+
paddingLeft,
|
47
|
+
paddingRight,
|
48
|
+
gap,
|
49
|
+
display,
|
50
|
+
flexDirection,
|
51
|
+
justifyContent,
|
52
|
+
flexWrap,
|
53
|
+
flex,
|
54
|
+
width,
|
55
|
+
height,
|
56
|
+
minWidth,
|
57
|
+
maxWidth,
|
58
|
+
minHeight,
|
59
|
+
position,
|
60
|
+
top,
|
61
|
+
bottom,
|
62
|
+
left,
|
63
|
+
right,
|
64
|
+
zIndex,
|
65
|
+
fontSize,
|
66
|
+
fontFamily,
|
67
|
+
lineHeight,
|
68
|
+
textAlign,
|
69
|
+
fontWeight,
|
70
|
+
color,
|
71
|
+
backgroundColor,
|
72
|
+
borderRadius,
|
73
|
+
borderWidth,
|
74
|
+
borderStyle,
|
75
|
+
borderColor,
|
76
|
+
boxShadow,
|
77
|
+
opacity,
|
78
|
+
overflow,
|
79
|
+
overflowX,
|
80
|
+
overflowY,
|
81
|
+
...htmlProps
|
82
|
+
},
|
83
|
+
ref
|
84
|
+
) => {
|
85
|
+
const handleSelectChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
86
|
+
onChange(event.target.value);
|
87
|
+
};
|
88
|
+
|
89
|
+
return (
|
90
|
+
<div
|
91
|
+
ref={ref}
|
92
|
+
className={clsx(
|
93
|
+
languageSwitcherRecipe({ variant, size }),
|
94
|
+
sprinkles({
|
95
|
+
margin,
|
96
|
+
marginTop,
|
97
|
+
marginBottom,
|
98
|
+
marginLeft,
|
99
|
+
marginRight,
|
100
|
+
padding,
|
101
|
+
paddingTop,
|
102
|
+
paddingBottom,
|
103
|
+
paddingLeft,
|
104
|
+
paddingRight,
|
105
|
+
gap,
|
106
|
+
display,
|
107
|
+
flexDirection,
|
108
|
+
justifyContent,
|
109
|
+
flexWrap,
|
110
|
+
flex,
|
111
|
+
width,
|
112
|
+
height,
|
113
|
+
minWidth,
|
114
|
+
maxWidth,
|
115
|
+
minHeight,
|
116
|
+
position,
|
117
|
+
top,
|
118
|
+
bottom,
|
119
|
+
left,
|
120
|
+
right,
|
121
|
+
zIndex,
|
122
|
+
fontSize,
|
123
|
+
fontFamily,
|
124
|
+
lineHeight,
|
125
|
+
textAlign,
|
126
|
+
fontWeight,
|
127
|
+
color,
|
128
|
+
backgroundColor,
|
129
|
+
borderRadius,
|
130
|
+
borderWidth,
|
131
|
+
borderStyle,
|
132
|
+
borderColor,
|
133
|
+
boxShadow,
|
134
|
+
opacity,
|
135
|
+
overflow,
|
136
|
+
overflowX,
|
137
|
+
overflowY,
|
138
|
+
}),
|
139
|
+
css,
|
140
|
+
className
|
141
|
+
)}
|
142
|
+
{...htmlProps}>
|
143
|
+
<select
|
144
|
+
className={languageSwitcherSelect}
|
145
|
+
value={currentLocale}
|
146
|
+
onChange={handleSelectChange}
|
147
|
+
disabled={disabled}
|
148
|
+
aria-label="Switch language">
|
149
|
+
{placeholder && (
|
150
|
+
<option value="" disabled>
|
151
|
+
{placeholder}
|
152
|
+
</option>
|
153
|
+
)}
|
154
|
+
{locales.map((locale) => (
|
155
|
+
<option key={locale.code} value={locale.code} disabled={locale.code === currentLocale}>
|
156
|
+
{locale.label || locale.name}
|
157
|
+
</option>
|
158
|
+
))}
|
159
|
+
</select>
|
160
|
+
<div className={languageSwitcherIcon}>
|
161
|
+
<Icon icon="caret" size="sm" />
|
162
|
+
</div>
|
163
|
+
</div>
|
164
|
+
);
|
165
|
+
}
|
166
|
+
);
|
167
|
+
|
168
|
+
LanguageSwitcher.displayName = 'LanguageSwitcher';
|