@akad/design-system 1.1.6 → 1.1.8
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/css/core.css +1 -1
- package/package.json +1 -1
- package/react/react-lib.js +1833 -1675
- package/react/react-lib.umd.cjs +5 -5
- package/react/src/components/atoms/SegmentControl/SegmentControl.config.d.ts +66 -0
- package/react/src/components/atoms/SegmentControl/SegmentControl.d.ts +18 -0
- package/react/src/components/atoms/SegmentControl/SegmentControl.stories.d.ts +73 -0
- package/react/src/components/atoms/SegmentControl/SegmentControl.test.d.ts +1 -0
- package/react/src/components/atoms/SegmentControl/index.d.ts +4 -0
- package/react/src/components/atoms/SegmentControl/index.test.d.ts +1 -0
- package/react/src/components/index.d.ts +1 -0
- package/scss/core/components/atoms/segment-control.scss +143 -0
- package/scss/core/components/index.scss +1 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export declare enum SegmentControlSize {
|
|
4
|
+
Small = "sm",
|
|
5
|
+
Medium = "md"
|
|
6
|
+
}
|
|
7
|
+
export interface DsSegmentControlItem {
|
|
8
|
+
value: string;
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
testId?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SegmentControlItemsProps {
|
|
14
|
+
type: ArrayConstructor;
|
|
15
|
+
required: true;
|
|
16
|
+
}
|
|
17
|
+
export interface SegmentControlValueProps {
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
required: false;
|
|
20
|
+
}
|
|
21
|
+
export interface SegmentControlDefaultValueProps {
|
|
22
|
+
type: StringConstructor;
|
|
23
|
+
required: false;
|
|
24
|
+
}
|
|
25
|
+
export interface SegmentControlSizeProps {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: SegmentControlSize;
|
|
28
|
+
options: SegmentControlSize[];
|
|
29
|
+
}
|
|
30
|
+
export interface SegmentControlFullWidthProps {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface SegmentControlDisabledProps {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface SegmentControlClassNameProps {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
default: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SegmentControlTestIdProps {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: string;
|
|
45
|
+
}
|
|
46
|
+
export interface SegmentControlOnChangeProps {
|
|
47
|
+
type: FunctionConstructor;
|
|
48
|
+
default: (value: string, index: number) => void;
|
|
49
|
+
}
|
|
50
|
+
export interface SegmentControlConfig {
|
|
51
|
+
name: string;
|
|
52
|
+
class: string;
|
|
53
|
+
props: {
|
|
54
|
+
items: SegmentControlItemsProps;
|
|
55
|
+
value: SegmentControlValueProps;
|
|
56
|
+
defaultValue: SegmentControlDefaultValueProps;
|
|
57
|
+
size: SegmentControlSizeProps;
|
|
58
|
+
fullWidth: SegmentControlFullWidthProps;
|
|
59
|
+
disabled: SegmentControlDisabledProps;
|
|
60
|
+
className: SegmentControlClassNameProps;
|
|
61
|
+
testId: SegmentControlTestIdProps;
|
|
62
|
+
onChange: SegmentControlOnChangeProps;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
declare const segmentControlConfig: SegmentControlConfig;
|
|
66
|
+
export default segmentControlConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DsSegmentControlItem, SegmentControlSize } from './SegmentControl.config';
|
|
2
|
+
|
|
3
|
+
export interface DsSegmentControlProps {
|
|
4
|
+
items: DsSegmentControlItem[];
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
size?: SegmentControlSize;
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
testId?: string;
|
|
13
|
+
onChange?: (value: string, index: number) => void;
|
|
14
|
+
'aria-label'?: string;
|
|
15
|
+
'aria-labelledby'?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const DsSegmentControl: import('react').ForwardRefExoticComponent<DsSegmentControlProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export default DsSegmentControl;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { DsSegmentControlProps } from './SegmentControl';
|
|
3
|
+
import { DsSegmentControlItem, SegmentControlSize } from './SegmentControl.config';
|
|
4
|
+
|
|
5
|
+
declare const meta: Meta<DsSegmentControlProps>;
|
|
6
|
+
export default meta;
|
|
7
|
+
export declare const Default: {
|
|
8
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsSegmentControlProps>;
|
|
9
|
+
args: {
|
|
10
|
+
items: DsSegmentControlItem[];
|
|
11
|
+
defaultValue: string;
|
|
12
|
+
size: SegmentControlSize;
|
|
13
|
+
onChange: import('@storybook/addon-actions').HandlerFunction;
|
|
14
|
+
'aria-label': string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const Medium: {
|
|
18
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsSegmentControlProps>;
|
|
19
|
+
args: {
|
|
20
|
+
size: SegmentControlSize;
|
|
21
|
+
items: DsSegmentControlItem[];
|
|
22
|
+
defaultValue: string;
|
|
23
|
+
onChange: import('@storybook/addon-actions').HandlerFunction;
|
|
24
|
+
'aria-label': string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const FullWidth: {
|
|
28
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsSegmentControlProps>;
|
|
29
|
+
args: {
|
|
30
|
+
fullWidth: boolean;
|
|
31
|
+
items: DsSegmentControlItem[];
|
|
32
|
+
defaultValue: string;
|
|
33
|
+
size: SegmentControlSize;
|
|
34
|
+
onChange: import('@storybook/addon-actions').HandlerFunction;
|
|
35
|
+
'aria-label': string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const WithDisabledItem: {
|
|
39
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsSegmentControlProps>;
|
|
40
|
+
args: {
|
|
41
|
+
items: ({
|
|
42
|
+
value: string;
|
|
43
|
+
label: string;
|
|
44
|
+
disabled?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
value: string;
|
|
47
|
+
label: string;
|
|
48
|
+
disabled: boolean;
|
|
49
|
+
})[];
|
|
50
|
+
defaultValue: string;
|
|
51
|
+
size: SegmentControlSize;
|
|
52
|
+
onChange: import('@storybook/addon-actions').HandlerFunction;
|
|
53
|
+
'aria-label': string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export declare const FullyDisabled: {
|
|
57
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsSegmentControlProps>;
|
|
58
|
+
args: {
|
|
59
|
+
disabled: boolean;
|
|
60
|
+
items: DsSegmentControlItem[];
|
|
61
|
+
defaultValue: string;
|
|
62
|
+
size: SegmentControlSize;
|
|
63
|
+
onChange: import('@storybook/addon-actions').HandlerFunction;
|
|
64
|
+
'aria-label': string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export declare const Controlled: {
|
|
68
|
+
render: (args: DsSegmentControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
args: {
|
|
70
|
+
items: DsSegmentControlItem[];
|
|
71
|
+
'aria-label': string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,7 @@ export * from './atoms/Option';
|
|
|
12
12
|
export * from './atoms/Paragraph';
|
|
13
13
|
export * from './atoms/Progress';
|
|
14
14
|
export * from './atoms/Radio';
|
|
15
|
+
export * from './atoms/SegmentControl';
|
|
15
16
|
export * from './atoms/Select';
|
|
16
17
|
export * from './atoms/Subtitle';
|
|
17
18
|
export * from './atoms/TextArea';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// === SEGMENT CONTROL TOKENS ===
|
|
2
|
+
$segment-control__padding: $spacing__inset--quark !default;
|
|
3
|
+
$segment-control__gap: $spacing--quark !default; // 4px
|
|
4
|
+
$segment-control__border-radius: $border__radius--md !default;
|
|
5
|
+
$segment-control__item-radius: $border__radius--sm !default;
|
|
6
|
+
$segment-control__padding-y--sm: $spacing__inset--quark !default;
|
|
7
|
+
$segment-control__padding-x--sm: $spacing__inset--xs !default;
|
|
8
|
+
$segment-control__padding-y--md: $spacing__inset--nano !default;
|
|
9
|
+
$segment-control__padding-x--md: $spacing__inset--sm !default;
|
|
10
|
+
$segment-control__transition: 150ms ease-in-out !default;
|
|
11
|
+
|
|
12
|
+
// === SEGMENT CONTROL COMPONENT ===
|
|
13
|
+
.ds-segment-control {
|
|
14
|
+
--segment-control__background-track: var(--color__neutral--20);
|
|
15
|
+
--segment-control__background-item: transparent;
|
|
16
|
+
--segment-control__background-item--hover: var(--color__neutral--30);
|
|
17
|
+
--segment-control__background-item--active: var(--color__neutral--00);
|
|
18
|
+
--segment-control__color-item: var(--color__neutral--90);
|
|
19
|
+
--segment-control__color-item--hover: var(--color__neutral--90);
|
|
20
|
+
--segment-control__color-item--active: var(--color__primary);
|
|
21
|
+
--segment-control__color-item--disabled: var(--color__neutral--50);
|
|
22
|
+
--segment-control__shadow-item--active: #{$shadow__level--1};
|
|
23
|
+
|
|
24
|
+
background-color: var(--segment-control__background-track);
|
|
25
|
+
border-radius: $segment-control__border-radius;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
flex: 0 0 auto;
|
|
29
|
+
font-family: var(--font__family--highlight);
|
|
30
|
+
gap: $segment-control__gap;
|
|
31
|
+
max-width: 100%;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
padding: $segment-control__padding;
|
|
34
|
+
width: fit-content;
|
|
35
|
+
|
|
36
|
+
&--full-width {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex: 1 0 100%;
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ds-segment-control__item {
|
|
43
|
+
align-items: center;
|
|
44
|
+
appearance: none;
|
|
45
|
+
background-color: var(--segment-control__background-item);
|
|
46
|
+
border: 0;
|
|
47
|
+
border-radius: $segment-control__item-radius;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
color: var(--segment-control__color-item);
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
flex: 0 0 auto;
|
|
53
|
+
font-family: inherit;
|
|
54
|
+
font-size: $font__size--xs;
|
|
55
|
+
font-weight: $font__weight--medium;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
letter-spacing: 0;
|
|
58
|
+
line-height: 1.4;
|
|
59
|
+
margin: 0;
|
|
60
|
+
position: relative;
|
|
61
|
+
text-align: center;
|
|
62
|
+
transition:
|
|
63
|
+
background-color $segment-control__transition,
|
|
64
|
+
color $segment-control__transition,
|
|
65
|
+
box-shadow $segment-control__transition;
|
|
66
|
+
user-select: none;
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
width: auto;
|
|
69
|
+
z-index: 0;
|
|
70
|
+
|
|
71
|
+
&:hover:not(
|
|
72
|
+
.ds-segment-control__item--active,
|
|
73
|
+
.ds-segment-control__item--disabled
|
|
74
|
+
) {
|
|
75
|
+
background-color: var(--segment-control__background-item--hover);
|
|
76
|
+
color: var(--segment-control__color-item--hover);
|
|
77
|
+
z-index: 1;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&--active {
|
|
81
|
+
background-color: var(--segment-control__background-item--active);
|
|
82
|
+
box-shadow: var(--segment-control__shadow-item--active);
|
|
83
|
+
color: var(--segment-control__color-item--active);
|
|
84
|
+
z-index: 2;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&:has(.ds-segment-control__item-input:focus-visible) {
|
|
88
|
+
outline: $border__width--thin solid var(--color__primary);
|
|
89
|
+
outline-offset: $border__width--thin;
|
|
90
|
+
z-index: 3;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&--disabled {
|
|
94
|
+
color: var(--segment-control__color-item--disabled);
|
|
95
|
+
cursor: not-allowed;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.ds-segment-control__item-input {
|
|
100
|
+
appearance: none;
|
|
101
|
+
inset: 0;
|
|
102
|
+
margin: 0;
|
|
103
|
+
opacity: 0;
|
|
104
|
+
position: absolute;
|
|
105
|
+
|
|
106
|
+
&:disabled {
|
|
107
|
+
cursor: not-allowed;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Sizes
|
|
112
|
+
&--size-sm {
|
|
113
|
+
min-height: $spacing--xs;
|
|
114
|
+
|
|
115
|
+
.ds-segment-control__item {
|
|
116
|
+
padding: $segment-control__padding-y--sm $segment-control__padding-x--sm;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&--size-md {
|
|
121
|
+
min-height: $spacing--sm;
|
|
122
|
+
|
|
123
|
+
.ds-segment-control__item {
|
|
124
|
+
padding: $segment-control__padding-y--md $segment-control__padding-x--md;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&--full-width .ds-segment-control__item {
|
|
129
|
+
flex: 1 1 0;
|
|
130
|
+
width: auto;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Dark mode
|
|
135
|
+
[data-theme='dark'] .ds-segment-control {
|
|
136
|
+
--segment-control__background-track: var(--color__neutral--80);
|
|
137
|
+
--segment-control__background-item--hover: var(--color__neutral--70);
|
|
138
|
+
--segment-control__background-item--active: var(--color__primary);
|
|
139
|
+
--segment-control__color-item: var(--color__neutral--10);
|
|
140
|
+
--segment-control__color-item--hover: var(--color__neutral--00);
|
|
141
|
+
--segment-control__color-item--active: var(--color__neutral--00);
|
|
142
|
+
--segment-control__color-item--disabled: var(--color__neutral--50);
|
|
143
|
+
}
|