@indico-data/design-system 2.23.0 → 2.24.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/lib/index.css +20 -0
- package/lib/index.d.ts +68 -65
- package/lib/index.esm.css +20 -0
- package/lib/index.esm.js +4 -4
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/src/components/button/types.d.ts +2 -3
- package/lib/src/components/pill/Pill.d.ts +2 -7
- package/lib/src/components/pill/types.d.ts +10 -0
- package/lib/src/types.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/button/types.ts +2 -4
- package/src/components/pill/Pill.stories.tsx +12 -12
- package/src/components/pill/Pill.tsx +5 -10
- package/src/components/pill/__tests__/Pill.test.tsx +10 -12
- package/src/components/pill/types.ts +12 -0
- package/src/styles/variables/_size.scss +19 -0
- package/src/styles/variables/index.scss +1 -0
- package/src/types.ts +6 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IconName } from '@/types';
|
|
1
|
+
import { IconName, SemanticColor } from '@/types';
|
|
2
2
|
export type ButtonVariants = 'solid' | 'outline' | 'text';
|
|
3
|
-
export type ButtonColors = 'primary' | 'secondary' | 'warning' | 'error' | 'success' | 'info';
|
|
4
3
|
export type ButtonIconPositions = 'left' | 'right';
|
|
5
4
|
export type ButtonSizes = 'sm' | 'md' | 'lg';
|
|
6
5
|
export type ButtonTypes = 'button' | 'submit' | 'reset';
|
|
@@ -15,7 +14,7 @@ export interface ButtonProps {
|
|
|
15
14
|
onClick?: (...args: any[]) => void;
|
|
16
15
|
variant?: ButtonVariants;
|
|
17
16
|
iconPosition?: ButtonIconPositions;
|
|
18
|
-
color?:
|
|
17
|
+
color?: SemanticColor;
|
|
19
18
|
size?: ButtonSizes;
|
|
20
19
|
iconName?: IconName;
|
|
21
20
|
type?: ButtonTypes;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
status?: 'success' | 'warning' | 'error' | 'info' | 'neutral' | 'primary' | 'secondary';
|
|
4
|
-
size?: 'sm' | 'md' | 'lg';
|
|
5
|
-
};
|
|
6
|
-
export declare const Pill: ({ children, status, size, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
1
|
+
import { PillProps } from './types';
|
|
2
|
+
export declare const Pill: ({ children, className, color, size, ...rest }: PillProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SemanticColor } from '@/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type PillSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
export type PillColor = SemanticColor | 'neutral';
|
|
5
|
+
export interface PillProps {
|
|
6
|
+
children: React.ReactNode | React.ReactNode[];
|
|
7
|
+
color?: PillColor;
|
|
8
|
+
size?: PillSize;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
package/lib/src/types.d.ts
CHANGED
|
@@ -14,3 +14,6 @@ import { SelectOption } from './components/forms/select/types';
|
|
|
14
14
|
export type { SelectOption };
|
|
15
15
|
import { TableProps, TableColumn, Direction, Alignment } from './components/table/types';
|
|
16
16
|
export type { TableProps, TableColumn, Direction, Alignment };
|
|
17
|
+
export type SemanticColor = 'primary' | 'secondary' | 'warning' | 'error' | 'success' | 'info';
|
|
18
|
+
import { PillColor, PillSize } from './components/pill/types';
|
|
19
|
+
export type { PillColor, PillSize };
|
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { IconName } from '@/types';
|
|
1
|
+
import { IconName, SemanticColor } from '@/types';
|
|
2
2
|
|
|
3
3
|
export type ButtonVariants = 'solid' | 'outline' | 'text';
|
|
4
4
|
|
|
5
|
-
export type ButtonColors = 'primary' | 'secondary' | 'warning' | 'error' | 'success' | 'info';
|
|
6
|
-
|
|
7
5
|
export type ButtonIconPositions = 'left' | 'right';
|
|
8
6
|
|
|
9
7
|
export type ButtonSizes = 'sm' | 'md' | 'lg';
|
|
@@ -21,7 +19,7 @@ export interface ButtonProps {
|
|
|
21
19
|
onClick?: (...args: any[]) => void;
|
|
22
20
|
variant?: ButtonVariants;
|
|
23
21
|
iconPosition?: ButtonIconPositions;
|
|
24
|
-
color?:
|
|
22
|
+
color?: SemanticColor;
|
|
25
23
|
size?: ButtonSizes;
|
|
26
24
|
iconName?: IconName;
|
|
27
25
|
type?: ButtonTypes;
|
|
@@ -52,11 +52,11 @@ type Story = StoryObj<typeof Pill>;
|
|
|
52
52
|
export const Default: Story = {
|
|
53
53
|
args: {
|
|
54
54
|
children: 'Success',
|
|
55
|
-
|
|
55
|
+
color: 'success',
|
|
56
56
|
},
|
|
57
57
|
render: (args) => {
|
|
58
58
|
return (
|
|
59
|
-
<Pill
|
|
59
|
+
<Pill color={args.color} size={args.size}>
|
|
60
60
|
{args.children}
|
|
61
61
|
</Pill>
|
|
62
62
|
);
|
|
@@ -69,17 +69,17 @@ export const AllSizes: Story = {
|
|
|
69
69
|
<Container>
|
|
70
70
|
<Row>
|
|
71
71
|
<Col>
|
|
72
|
-
<Pill
|
|
72
|
+
<Pill color="info" size="lg">
|
|
73
73
|
Large (lg)
|
|
74
74
|
</Pill>
|
|
75
75
|
</Col>
|
|
76
76
|
<Col>
|
|
77
|
-
<Pill
|
|
77
|
+
<Pill color="info" size="md">
|
|
78
78
|
Medium (md)
|
|
79
79
|
</Pill>
|
|
80
80
|
</Col>
|
|
81
81
|
<Col>
|
|
82
|
-
<Pill
|
|
82
|
+
<Pill color="info" size="sm">
|
|
83
83
|
Small (sm)
|
|
84
84
|
</Pill>
|
|
85
85
|
</Col>
|
|
@@ -95,37 +95,37 @@ export const AllStatuses: Story = {
|
|
|
95
95
|
<Container>
|
|
96
96
|
<Row>
|
|
97
97
|
<Col>
|
|
98
|
-
<Pill
|
|
98
|
+
<Pill color="success" size="md">
|
|
99
99
|
Success
|
|
100
100
|
</Pill>
|
|
101
101
|
</Col>
|
|
102
102
|
<Col>
|
|
103
|
-
<Pill
|
|
103
|
+
<Pill color="warning" size="md">
|
|
104
104
|
Warning
|
|
105
105
|
</Pill>
|
|
106
106
|
</Col>
|
|
107
107
|
<Col>
|
|
108
|
-
<Pill
|
|
108
|
+
<Pill color="error" size="md">
|
|
109
109
|
Error
|
|
110
110
|
</Pill>
|
|
111
111
|
</Col>
|
|
112
112
|
<Col>
|
|
113
|
-
<Pill
|
|
113
|
+
<Pill color="primary" size="md">
|
|
114
114
|
Primary
|
|
115
115
|
</Pill>
|
|
116
116
|
</Col>
|
|
117
117
|
<Col>
|
|
118
|
-
<Pill
|
|
118
|
+
<Pill color="secondary" size="md">
|
|
119
119
|
Secondary
|
|
120
120
|
</Pill>
|
|
121
121
|
</Col>
|
|
122
122
|
<Col>
|
|
123
|
-
<Pill
|
|
123
|
+
<Pill color="info" size="md">
|
|
124
124
|
Info
|
|
125
125
|
</Pill>
|
|
126
126
|
</Col>
|
|
127
127
|
<Col>
|
|
128
|
-
<Pill
|
|
128
|
+
<Pill color="neutral" size="md">
|
|
129
129
|
Neutral
|
|
130
130
|
</Pill>
|
|
131
131
|
</Col>
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
+
import { PillProps } from './types';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
size?: 'sm' | 'md' | 'lg';
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Pill = ({ children, status = 'info', size = 'sm', ...rest }: Props) => {
|
|
10
|
-
const className = classNames('pill', {
|
|
11
|
-
[`pill--${status}`]: status,
|
|
4
|
+
export const Pill = ({ children, className, color = 'info', size = 'sm', ...rest }: PillProps) => {
|
|
5
|
+
const pillClasses = classNames('pill', className, {
|
|
6
|
+
[`pill--${color}`]: color,
|
|
12
7
|
[`pill--${size}`]: size,
|
|
13
8
|
});
|
|
14
9
|
|
|
15
10
|
return (
|
|
16
|
-
<div className={
|
|
11
|
+
<div className={pillClasses} {...rest}>
|
|
17
12
|
{children}
|
|
18
13
|
</div>
|
|
19
14
|
);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import { Pill } from '@/components/pill/Pill';
|
|
3
|
+
import { PillColor, PillSize } from '../types';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const sizes = ['sm', 'md', 'lg'] as Size[];
|
|
8
|
-
const statuses = [
|
|
5
|
+
const sizes = ['sm', 'md', 'lg'] as PillSize[];
|
|
6
|
+
const colors = [
|
|
9
7
|
'success',
|
|
10
8
|
'warning',
|
|
11
9
|
'error',
|
|
@@ -13,13 +11,13 @@ const statuses = [
|
|
|
13
11
|
'neutral',
|
|
14
12
|
'primary',
|
|
15
13
|
'secondary',
|
|
16
|
-
] as
|
|
14
|
+
] as PillColor[];
|
|
17
15
|
|
|
18
16
|
describe('Pill', () => {
|
|
19
17
|
sizes.forEach((size) => {
|
|
20
18
|
it(`checks that the proper size class is applied when size is ${size}`, () => {
|
|
21
19
|
render(
|
|
22
|
-
<Pill
|
|
20
|
+
<Pill color="success" size={size} data-testid={`pill-${size}`}>
|
|
23
21
|
Success
|
|
24
22
|
</Pill>,
|
|
25
23
|
);
|
|
@@ -28,15 +26,15 @@ describe('Pill', () => {
|
|
|
28
26
|
});
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
it(`checks that the proper style class has been applied when
|
|
29
|
+
colors.forEach((color) => {
|
|
30
|
+
it(`checks that the proper style class has been applied when color is ${color}`, () => {
|
|
33
31
|
render(
|
|
34
|
-
<Pill
|
|
32
|
+
<Pill color={color} size="md" data-testid={`pill-${color}`}>
|
|
35
33
|
Status
|
|
36
34
|
</Pill>,
|
|
37
35
|
);
|
|
38
|
-
const pill = screen.getByTestId(`pill-${
|
|
39
|
-
expect(pill).toHaveClass(`pill pill--${
|
|
36
|
+
const pill = screen.getByTestId(`pill-${color}`);
|
|
37
|
+
expect(pill).toHaveClass(`pill pill--${color} pill--md`);
|
|
40
38
|
});
|
|
41
39
|
});
|
|
42
40
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SemanticColor } from '@/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
export type PillSize = 'sm' | 'md' | 'lg';
|
|
5
|
+
export type PillColor = SemanticColor | 'neutral';
|
|
6
|
+
|
|
7
|
+
export interface PillProps {
|
|
8
|
+
children: React.ReactNode | React.ReactNode[];
|
|
9
|
+
color?: PillColor;
|
|
10
|
+
size?: PillSize;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--pf-size-0: 0;
|
|
3
|
+
--pf-size-1: 4px;
|
|
4
|
+
--pf-size-2: 8px;
|
|
5
|
+
--pf-size-3: 12px;
|
|
6
|
+
--pf-size-4: 16px;
|
|
7
|
+
--pf-size-5: 20px;
|
|
8
|
+
--pf-size-6: 24px;
|
|
9
|
+
--pf-size-7: 28px;
|
|
10
|
+
--pf-size-8: 32px;
|
|
11
|
+
--pf-size-9: 36px;
|
|
12
|
+
--pf-size-10: 40px;
|
|
13
|
+
--pf-size-11: 44px;
|
|
14
|
+
--pf-size-12: 48px;
|
|
15
|
+
--pf-size-13: 52px;
|
|
16
|
+
--pf-size-14: 56px;
|
|
17
|
+
--pf-size-15: 60px;
|
|
18
|
+
--pf-size-16: 64px;
|
|
19
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type PermafrostComponent = {
|
|
|
5
5
|
'data-testid'?: string;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// TODO: Deprecrate, these are legacy types
|
|
8
9
|
export type ButtonVariant = 'default' | 'primary' | 'destructive';
|
|
9
10
|
export type ButtonSize = 'normal' | 'large';
|
|
10
11
|
|
|
@@ -19,3 +20,8 @@ export type { SelectOption };
|
|
|
19
20
|
|
|
20
21
|
import { TableProps, TableColumn, Direction, Alignment } from './components/table/types';
|
|
21
22
|
export type { TableProps, TableColumn, Direction, Alignment };
|
|
23
|
+
|
|
24
|
+
export type SemanticColor = 'primary' | 'secondary' | 'warning' | 'error' | 'success' | 'info';
|
|
25
|
+
|
|
26
|
+
import { PillColor, PillSize } from './components/pill/types';
|
|
27
|
+
export type { PillColor, PillSize };
|