@redsift/design-system-legacy 6.0.0-alpha.9 → 6.1.0-alpha.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.
- package/CONTRIBUTING.md +382 -0
- package/index.js +5708 -0
- package/index.js.map +1 -0
- package/package.json +7 -23
- package/esm/_internal/Alert.js +0 -10
- package/esm/_internal/Alert.js.map +0 -1
- package/esm/_internal/Alert2.js +0 -59
- package/esm/_internal/Alert2.js.map +0 -1
- package/esm/_internal/Button.js +0 -5
- package/esm/_internal/Button.js.map +0 -1
- package/esm/_internal/Button2.js +0 -56
- package/esm/_internal/Button2.js.map +0 -1
- package/esm/_internal/Card.js +0 -6
- package/esm/_internal/Card.js.map +0 -1
- package/esm/_internal/Card2.js +0 -33
- package/esm/_internal/Card2.js.map +0 -1
- package/esm/_internal/CardHeader.js +0 -7
- package/esm/_internal/CardHeader.js.map +0 -1
- package/esm/_internal/CardHeader2.js +0 -35
- package/esm/_internal/CardHeader2.js.map +0 -1
- package/esm/_internal/Checkbox.js +0 -7
- package/esm/_internal/Checkbox.js.map +0 -1
- package/esm/_internal/Checkbox2.js +0 -53
- package/esm/_internal/Checkbox2.js.map +0 -1
- package/esm/_internal/CheckboxTree.js +0 -8
- package/esm/_internal/CheckboxTree.js.map +0 -1
- package/esm/_internal/CheckboxTree2.js +0 -185
- package/esm/_internal/CheckboxTree2.js.map +0 -1
- package/esm/_internal/IconContainer.js +0 -6
- package/esm/_internal/IconContainer.js.map +0 -1
- package/esm/_internal/IconContainer2.js +0 -37
- package/esm/_internal/IconContainer2.js.map +0 -1
- package/esm/_internal/Input.js +0 -7
- package/esm/_internal/Input.js.map +0 -1
- package/esm/_internal/Input2.js +0 -185
- package/esm/_internal/Input2.js.map +0 -1
- package/esm/_internal/Pagination.js +0 -10
- package/esm/_internal/Pagination.js.map +0 -1
- package/esm/_internal/Pagination2.js +0 -82
- package/esm/_internal/Pagination2.js.map +0 -1
- package/esm/_internal/Radio.js +0 -7
- package/esm/_internal/Radio.js.map +0 -1
- package/esm/_internal/Radio2.js +0 -51
- package/esm/_internal/Radio2.js.map +0 -1
- package/esm/_internal/Select.js +0 -9
- package/esm/_internal/Select.js.map +0 -1
- package/esm/_internal/Select2.js +0 -458
- package/esm/_internal/Select2.js.map +0 -1
- package/esm/_internal/Switch.js +0 -7
- package/esm/_internal/Switch.js.map +0 -1
- package/esm/_internal/Switch2.js +0 -55
- package/esm/_internal/Switch2.js.map +0 -1
- package/esm/_internal/Table.js +0 -27
- package/esm/_internal/Table.js.map +0 -1
- package/esm/_internal/Table2.js +0 -1252
- package/esm/_internal/Table2.js.map +0 -1
- package/esm/_internal/Tabs.js +0 -7
- package/esm/_internal/Tabs.js.map +0 -1
- package/esm/_internal/Tabs2.js +0 -121
- package/esm/_internal/Tabs2.js.map +0 -1
- package/esm/_internal/Typography.js +0 -6
- package/esm/_internal/Typography.js.map +0 -1
- package/esm/_internal/Typography2.js +0 -75
- package/esm/_internal/Typography2.js.map +0 -1
- package/esm/_internal/_rollupPluginBabelHelpers.js +0 -108
- package/esm/_internal/_rollupPluginBabelHelpers.js.map +0 -1
- package/esm/_internal/icons/ActionsIcon.js +0 -20
- package/esm/_internal/icons/ActionsIcon.js.map +0 -1
- package/esm/_internal/icons/AddIcon.js +0 -16
- package/esm/_internal/icons/AddIcon.js.map +0 -1
- package/esm/_internal/icons/Arrow.js +0 -36
- package/esm/_internal/icons/Arrow.js.map +0 -1
- package/esm/_internal/icons/ArrowDown.js +0 -17
- package/esm/_internal/icons/ArrowDown.js.map +0 -1
- package/esm/_internal/icons/ArrowIcon.js +0 -29
- package/esm/_internal/icons/ArrowIcon.js.map +0 -1
- package/esm/_internal/icons/ArrowUp.js +0 -16
- package/esm/_internal/icons/ArrowUp.js.map +0 -1
- package/esm/_internal/icons/BarchartHorizontal.js +0 -26
- package/esm/_internal/icons/BarchartHorizontal.js.map +0 -1
- package/esm/_internal/icons/BellIcon.js +0 -27
- package/esm/_internal/icons/BellIcon.js.map +0 -1
- package/esm/_internal/icons/BimiSetupIcon.js +0 -21
- package/esm/_internal/icons/BimiSetupIcon.js.map +0 -1
- package/esm/_internal/icons/Chevron.js +0 -40
- package/esm/_internal/icons/Chevron.js.map +0 -1
- package/esm/_internal/icons/ChevronLeft.js +0 -16
- package/esm/_internal/icons/ChevronLeft.js.map +0 -1
- package/esm/_internal/icons/ChevronRight.js +0 -16
- package/esm/_internal/icons/ChevronRight.js.map +0 -1
- package/esm/_internal/icons/ClearIcon.js +0 -16
- package/esm/_internal/icons/ClearIcon.js.map +0 -1
- package/esm/_internal/icons/Cloud.js +0 -28
- package/esm/_internal/icons/Cloud.js.map +0 -1
- package/esm/_internal/icons/Cross.js +0 -26
- package/esm/_internal/icons/Cross.js.map +0 -1
- package/esm/_internal/icons/DeleteIcon.js +0 -24
- package/esm/_internal/icons/DeleteIcon.js.map +0 -1
- package/esm/_internal/icons/DynamicDmarcIcon.js +0 -36
- package/esm/_internal/icons/DynamicDmarcIcon.js.map +0 -1
- package/esm/_internal/icons/EditOutline.js +0 -16
- package/esm/_internal/icons/EditOutline.js.map +0 -1
- package/esm/_internal/icons/Email.js +0 -55
- package/esm/_internal/icons/Email.js.map +0 -1
- package/esm/_internal/icons/EmailSourcesIcon.js +0 -29
- package/esm/_internal/icons/EmailSourcesIcon.js.map +0 -1
- package/esm/_internal/icons/ExpandLayoutIcon.js +0 -35
- package/esm/_internal/icons/ExpandLayoutIcon.js.map +0 -1
- package/esm/_internal/icons/ExportIcon.js +0 -12
- package/esm/_internal/icons/ExportIcon.js.map +0 -1
- package/esm/_internal/icons/Eye.js +0 -35
- package/esm/_internal/icons/Eye.js.map +0 -1
- package/esm/_internal/icons/Facebook.js +0 -32
- package/esm/_internal/icons/Facebook.js.map +0 -1
- package/esm/_internal/icons/FilterList.js +0 -16
- package/esm/_internal/icons/FilterList.js.map +0 -1
- package/esm/_internal/icons/FindOutHowIcon.js +0 -41
- package/esm/_internal/icons/FindOutHowIcon.js.map +0 -1
- package/esm/_internal/icons/FlatArrow.js +0 -34
- package/esm/_internal/icons/FlatArrow.js.map +0 -1
- package/esm/_internal/icons/ForwardArrowIcon.js +0 -53
- package/esm/_internal/icons/ForwardArrowIcon.js.map +0 -1
- package/esm/_internal/icons/Github.js +0 -33
- package/esm/_internal/icons/Github.js.map +0 -1
- package/esm/_internal/icons/Globe.js +0 -61
- package/esm/_internal/icons/Globe.js.map +0 -1
- package/esm/_internal/icons/Hand.js +0 -25
- package/esm/_internal/icons/Hand.js.map +0 -1
- package/esm/_internal/icons/InfinityLoop.js +0 -22
- package/esm/_internal/icons/InfinityLoop.js.map +0 -1
- package/esm/_internal/icons/InfinityLoopBreak.js +0 -31
- package/esm/_internal/icons/InfinityLoopBreak.js.map +0 -1
- package/esm/_internal/icons/IngrainIcon.js +0 -39
- package/esm/_internal/icons/IngrainIcon.js.map +0 -1
- package/esm/_internal/icons/LanguageIcon.js +0 -37
- package/esm/_internal/icons/LanguageIcon.js.map +0 -1
- package/esm/_internal/icons/Linkedin.js +0 -29
- package/esm/_internal/icons/Linkedin.js.map +0 -1
- package/esm/_internal/icons/LocationPin.js +0 -31
- package/esm/_internal/icons/LocationPin.js.map +0 -1
- package/esm/_internal/icons/MicrosoftShield.js +0 -40
- package/esm/_internal/icons/MicrosoftShield.js.map +0 -1
- package/esm/_internal/icons/News.js +0 -44
- package/esm/_internal/icons/News.js.map +0 -1
- package/esm/_internal/icons/Nodes.js +0 -27
- package/esm/_internal/icons/Nodes.js.map +0 -1
- package/esm/_internal/icons/OnDmarcIcon.js +0 -34
- package/esm/_internal/icons/OnDmarcIcon.js.map +0 -1
- package/esm/_internal/icons/OnDmarcLogo.js +0 -52
- package/esm/_internal/icons/OnDmarcLogo.js.map +0 -1
- package/esm/_internal/icons/OnDomainIcon.js +0 -32
- package/esm/_internal/icons/OnDomainIcon.js.map +0 -1
- package/esm/_internal/icons/OnInboxIcon.js +0 -48
- package/esm/_internal/icons/OnInboxIcon.js.map +0 -1
- package/esm/_internal/icons/OnInboxLogo.js +0 -68
- package/esm/_internal/icons/OnInboxLogo.js.map +0 -1
- package/esm/_internal/icons/OnInboxManagerIcon.js +0 -49
- package/esm/_internal/icons/OnInboxManagerIcon.js.map +0 -1
- package/esm/_internal/icons/OpenInNewTabIcon.js +0 -23
- package/esm/_internal/icons/OpenInNewTabIcon.js.map +0 -1
- package/esm/_internal/icons/Padlock.js +0 -33
- package/esm/_internal/icons/Padlock.js.map +0 -1
- package/esm/_internal/icons/PlusIcon.js +0 -18
- package/esm/_internal/icons/PlusIcon.js.map +0 -1
- package/esm/_internal/icons/Question.js +0 -24
- package/esm/_internal/icons/Question.js.map +0 -1
- package/esm/_internal/icons/Recruiting.js +0 -23
- package/esm/_internal/icons/Recruiting.js.map +0 -1
- package/esm/_internal/icons/ReportsIcon.js +0 -21
- package/esm/_internal/icons/ReportsIcon.js.map +0 -1
- package/esm/_internal/icons/SearchIcon.js +0 -16
- package/esm/_internal/icons/SearchIcon.js.map +0 -1
- package/esm/_internal/icons/Shield.js +0 -22
- package/esm/_internal/icons/Shield.js.map +0 -1
- package/esm/_internal/icons/ShieldPassIcon.js +0 -19
- package/esm/_internal/icons/ShieldPassIcon.js.map +0 -1
- package/esm/_internal/icons/ShieldSolid.js +0 -31
- package/esm/_internal/icons/ShieldSolid.js.map +0 -1
- package/esm/_internal/icons/ShieldWarningIcon.js +0 -34
- package/esm/_internal/icons/ShieldWarningIcon.js.map +0 -1
- package/esm/_internal/icons/ShieldWarningInvertedIcon.js +0 -29
- package/esm/_internal/icons/ShieldWarningInvertedIcon.js.map +0 -1
- package/esm/_internal/icons/Spinner.js +0 -75
- package/esm/_internal/icons/Spinner.js.map +0 -1
- package/esm/_internal/icons/Team.js +0 -81
- package/esm/_internal/icons/Team.js.map +0 -1
- package/esm/_internal/icons/ThreeDotsIcon.js +0 -19
- package/esm/_internal/icons/ThreeDotsIcon.js.map +0 -1
- package/esm/_internal/icons/Thumb.js +0 -22
- package/esm/_internal/icons/Thumb.js.map +0 -1
- package/esm/_internal/icons/Traffic.js +0 -28
- package/esm/_internal/icons/Traffic.js.map +0 -1
- package/esm/_internal/icons/Twitter.js +0 -37
- package/esm/_internal/icons/Twitter.js.map +0 -1
- package/esm/_internal/icons/Upload.js +0 -25
- package/esm/_internal/icons/Upload.js.map +0 -1
- package/esm/_internal/icons/VerticalDots.js +0 -40
- package/esm/_internal/icons/VerticalDots.js.map +0 -1
- package/esm/_internal/icons/Warning.js +0 -36
- package/esm/_internal/icons/Warning.js.map +0 -1
- package/esm/_internal/icons/WarningTriangle.js +0 -39
- package/esm/_internal/icons/WarningTriangle.js.map +0 -1
- package/esm/_internal/icons/Youtube.js +0 -29
- package/esm/_internal/icons/Youtube.js.map +0 -1
- package/esm/index.js +0 -132
- package/esm/index.js.map +0 -1
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# Contribute
|
|
2
|
+
|
|
3
|
+
## Develop
|
|
4
|
+
|
|
5
|
+
Make sure you have the following requirements installed: [node](https://nodejs.org/) (v16+) and [yarn](https://yarnpkg.com/en/) (v1.22.0+)
|
|
6
|
+
|
|
7
|
+
Clone the repo (or fork it first if you're not part of Red Sift organization).
|
|
8
|
+
```
|
|
9
|
+
git clone git@github.com:redsift/design-system.git
|
|
10
|
+
cd design-system
|
|
11
|
+
yarn install
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
You can then run the storybook and browse to [http://localhost:9000](http://localhost:9000) with:
|
|
15
|
+
```bash
|
|
16
|
+
yarn start:storybook
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### Architecture
|
|
20
|
+
|
|
21
|
+
The Design System is following a monorepo architecture, providing multiple packages based on different use cases.
|
|
22
|
+
|
|
23
|
+
- `@redsift/icons`
|
|
24
|
+
|
|
25
|
+
This package provides icons based on [Material Design Icon](https://materialdesignicons.com/) library.
|
|
26
|
+
|
|
27
|
+
- `@redsift/design-system`
|
|
28
|
+
|
|
29
|
+
This package is the main package of Red Sift's Design System. It provides the majority of the components, including layout, formatting, navigation, form and interactive components.
|
|
30
|
+
|
|
31
|
+
- `@redsift/table`
|
|
32
|
+
|
|
33
|
+
This package provides datagrid components and features based on [MUI DataGrid](https://mui.com/x/react-data-grid/). Due to the use of advanced features, a [premium license](https://mui.com/x/introduction/licensing/#premium-plan) from MUI is required.
|
|
34
|
+
|
|
35
|
+
- `@redsift/charts`
|
|
36
|
+
|
|
37
|
+
This package provides charts components. Charts are based on [d3.js](https://d3js.org/) and are mainly static. For filterable charts, see `@redsift/dashboard`.
|
|
38
|
+
|
|
39
|
+
- `@redsift/dashboard`
|
|
40
|
+
|
|
41
|
+
This package provides dashboard-related components. Charts are based on [dc.js](https://dc-js.github.io/dc.js/) and [crossfilter](https://crossfilter.github.io/crossfilter/) and datagrids are based on `@redsift/table`. It contains every filterable elements to use inside a dashboard. For static charts, see `@redsift/charts`.
|
|
42
|
+
|
|
43
|
+
- _Deprecated_ `@redsift/design-system-legacy`
|
|
44
|
+
|
|
45
|
+
This package contains all components prior to the 6.0.0 version. These components are deprecated and contributing to this package is discouraged since it will be removed in the future.
|
|
46
|
+
|
|
47
|
+
Please make sure to work inside the correct package when making contribution.
|
|
48
|
+
|
|
49
|
+
#### Shared code
|
|
50
|
+
|
|
51
|
+
If you need something inside more than one package, do not duplicate the code. Place it inside one package, export it from this package and import it inside the others.
|
|
52
|
+
|
|
53
|
+
For instance, `@redsift/dashboard` and `@redsift/charts` both have a `PieChart` component that both share the `PieChartVariant` type interface. `PieChartVariant` has been implemented inside `@redsift/charts` and is imported inside `@redsift/dashboard`.
|
|
54
|
+
|
|
55
|
+
For more convenience, add an export of this shared code in every package using it. In this example, `@redsift/dashboard` also exports `PieChartVariant`. This will make it easier for the user later.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// Even if PieChartVariant is implemented inside the charts package, the following code is not practical
|
|
59
|
+
import { PieChartVariant } from '@redsift/charts';
|
|
60
|
+
import { PieChart } from '@redsift/dashbord';
|
|
61
|
+
|
|
62
|
+
// Reexporting it from the dashboard package makes it really easier
|
|
63
|
+
import { PieChart, PieChartVariant } from '@redsift/dashbord';
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
To define which package should contain the shared code, select the one that would not create any circular dependencies.
|
|
67
|
+
|
|
68
|
+
#### Dependencies
|
|
69
|
+
|
|
70
|
+
We try to use as few dependencies as possible.
|
|
71
|
+
|
|
72
|
+
For instance, we don't want to use `lodash` or `underscore` in the Design System. See why [you don't need them](https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore) and how to work without them.
|
|
73
|
+
|
|
74
|
+
We also don't want to use `momentjs`. See why [you don't need it](https://github.com/you-dont-need/You-Dont-Need-Momentjs) and what alternatives are there.
|
|
75
|
+
|
|
76
|
+
When dependencies are required, we try not to import them entirely to optimise the tree-shaking of the Design System.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
// don't
|
|
80
|
+
import * as d3 from 'd3';
|
|
81
|
+
|
|
82
|
+
// do
|
|
83
|
+
import { sum, scaleOrdinal } from 'd3';
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Scaffolding
|
|
87
|
+
|
|
88
|
+
Each component should be in its own folder. If a subcomponent can be used as a standalone component, it should be in its own folder too. For instance, `CheckboxGroup` uses `Checkbox` but `Checkbox` can be used alone. In this case, `CheckboxGroup` and `Checkbox` both have their own folder. For `PieChart` and `PieChartSlice`, a `PieChartSlice` can not be used alone. It only exists inside a `PieChart` component. Therefore, both components are inside the same folder.
|
|
89
|
+
|
|
90
|
+
The name of the folder shoud be in kebab-case, the names of the component files are in PascalCase and the names of others files are in kebab-case. The scaffolding should be the same for every component. For instance, for the `Badge` component, it looks like this:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
badge/
|
|
94
|
+
__snapshots__/
|
|
95
|
+
Badge.stories.tsx
|
|
96
|
+
Badge.test.tsx
|
|
97
|
+
Badge.tsx
|
|
98
|
+
index.ts
|
|
99
|
+
styles.ts
|
|
100
|
+
types.ts
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
See the Typescript section to see what to put inside the `types.ts` file.
|
|
104
|
+
|
|
105
|
+
See the Styling section to see what to put inside the `styles.ts` file.
|
|
106
|
+
|
|
107
|
+
The component should stricly follow the following structure:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import React, { forwardRef, RefObject, useRef } from 'react';
|
|
111
|
+
import classNames from 'classnames';
|
|
112
|
+
import { Comp } from '~/types';
|
|
113
|
+
import { StyledBadge } from './styles';
|
|
114
|
+
import { BadgeProps } from './types';
|
|
115
|
+
|
|
116
|
+
const COMPONENT_NAME = 'RedSiftBadge';
|
|
117
|
+
const CLASSNAME = 'redsift-badge';
|
|
118
|
+
const DEFAULT_PROPS: Partial<BadgeProps> = {
|
|
119
|
+
// default values
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The Badge component.
|
|
124
|
+
*/
|
|
125
|
+
export const Badge: Comp<BadgeProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
126
|
+
const {
|
|
127
|
+
// props
|
|
128
|
+
...forwardedProps
|
|
129
|
+
} = props;
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<StyledBadge
|
|
133
|
+
{...forwardedProps}
|
|
134
|
+
// transient props
|
|
135
|
+
className={classNames(Badge.className, `${Badge.className}-${variant}`, className)}
|
|
136
|
+
ref={badgeRef as RefObject<HTMLDivElement>}
|
|
137
|
+
>
|
|
138
|
+
// content of the component if needed
|
|
139
|
+
</StyledBadge>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
Badge.className = CLASSNAME;
|
|
143
|
+
Badge.defaultProps = DEFAULT_PROPS;
|
|
144
|
+
Badge.displayName = COMPONENT_NAME;
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The main things to keep in mind here are:
|
|
148
|
+
- to use the custom `Comp` type,
|
|
149
|
+
- to forward ref and props,
|
|
150
|
+
- to concatenate classNames,
|
|
151
|
+
- to define default values and
|
|
152
|
+
- to use types from `types.ts` and styles from `styles.ts`.
|
|
153
|
+
|
|
154
|
+
#### API
|
|
155
|
+
|
|
156
|
+
The API of the components should be consistent with other components.
|
|
157
|
+
|
|
158
|
+
For instance, `isSelected` is the dedicated name for a prop indicating whether a component is selected or not. You should not use `selected` for instance. You could even be tempted to use `checked` or `isChecked` for a Checkbox component, but even if it can feel more suitable for this particular component, it creates inconsistencies among all components.
|
|
159
|
+
|
|
160
|
+
Try to think Design System when creating the API of your component. We want to provide visual options and variants for our components, but the possibilities should be limited.
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
// don't
|
|
164
|
+
innerRadius?: number;
|
|
165
|
+
outerRadius?: number;
|
|
166
|
+
height?: number;
|
|
167
|
+
width?: number;
|
|
168
|
+
|
|
169
|
+
// do
|
|
170
|
+
size?: ButtonSize;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
To know how to define your API, to name and document your props, take a look at the existing components.
|
|
174
|
+
|
|
175
|
+
### Tests
|
|
176
|
+
We use [jest](https://jestjs.io/) for unit tests and [react-testing-library](https://testing-library.com/docs/react-testing-library/intro) for rendering and writing assertions. We also use [Storyshots](https://storybook.js.org/addons/@storybook/addon-storyshots) to automatically take a code snapshot of every story.
|
|
177
|
+
|
|
178
|
+
Please make sure you include tests with your pull requests. Our CI will run the tests on each PR. A minimum of 90% code coverage is required for statements, branches, functions and lines of every package. However, in practice, we try to reach a 100% code coverage.
|
|
179
|
+
|
|
180
|
+
We split the tests into 2 groups.
|
|
181
|
+
|
|
182
|
+
*Visual tests*
|
|
183
|
+
- A Storybook story should be written for each visual state that a component can be in (based on props).
|
|
184
|
+
|
|
185
|
+
*Unit tests*
|
|
186
|
+
- (Props) Anything that should be changed by a prop should be tested via react-testing-library.
|
|
187
|
+
- (Events) Anything that should trigger an event should be tested via react-testing-library.
|
|
188
|
+
|
|
189
|
+
You can run the tests with:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
yarn test
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Or for a specific package with:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
yarn test:design-system
|
|
199
|
+
yarn test:charts
|
|
200
|
+
yarn test:dashboard
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Do not forget to update the snapshots with the `-u` option when you modify or create stories. However, you should **always** check the generated snapshots to see if they are correct. Do **not** blindly update the snapshots.
|
|
204
|
+
|
|
205
|
+
### Linting
|
|
206
|
+
|
|
207
|
+
The code is linted with [eslint](https://eslint.org/). You can run the linter with:
|
|
208
|
+
```bash
|
|
209
|
+
yarn lint
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Or for a specific package with:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
yarn lint:charts
|
|
216
|
+
yarn lint:dashboard
|
|
217
|
+
yarn lint:design-system
|
|
218
|
+
yarn lint:table
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### TypeScript
|
|
222
|
+
|
|
223
|
+
The code is written in [TypeScript](https://www.typescriptlang.org/). The type checker will usually run in your editor, but also runs when you run:
|
|
224
|
+
```bash
|
|
225
|
+
yarn check-types
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Or for a specific package with:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
yarn check-types:charts
|
|
232
|
+
yarn check-types:dashboard
|
|
233
|
+
yarn check-types:design-system
|
|
234
|
+
yarn check-types:table
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Types and interfaces are implemented inside `types.ts` files. Every shared type and interface should be placed inside a `types.ts` file at the root of the `src` folder of a component.
|
|
238
|
+
|
|
239
|
+
The `types.ts` file of a component should at minima export an interface for the component itself, named using the name of the component followed by `Props` (i.e. `BadgeProps`) and extending the HTML element it is based on (i.e. `React.ComponentProps<'div'>`). It should also export an interface for the main styled components it uses, using the same name prefixed by `Styled` (i.e. `StyledBadgeProps`). The props of the main interface **must** be documented with [jsdoc](https://jsdoc.app/) comments because this will be automatically parsed to fill the prop table inside the documentation website.
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
/**
|
|
243
|
+
* Component props.
|
|
244
|
+
*/
|
|
245
|
+
export interface BadgeProps extends ComponentProps<'div'> {
|
|
246
|
+
/** Badge variant. */
|
|
247
|
+
variant?: BadgeVariant;
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
The styled component interface should be based on the main interface but omit every prop you don't want to forward to the rendered component. Every non native prop you need to use inside the styled component should be use as [transient props](https://styled-components.com/docs/api#transient-props) and therefore prefixed by a `$` character.
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
export type StyledBadgeProps = Omit<BadgeProps, 'variant'> & {
|
|
255
|
+
$variant: BadgeProps['variant'];
|
|
256
|
+
};
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
This file is also use to implement and export any other props you may need for your component like variant interface, color interface, etc.
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
/**
|
|
263
|
+
* Component variant.
|
|
264
|
+
*/
|
|
265
|
+
export const BadgeVariant = {
|
|
266
|
+
dot: 'dot',
|
|
267
|
+
standard: 'standard',
|
|
268
|
+
} as const;
|
|
269
|
+
export type BadgeVariant = ValueOf<typeof BadgeVariant>;
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The variants, colors and all other enum-based interfaces should be implemented exactly as above to make the property compatible with both the enum values and their string equivalent values. In this example, `BadgeVariant.standard` and `"standard"` are both valid values for the `variant` prop.
|
|
273
|
+
|
|
274
|
+
### Styling
|
|
275
|
+
|
|
276
|
+
We use [styled-components](https://styled-components.com/) and [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) for styling. CSS variables are centralized through a [style dictionary](https://amzn.github.io/style-dictionary/#/).
|
|
277
|
+
|
|
278
|
+
The `styles.ts` of a component should contain all the styled-component codes. At least one main variable should be implemented and named using the name of the component prefixed by `Styled` (i.e. `StyledBadge`).
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
/**
|
|
282
|
+
* Component style.
|
|
283
|
+
*/
|
|
284
|
+
export const StyledBadge = styled.div<StyledBadgeProps>`
|
|
285
|
+
${({ $color }) => $color ? css`
|
|
286
|
+
color: var(--redsift-color-${$color}-contrast);
|
|
287
|
+
background-color: var(--redsift-color-${$color}-main);
|
|
288
|
+
` : ''}
|
|
289
|
+
`
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Make sure you are using the same HTML element for the styled component (i.e. `styled.div`) and the type interface (i.e. `ComponentProps<'div'>`). Type your variable with the interface you created in the `types.ts` file.
|
|
293
|
+
|
|
294
|
+
Make sure to use only [transient props](https://styled-components.com/docs/api#transient-props) and to use the styled-component's `css` helper when conditionnaly creating a new CSS block.
|
|
295
|
+
|
|
296
|
+
### Accessibility
|
|
297
|
+
|
|
298
|
+
We are trying to make the Design System as accessible as possible by following the [Web Accessibility Initiative guidelines](https://www.w3.org/WAI/ARIA/apg/).
|
|
299
|
+
|
|
300
|
+
Before implementing a component, try to see if there is a [pattern](https://www.w3.org/WAI/ARIA/apg/patterns/) - or a composition of multiple patterns - that is suitable for this component and follow the guidelines.
|
|
301
|
+
|
|
302
|
+
However, before using any ARIA, [read this disclaimer carefully](https://www.w3.org/WAI/ARIA/apg/practices/read-me-first/).
|
|
303
|
+
|
|
304
|
+
### Storybook
|
|
305
|
+
We use [Storybook](https://storybooks.js.org) for local development. Run the following command to start it:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
yarn start:storybook
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Then, open [http://localhost:9000](http://localhost:9000) in your browser to play around with the components and test your changes.
|
|
312
|
+
|
|
313
|
+
You can use knobs and other storybook addons to create your stories. However, it is necessary to create stories covering all the options and variants of your component to generate snapshots.
|
|
314
|
+
|
|
315
|
+
Storybook is shared among every packages of the Design System. Follow the naming of the components that already exists in the same package to make sure it will appear in the correct section.
|
|
316
|
+
|
|
317
|
+
### Documentation
|
|
318
|
+
|
|
319
|
+
We use a [Next.js](https://nextjs.org/) app with [MDX](https://mdxjs.com/) support as a documentation and demonstration site for the Design System. This app can be run as following:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
yarn dev:website
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Then, open [http://localhost:3000](http://localhost:3000) in your browser.
|
|
326
|
+
|
|
327
|
+
To add documentation for a component, a MDX file should be created in the `packages/website/pages/` folder and more precisely inside the subfolder corresponding to the section the page belongs to (i.e. `packages/website/pages/forms/checkbox.mdx` for the `Checkbox` component inside the `Forms` section).
|
|
328
|
+
|
|
329
|
+
To appear in the website's Side Panel, the page should be listed in `packages/website/components/CustomAppSidePanel/CustomAppSidePanel.tsx`) under the corresponding section.
|
|
330
|
+
|
|
331
|
+
A component page should be structured as following:
|
|
332
|
+
- **Introduction**
|
|
333
|
+
- **Installation**: explains which package to install and how
|
|
334
|
+
- **Usage**: explains how to import the component
|
|
335
|
+
- **Example**: explains the simplest example of usage for the component
|
|
336
|
+
- **Content** (optional): explains what the component can contain, if it can (for instance, a CheckboxGroup can contain Checkboxes)
|
|
337
|
+
- **Labeling** (optional): explains how to label the component, with accessibility and internationalization concerns; should only be used when the label is the only accessibility concern for this component, if there is more, use the Accessbility section below instead
|
|
338
|
+
- **Value** (optional): explains the values and states a component can have; only used for form components
|
|
339
|
+
- **Data** (optional): explains how the data should be formatted to display the component; only used for charts, table and dashboard components
|
|
340
|
+
- **Events** (optional): explains the different events attached to the component, controlled and uncontrolled version, validation system, etc...
|
|
341
|
+
- **Accessibility** (optional): dedicated accessibility section when it goes beyond the labeling, for instance to give navigation advice, etc
|
|
342
|
+
- **Visual options**: displays all the visual options and variants of the component
|
|
343
|
+
- **Props**: displays a table of component props
|
|
344
|
+
|
|
345
|
+
To display a prop table, use the `PropsTable` component as following:
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
<PropsTable component="Button" />
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
To display a demo, first create a demo (a simple `tsx` file) in the demo folder (`packages/website/demo/`) inside a subfolder with the name of the component (i.e. `packages/website/demo/button/coloring` for a coloring demo of the `Button` component). Then use the `DemoBlock` as following:
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
<DemoBlock path="button/coloring" />
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
To display simple code, use the `CodeBlock` as following:
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
<CodeBlock codeString={`
|
|
361
|
+
yarn add @redsift/design-system
|
|
362
|
+
`} language="sh" />
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Build
|
|
366
|
+
|
|
367
|
+
The Design System is built using [Rollup](https://rollupjs.org/guide/en/) inside the `dist` folder of each package by running the following command:
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
yarn build
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Or for a specific package with:
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
yarn build:charts
|
|
377
|
+
yarn build:dashboard
|
|
378
|
+
yarn build:design-system
|
|
379
|
+
yarn build:icons
|
|
380
|
+
yarn build:legacy
|
|
381
|
+
yarn build:table
|
|
382
|
+
```
|