@latte-macchiat-io/latte-vanilla-components 0.0.177 → 0.0.179
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 +3 -1
- 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/index.tsx +0 -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/NavLegal/types.tsx +1 -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/NavSocial/types.tsx +1 -0
- 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/src/index.ts +1 -1
- package/src/components/Button/stories.ts +0 -127
- package/src/components/Section/stories.ts +0 -64
- /package/src/utils/{theme.css.ts → theme.ts} +0 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef, useEffect, useState } from 'react';
|
3
|
+
import { modalCloseButton, modalContentRecipe, type ModalContentVariants, modalRecipe, type ModalVariants } from './Modal.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
5
|
+
import { Icon } from '../Icon/Icon';
|
6
|
+
|
7
|
+
export interface ModalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>, Sprinkles, NonNullable<ModalVariants> {
|
8
|
+
css?: string;
|
9
|
+
isOpen: boolean;
|
10
|
+
onClose?: () => void;
|
11
|
+
showCloseButton?: boolean;
|
12
|
+
closeOnBackdropClick?: boolean;
|
13
|
+
closeOnEscape?: boolean;
|
14
|
+
contentProps?: ModalContentVariants & {
|
15
|
+
css?: string;
|
16
|
+
className?: string;
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
export const Modal = forwardRef<HTMLDivElement, ModalProps>(
|
21
|
+
(
|
22
|
+
{
|
23
|
+
children,
|
24
|
+
isOpen,
|
25
|
+
onClose,
|
26
|
+
showCloseButton = true,
|
27
|
+
closeOnBackdropClick = true,
|
28
|
+
closeOnEscape = true,
|
29
|
+
contentProps = {},
|
30
|
+
size,
|
31
|
+
centered,
|
32
|
+
css,
|
33
|
+
className,
|
34
|
+
// Extract sprinkles props
|
35
|
+
margin,
|
36
|
+
marginTop,
|
37
|
+
marginBottom,
|
38
|
+
marginLeft,
|
39
|
+
marginRight,
|
40
|
+
padding,
|
41
|
+
paddingTop,
|
42
|
+
paddingBottom,
|
43
|
+
paddingLeft,
|
44
|
+
paddingRight,
|
45
|
+
gap,
|
46
|
+
display,
|
47
|
+
flexDirection,
|
48
|
+
justifyContent,
|
49
|
+
flexWrap,
|
50
|
+
flex,
|
51
|
+
width,
|
52
|
+
height,
|
53
|
+
minWidth,
|
54
|
+
maxWidth,
|
55
|
+
minHeight,
|
56
|
+
position,
|
57
|
+
top,
|
58
|
+
bottom,
|
59
|
+
left,
|
60
|
+
right,
|
61
|
+
zIndex,
|
62
|
+
fontSize,
|
63
|
+
fontFamily,
|
64
|
+
lineHeight,
|
65
|
+
textAlign,
|
66
|
+
fontWeight,
|
67
|
+
color,
|
68
|
+
backgroundColor,
|
69
|
+
borderRadius,
|
70
|
+
borderWidth,
|
71
|
+
borderStyle,
|
72
|
+
borderColor,
|
73
|
+
boxShadow,
|
74
|
+
opacity,
|
75
|
+
overflow,
|
76
|
+
overflowX,
|
77
|
+
overflowY,
|
78
|
+
...htmlProps
|
79
|
+
},
|
80
|
+
ref
|
81
|
+
) => {
|
82
|
+
const [shouldRender, setShouldRender] = useState(isOpen);
|
83
|
+
|
84
|
+
useEffect(() => {
|
85
|
+
if (isOpen) {
|
86
|
+
setShouldRender(true);
|
87
|
+
document.body.style.overflow = 'hidden';
|
88
|
+
} else {
|
89
|
+
const timer = setTimeout(() => setShouldRender(false), 300);
|
90
|
+
document.body.style.overflow = '';
|
91
|
+
return () => clearTimeout(timer);
|
92
|
+
}
|
93
|
+
}, [isOpen]);
|
94
|
+
|
95
|
+
useEffect(() => {
|
96
|
+
const handleEscape = (event: KeyboardEvent) => {
|
97
|
+
if (closeOnEscape && event.key === 'Escape' && onClose) {
|
98
|
+
onClose();
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
if (isOpen) {
|
103
|
+
document.addEventListener('keydown', handleEscape);
|
104
|
+
return () => document.removeEventListener('keydown', handleEscape);
|
105
|
+
}
|
106
|
+
}, [isOpen, closeOnEscape, onClose]);
|
107
|
+
|
108
|
+
const handleBackdropClick = (event: React.MouseEvent) => {
|
109
|
+
if (closeOnBackdropClick && event.target === event.currentTarget && onClose) {
|
110
|
+
onClose();
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
if (!shouldRender) return null;
|
115
|
+
|
116
|
+
return (
|
117
|
+
<div
|
118
|
+
ref={ref}
|
119
|
+
className={clsx(
|
120
|
+
modalRecipe({ size, centered }),
|
121
|
+
sprinkles({
|
122
|
+
margin,
|
123
|
+
marginTop,
|
124
|
+
marginBottom,
|
125
|
+
marginLeft,
|
126
|
+
marginRight,
|
127
|
+
padding,
|
128
|
+
paddingTop,
|
129
|
+
paddingBottom,
|
130
|
+
paddingLeft,
|
131
|
+
paddingRight,
|
132
|
+
gap,
|
133
|
+
display,
|
134
|
+
flexDirection,
|
135
|
+
justifyContent,
|
136
|
+
flexWrap,
|
137
|
+
flex,
|
138
|
+
width,
|
139
|
+
height,
|
140
|
+
minWidth,
|
141
|
+
maxWidth,
|
142
|
+
minHeight,
|
143
|
+
position,
|
144
|
+
top,
|
145
|
+
bottom,
|
146
|
+
left,
|
147
|
+
right,
|
148
|
+
zIndex,
|
149
|
+
fontSize,
|
150
|
+
fontFamily,
|
151
|
+
lineHeight,
|
152
|
+
textAlign,
|
153
|
+
fontWeight,
|
154
|
+
color,
|
155
|
+
backgroundColor,
|
156
|
+
borderRadius,
|
157
|
+
borderWidth,
|
158
|
+
borderStyle,
|
159
|
+
borderColor,
|
160
|
+
boxShadow,
|
161
|
+
opacity,
|
162
|
+
overflow,
|
163
|
+
overflowX,
|
164
|
+
overflowY,
|
165
|
+
}),
|
166
|
+
css,
|
167
|
+
className
|
168
|
+
)}
|
169
|
+
onClick={handleBackdropClick}
|
170
|
+
role="dialog"
|
171
|
+
aria-modal="true"
|
172
|
+
{...htmlProps}>
|
173
|
+
<div
|
174
|
+
className={clsx(
|
175
|
+
modalContentRecipe({
|
176
|
+
size: contentProps.size || size,
|
177
|
+
align: contentProps.align,
|
178
|
+
}),
|
179
|
+
contentProps.css,
|
180
|
+
contentProps.className
|
181
|
+
)}>
|
182
|
+
{showCloseButton && onClose && (
|
183
|
+
<button type="button" className={modalCloseButton} onClick={onClose} aria-label="Close modal">
|
184
|
+
<Icon icon="close" size="sm" />
|
185
|
+
</button>
|
186
|
+
)}
|
187
|
+
{children}
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
);
|
191
|
+
}
|
192
|
+
);
|
193
|
+
|
194
|
+
Modal.displayName = 'Modal';
|
@@ -0,0 +1,129 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { navRecipe, type NavVariants } from './Nav.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export interface NavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Sprinkles, NonNullable<NavVariants> {
|
7
|
+
css?: string;
|
8
|
+
as?: 'nav' | 'div' | 'ul';
|
9
|
+
}
|
10
|
+
|
11
|
+
export const Nav = forwardRef<HTMLElement, NavProps>(
|
12
|
+
(
|
13
|
+
{
|
14
|
+
children,
|
15
|
+
orientation,
|
16
|
+
variant,
|
17
|
+
justify,
|
18
|
+
as: Component = 'nav',
|
19
|
+
css,
|
20
|
+
className,
|
21
|
+
// Extract sprinkles props
|
22
|
+
margin,
|
23
|
+
marginTop,
|
24
|
+
marginBottom,
|
25
|
+
marginLeft,
|
26
|
+
marginRight,
|
27
|
+
padding,
|
28
|
+
paddingTop,
|
29
|
+
paddingBottom,
|
30
|
+
paddingLeft,
|
31
|
+
paddingRight,
|
32
|
+
gap,
|
33
|
+
display,
|
34
|
+
flexDirection,
|
35
|
+
justifyContent,
|
36
|
+
flexWrap,
|
37
|
+
flex,
|
38
|
+
width,
|
39
|
+
height,
|
40
|
+
minWidth,
|
41
|
+
maxWidth,
|
42
|
+
minHeight,
|
43
|
+
position,
|
44
|
+
top,
|
45
|
+
bottom,
|
46
|
+
left,
|
47
|
+
right,
|
48
|
+
zIndex,
|
49
|
+
fontSize,
|
50
|
+
fontFamily,
|
51
|
+
lineHeight,
|
52
|
+
textAlign,
|
53
|
+
fontWeight,
|
54
|
+
color,
|
55
|
+
backgroundColor,
|
56
|
+
borderRadius,
|
57
|
+
borderWidth,
|
58
|
+
borderStyle,
|
59
|
+
borderColor,
|
60
|
+
boxShadow,
|
61
|
+
opacity,
|
62
|
+
overflow,
|
63
|
+
overflowX,
|
64
|
+
overflowY,
|
65
|
+
...htmlProps
|
66
|
+
},
|
67
|
+
ref
|
68
|
+
) => {
|
69
|
+
return (
|
70
|
+
<Component
|
71
|
+
ref={ref as any}
|
72
|
+
className={clsx(
|
73
|
+
navRecipe({ orientation, variant, justify }),
|
74
|
+
sprinkles({
|
75
|
+
margin,
|
76
|
+
marginTop,
|
77
|
+
marginBottom,
|
78
|
+
marginLeft,
|
79
|
+
marginRight,
|
80
|
+
padding,
|
81
|
+
paddingTop,
|
82
|
+
paddingBottom,
|
83
|
+
paddingLeft,
|
84
|
+
paddingRight,
|
85
|
+
gap,
|
86
|
+
display,
|
87
|
+
flexDirection,
|
88
|
+
justifyContent,
|
89
|
+
flexWrap,
|
90
|
+
flex,
|
91
|
+
width,
|
92
|
+
height,
|
93
|
+
minWidth,
|
94
|
+
maxWidth,
|
95
|
+
minHeight,
|
96
|
+
position,
|
97
|
+
top,
|
98
|
+
bottom,
|
99
|
+
left,
|
100
|
+
right,
|
101
|
+
zIndex,
|
102
|
+
fontSize,
|
103
|
+
fontFamily,
|
104
|
+
lineHeight,
|
105
|
+
textAlign,
|
106
|
+
fontWeight,
|
107
|
+
color,
|
108
|
+
backgroundColor,
|
109
|
+
borderRadius,
|
110
|
+
borderWidth,
|
111
|
+
borderStyle,
|
112
|
+
borderColor,
|
113
|
+
boxShadow,
|
114
|
+
opacity,
|
115
|
+
overflow,
|
116
|
+
overflowX,
|
117
|
+
overflowY,
|
118
|
+
}),
|
119
|
+
css,
|
120
|
+
className
|
121
|
+
)}
|
122
|
+
{...htmlProps}>
|
123
|
+
{children}
|
124
|
+
</Component>
|
125
|
+
);
|
126
|
+
}
|
127
|
+
);
|
128
|
+
|
129
|
+
Nav.displayName = 'Nav';
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
|
3
|
+
import { Nav } 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 Nav> = {
|
7
|
+
title: 'Latte Components / 6. Nav / Main',
|
8
|
+
component: Nav,
|
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
|
+
children: '',
|
27
|
+
},
|
28
|
+
};
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { navLegalRecipe, type NavLegalVariants } from './NavLegal.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
5
|
+
|
6
|
+
export interface NavLegalProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Sprinkles, NonNullable<NavLegalVariants> {
|
7
|
+
css?: string;
|
8
|
+
as?: 'nav' | 'div' | 'footer';
|
9
|
+
}
|
10
|
+
|
11
|
+
export const NavLegal = forwardRef<HTMLElement, NavLegalProps>(
|
12
|
+
(
|
13
|
+
{
|
14
|
+
children,
|
15
|
+
orientation,
|
16
|
+
size,
|
17
|
+
variant,
|
18
|
+
align,
|
19
|
+
as: Component = 'nav',
|
20
|
+
css,
|
21
|
+
className,
|
22
|
+
// Extract sprinkles props
|
23
|
+
margin,
|
24
|
+
marginTop,
|
25
|
+
marginBottom,
|
26
|
+
marginLeft,
|
27
|
+
marginRight,
|
28
|
+
padding,
|
29
|
+
paddingTop,
|
30
|
+
paddingBottom,
|
31
|
+
paddingLeft,
|
32
|
+
paddingRight,
|
33
|
+
gap,
|
34
|
+
display,
|
35
|
+
flexDirection,
|
36
|
+
justifyContent,
|
37
|
+
flexWrap,
|
38
|
+
flex,
|
39
|
+
width,
|
40
|
+
height,
|
41
|
+
minWidth,
|
42
|
+
maxWidth,
|
43
|
+
minHeight,
|
44
|
+
position,
|
45
|
+
top,
|
46
|
+
bottom,
|
47
|
+
left,
|
48
|
+
right,
|
49
|
+
zIndex,
|
50
|
+
fontSize,
|
51
|
+
fontFamily,
|
52
|
+
lineHeight,
|
53
|
+
textAlign,
|
54
|
+
fontWeight,
|
55
|
+
color,
|
56
|
+
backgroundColor,
|
57
|
+
borderRadius,
|
58
|
+
borderWidth,
|
59
|
+
borderStyle,
|
60
|
+
borderColor,
|
61
|
+
boxShadow,
|
62
|
+
opacity,
|
63
|
+
overflow,
|
64
|
+
overflowX,
|
65
|
+
overflowY,
|
66
|
+
...htmlProps
|
67
|
+
},
|
68
|
+
ref
|
69
|
+
) => {
|
70
|
+
return (
|
71
|
+
<Component
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
73
|
+
ref={ref as any}
|
74
|
+
className={clsx(
|
75
|
+
navLegalRecipe({ orientation, size, variant, align }),
|
76
|
+
sprinkles({
|
77
|
+
margin,
|
78
|
+
marginTop,
|
79
|
+
marginBottom,
|
80
|
+
marginLeft,
|
81
|
+
marginRight,
|
82
|
+
padding,
|
83
|
+
paddingTop,
|
84
|
+
paddingBottom,
|
85
|
+
paddingLeft,
|
86
|
+
paddingRight,
|
87
|
+
gap,
|
88
|
+
display,
|
89
|
+
flexDirection,
|
90
|
+
justifyContent,
|
91
|
+
flexWrap,
|
92
|
+
flex,
|
93
|
+
width,
|
94
|
+
height,
|
95
|
+
minWidth,
|
96
|
+
maxWidth,
|
97
|
+
minHeight,
|
98
|
+
position,
|
99
|
+
top,
|
100
|
+
bottom,
|
101
|
+
left,
|
102
|
+
right,
|
103
|
+
zIndex,
|
104
|
+
fontSize,
|
105
|
+
fontFamily,
|
106
|
+
lineHeight,
|
107
|
+
textAlign,
|
108
|
+
fontWeight,
|
109
|
+
color,
|
110
|
+
backgroundColor,
|
111
|
+
borderRadius,
|
112
|
+
borderWidth,
|
113
|
+
borderStyle,
|
114
|
+
borderColor,
|
115
|
+
boxShadow,
|
116
|
+
opacity,
|
117
|
+
overflow,
|
118
|
+
overflowX,
|
119
|
+
overflowY,
|
120
|
+
}),
|
121
|
+
css,
|
122
|
+
className
|
123
|
+
)}
|
124
|
+
role="navigation"
|
125
|
+
aria-label="Legal navigation"
|
126
|
+
{...htmlProps}>
|
127
|
+
{children}
|
128
|
+
</Component>
|
129
|
+
);
|
130
|
+
}
|
131
|
+
);
|
132
|
+
|
133
|
+
NavLegal.displayName = 'NavLegal';
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
|
3
|
+
import { NavLegal } 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 NavLegal> = {
|
7
|
+
title: 'Latte Components / 6. Nav / Legal',
|
8
|
+
component: NavLegal,
|
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
|
+
children: '',
|
27
|
+
},
|
28
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export type Social = 'instagram' | 'linkedIn' | 'facebook' | 'pinterest' | 'spotify' | 'X' | 'youtube' | 'tiktok';
|
@@ -0,0 +1,169 @@
|
|
1
|
+
import { clsx } from 'clsx';
|
2
|
+
import { forwardRef } from 'react';
|
3
|
+
import { navSocialLink, navSocialRecipe, type NavSocialVariants } from './NavSocial.css';
|
4
|
+
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css';
|
5
|
+
import { Icon } from '../Icon/Icon';
|
6
|
+
|
7
|
+
export type SocialNetwork = 'instagram' | 'linkedIn' | 'facebook' | 'pinterest' | 'spotify' | 'X' | 'youtube' | 'tiktok';
|
8
|
+
|
9
|
+
export interface SocialLink {
|
10
|
+
name: SocialNetwork;
|
11
|
+
url: string;
|
12
|
+
label?: string;
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface NavSocialProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Sprinkles, NonNullable<NavSocialVariants> {
|
16
|
+
css?: string;
|
17
|
+
links: SocialLink[];
|
18
|
+
iconSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
19
|
+
as?: 'nav' | 'div' | 'ul';
|
20
|
+
}
|
21
|
+
|
22
|
+
export const NavSocial = forwardRef<HTMLElement, NavSocialProps>(
|
23
|
+
(
|
24
|
+
{
|
25
|
+
links,
|
26
|
+
iconSize = 'md',
|
27
|
+
orientation,
|
28
|
+
size,
|
29
|
+
variant,
|
30
|
+
as: Component = 'nav',
|
31
|
+
css,
|
32
|
+
className,
|
33
|
+
// Extract sprinkles props
|
34
|
+
margin,
|
35
|
+
marginTop,
|
36
|
+
marginBottom,
|
37
|
+
marginLeft,
|
38
|
+
marginRight,
|
39
|
+
padding,
|
40
|
+
paddingTop,
|
41
|
+
paddingBottom,
|
42
|
+
paddingLeft,
|
43
|
+
paddingRight,
|
44
|
+
gap,
|
45
|
+
display,
|
46
|
+
flexDirection,
|
47
|
+
justifyContent,
|
48
|
+
flexWrap,
|
49
|
+
flex,
|
50
|
+
width,
|
51
|
+
height,
|
52
|
+
minWidth,
|
53
|
+
maxWidth,
|
54
|
+
minHeight,
|
55
|
+
position,
|
56
|
+
top,
|
57
|
+
bottom,
|
58
|
+
left,
|
59
|
+
right,
|
60
|
+
zIndex,
|
61
|
+
fontSize,
|
62
|
+
fontFamily,
|
63
|
+
lineHeight,
|
64
|
+
textAlign,
|
65
|
+
fontWeight,
|
66
|
+
color,
|
67
|
+
backgroundColor,
|
68
|
+
borderRadius,
|
69
|
+
borderWidth,
|
70
|
+
borderStyle,
|
71
|
+
borderColor,
|
72
|
+
boxShadow,
|
73
|
+
opacity,
|
74
|
+
overflow,
|
75
|
+
overflowX,
|
76
|
+
overflowY,
|
77
|
+
...htmlProps
|
78
|
+
},
|
79
|
+
ref
|
80
|
+
) => {
|
81
|
+
const getSocialIcon = (name: SocialNetwork): string => {
|
82
|
+
const iconMap: Record<SocialNetwork, string> = {
|
83
|
+
instagram: 'socialInstagram',
|
84
|
+
linkedIn: 'socialLinkedIn',
|
85
|
+
facebook: 'socialFacebook',
|
86
|
+
pinterest: 'socialPinterest',
|
87
|
+
spotify: 'socialSpotify',
|
88
|
+
X: 'socialX',
|
89
|
+
youtube: 'socialYoutube',
|
90
|
+
tiktok: 'socialTiktok',
|
91
|
+
};
|
92
|
+
return iconMap[name];
|
93
|
+
};
|
94
|
+
|
95
|
+
return (
|
96
|
+
<Component
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
98
|
+
ref={ref as any}
|
99
|
+
className={clsx(
|
100
|
+
navSocialRecipe({ orientation, size, variant }),
|
101
|
+
sprinkles({
|
102
|
+
margin,
|
103
|
+
marginTop,
|
104
|
+
marginBottom,
|
105
|
+
marginLeft,
|
106
|
+
marginRight,
|
107
|
+
padding,
|
108
|
+
paddingTop,
|
109
|
+
paddingBottom,
|
110
|
+
paddingLeft,
|
111
|
+
paddingRight,
|
112
|
+
gap,
|
113
|
+
display,
|
114
|
+
flexDirection,
|
115
|
+
justifyContent,
|
116
|
+
flexWrap,
|
117
|
+
flex,
|
118
|
+
width,
|
119
|
+
height,
|
120
|
+
minWidth,
|
121
|
+
maxWidth,
|
122
|
+
minHeight,
|
123
|
+
position,
|
124
|
+
top,
|
125
|
+
bottom,
|
126
|
+
left,
|
127
|
+
right,
|
128
|
+
zIndex,
|
129
|
+
fontSize,
|
130
|
+
fontFamily,
|
131
|
+
lineHeight,
|
132
|
+
textAlign,
|
133
|
+
fontWeight,
|
134
|
+
color,
|
135
|
+
backgroundColor,
|
136
|
+
borderRadius,
|
137
|
+
borderWidth,
|
138
|
+
borderStyle,
|
139
|
+
borderColor,
|
140
|
+
boxShadow,
|
141
|
+
opacity,
|
142
|
+
overflow,
|
143
|
+
overflowX,
|
144
|
+
overflowY,
|
145
|
+
}),
|
146
|
+
css,
|
147
|
+
className
|
148
|
+
)}
|
149
|
+
role="navigation"
|
150
|
+
aria-label="Social media links"
|
151
|
+
{...htmlProps}>
|
152
|
+
{links.map((social, index) => (
|
153
|
+
<a
|
154
|
+
key={`${social.name}-${index}`}
|
155
|
+
href={social.url}
|
156
|
+
target="_blank"
|
157
|
+
rel="noopener noreferrer"
|
158
|
+
className={navSocialLink}
|
159
|
+
aria-label={social.label || `Visit our ${social.name} page`}>
|
160
|
+
{/*eslint-disable-next-line @typescript-eslint/no-explicit-any*/}
|
161
|
+
<Icon icon={getSocialIcon(social.name) as any} size={iconSize} aria-hidden="true" />
|
162
|
+
</a>
|
163
|
+
))}
|
164
|
+
</Component>
|
165
|
+
);
|
166
|
+
}
|
167
|
+
);
|
168
|
+
|
169
|
+
NavSocial.displayName = 'NavSocial';
|