@indico-data/design-system 2.24.0 → 2.25.0

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.
@@ -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?: ButtonColors;
17
+ color?: SemanticColor;
19
18
  size?: ButtonSizes;
20
19
  iconName?: IconName;
21
20
  type?: ButtonTypes;
@@ -1,7 +1,2 @@
1
- type Props = {
2
- children: React.ReactNode | React.ReactNode[];
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
+ }
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "2.24.0",
3
+ "version": "2.25.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -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?: ButtonColors;
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
- status: 'success',
55
+ color: 'success',
56
56
  },
57
57
  render: (args) => {
58
58
  return (
59
- <Pill status={args.status} size={args.size}>
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 status="info" size="lg">
72
+ <Pill color="info" size="lg">
73
73
  Large (lg)
74
74
  </Pill>
75
75
  </Col>
76
76
  <Col>
77
- <Pill status="info" size="md">
77
+ <Pill color="info" size="md">
78
78
  Medium (md)
79
79
  </Pill>
80
80
  </Col>
81
81
  <Col>
82
- <Pill status="info" size="sm">
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 status="success" size="md">
98
+ <Pill color="success" size="md">
99
99
  Success
100
100
  </Pill>
101
101
  </Col>
102
102
  <Col>
103
- <Pill status="warning" size="md">
103
+ <Pill color="warning" size="md">
104
104
  Warning
105
105
  </Pill>
106
106
  </Col>
107
107
  <Col>
108
- <Pill status="error" size="md">
108
+ <Pill color="error" size="md">
109
109
  Error
110
110
  </Pill>
111
111
  </Col>
112
112
  <Col>
113
- <Pill status="primary" size="md">
113
+ <Pill color="primary" size="md">
114
114
  Primary
115
115
  </Pill>
116
116
  </Col>
117
117
  <Col>
118
- <Pill status="secondary" size="md">
118
+ <Pill color="secondary" size="md">
119
119
  Secondary
120
120
  </Pill>
121
121
  </Col>
122
122
  <Col>
123
- <Pill status="info" size="md">
123
+ <Pill color="info" size="md">
124
124
  Info
125
125
  </Pill>
126
126
  </Col>
127
127
  <Col>
128
- <Pill status="neutral" size="md">
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
- type Props = {
4
- children: React.ReactNode | React.ReactNode[];
5
- status?: 'success' | 'warning' | 'error' | 'info' | 'neutral' | 'primary' | 'secondary';
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={className} {...rest}>
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
- type Status = 'success' | 'warning' | 'error' | 'info' | 'neutral' | 'primary' | 'secondary';
5
- type Size = 'sm' | 'md' | 'lg';
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 Status[];
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 status="success" size={size} data-testid={`pill-${size}`}>
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
- statuses.forEach((status) => {
32
- it(`checks that the proper style class has been applied when status is ${status}`, () => {
29
+ colors.forEach((color) => {
30
+ it(`checks that the proper style class has been applied when color is ${color}`, () => {
33
31
  render(
34
- <Pill status={status} size="md" data-testid={`pill-${status}`}>
32
+ <Pill color={color} size="md" data-testid={`pill-${color}`}>
35
33
  Status
36
34
  </Pill>,
37
35
  );
38
- const pill = screen.getByTestId(`pill-${status}`);
39
- expect(pill).toHaveClass(`pill pill--${status} pill--md`);
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
+ }
@@ -132,3 +132,18 @@ html {
132
132
  .text-info {
133
133
  color: var(--pf-info-color);
134
134
  }
135
+
136
+ // Label Sizes
137
+ @each $size-name,
138
+ $size-var
139
+ in (
140
+ default: --pf-label-size,
141
+ small: --pf-label-size-small,
142
+ medium: --pf-label-size-medium,
143
+ large: --pf-label-size-large
144
+ )
145
+ {
146
+ .label-size--#{$size-name} {
147
+ font-size: var(#{$size-var});
148
+ }
149
+ }
@@ -26,4 +26,10 @@
26
26
  --pf-font-weight-medium: 500;
27
27
  --pf-font-weight-bold: 700;
28
28
  --pf-font-weight-heavy: 900;
29
+
30
+ /* Labels */
31
+ --pf-label-size: var(--pf-font-size-body);
32
+ --pf-label-size-sm: var(--pf-font-size-overline);
33
+ --pf-label-size-md: var(--pf-font-size-body);
34
+ --pf-label-size-lg: var(--pf-font-size-h2);
29
35
  }
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 };