@indico-data/design-system 2.12.1 → 2.14.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.
@@ -10,3 +10,4 @@ export { Textarea } from './forms/textarea';
10
10
  export { PasswordInput } from './forms/passwordInput';
11
11
  export { Select } from './forms/select';
12
12
  export { Form } from './forms/form';
13
+ export { Skeleton } from './skeleton';
@@ -0,0 +1,9 @@
1
+ type Props = {
2
+ className?: string;
3
+ height?: number;
4
+ width?: number;
5
+ isCircle?: boolean;
6
+ isFullHeight?: boolean;
7
+ };
8
+ export declare const Skeleton: ({ className, height, width, isCircle, isFullHeight, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { Skeleton } from './Skeleton';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Skeleton>;
6
+ export declare const Default: Story;
7
+ export declare const Circle: Story;
8
+ export declare const Square: Story;
9
+ export declare const Composition: Story;
@@ -0,0 +1 @@
1
+ export { Skeleton } from './Skeleton';
@@ -15,3 +15,4 @@ export { Textarea } from './components/forms/textarea';
15
15
  export { PasswordInput } from './components/forms/passwordInput';
16
16
  export { Select as SelectInput } from './components/forms/select';
17
17
  export { Form } from './components/forms/form';
18
+ export { Skeleton } from './components/skeleton';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "2.12.1",
3
+ "version": "2.14.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -0,0 +1,12 @@
1
+ import { Canvas, Meta, Controls } from '@storybook/blocks';
2
+ import * as Select from './Select.stories';
3
+
4
+ <Meta title="Forms/Select" name="Select" />
5
+
6
+ # Select
7
+
8
+ The select component is a flexible dropdown component that allows users to choose from a list of options. It supports various configurations, such as searchable, clearable, and custom components. It is recommended to use this component with [React Hook Form](https://react-hook-form.com/) for better form state management and best practices. The `Select` component is built using `react-select`, so refer to its [documentation](https://react-select.com/props) for full details on available props.
9
+
10
+ <Canvas of={Select.Default} />
11
+
12
+ <Controls of={Select.Default} />
@@ -83,6 +83,18 @@ const meta: Meta<SelectProps<SelectOption>> = {
83
83
  },
84
84
  defaultValue: { summary: '' },
85
85
  },
86
+ classNamePrefix: {
87
+ control: 'text',
88
+ description:
89
+ 'The prefix to use for the CSS class names. Changing this will result in losing all default styles',
90
+ table: {
91
+ category: 'Props',
92
+ type: {
93
+ summary: 'string',
94
+ },
95
+ },
96
+ defaultValue: { summary: 'select' },
97
+ },
86
98
  onChange: {
87
99
  control: false,
88
100
  description: 'Event handler for when the selected value changes',
@@ -115,4 +127,11 @@ export const Default: Story = {
115
127
  isDisabled: false,
116
128
  isLoading: false,
117
129
  },
130
+ decorators: [
131
+ (Story) => (
132
+ <div style={{ height: 175 }}>
133
+ <Story />
134
+ </div>
135
+ ),
136
+ ],
118
137
  };
@@ -10,3 +10,4 @@ export { Textarea } from './forms/textarea';
10
10
  export { PasswordInput } from './forms/passwordInput';
11
11
  export { Select } from './forms/select';
12
12
  export { Form } from './forms/form';
13
+ export { Skeleton } from './skeleton';
@@ -0,0 +1,44 @@
1
+ import { Canvas, Meta, Controls } from '@storybook/blocks';
2
+ import * as Skeleton from './Skeleton.stories';
3
+
4
+ <Meta title="Layout/Skeleton" name="Skeleton" />
5
+
6
+ # Skeleton
7
+
8
+ This component is meant to be used in situations where you need a loading placeholder. It can be used as an image placeholder, text, or even a composite of multiple elements as shown below.
9
+
10
+ <Canvas of={Skeleton.Default} source={{
11
+ code: `<Skeleton width={100} height={20} />`}} />
12
+ <Controls of={Skeleton.Default} />
13
+
14
+ ## Composition
15
+ This is an example of how you can compose the Skeleton component to create a more complex loading placeholder.
16
+
17
+ <Canvas of={Skeleton.Composition} source={{
18
+ code: `
19
+ <Container>
20
+ <Row>
21
+ <Col sm={4}>
22
+ <h2 className="mb-2">Composition</h2>
23
+ <div className="sb__mock-card border-gray-100 border-md pa-4 rounded">
24
+ <div className="sb__mock-card-title">
25
+ <Skeleton height={40} width={40} isCircle className="mb-5" />
26
+ <Skeleton height={40} className="mb-5" />
27
+ </div>
28
+ <Skeleton height={20} className="mb-2" />
29
+ <Skeleton height={20} className="mb-2" />
30
+ <Skeleton height={20} className="mb-2" />
31
+ <Skeleton height={20} width={200} className="mb-2" />
32
+ </div>
33
+ </Col>
34
+ <Col sm={4}>
35
+ <h2 className="mb-2">Circle</h2>
36
+ <Skeleton height={40} width={40} isCircle />
37
+ </Col>
38
+ <Col sm={4}>
39
+ <h2 className="mb-2">Square</h2>
40
+ <Skeleton height={40} width={40} />
41
+ </Col>
42
+ </Row>
43
+ </Container>`
44
+ }} />
@@ -0,0 +1,132 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { Skeleton } from './Skeleton';
3
+ import { Col, Container, Row } from '../grid';
4
+
5
+ const meta: Meta = {
6
+ title: 'Layout/Skeleton',
7
+ component: Skeleton,
8
+ argTypes: {
9
+ className: {
10
+ control: 'text',
11
+ description: 'Additional classes for the skeleton component',
12
+ table: {
13
+ category: 'Props',
14
+ type: {
15
+ summary: 'string',
16
+ },
17
+ },
18
+ },
19
+ height: {
20
+ control: 'number',
21
+ description: 'The height of the skeleton component',
22
+ table: {
23
+ category: 'Props',
24
+ type: {
25
+ summary: 'number',
26
+ },
27
+ },
28
+ },
29
+ width: {
30
+ control: 'number',
31
+ description: 'The width of the skeleton component',
32
+ table: {
33
+ category: 'Props',
34
+ type: {
35
+ summary: 'number',
36
+ },
37
+ },
38
+ },
39
+ isCircle: {
40
+ control: 'boolean',
41
+ description: 'Sets the skeleton component to be a circle',
42
+ table: {
43
+ category: 'Props',
44
+ type: {
45
+ summary: 'boolean',
46
+ },
47
+ },
48
+ defaultValue: { summary: false },
49
+ },
50
+ isFullHeight: {
51
+ control: 'boolean',
52
+ description: 'Sets the skeleton component to be full height',
53
+ table: {
54
+ category: 'Props',
55
+ type: {
56
+ summary: 'boolean',
57
+ },
58
+ },
59
+ defaultValue: { summary: false },
60
+ },
61
+ },
62
+ };
63
+
64
+ export default meta;
65
+
66
+ type Story = StoryObj<typeof Skeleton>;
67
+
68
+ export const Default: Story = {
69
+ args: {
70
+ height: 20,
71
+ width: 100,
72
+ isCircle: false,
73
+ isFullHeight: false,
74
+ className: 'custom-class',
75
+ },
76
+ render: (args) => {
77
+ return <Skeleton {...args} />;
78
+ },
79
+ };
80
+
81
+ export const Circle: Story = {
82
+ args: {
83
+ height: 50,
84
+ width: 50,
85
+ isCircle: true,
86
+ },
87
+ render: (args) => {
88
+ return <Skeleton {...args} />;
89
+ },
90
+ };
91
+
92
+ export const Square: Story = {
93
+ args: {
94
+ height: 50,
95
+ width: 50,
96
+ },
97
+ render: (args) => {
98
+ return <Skeleton {...args} />;
99
+ },
100
+ };
101
+
102
+ export const Composition: Story = {
103
+ render: () => {
104
+ return (
105
+ <Container>
106
+ <Row>
107
+ <Col sm={4}>
108
+ <h2 className="mb-2">Composition</h2>
109
+ <div className="sb__mock-card border-gray-100 border-md pa-4 rounded">
110
+ <div className="sb__mock-card-title">
111
+ <Skeleton height={40} width={40} isCircle className="mb-5" />
112
+ <Skeleton height={40} className="mb-5" />
113
+ </div>
114
+ <Skeleton height={20} className="mb-2" />
115
+ <Skeleton height={20} className="mb-2" />
116
+ <Skeleton height={20} className="mb-2" />
117
+ <Skeleton height={20} width={200} className="mb-2" />
118
+ </div>
119
+ </Col>
120
+ <Col sm={4}>
121
+ <h2 className="mb-2">Circle</h2>
122
+ <Skeleton height={40} width={40} isCircle />
123
+ </Col>
124
+ <Col sm={4}>
125
+ <h2 className="mb-2">Square</h2>
126
+ <Skeleton height={40} width={40} />
127
+ </Col>
128
+ </Row>
129
+ </Container>
130
+ );
131
+ },
132
+ };
@@ -0,0 +1,20 @@
1
+ type Props = {
2
+ className?: string;
3
+ height?: number;
4
+ width?: number;
5
+ isCircle?: boolean;
6
+ isFullHeight?: boolean;
7
+ };
8
+
9
+ export const Skeleton = ({ className, height, width, isCircle, isFullHeight, ...rest }: Props) => {
10
+ const dynamicStyle = {
11
+ ...(height && { height: `${height}px` }),
12
+ ...(width && { width: `${width}px` }),
13
+ };
14
+
15
+ const circleClass = isCircle ? 'skeleton--circle' : '';
16
+ const fullHeightClass = isFullHeight ? 'skeleton--full-height' : '';
17
+ const combinedClassName = `skeleton ${circleClass} ${fullHeightClass} ${className || ''}`.trim();
18
+
19
+ return <div className={combinedClassName} style={dynamicStyle} {...rest} />;
20
+ };
@@ -0,0 +1,25 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { Skeleton } from '@/components/skeleton/Skeleton';
3
+
4
+ describe('Skeleton', () => {
5
+ it('sets the width of the skeleton component', () => {
6
+ render(<Skeleton width={100} data-testid="skeleton" />);
7
+ expect(screen.getByTestId('skeleton')).toHaveStyle({ width: '100px' });
8
+ });
9
+ it('sets the height of the skeleton component', () => {
10
+ render(<Skeleton height={100} data-testid="skeleton" />);
11
+ expect(screen.getByTestId('skeleton')).toHaveStyle({ height: '100px' });
12
+ });
13
+ it('sets the skeleton component to be a circle', () => {
14
+ render(<Skeleton isCircle data-testid="skeleton" />);
15
+ expect(screen.getByTestId('skeleton')).toHaveClass('skeleton--circle');
16
+ });
17
+ it('sets the skeleton component to be full height', () => {
18
+ render(<Skeleton isFullHeight data-testid="skeleton" />);
19
+ expect(screen.getByTestId('skeleton')).toHaveClass('skeleton--full-height');
20
+ });
21
+ it('sets the className of the skeleton component', () => {
22
+ render(<Skeleton className="custom-class" data-testid="skeleton" />);
23
+ expect(screen.getByTestId('skeleton')).toHaveClass('custom-class');
24
+ });
25
+ });
@@ -0,0 +1 @@
1
+ export { Skeleton } from './Skeleton';
@@ -0,0 +1,41 @@
1
+ // Common Variables
2
+ :root,
3
+ :root [data-theme='light'],
4
+ :root [data-theme='dark'] {
5
+ --pf-skeleton-color-one: var(--pf-gray-color-200);
6
+ --pf-skeleton-color-two: var(--pf-gray-color-100);
7
+ }
8
+
9
+ // Dark Theme Specific Variables
10
+ :root [data-theme='dark'] {
11
+ --pf-skeleton-color-one: var(--pf-primary-color-200);
12
+ --pf-skeleton-color-two: var(--pf-primary-color-100);
13
+ }
14
+
15
+ .skeleton {
16
+ border-radius: var(--pf-rounded);
17
+ background-color: var(--pf-gray-color-100);
18
+ opacity: 0.7;
19
+ animation: skeleton-loading 1s linear infinite alternate;
20
+ display: flex;
21
+ flex-direction: column;
22
+ width: 100%;
23
+ height: 30px;
24
+
25
+ &.skeleton--full-height {
26
+ height: 100%;
27
+ }
28
+
29
+ &.skeleton--circle {
30
+ border-radius: var(--pf-rounded-circle);
31
+ }
32
+
33
+ @keyframes skeleton-loading {
34
+ 0% {
35
+ background-color: var(--pf-skeleton-color-one);
36
+ }
37
+ 100% {
38
+ background-color: var(--pf-skeleton-color-two);
39
+ }
40
+ }
41
+ }
package/src/index.ts CHANGED
@@ -69,3 +69,4 @@ export { Textarea } from './components/forms/textarea';
69
69
  export { PasswordInput } from './components/forms/passwordInput';
70
70
  export { Select as SelectInput } from './components/forms/select';
71
71
  export { Form } from './components/forms/form';
72
+ export { Skeleton } from './components/skeleton';
@@ -14,6 +14,7 @@
14
14
  @import '../components/forms/form/styles/Form.scss';
15
15
  @import '../components/forms/select/styles/Select.scss';
16
16
  @import '../components/forms/toggle/styles/Toggle.scss';
17
+ @import '../components/skeleton/styles/Skeleton.scss';
17
18
 
18
19
  @import 'typography';
19
20
  @import 'colors';
@@ -13,3 +13,15 @@
13
13
  background-color: var(--storybook-bg-color);
14
14
  color: var(--storybook-font-color);
15
15
  }
16
+
17
+ .sb__mock-card {
18
+ border-radius: var(--pf-rounded-lg);
19
+ box-shadow: 0 0 0 1px var(--pf-border-color);
20
+ margin: 1rem;
21
+ padding: 1rem;
22
+ .sb__mock-card-title {
23
+ display: grid;
24
+ grid-gap: 1rem;
25
+ grid-template-columns: 1fr 11fr;
26
+ }
27
+ }