@latte-macchiat-io/latte-vanilla-components 0.0.478 → 0.0.480
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/ExpandCollapse/Item/index.tsx +49 -0
- package/src/components/ExpandCollapse/Item/styles.css.ts +82 -0
- package/src/components/ExpandCollapse/export.tsx +1 -0
- package/src/components/ExpandCollapse/index.tsx +23 -0
- package/src/components/ExpandCollapse/styles.css.ts +22 -0
- package/src/components/ExpandCollapse/theme.ts +35 -0
- package/src/index.ts +2 -0
- package/src/theme/baseThemeValues.ts +5 -0
- package/src/theme/contract.css.ts +21 -0
- package/src/theme/createTheme.ts +3 -0
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
collapseExpandContent,
|
|
7
|
+
collapseExpandContentOpen,
|
|
8
|
+
collapseExpandItem,
|
|
9
|
+
collapseExpandItemOpen,
|
|
10
|
+
collapseExpandItemTitle,
|
|
11
|
+
collapseExpandTitleIcon,
|
|
12
|
+
} from './styles.css';
|
|
13
|
+
|
|
14
|
+
import { Heading } from '../../Heading';
|
|
15
|
+
import { Icon } from '../../Icon';
|
|
16
|
+
import icons from '../../Icon/path';
|
|
17
|
+
import { Paragraph } from '../../Paragraph';
|
|
18
|
+
|
|
19
|
+
export type ExpandCollapseItemsProps = {
|
|
20
|
+
title: string;
|
|
21
|
+
text: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const ExpandCollapseItem = ({ title, text }: ExpandCollapseItemsProps): React.ReactElement => {
|
|
25
|
+
const [isOpen, setOpen] = useState(false);
|
|
26
|
+
const toggleList = () => setOpen(!isOpen);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className={`${collapseExpandItem} ${isOpen ? collapseExpandItemOpen : ''}`}>
|
|
30
|
+
<div
|
|
31
|
+
tabIndex={0}
|
|
32
|
+
role="button"
|
|
33
|
+
onClick={toggleList}
|
|
34
|
+
aria-expanded={isOpen}
|
|
35
|
+
className={collapseExpandItemTitle}
|
|
36
|
+
onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && toggleList()}>
|
|
37
|
+
<Icon size={15} iconPath={icons.caret} className={collapseExpandTitleIcon} />
|
|
38
|
+
<Heading as="h3" size="sm">
|
|
39
|
+
{title}
|
|
40
|
+
</Heading>
|
|
41
|
+
</div>
|
|
42
|
+
<div className={`${collapseExpandContent} ${isOpen ? collapseExpandContentOpen : ''}`}>
|
|
43
|
+
<div>
|
|
44
|
+
<Paragraph>{text}</Paragraph>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { globalStyle, style } from '@vanilla-extract/css';
|
|
2
|
+
|
|
3
|
+
export const collapseExpandItem = style({
|
|
4
|
+
gap: 0,
|
|
5
|
+
display: 'flex',
|
|
6
|
+
borderRadius: 20,
|
|
7
|
+
flexDirection: 'column',
|
|
8
|
+
transition: 'gap 0.3s ease-out',
|
|
9
|
+
// backgroundColor: brandColorGreyXXLight,
|
|
10
|
+
|
|
11
|
+
// '@media': generateResponsiveMedia({
|
|
12
|
+
// padding: breakpointMapper([8, 8, 8, 8, 8, 8]),
|
|
13
|
+
// }),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const collapseExpandItemOpen = style({
|
|
17
|
+
// '@media': generateResponsiveMedia({
|
|
18
|
+
// gap: breakpointMapper([10, 10, 10, 15, 15, 15]),
|
|
19
|
+
// }),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const collapseExpandItemTitle = style({
|
|
23
|
+
display: 'flex',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
|
|
26
|
+
// '@media': generateResponsiveMedia({
|
|
27
|
+
// gap: breakpointMapper([15, 15, 20, 20, 30, 30]),
|
|
28
|
+
// paddingTop: breakpointMapper([10, 10, 10, 10, 15, 15]),
|
|
29
|
+
// paddingLeft: breakpointMapper([10, 10, 10, 10, 30, 30]),
|
|
30
|
+
// paddingRight: breakpointMapper([10, 10, 10, 10, 30, 30]),
|
|
31
|
+
// paddingBottom: breakpointMapper([10, 10, 10, 10, 15, 15]),
|
|
32
|
+
// }),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const collapseExpandTitleIcon = style({
|
|
36
|
+
transition: 'transform 0.3s ease-out',
|
|
37
|
+
|
|
38
|
+
// '@media': generateResponsiveMedia({
|
|
39
|
+
// marginTop: breakpointMapper([5, 5, 5, 5, 5, 5]),
|
|
40
|
+
// }),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
globalStyle(`${collapseExpandItemOpen} .${collapseExpandTitleIcon}`, {
|
|
44
|
+
transform: 'rotate(-90deg)',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
globalStyle(`${collapseExpandItemTitle} > h3`, {
|
|
48
|
+
fontWeight: 400,
|
|
49
|
+
paddingBottom: 0,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const collapseExpandContent = style({
|
|
53
|
+
display: 'grid',
|
|
54
|
+
overflow: 'hidden',
|
|
55
|
+
gridTemplateRows: '0fr',
|
|
56
|
+
transition: 'grid-template-rows 0.3s ease-out',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
globalStyle(`${collapseExpandContent} > div`, {
|
|
60
|
+
opacity: 0,
|
|
61
|
+
padding: 0,
|
|
62
|
+
minHeight: 0,
|
|
63
|
+
borderRadius: 20,
|
|
64
|
+
visibility: 'hidden',
|
|
65
|
+
// backgroundColor: brandColorWhite,
|
|
66
|
+
transition: 'visibility 0.2s ease-out, opacity 0.3s ease-out, padding 0.3s ease-out 0.2s',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export const collapseExpandContentOpen = style({
|
|
70
|
+
gridTemplateRows: '1fr',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
globalStyle(`${collapseExpandContentOpen} > div`, {
|
|
74
|
+
opacity: 1,
|
|
75
|
+
visibility: 'visible',
|
|
76
|
+
transition: 'visibility 0.2s ease-out, opacity 0.3s ease-out',
|
|
77
|
+
transitionDelay: '0.1s',
|
|
78
|
+
|
|
79
|
+
// '@media': generateResponsiveMedia({
|
|
80
|
+
// padding: breakpointMapper([15, 15, 20, 20, 30, 30]),
|
|
81
|
+
// }),
|
|
82
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExpandCollapse, type ExpandCollapseProps } from './';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ExpandCollapseItem, ExpandCollapseItemsProps } from './Item';
|
|
2
|
+
|
|
3
|
+
import { collapseExpand, collapseExpandList } from './styles.css';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../utils/styleOverride';
|
|
6
|
+
|
|
7
|
+
import { Heading } from '../Heading';
|
|
8
|
+
|
|
9
|
+
export type ExpandCollapseProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
10
|
+
title?: string;
|
|
11
|
+
list: ExpandCollapseItemsProps[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const ExpandCollapse = ({ title, list, className }: ExpandCollapseProps): React.ReactElement => (
|
|
15
|
+
<div className={cn(collapseExpand, className)}>
|
|
16
|
+
{title && <Heading as="h2">{title}</Heading>}
|
|
17
|
+
<div className={collapseExpandList}>
|
|
18
|
+
{list.map((expandCollapseItem, index) => (
|
|
19
|
+
<ExpandCollapseItem {...expandCollapseItem} key={`expandCollapseItem-${index}`} />
|
|
20
|
+
))}
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { style } from '@vanilla-extract/css';
|
|
2
|
+
|
|
3
|
+
import { themeContract } from '../../theme/contract.css';
|
|
4
|
+
import { generateResponsiveMedia } from '../../utils/generateResponsiveMedia';
|
|
5
|
+
|
|
6
|
+
export const collapseExpand = style({
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
|
|
10
|
+
'@media': generateResponsiveMedia({
|
|
11
|
+
gap: themeContract.expandCollapse.gap,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const collapseExpandList = style({
|
|
16
|
+
display: 'flex',
|
|
17
|
+
flexDirection: 'column',
|
|
18
|
+
|
|
19
|
+
'@media': generateResponsiveMedia({
|
|
20
|
+
gap: themeContract.expandCollapse.list.gap,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const themeExpandCollapseBase = {
|
|
2
|
+
expandCollapse: {
|
|
3
|
+
gap: {
|
|
4
|
+
mobile: '15px',
|
|
5
|
+
sm: '15px',
|
|
6
|
+
md: '30px',
|
|
7
|
+
lg: '30px',
|
|
8
|
+
xl: '50px',
|
|
9
|
+
'2xl': '50px',
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
list: {
|
|
13
|
+
gap: {
|
|
14
|
+
mobile: '15px',
|
|
15
|
+
sm: '15px',
|
|
16
|
+
md: '30px',
|
|
17
|
+
lg: '30px',
|
|
18
|
+
xl: '50px',
|
|
19
|
+
'2xl': '50px',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const themeExpandCollapseLight = {
|
|
26
|
+
expandCollapse: {
|
|
27
|
+
...themeExpandCollapseBase.expandCollapse,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const themeExpandCollapseDark = {
|
|
32
|
+
expandCollapse: {
|
|
33
|
+
...themeExpandCollapseBase.expandCollapse,
|
|
34
|
+
},
|
|
35
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,8 @@ export * from './components/Logo/export';
|
|
|
42
42
|
|
|
43
43
|
export * from './components/ConsentCookie/export';
|
|
44
44
|
|
|
45
|
+
export * from './components/ExpandCollapse/export';
|
|
46
|
+
|
|
45
47
|
export * from './components/KeyNumber/export';
|
|
46
48
|
|
|
47
49
|
export * from './components/NavSocial/export';
|
|
@@ -5,6 +5,7 @@ import { themeButtonDark, themeButtonLight } from '../components/Button/theme';
|
|
|
5
5
|
import { themeCarouselDark, themeCarouselLight } from '../components/Carousel/theme';
|
|
6
6
|
import { themeColumnsDark, themeColumnsLight } from '../components/Columns/theme';
|
|
7
7
|
import { themeConsentCookieDark, themeConsentCookieLight } from '../components/ConsentCookie/theme';
|
|
8
|
+
import { themeExpandCollapseDark, themeExpandCollapseLight } from '../components/ExpandCollapse/theme';
|
|
8
9
|
import { themeFooterDark, themeFooterLight } from '../components/Footer/theme';
|
|
9
10
|
import { themeFormRowDark, themeFormRowLight } from '../components/Form/Row/theme';
|
|
10
11
|
import { themeFormTextFieldDark, themeFormTextFieldLight } from '../components/Form/TextField/theme';
|
|
@@ -156,6 +157,8 @@ export const baseLightTheme = {
|
|
|
156
157
|
...themeBoxLight,
|
|
157
158
|
...themeBoxAlertLight,
|
|
158
159
|
|
|
160
|
+
...themeExpandCollapseLight,
|
|
161
|
+
|
|
159
162
|
form: {
|
|
160
163
|
...themeFormLight.form,
|
|
161
164
|
...themeFormRowLight,
|
|
@@ -297,6 +300,8 @@ export const baseDarkTheme = {
|
|
|
297
300
|
...themeBoxDark,
|
|
298
301
|
...themeBoxAlertDark,
|
|
299
302
|
|
|
303
|
+
...themeExpandCollapseDark,
|
|
304
|
+
|
|
300
305
|
form: {
|
|
301
306
|
...themeFormDark.form,
|
|
302
307
|
...themeFormRowDark,
|
|
@@ -1269,4 +1269,25 @@ export const themeContract = createGlobalThemeContract({
|
|
|
1269
1269
|
'2xl': 'latte-consentCookie-paddingRight-2xl',
|
|
1270
1270
|
},
|
|
1271
1271
|
},
|
|
1272
|
+
|
|
1273
|
+
expandCollapse: {
|
|
1274
|
+
gap: {
|
|
1275
|
+
mobile: 'latte-expandCollapse-gap-mobile',
|
|
1276
|
+
sm: 'latte-expandCollapse-gap-sm',
|
|
1277
|
+
md: 'latte-expandCollapse-gap-md',
|
|
1278
|
+
lg: 'latte-expandCollapse-gap-lg',
|
|
1279
|
+
xl: 'latte-expandCollapse-gap-xl',
|
|
1280
|
+
'2xl': 'latte-expandCollapse-gap-2xl',
|
|
1281
|
+
},
|
|
1282
|
+
list: {
|
|
1283
|
+
gap: {
|
|
1284
|
+
mobile: 'latte-expandCollapse-list-gap-mobile',
|
|
1285
|
+
sm: 'latte-expandCollapse-list-gap-sm',
|
|
1286
|
+
md: 'latte-expandCollapse-list-gap-md',
|
|
1287
|
+
lg: 'latte-expandCollapse-list-gap-lg',
|
|
1288
|
+
xl: 'latte-expandCollapse-list-gap-xl',
|
|
1289
|
+
'2xl': 'latte-expandCollapse-list-gap-2xl',
|
|
1290
|
+
},
|
|
1291
|
+
},
|
|
1292
|
+
},
|
|
1272
1293
|
});
|
package/src/theme/createTheme.ts
CHANGED
|
@@ -37,6 +37,7 @@ export type ThemeOverrides = {
|
|
|
37
37
|
box?: Partial<typeof baseLightTheme.box>;
|
|
38
38
|
boxAlert?: Partial<typeof baseLightTheme.boxAlert>;
|
|
39
39
|
consentCookie?: Partial<typeof baseLightTheme.consentCookie>;
|
|
40
|
+
expandCollapse?: Partial<typeof baseLightTheme.expandCollapse>;
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
// Utility to create a theme with partial overrides over light theme base
|
|
@@ -75,6 +76,7 @@ const createAppTheme = (selector: string, overrides: ThemeOverrides = {}) => {
|
|
|
75
76
|
box: { ...baseLightTheme.box, ...overrides.box },
|
|
76
77
|
boxAlert: { ...baseLightTheme.boxAlert, ...overrides.boxAlert },
|
|
77
78
|
consentCookie: { ...baseLightTheme.consentCookie, ...overrides.consentCookie },
|
|
79
|
+
expandCollapse: { ...baseLightTheme.expandCollapse, ...overrides.expandCollapse },
|
|
78
80
|
});
|
|
79
81
|
};
|
|
80
82
|
|
|
@@ -114,6 +116,7 @@ const createAppDarkTheme = (selector: string, overrides: ThemeOverrides = {}) =>
|
|
|
114
116
|
box: { ...baseDarkTheme.box, ...overrides.box },
|
|
115
117
|
boxAlert: { ...baseDarkTheme.boxAlert, ...overrides.boxAlert },
|
|
116
118
|
consentCookie: { ...baseDarkTheme.consentCookie, ...overrides.consentCookie },
|
|
119
|
+
expandCollapse: { ...baseLightTheme.expandCollapse, ...overrides.expandCollapse },
|
|
117
120
|
});
|
|
118
121
|
};
|
|
119
122
|
|