@tcn/ui 0.0.4 → 0.1.1
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/dist/actions/button/base_button/base_button.d.ts.map +1 -1
- package/dist/actions/button/base_button/base_button.js +17 -12
- package/dist/actions/button/base_button/base_button.js.map +1 -1
- package/dist/actions/button/button/button.d.ts.map +1 -1
- package/dist/actions/button/button/button.js +7 -7
- package/dist/actions/button/button/button.js.map +1 -1
- package/dist/actions/button/slim_button/slim_button.js +2 -2
- package/dist/actions/button/slim_button/slim_button.js.map +1 -1
- package/dist/button.css +1 -1
- package/dist/footer.css +1 -1
- package/dist/form/field/common/field_error.js +3 -2
- package/dist/form/field/common/field_error.js.map +1 -1
- package/dist/inputs/input/input.d.ts +2 -2
- package/dist/inputs/input/input.d.ts.map +1 -1
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/options/option.d.ts +1 -0
- package/dist/inputs/options/option.d.ts.map +1 -1
- package/dist/inputs/options/option.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +6 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +169 -125
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_item.d.ts +1 -1
- package/dist/inputs/suggestions/suggestion_item.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_item.js +23 -18
- package/dist/inputs/suggestions/suggestion_item.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +105 -95
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/layouts/footer/footer.js +5 -5
- package/dist/layouts/footer/footer.js.map +1 -1
- package/dist/layouts/index.d.ts +3 -2
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +26 -24
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/list/item.d.ts +1 -0
- package/dist/layouts/list/item.d.ts.map +1 -1
- package/dist/layouts/list/item.js +17 -6
- package/dist/layouts/list/item.js.map +1 -1
- package/dist/layouts/list/list.js +10 -10
- package/dist/layouts/list/list.js.map +1 -1
- package/dist/overlay/context_menu/context_menu.js +4 -4
- package/dist/overlay/index.js +3 -3
- package/dist/overlay/popper/popper.js +12 -12
- package/dist/{portal-qqIp4SIl.js → overlay/portal/portal.js} +3 -3
- package/dist/overlay/portal/portal.js.map +1 -0
- package/dist/overlay/portal/portal_platform.js +3 -4
- package/dist/overlay/portal/portal_platform.js.map +1 -1
- package/dist/phone_number_input.css +1 -1
- package/dist/slim_button.css +1 -1
- package/dist/surfaces/card/card.d.ts.map +1 -1
- package/dist/surfaces/card/card.js +7 -16
- package/dist/surfaces/card/card.js.map +1 -1
- package/dist/surfaces/confirm/confirm.js +4 -4
- package/dist/themes/index.js +6 -141
- package/dist/themes/index.js.map +1 -1
- package/dist/themes/stylesheets/reset.js +140 -0
- package/dist/themes/stylesheets/reset.js.map +1 -0
- package/dist/themes/themes/ergo/ergo_theme.js +595 -0
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -0
- package/dist/tokens/bubble/bubble.js +17 -16
- package/dist/tokens/bubble/bubble.js.map +1 -1
- package/dist/tokens/chip/chip.js +9 -8
- package/dist/tokens/chip/chip.js.map +1 -1
- package/dist/typography/title/title.js +8 -8
- package/dist/typography/title/title.js.map +1 -1
- package/package.json +3 -3
- package/src/actions/button/base_button/base_button.tsx +7 -2
- package/src/actions/button/button/button.module.css +0 -78
- package/src/actions/button/button/button.tsx +2 -4
- package/src/actions/button/slim_button/slim_button.module.css +0 -26
- package/src/actions/button/slim_button/slim_button.tsx +1 -1
- package/src/inputs/input/input.tsx +3 -2
- package/src/inputs/options/option.tsx +1 -0
- package/src/inputs/phone_number_input/phone_number_input.module.css +12 -0
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +8 -0
- package/src/inputs/phone_number_input/phone_number_input.tsx +99 -21
- package/src/inputs/suggestions/suggestion_item.tsx +12 -2
- package/src/inputs/suggestions/suggestion_list.tsx +22 -3
- package/src/layouts/footer/footer.module.css +0 -1
- package/src/layouts/footer/footer.tsx +1 -1
- package/src/layouts/index.ts +3 -2
- package/src/layouts/list/item.tsx +10 -2
- package/src/layouts/list/list.tsx +2 -2
- package/src/surfaces/card/card.tsx +2 -8
- package/src/surfaces/modal/__stories__/modal.stories.tsx +1 -1
- package/src/surfaces/panel/__stories__/panel.stories.tsx +13 -12
- package/src/themes/themes/ergo/__stories__/components/material_picker/sb_inverted_materials.module.css +34 -0
- package/src/themes/themes/ergo/__stories__/components/material_picker/sb_material_picker.tsx +52 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_card.module.css +5 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_card.tsx +40 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_picker.tsx +83 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/types.ts +7 -0
- package/src/themes/themes/ergo/__stories__/material.stories.tsx +154 -0
- package/src/themes/themes/ergo/__stories__/sb_materials.module.css +110 -0
- package/src/themes/themes/ergo/__stories__/utils.ts +92 -0
- package/src/themes/themes/ergo/ergo_theme.css +298 -35
- package/src/typography/title/title.tsx +1 -1
- package/tsconfig.json +0 -3
- package/dist/card.css +0 -1
- package/dist/portal-qqIp4SIl.js.map +0 -1
- package/dist/themes/stylesheets/reset.css +0 -1
- package/dist/themes/themes/ergo/ergo_theme.css +0 -1
- package/dist/themes/themes/windows_98/windows_98.css +0 -1
- package/src/surfaces/card/card.module.css +0 -5
- /package/dist/{overlay/portal/portal.css → portal_platform.css} +0 -0
|
@@ -4,14 +4,22 @@ import { clsx } from 'clsx';
|
|
|
4
4
|
|
|
5
5
|
export interface ItemProps extends Omit<HStackProps, 'as' | 'children'> {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
|
+
selected?: boolean;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const Item = React.forwardRef<HTMLDivElement, ItemProps>(function Item(
|
|
10
|
-
{ children, className, ...props }: ItemProps,
|
|
11
|
+
{ children, className, selected = false, ...props }: ItemProps,
|
|
11
12
|
ref
|
|
12
13
|
) {
|
|
13
14
|
return (
|
|
14
|
-
<HStack
|
|
15
|
+
<HStack
|
|
16
|
+
ref={ref}
|
|
17
|
+
as="li"
|
|
18
|
+
data-hierarchy={selected ? 'primary' : 'tertiary'}
|
|
19
|
+
data-is-selected={selected}
|
|
20
|
+
className={clsx('tcn-item', 'tcn-interactive', className)}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
15
23
|
{children}
|
|
16
24
|
</HStack>
|
|
17
25
|
);
|
|
@@ -6,7 +6,7 @@ export interface ListProps extends Omit<VStackProps, 'as'> {
|
|
|
6
6
|
isOrdered?: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const List = React.forwardRef<HTMLDivElement, ListProps>(function
|
|
9
|
+
export const List = React.forwardRef<HTMLDivElement, ListProps>(function List(
|
|
10
10
|
{ children, className, isOrdered = false, ...props }: ListProps,
|
|
11
11
|
ref
|
|
12
12
|
) {
|
|
@@ -14,7 +14,7 @@ export const List = React.forwardRef<HTMLDivElement, ListProps>(function Item(
|
|
|
14
14
|
<VStack
|
|
15
15
|
ref={ref}
|
|
16
16
|
as={isOrdered ? 'ol' : 'ul'}
|
|
17
|
-
className={clsx('list', className)}
|
|
17
|
+
className={clsx('tcn-list', className)}
|
|
18
18
|
{...props}
|
|
19
19
|
>
|
|
20
20
|
{children}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { VStack, type VStackProps } from '../../stacks/v_stack.js';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import styles from './card.module.css';
|
|
5
4
|
|
|
6
5
|
export interface CardProps extends Omit<VStackProps, 'as' | 'children'> {
|
|
7
6
|
children?: React.ReactNode;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
export const Card = React.forwardRef<HTMLElement, CardProps>(function
|
|
9
|
+
export const Card = React.forwardRef<HTMLElement, CardProps>(function Card(
|
|
11
10
|
{ children, className, ...props }: CardProps,
|
|
12
11
|
ref
|
|
13
12
|
) {
|
|
14
13
|
return (
|
|
15
|
-
<VStack
|
|
16
|
-
ref={ref}
|
|
17
|
-
as="section"
|
|
18
|
-
className={clsx(className, styles.card, 'card')}
|
|
19
|
-
{...props}
|
|
20
|
-
>
|
|
14
|
+
<VStack ref={ref} as="section" className={clsx(className, 'tcn-card')} {...props}>
|
|
21
15
|
{children}
|
|
22
16
|
</VStack>
|
|
23
17
|
);
|
|
@@ -11,6 +11,7 @@ import { Title } from '../../../typography/title/title.js';
|
|
|
11
11
|
import { VPanel } from '../v_panel.js';
|
|
12
12
|
// Styles
|
|
13
13
|
import styles from './panel_stories.module.css';
|
|
14
|
+
import { SlimButton } from '../../../actions/index.js';
|
|
14
15
|
|
|
15
16
|
export default {
|
|
16
17
|
title: 'Surfaces/Panel',
|
|
@@ -25,29 +26,29 @@ export const Default = () => {
|
|
|
25
26
|
<Header>
|
|
26
27
|
<Title>Panel Primary Header</Title>
|
|
27
28
|
<Spacer />
|
|
28
|
-
<
|
|
29
|
+
<SlimButton hierarchy="tertiary">
|
|
29
30
|
<GridOneIcon />
|
|
30
|
-
</
|
|
31
|
+
</SlimButton>
|
|
31
32
|
<Divider length="md" vertical />
|
|
32
|
-
<
|
|
33
|
+
<SlimButton hierarchy="tertiary">
|
|
33
34
|
<CrossIcon />
|
|
34
|
-
</
|
|
35
|
+
</SlimButton>
|
|
35
36
|
</Header>
|
|
36
37
|
<UtilityBar>
|
|
37
38
|
<Title>Utility Bar</Title>
|
|
38
39
|
<Spacer />
|
|
39
|
-
<
|
|
40
|
+
<SlimButton hierarchy="tertiary">
|
|
40
41
|
<BugIcon />
|
|
41
|
-
</
|
|
42
|
-
<
|
|
42
|
+
</SlimButton>
|
|
43
|
+
<SlimButton hierarchy="tertiary">
|
|
43
44
|
<BugIcon />
|
|
44
|
-
</
|
|
45
|
-
<
|
|
45
|
+
</SlimButton>
|
|
46
|
+
<SlimButton size="md" hierarchy="tertiary">
|
|
46
47
|
<BugIcon />
|
|
47
|
-
</
|
|
48
|
-
<
|
|
48
|
+
</SlimButton>
|
|
49
|
+
<SlimButton hierarchy="tertiary">
|
|
49
50
|
<BugIcon />
|
|
50
|
-
</
|
|
51
|
+
</SlimButton>
|
|
51
52
|
</UtilityBar>
|
|
52
53
|
|
|
53
54
|
<VBody>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.light-primary-inverted {
|
|
2
|
+
--action: var(--primary);
|
|
3
|
+
--on-action: var(--white);
|
|
4
|
+
--material: var(--white);
|
|
5
|
+
--on-material: var(--navy);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.light-secondary-inverted {
|
|
9
|
+
--action: var(--tan);
|
|
10
|
+
--on-action: var(--navy);
|
|
11
|
+
--material: var(--white);
|
|
12
|
+
--on-material: var(--navy);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dark-primary-inverted {
|
|
16
|
+
--action: var(--slate);
|
|
17
|
+
--on-action: var(--white);
|
|
18
|
+
--material: var(--white);
|
|
19
|
+
--on-material: var(--navy);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dark-secondary-inverted {
|
|
23
|
+
--action: var(--navy);
|
|
24
|
+
--on-action: var(--white);
|
|
25
|
+
--material: var(--white);
|
|
26
|
+
--on-material: var(--navy);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.surface-custom-inverted {
|
|
30
|
+
--action: var(--custom-material);
|
|
31
|
+
--on-action: var(--custom-on-material);
|
|
32
|
+
--material: var(--navy);
|
|
33
|
+
--on-material: var(--white);
|
|
34
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { Header } from '../../../../../../layouts/index.js';
|
|
4
|
+
import { Button } from '../../../../../../actions/button/button/button.js';
|
|
5
|
+
import { theme } from '../../../../../theme_variables.js';
|
|
6
|
+
|
|
7
|
+
// Styles
|
|
8
|
+
import styles from './sb_inverted_materials.module.css';
|
|
9
|
+
|
|
10
|
+
export const SB_MaterialPicker: React.FC<{
|
|
11
|
+
handleSurfaceClick: (surface: string) => () => void;
|
|
12
|
+
}> = ({ handleSurfaceClick }) => {
|
|
13
|
+
return (
|
|
14
|
+
<Header gap={theme.gap.md} height="48px">
|
|
15
|
+
<Button
|
|
16
|
+
hierarchy="primary"
|
|
17
|
+
className={clsx(styles['light-primary-inverted'])}
|
|
18
|
+
onClick={handleSurfaceClick('light-primary')}
|
|
19
|
+
>
|
|
20
|
+
Light
|
|
21
|
+
</Button>
|
|
22
|
+
<Button
|
|
23
|
+
onClick={handleSurfaceClick('light-secondary')}
|
|
24
|
+
hierarchy="primary"
|
|
25
|
+
className={clsx(styles['light-secondary-inverted'])}
|
|
26
|
+
>
|
|
27
|
+
Light Variant
|
|
28
|
+
</Button>
|
|
29
|
+
<Button
|
|
30
|
+
onClick={handleSurfaceClick('dark-primary')}
|
|
31
|
+
hierarchy="primary"
|
|
32
|
+
className={clsx(styles['dark-primary-inverted'])}
|
|
33
|
+
>
|
|
34
|
+
Dark
|
|
35
|
+
</Button>
|
|
36
|
+
<Button
|
|
37
|
+
onClick={handleSurfaceClick('dark-secondary')}
|
|
38
|
+
hierarchy="primary"
|
|
39
|
+
className={clsx(styles['dark-secondary-inverted'])}
|
|
40
|
+
>
|
|
41
|
+
Dark Variant
|
|
42
|
+
</Button>
|
|
43
|
+
<Button
|
|
44
|
+
onClick={handleSurfaceClick('surface-custom')}
|
|
45
|
+
hierarchy="primary"
|
|
46
|
+
className={clsx(styles['surface-custom-inverted'])}
|
|
47
|
+
>
|
|
48
|
+
Custom
|
|
49
|
+
</Button>
|
|
50
|
+
</Header>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Header, VBody } from '../../../../../../layouts/index.js';
|
|
2
|
+
import { Card } from '../../../../../../surfaces/index.js';
|
|
3
|
+
import { SlimButton } from '../../../../../../actions/button/slim_button/slim_button.js';
|
|
4
|
+
import { Spacer } from '../../../../../../stacks/spacer.js';
|
|
5
|
+
import { Box } from '../../../../../../stacks/index.js';
|
|
6
|
+
import { InfoIcon } from '@tcn/icons/info_icon.js';
|
|
7
|
+
import { AlertCircleIcon } from '@tcn/icons/alert_circle_icon.js';
|
|
8
|
+
import { CheckCircleIcon } from '@tcn/icons/check_circle_icon.js';
|
|
9
|
+
import { theme } from '../../../../../theme_variables.js';
|
|
10
|
+
|
|
11
|
+
// Styles
|
|
12
|
+
import styles from './sb_card.module.css';
|
|
13
|
+
import type { SB_ToneListItem } from './types.js';
|
|
14
|
+
|
|
15
|
+
export const SB_ToneCard: React.FC<{
|
|
16
|
+
item: SB_ToneListItem | null;
|
|
17
|
+
}> = ({ item }) => {
|
|
18
|
+
return (
|
|
19
|
+
<Card data-tone={item?.tone || 'neutral'}>
|
|
20
|
+
<Header>
|
|
21
|
+
{item?.name ?? 'Neutral'}
|
|
22
|
+
<Spacer />
|
|
23
|
+
<SlimButton size="sm" hierarchy="tertiary">
|
|
24
|
+
<InfoIcon />
|
|
25
|
+
</SlimButton>
|
|
26
|
+
<SlimButton size="sm" hierarchy="secondary">
|
|
27
|
+
<AlertCircleIcon />
|
|
28
|
+
</SlimButton>
|
|
29
|
+
<SlimButton size="sm" hierarchy="primary">
|
|
30
|
+
<CheckCircleIcon />
|
|
31
|
+
</SlimButton>
|
|
32
|
+
</Header>
|
|
33
|
+
<VBody gap={theme.gap.md}>
|
|
34
|
+
<Box className={styles.box} />
|
|
35
|
+
<Box className={styles.box} />
|
|
36
|
+
<Box className={styles.box} />
|
|
37
|
+
</VBody>
|
|
38
|
+
</Card>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { BodyText } from '../../../../../../typography/body_text/body_text.js';
|
|
3
|
+
import { Item, List, SectionHeader } from '../../../../../../layouts/index.js';
|
|
4
|
+
import { HStack } from '../../../../../../stacks/h_stack.js';
|
|
5
|
+
import type { SB_ToneListItem } from './types.js';
|
|
6
|
+
import { SB_ToneCard } from './sb_tone_card.js';
|
|
7
|
+
import { theme } from '../../../../../theme_variables.js';
|
|
8
|
+
import { VStack } from '../../../../../../stacks/v_stack.js';
|
|
9
|
+
|
|
10
|
+
const items: SB_ToneListItem[] = [
|
|
11
|
+
{
|
|
12
|
+
id: 'positive',
|
|
13
|
+
name: 'Positive',
|
|
14
|
+
tone: 'positive',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'notice',
|
|
18
|
+
name: 'Notice',
|
|
19
|
+
tone: 'notice',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'neutral',
|
|
23
|
+
name: 'Neutral',
|
|
24
|
+
tone: 'neutral',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'warning',
|
|
28
|
+
name: 'Warning',
|
|
29
|
+
tone: 'warning',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'danger',
|
|
33
|
+
name: 'Danger',
|
|
34
|
+
tone: 'danger',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export const SB_TonePicker = () => {
|
|
39
|
+
const [selectedItem, setSelectedItem] = useState<SB_ToneListItem | null>(null);
|
|
40
|
+
|
|
41
|
+
const handleItemClick = (item: SB_ToneListItem) => () => {
|
|
42
|
+
setSelectedItem(item);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<HStack
|
|
47
|
+
gap={theme.gap.md}
|
|
48
|
+
growWeight={1}
|
|
49
|
+
paddingTop={theme.padding.md}
|
|
50
|
+
paddingBottom={theme.padding.md}
|
|
51
|
+
>
|
|
52
|
+
<VStack
|
|
53
|
+
height="100%"
|
|
54
|
+
width="auto"
|
|
55
|
+
gap={theme.gap.md}
|
|
56
|
+
hAlign="start"
|
|
57
|
+
minWidth="300px"
|
|
58
|
+
>
|
|
59
|
+
<SectionHeader>Tone Picker (WIP)</SectionHeader>
|
|
60
|
+
<List
|
|
61
|
+
padding={theme.padding.md}
|
|
62
|
+
maxWidth="200px"
|
|
63
|
+
growWeight={1}
|
|
64
|
+
height="100%"
|
|
65
|
+
overflowY="auto"
|
|
66
|
+
>
|
|
67
|
+
{items.map(item => (
|
|
68
|
+
<Item
|
|
69
|
+
key={item.id}
|
|
70
|
+
onClick={handleItemClick(item)}
|
|
71
|
+
selected={selectedItem?.id === item.id}
|
|
72
|
+
>
|
|
73
|
+
<BodyText>{item.name}</BodyText>
|
|
74
|
+
</Item>
|
|
75
|
+
))}
|
|
76
|
+
</List>
|
|
77
|
+
</VStack>
|
|
78
|
+
<VStack height="100%">
|
|
79
|
+
<SB_ToneCard item={selectedItem || null} />
|
|
80
|
+
</VStack>
|
|
81
|
+
</HStack>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { VStack } from '../../../../stacks/v_stack.js';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { PlusIcon } from '@tcn/icons/plus_icon.js';
|
|
5
|
+
import { Divider, Footer, Header, VBody } from '../../../../layouts/index.js';
|
|
6
|
+
import { VPanel } from '../../../../surfaces/index.js';
|
|
7
|
+
import { Button } from '../../../../actions/button/button/button.js';
|
|
8
|
+
import { Spacer } from '../../../../stacks/spacer.js';
|
|
9
|
+
import { SlimButton } from '../../../../actions/button/slim_button/slim_button.js';
|
|
10
|
+
import { SB_TonePicker } from './components/tone_picker/sb_tone_picker.js';
|
|
11
|
+
import { formatHSLString, getContrastText, parseHSL } from './utils.js';
|
|
12
|
+
import { SB_MaterialPicker } from './components/material_picker/sb_material_picker.js';
|
|
13
|
+
import { Title } from '../../../../typography/index.js';
|
|
14
|
+
import { theme } from '../../../theme_variables.js';
|
|
15
|
+
|
|
16
|
+
// Styles
|
|
17
|
+
import styles from './sb_materials.module.css';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
title: 'Themes/Material',
|
|
21
|
+
tags: ['autodocs'],
|
|
22
|
+
argTypes: {
|
|
23
|
+
materialColor: {
|
|
24
|
+
control: { type: 'color', presetColors: [], disableAlpha: false },
|
|
25
|
+
label: 'Custom Material Color',
|
|
26
|
+
format: 'hsla',
|
|
27
|
+
},
|
|
28
|
+
accentColor: {
|
|
29
|
+
control: { type: 'color', presetColors: [], disableAlpha: false },
|
|
30
|
+
label: 'Custom Accent Color',
|
|
31
|
+
format: 'hsla',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
args: {
|
|
35
|
+
materialColor: 'hsl(122, 100%, 20%)',
|
|
36
|
+
accentColor: 'hsl(122, 100%, 55%)',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function useCustomSurface(materialColor?: string, accentColor?: string) {
|
|
41
|
+
const mat = materialColor || 'hsl(122, 100%, 20%)';
|
|
42
|
+
const acc = accentColor || 'hsl(122, 100%, 55%)';
|
|
43
|
+
|
|
44
|
+
const material = parseHSL(mat);
|
|
45
|
+
const accent = parseHSL(acc);
|
|
46
|
+
const onMaterial = getContrastText(material);
|
|
47
|
+
const onAction = getContrastText(accent);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
material: formatHSLString(material),
|
|
51
|
+
accent: formatHSLString(accent),
|
|
52
|
+
onMaterial: formatHSLString(onMaterial),
|
|
53
|
+
onAction: formatHSLString(onAction),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const DynamicSurface = (args: {
|
|
58
|
+
materialColor?: string;
|
|
59
|
+
accentColor?: string;
|
|
60
|
+
}) => {
|
|
61
|
+
const [surface, setSurface] = useState('light-primary');
|
|
62
|
+
|
|
63
|
+
const handleSurfaceClick = (surface: string) => () => {
|
|
64
|
+
setSurface(surface);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const custom = useCustomSurface(args.materialColor, args.accentColor);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<VStack
|
|
71
|
+
className={styles['storybook-palette']}
|
|
72
|
+
height="100%"
|
|
73
|
+
gap={theme.gap.md}
|
|
74
|
+
padding={theme.padding.md}
|
|
75
|
+
growWeight={1}
|
|
76
|
+
style={
|
|
77
|
+
{
|
|
78
|
+
'--custom-action': custom.accent,
|
|
79
|
+
'--custom-on-action': custom.onAction,
|
|
80
|
+
'--custom-material': custom.material,
|
|
81
|
+
'--custom-on-material': custom.onMaterial,
|
|
82
|
+
} as React.CSSProperties
|
|
83
|
+
}
|
|
84
|
+
>
|
|
85
|
+
<Header>
|
|
86
|
+
<Title>Ergo Theme: Materials and Surfaces</Title>
|
|
87
|
+
</Header>
|
|
88
|
+
<SB_MaterialPicker handleSurfaceClick={handleSurfaceClick} />
|
|
89
|
+
<VPanel
|
|
90
|
+
// TODO: Find a better way to have typography inherit the on material color
|
|
91
|
+
style={{
|
|
92
|
+
color: 'inherit',
|
|
93
|
+
}}
|
|
94
|
+
minHeight="200px"
|
|
95
|
+
maxHeight="700px"
|
|
96
|
+
height="100%"
|
|
97
|
+
className={clsx(styles[`${surface}`], styles['surface'])}
|
|
98
|
+
>
|
|
99
|
+
<Header>
|
|
100
|
+
Enabled Utilities
|
|
101
|
+
<Spacer />
|
|
102
|
+
<SlimButton hierarchy="tertiary">
|
|
103
|
+
<PlusIcon />
|
|
104
|
+
</SlimButton>
|
|
105
|
+
<SlimButton hierarchy="secondary">
|
|
106
|
+
<PlusIcon />
|
|
107
|
+
</SlimButton>
|
|
108
|
+
<Divider vertical />
|
|
109
|
+
<SlimButton hierarchy="primary">
|
|
110
|
+
<PlusIcon />
|
|
111
|
+
</SlimButton>
|
|
112
|
+
</Header>
|
|
113
|
+
<Header>
|
|
114
|
+
Disabled Utilities
|
|
115
|
+
<Spacer />
|
|
116
|
+
<SlimButton hierarchy="tertiary" disabled>
|
|
117
|
+
<PlusIcon />
|
|
118
|
+
</SlimButton>
|
|
119
|
+
<SlimButton hierarchy="secondary" disabled>
|
|
120
|
+
<PlusIcon />
|
|
121
|
+
</SlimButton>
|
|
122
|
+
<Divider vertical />
|
|
123
|
+
<SlimButton hierarchy="primary" disabled>
|
|
124
|
+
<PlusIcon />
|
|
125
|
+
</SlimButton>
|
|
126
|
+
</Header>
|
|
127
|
+
<VBody>
|
|
128
|
+
<SB_TonePicker />
|
|
129
|
+
</VBody>
|
|
130
|
+
<Footer>
|
|
131
|
+
Disabled Buttons
|
|
132
|
+
<Spacer />
|
|
133
|
+
<Button hierarchy="tertiary" disabled>
|
|
134
|
+
Tertiary
|
|
135
|
+
</Button>
|
|
136
|
+
<Button hierarchy="secondary" disabled>
|
|
137
|
+
Secondary
|
|
138
|
+
</Button>
|
|
139
|
+
<Button hierarchy="primary" disabled>
|
|
140
|
+
Primary
|
|
141
|
+
</Button>
|
|
142
|
+
</Footer>
|
|
143
|
+
<Footer>
|
|
144
|
+
Enabled Buttons
|
|
145
|
+
<Spacer />
|
|
146
|
+
<Button hierarchy="tertiary">Tertiary</Button>
|
|
147
|
+
<Button hierarchy="secondary">Secondary</Button>
|
|
148
|
+
<Button hierarchy="primary">Primary</Button>
|
|
149
|
+
</Footer>
|
|
150
|
+
</VPanel>
|
|
151
|
+
<Header></Header>
|
|
152
|
+
</VStack>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
.storybook-palette {
|
|
2
|
+
--background: #f1f1f1;
|
|
3
|
+
--primary: 23, 65%, 49%;
|
|
4
|
+
--navy: 213, 35.6%, 34.7%;
|
|
5
|
+
--white: 0, 0%, 100%;
|
|
6
|
+
--tan: 33, 22%, 84%;
|
|
7
|
+
--secondary: 197, 34.2%, 55.3%;
|
|
8
|
+
--secondary-light: 208 65.2% 95.5%;
|
|
9
|
+
--slate: 217, 32.6%, 17.5%;
|
|
10
|
+
|
|
11
|
+
--positive: 141, 71%, 48%; /* Green */
|
|
12
|
+
--notice: 202, 76%, 50%; /* Blue */
|
|
13
|
+
--neutral: 0, 0%, 100%; /* White */
|
|
14
|
+
--warning: 48, 100%, 50%; /* Yellow */
|
|
15
|
+
--danger: 0, 100%, 50%; /* Red */
|
|
16
|
+
|
|
17
|
+
background: var(--background);
|
|
18
|
+
|
|
19
|
+
/* This behavior can be moved to ergo theme once dialed and the global will be dropped */
|
|
20
|
+
:global(.tcn-card) {
|
|
21
|
+
:global(.tcn-header) {
|
|
22
|
+
background: hsl(var(--material));
|
|
23
|
+
color: hsl(var(--on-material));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:global(.tcn-card[data-tone="positive"]) {
|
|
28
|
+
--material: var(--positive);
|
|
29
|
+
--on-material: var(--white);
|
|
30
|
+
--action: var(--white);
|
|
31
|
+
--on-action: var(--positive);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:global(.tcn-card[data-tone="notice"]) {
|
|
35
|
+
--material: var(--notice);
|
|
36
|
+
--on-material: var(--white);
|
|
37
|
+
--action: var(--white);
|
|
38
|
+
--on-action: var(--notice);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* :global(.tcn-card[data-tone="neutral"]) {} */
|
|
42
|
+
|
|
43
|
+
:global(.tcn-card[data-tone="warning"]) {
|
|
44
|
+
--material: var(--warning);
|
|
45
|
+
--on-material: var(--navy);
|
|
46
|
+
--action: var(--navy);
|
|
47
|
+
--on-action: var(--white);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:global(.tcn-card[data-tone="danger"]) {
|
|
51
|
+
--material: var(--danger);
|
|
52
|
+
--on-material: var(--white);
|
|
53
|
+
--action: var(--white);
|
|
54
|
+
--on-action: var(--danger);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.light-primary {
|
|
59
|
+
--action: var(--primary);
|
|
60
|
+
--on-action: var(--white);
|
|
61
|
+
--material: var(--white);
|
|
62
|
+
--on-material: var(--navy);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.light-secondary {
|
|
66
|
+
--action: var(--navy);
|
|
67
|
+
--on-action: var(--white);
|
|
68
|
+
--material: var(--tan);
|
|
69
|
+
--on-material: var(--navy);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.dark-primary {
|
|
73
|
+
--action: var(--secondary);
|
|
74
|
+
--on-action: var(--white);
|
|
75
|
+
--material: var(--slate);
|
|
76
|
+
--on-material: var(--white);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.dark-secondary {
|
|
80
|
+
--action: var(--tan);
|
|
81
|
+
--on-action: var(--navy);
|
|
82
|
+
--material: var(--navy);
|
|
83
|
+
--on-material: var(--white);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.light-tertiary {
|
|
87
|
+
--action: var(--navy);
|
|
88
|
+
--on-action: var(--white);
|
|
89
|
+
--material: var(--secondary-light);
|
|
90
|
+
--on-material: var(--navy);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.surface-custom {
|
|
94
|
+
--action: var(--custom-action);
|
|
95
|
+
--on-action: var(--custom-on-action);
|
|
96
|
+
--material: var(--custom-material);
|
|
97
|
+
--on-material: var(--custom-on-material);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.surface-custom-inverted {
|
|
101
|
+
--action: var(--custom-material);
|
|
102
|
+
--on-action: var(--custom-on-material);
|
|
103
|
+
--material: var(--navy);
|
|
104
|
+
--on-material: var(--white);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.surface {
|
|
108
|
+
background: hsl(var(--material));
|
|
109
|
+
color: hsl(var(--on-material));
|
|
110
|
+
}
|