@automattic/vip-design-system 1.3.2 → 1.3.3
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/README.md +19 -4
- package/build/system/Notice/Notice.js +3 -4
- package/build/system/index.d.ts +1 -1
- package/build/system/index.js +1 -2
- package/docs/ARCHITECTURE.md +88 -0
- package/docs/CONTRIBUTING.md +29 -0
- package/docs/RELEASING.md +70 -0
- package/docs/SETUP.md +68 -0
- package/docs/TESTING.md +63 -0
- package/package.json +1 -1
- package/src/system/Notice/Notice.tsx +3 -3
- package/src/system/index.js +1 -2
- package/CONTRIBUTING.md +0 -138
package/README.md
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
# VIP Design System
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This is the main repository to store Design system tokens and components used throughout VIP projects.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- [React Components Website](https://vip-design-system-components.netlify.app/)
|
|
8
|
+
- [Figma Productive Components](https://www.figma.com/file/jcGe2KIAlh2PxaAZ5liYWi/Productive-Components?type=design&node-id=7378-4230&mode=design&t=QUgpLoxTpJvAfTiN-0)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
## Further documentation
|
|
11
|
+
|
|
12
|
+
- [SETUP.md](https://github.com/Automattic/vip-design-system/blob/trunk/docs/SETUP.md) for installation and setup instructions, basic usage and environmental variables.
|
|
13
|
+
- [ARCHITECTURE.md](https://github.com/Automattic/vip-design-system/blob/trunk/docs/ARCHITECTURE.md) for information on architecture, code structure, data storage and security.
|
|
14
|
+
- [CONTRIBUTING.md](https://github.com/Automattic/vip-design-system/blob/trunk/docs/CONTRIBUTING.md) for information on how to contribute patches and features, also issue and pull request labels.
|
|
15
|
+
- [TESTING.md](https://github.com/Automattic/vip-design-system/blob/trunk/docs/TESTING.md) for details on testing the software and individual tasks.
|
|
16
|
+
- [RELEASING.md](https://github.com/Automattic/vip-design-system/blob/trunk/docs/RELEASING.md) for details on deploying a new release.
|
|
17
|
+
|
|
18
|
+
## Health, logs and monitoring
|
|
19
|
+
|
|
20
|
+
- TBD
|
|
21
|
+
|
|
22
|
+
## Links to historical documents
|
|
23
|
+
|
|
24
|
+
- TBD
|
|
@@ -23,8 +23,7 @@ var NoticeIcon = function NoticeIcon(_ref) {
|
|
|
23
23
|
variant = _ref.variant;
|
|
24
24
|
var sx = {
|
|
25
25
|
color: color,
|
|
26
|
-
flex: '0 0 auto'
|
|
27
|
-
mt: 0
|
|
26
|
+
flex: '0 0 auto'
|
|
28
27
|
};
|
|
29
28
|
var size = 20;
|
|
30
29
|
switch (variant) {
|
|
@@ -102,9 +101,9 @@ var Notice = exports.Notice = /*#__PURE__*/_react["default"].forwardRef(function
|
|
|
102
101
|
children: [(0, _jsxRuntime.jsx)(_.Flex, {
|
|
103
102
|
sx: {
|
|
104
103
|
mr: 3,
|
|
105
|
-
mt: 0,
|
|
104
|
+
mt: title ? 2 : 0,
|
|
106
105
|
flexShrink: 0,
|
|
107
|
-
alignSelf: 'center'
|
|
106
|
+
alignSelf: title ? undefined : 'center'
|
|
108
107
|
},
|
|
109
108
|
children: (0, _jsxRuntime.jsx)(NoticeIcon, {
|
|
110
109
|
color: "notice.icon." + variant,
|
package/build/system/index.d.ts
CHANGED
|
@@ -48,4 +48,4 @@ import { Validation } from './Form';
|
|
|
48
48
|
import { Wizard } from './Wizard';
|
|
49
49
|
import { WizardStep } from './Wizard';
|
|
50
50
|
import theme from './theme';
|
|
51
|
-
export { Accordion, Avatar, Badge, Box, Button, ButtonSubmit, ButtonVariant, Card, Checkbox, Code, Dialog, NewDialog, Form, Dropdown, DialogButton, DialogMenu, DialogMenuItem, DialogDivider, DialogContent, DialogTrigger, ConfirmationDialog, NewConfirmationDialog, Grid, Flex, Notice, OptionRow, Heading, Input, Label, Spinner, Table, TableRow, TableCell, Tooltip, Link, Radio, RadioBoxGroup, Textarea, Progress, Text, Tabs, TabsTrigger, TabsContent, TabsList, Toggle, ToggleRow, Validation, Wizard, WizardStep,
|
|
51
|
+
export { Accordion, Avatar, Badge, Box, Button, ButtonSubmit, ButtonVariant, Card, Checkbox, Code, Dialog, NewDialog, Form, Dropdown, DialogButton, DialogMenu, DialogMenuItem, DialogDivider, DialogContent, DialogTrigger, ConfirmationDialog, NewConfirmationDialog, Grid, Flex, Notice, OptionRow, Heading, Input, Label, Spinner, Table, TableRow, TableCell, Tooltip, Link, Radio, RadioBoxGroup, Textarea, Progress, Text, Tabs, TabsTrigger, TabsContent, TabsList, Toggle, ToggleRow, Validation, Wizard, WizardStep, theme };
|
package/build/system/index.js
CHANGED
|
@@ -48,7 +48,7 @@ import { OptionRow } from './OptionRow';
|
|
|
48
48
|
import { Table, TableRow, TableCell } from './Table';
|
|
49
49
|
import { Text } from './Text';
|
|
50
50
|
import theme from './theme';
|
|
51
|
-
import { Wizard, WizardStep
|
|
51
|
+
import { Wizard, WizardStep } from './Wizard';
|
|
52
52
|
import { Tabs, TabsList, TabsContent, TabsTrigger } from './Tabs';
|
|
53
53
|
|
|
54
54
|
export {
|
|
@@ -101,6 +101,5 @@ export {
|
|
|
101
101
|
Validation,
|
|
102
102
|
Wizard,
|
|
103
103
|
WizardStep,
|
|
104
|
-
WizardStepHorizontal,
|
|
105
104
|
theme,
|
|
106
105
|
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Basic functionality
|
|
4
|
+
|
|
5
|
+
`vip-design-system` is a React component released in the NPM registry. It's a [public package](https://www.npmjs.com/package/@automattic/vip-design-system) that anyone can install.
|
|
6
|
+
|
|
7
|
+
## Languages & coding standard
|
|
8
|
+
|
|
9
|
+
Both JavaScript and TypeScript are used to implement the software.
|
|
10
|
+
|
|
11
|
+
We require that the WPVIP defined coding style to be used, defined in [.eslintrc.js](https://github.com/Automattic/vip-design-system/blob/trunk/.eslintrc.js).
|
|
12
|
+
|
|
13
|
+
We also use [.prettierrc](https://github.com/Automattic/vip-design-system/blob/trunk/.prettierrc) to have a standard on coding formatting. It's recommended to set your Editor to apply "Format on Save".
|
|
14
|
+
|
|
15
|
+
[JEST](https://github.com/Automattic/vip-design-system/blob/readme-update/package.json#L16-L17) is the test-runnner used in this application.
|
|
16
|
+
|
|
17
|
+
## Code structure
|
|
18
|
+
|
|
19
|
+
The code is structured in the following way:
|
|
20
|
+
|
|
21
|
+
- [.github/](https://github.com/Automattic/vip-design-system/tree/trunk/.github) — configuration and templates for GitHub actions.
|
|
22
|
+
- [.storybook/](https://github.com/Automattic/vip-design-system/tree/trunk/.storybook) — configuration files for Storybook
|
|
23
|
+
- [src/](https://github.com/Automattic/vip-design-system/tree/trunk/src) — Javascript and Typescript react component files + Theme configuration + Components tests (on each component folder).
|
|
24
|
+
- [test/](https://github.com/Automattic/vip-design-system/tree/trunk/test) — Test utilities, mocks or configuration for the test suite.
|
|
25
|
+
- [tokens/](https://github.com/Automattic/vip-design-system/tree/trunk/test) — VIP Design Sytem tokens exported using [Figma Studio](https://docs.tokens.studio/). This is the source of truth for the Design team tokens, variables, etc.
|
|
26
|
+
|
|
27
|
+
### Components structure
|
|
28
|
+
|
|
29
|
+
Components lives under the `src/system/ComponentName` directory. Each component folder contains a similar set of files. Let's use the [Avatar](https://github.com/Automattic/vip-design-system/tree/trunk/src/system/Avatar) component as an example:
|
|
30
|
+
|
|
31
|
+
- **Avatar.stories.tsx**: This is the documentation file of the component. The `*.stories` is related to the Storybook story files.
|
|
32
|
+
- **Avatar.test.tsx**: This is the test file for this component. We run `jest` as a runner in this application.
|
|
33
|
+
- **Avatar.tsx**: This is the TypeScript component itself.
|
|
34
|
+
- **index.ts**: Some components has a index file to export different files. This is not recommended anymore.
|
|
35
|
+
|
|
36
|
+
### Theme UI & Radix UI Primitives
|
|
37
|
+
|
|
38
|
+
Most of our components are based on [https://theme-ui.com/](https://theme-ui.com/) components. We try to write our own components as much as we can. Other components are based on [Radix UI Primitives](https://www.radix-ui.com/primitives) components. Radix usually has some solid and accessible components that we can use as a base.
|
|
39
|
+
|
|
40
|
+
## Updating the Theme with VIP Design System Tokens
|
|
41
|
+
|
|
42
|
+
You need to update the tokens once the VIP Design System updates the core files. The Figma Studio plugin will push files into the [tokens/](https://github.com/Automattic/vip-design-system/tree/trunk/tokens) folder. Once these files are there, you can run the following:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run theme-update
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
to have an updated json theme under [src/system/theme/generated/](https://github.com/Automattic/vip-design-system/tree/trunk/src/system/theme/generated).
|
|
49
|
+
|
|
50
|
+
### How the theming works
|
|
51
|
+
|
|
52
|
+
We use the VIP Design System Tokens as our base theme structure. All colors, spaces, types should come from a dynamic token system provided by the VIP Design team, currently using Figma as the design software. When the design system is updated by the Design team, they push files to the [tokens/](https://github.com/Automattic/vip-design-system/tree/trunk/tokens) directory.
|
|
53
|
+
|
|
54
|
+
By using the [Token Transformer](https://docs.tokens.studio/sync/github#7-how-to-use-tokens-stored-in-github-in-development) and a custom npm script, we parse this file getting only the VIP Dashboard theme we need for the react components. The light theme is called: `wpvip-product-core`, and the dark theme is called `wpvip-product-dark`.
|
|
55
|
+
|
|
56
|
+
Once the new file is updated, we need to generate a custom theme file in [src/system/theme/generated/valet-theme-light.json](https://github.com/Automattic/vip-design-system/blob/trunk/src/system/theme/generated/valet-theme-light.json). It will also generate a Dark theme version. This operation generates JSON files with the colors we need already filled in.
|
|
57
|
+
|
|
58
|
+
Once the theme is updated, the file [src/system/theme/index.js](https://github.com/Automattic/vip-design-system/blob/trunk/src/system/theme/index.js) reads the colors and apply to all components.
|
|
59
|
+
|
|
60
|
+
Use the section below to run the script and update the theme.
|
|
61
|
+
|
|
62
|
+
_Important:_ If you change the `generated/valet-theme-light.json` or the `generated/valet-theme-dark.json`, or changes will be overwritten once someone runs `npm run theme-update` again.
|
|
63
|
+
|
|
64
|
+
### Update theme script
|
|
65
|
+
|
|
66
|
+
Run this command to update the VIP Valet Theme with the latest `tokens/**` files.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm run theme-update
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Feature flags
|
|
73
|
+
|
|
74
|
+
No feature flags are currently in use.
|
|
75
|
+
|
|
76
|
+
## Database
|
|
77
|
+
|
|
78
|
+
This project has no database storage.
|
|
79
|
+
|
|
80
|
+
## Dependencies
|
|
81
|
+
|
|
82
|
+
This is a standalone NPM package. Currently there's no API communication. All the code dependencies are listed in the [package.json](https://github.com/Automattic/vip-design-system/blob/trunk/package.json) file of this project.
|
|
83
|
+
|
|
84
|
+
Major dependencies of this project are:
|
|
85
|
+
|
|
86
|
+
- Storybook — Dev dependency for previewing our components and documentation
|
|
87
|
+
- Theme UI — Base theme and components structure
|
|
88
|
+
- Radix — React primitives components used to build some of our custom components
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Pull requests & issues
|
|
4
|
+
|
|
5
|
+
We welcome any contributions to this project.
|
|
6
|
+
|
|
7
|
+
If you have a small bugfix and already have the code available, feel free to [create a pull request](https://github.com/Automattic/vip-design-system/compare). If you have a feature suggestion, please [create an issue](https://github.com/Automattic/vip-design-system/issues/new). Please follow the instructions provided. Please assign a priority to the issue/pull request according to the definitions found below.
|
|
8
|
+
|
|
9
|
+
Before writing a patch or a larger chunk of code, please ensure to study the [ARCHITECTURE.md](ARCHITECTURE.md) and [TESTING.md](TESTING.md) files. Ensure that all tests pass before asking for a review of your pull request.
|
|
10
|
+
|
|
11
|
+
## Watching for changes
|
|
12
|
+
|
|
13
|
+
You can build it continuously so that every time you make a change, build files are automatically updated:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run watch
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Troubleshooting
|
|
20
|
+
|
|
21
|
+
### Dialog + Dropdown usage
|
|
22
|
+
|
|
23
|
+
If you are facing a Dialog overlaping a Dropdown content, add this CSS to your application:
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
div[data-radix-popper-content-wrapper][data-aria-hidden='true'] {
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
This package is published to [NPM](https://www.npmjs.com/package/@automattic/vip-design-system). The process to release to NPM should be started when all pull requests intended for publishing have been merged and the software has been fully tested for publication. You can release either using GitHub Actions or locally.
|
|
4
|
+
|
|
5
|
+
## Versioning Guidelines
|
|
6
|
+
|
|
7
|
+
- `patch`: for non-breaking changes/bugfixes and small updates.
|
|
8
|
+
- `minor`: for some new features, bug fixes, and other non-breaking changes.
|
|
9
|
+
- `major`: for breaking changes.
|
|
10
|
+
|
|
11
|
+
## Note on NPM token
|
|
12
|
+
|
|
13
|
+
Publishing via the GitHub Action requires that the `NPM_TOKEN` be set correctly in [GitHub Actions secrets](https://github.com/Automattic/vip-design-system/settings/secrets/actions). This should be an npm token generated for a bot user on [the npm @automattic org](https://www.npmjs.com/settings/automattic) that has publish access to this repo.
|
|
14
|
+
|
|
15
|
+
## Release Methods
|
|
16
|
+
|
|
17
|
+
### GitHub Actions (Preferred)
|
|
18
|
+
|
|
19
|
+
This is the preferred method for pushing out the latest release. The workflow runs a bunch of validations, generates a build, bump versions + tags, pushes out to npm, and bumps to the next dev version.
|
|
20
|
+
|
|
21
|
+
1. Initiate the [release process here](https://github.com/Automattic/vip-design-system/actions/workflows/npm-prepare-release.yml).
|
|
22
|
+
1. On the right-hand side, select "Run Workflow".
|
|
23
|
+
1. Pick your preferred version bump.
|
|
24
|
+
1. Click `Run Workflow`.
|
|
25
|
+
1. Wait for a pull request to appear. The pull request will update the version number and shall be assigned to you.
|
|
26
|
+
1. When ready, merge the pull request. This will lead to a new version to be [published on npmjs.com](https://www.npmjs.com/package/@automattic/vip-design-system).
|
|
27
|
+
1. Another pull request will be created to bump to a development version, also assigned to you. Merge it to finish the process.
|
|
28
|
+
|
|
29
|
+
### Local
|
|
30
|
+
|
|
31
|
+
Follow these steps to publish locally:
|
|
32
|
+
|
|
33
|
+
1. Make sure you have NPM access to our @Automattic organization. Ask for #vip-platform-pâtisserie help in case you need it.
|
|
34
|
+
2. Pull all the changes to your local `trunk` branch. Make sure you have the latest changes (`git pull`).
|
|
35
|
+
3. We follow the [https://semver.org/](https://semver.org/) versioning. You should run the specific version you are trying to publish:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm version major|minor|patch
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
4. You should see a version bump in the [package.json](https://github.com/Automattic/vip-design-system/blob/trunk/package.json) file.
|
|
42
|
+
5. Build the application:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
6. Publish the application
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm publish
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Note: You need to have two-factor enabled in your npm account. The publish command will request a two-factor code to complete the publishing process. You can also add `--otp=CODE` to the `npm publish` command if you already have the code.
|
|
55
|
+
|
|
56
|
+
7. Push the tags to the repository and trunk updates.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git push --tags
|
|
60
|
+
git push origin trunk
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
8. For major versions or breaking changes, it's recommended to [create a RELEASE](https://github.com/Automattic/vip-design-system/releases) with the published tag.
|
|
64
|
+
|
|
65
|
+
Ps: Add a `BREAKING CHANGES` section to the release. This will avoid folks trying to figure out why their code is not working on the VIP Dashboard or any other system.
|
|
66
|
+
|
|
67
|
+
## In case of problems
|
|
68
|
+
|
|
69
|
+
If you released a broken version, ensure to inform in the GitHub release entry about the breaking change, and follow the instructions provided by NPM in: [Deprecating and undeprecating packages or package versions
|
|
70
|
+
](https://docs.npmjs.com/deprecating-and-undeprecating-packages-or-package-versions).
|
package/docs/SETUP.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Setup
|
|
2
|
+
|
|
3
|
+
## Language & requirements
|
|
4
|
+
|
|
5
|
+
- Implemented in JavaScript and TypeScript.
|
|
6
|
+
- Requirements are:
|
|
7
|
+
- Node, see version in [package.json](https://github.com/Automattic/vip-design-system/blob/trunk/package.json)
|
|
8
|
+
- A few NPM packages are needed, those are listed in the same file.
|
|
9
|
+
- The software is fairly lightweight, no special hardware requirements.
|
|
10
|
+
- Network access.
|
|
11
|
+
|
|
12
|
+
## Installation & setup instructions
|
|
13
|
+
|
|
14
|
+
### Fetching & installing
|
|
15
|
+
|
|
16
|
+
This will fetch the package and install all dependencies:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
git clone git@github.com:Automattic/vip-design-system.git && \
|
|
20
|
+
cd vip-design-system && npm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Building
|
|
24
|
+
|
|
25
|
+
This will build all TypeScript files so they can be executed:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cd vip-design-system && \
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
The best experience is to use Storybook preview for set up and development.
|
|
35
|
+
|
|
36
|
+
### Starting up locally
|
|
37
|
+
|
|
38
|
+
Run:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
You can then visit [http://localhost:60006/](http://localhost:60006/) to view.
|
|
45
|
+
|
|
46
|
+
## Updating dependencies
|
|
47
|
+
|
|
48
|
+
Dependencies should be updated by merging [pull requests from dependabot](https://github.com/Automattic/vip-design-system/pulls/app%2Fdependabot). However, great care should be taken before merging as updating dependencies can cause errors with the `vip-design-system` components. There can also be effects to the [RELEASING](https://github.com/Automattic/vip-design-system/blob/trunk/docs/RELEASING.md) process. This can happen silently.
|
|
49
|
+
|
|
50
|
+
### Before merging
|
|
51
|
+
|
|
52
|
+
Consider removing the dependency. Can the functionality needed from the dependency be implemented directly into `vip-design-system` or our own common libraries? If not, evaluate the following:
|
|
53
|
+
|
|
54
|
+
1. If the dependency is one of the [development dependencies](https://github.com/Automattic/vip-design-system/blob/trunk/package.json) (`devDependencies`), and/or only used by one of those, the likelihood of customer-impacting failure is low.
|
|
55
|
+
2. Is the package used in the [RELEASING](https://github.com/Automattic/vip-design-system/blob/trunk/docs/RELEASING.md) process? If it is, evaluate if any failure is likely to be silent. If that seems not to be the case, the risk of customer-impacting failure is low.
|
|
56
|
+
3. Is the package used in one or more [components](https://github.com/Automattic/vip-design-system/blob/trunk/src/system)? If it is, evaluate if any failure is likely to be silent. Take a look at the [TESTING](https://github.com/Automattic/vip-design-system/blob/trunk/docs/RELEASING.md) strategies to ensure the update is good.
|
|
57
|
+
|
|
58
|
+
#### Low risk dependencies
|
|
59
|
+
|
|
60
|
+
If the risk of merging is low, you can go a head and merge without doing anything further (given that all tests succeed).
|
|
61
|
+
|
|
62
|
+
#### Higher risk dependencies
|
|
63
|
+
|
|
64
|
+
For higher risk dependencies, the jobs using the dependency [will have to be tested locally](https://github.com/Automattic/vip-design-system/blob/trunk/docs/TESTING.md#locally) and the results verified. You can [run it locally](https://github.com/Automattic/vip-design-system/blob/trunk/docs/SETUP.md#starting-up-locally) and verify that all affected components are working normally.
|
|
65
|
+
|
|
66
|
+
### After merging
|
|
67
|
+
|
|
68
|
+
Test any [external Applications tests](https://github.com/Automattic/vip-design-system/blob/trunk/docs/TESTING.md#external-applications-tests) using the `vip-design-system` as a dependency, for example, [the VIP Dashboard](https://github.com/automattic/vip-dashboard).
|
package/docs/TESTING.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
Testing is an integral part of creating new features and maintaining the software.
|
|
4
|
+
|
|
5
|
+
## Automated testing
|
|
6
|
+
|
|
7
|
+
A [few actions](https://github.com/Automattic/vip-design-system/tree/trunk/.github/workflows) are automatically run via Github Actions when a pull request is created or updated.
|
|
8
|
+
|
|
9
|
+
### Linting
|
|
10
|
+
|
|
11
|
+
We run the following checks:
|
|
12
|
+
|
|
13
|
+
- linting (`npm run lint`)
|
|
14
|
+
- format checking (`npm run format:check`)
|
|
15
|
+
- type checks (`npm run check-types`)
|
|
16
|
+
|
|
17
|
+
### Dependency checks
|
|
18
|
+
|
|
19
|
+
We use the [dependaban action](https://github.com/Automattic/vip-actions/tree/trunk/dependaban) from [Automattic/vip-actions](https://github.com/Automattic/vip-actions/) to verify that no dependencies have install scripts.
|
|
20
|
+
|
|
21
|
+
### Unit tests
|
|
22
|
+
|
|
23
|
+
The tests are located inside of of each component. For example: [src/system/Accordion/Accordion.test.tsx](https://github.com/Automattic/vip-design-system/tree/trunk/src/system/Accordion/Accordion.test.tsx).
|
|
24
|
+
|
|
25
|
+
We recommend you to write tests close to the component implementation.
|
|
26
|
+
|
|
27
|
+
#### Adding new unit tests
|
|
28
|
+
|
|
29
|
+
When creating a new component, please consider adding a new unit test. Please ensure that the file name of the test matches the file name of the job. Example: `Button.test.tsx`. Put the test in the same folder as the component.
|
|
30
|
+
|
|
31
|
+
### Manual tests
|
|
32
|
+
|
|
33
|
+
We can test three ways:
|
|
34
|
+
|
|
35
|
+
**Storybook**
|
|
36
|
+
|
|
37
|
+
For components that include storybooks, we can run `npm run dev` to view the components in a sandbox-ed storybook environment.
|
|
38
|
+
|
|
39
|
+
**Pull Request Preview (Easy and recommended)**
|
|
40
|
+
|
|
41
|
+
Once you create a Pull request, a netlify bot will add a comment to your Pull Request with a preview link of the Storybook preview. This is helpful to share with other folks.
|
|
42
|
+
|
|
43
|
+
### External Applications tests
|
|
44
|
+
|
|
45
|
+
**npm link (not reliable)**
|
|
46
|
+
|
|
47
|
+
1. Run `npm link` in your checkout of this repo.
|
|
48
|
+
2. Spin up a local copy of [the VIP Dashboard](https://github.com/automattic/vip-dashboard) and navigate to a page using the linked components from `@automattic/vip-design-system`
|
|
49
|
+
|
|
50
|
+
Note: it's super useful to run `npm run watch` in another process, so any changes will be almost immediately available / testable.
|
|
51
|
+
|
|
52
|
+
**Manual Github Commit (More work, but reliable)**
|
|
53
|
+
|
|
54
|
+
1. Create your local changes and push to origin a new branch.
|
|
55
|
+
2. In a local copy of the [the VIP Dashboard](https://github.com/automattic/vip-dashboard) edit the vip-design-system line inside of the `package.json` file. Change the line with this:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
"@automattic/vip-design-system": "github:automattic/vip-design-system#YOUR_PUSHED_COMMIT_HASH",
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
3. Run `npm install` in the vip-dashboard
|
|
62
|
+
4. Run `npm run dev`
|
|
63
|
+
5. You should have your changes available.
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ export interface NoticeProps {
|
|
|
30
30
|
type ColorVariants = 'warning' | 'error' | 'alert' | 'success' | 'info';
|
|
31
31
|
|
|
32
32
|
const NoticeIcon = ( { color, variant }: NoticeIconProps ) => {
|
|
33
|
-
const sx = { color, flex: '0 0 auto'
|
|
33
|
+
const sx = { color, flex: '0 0 auto' };
|
|
34
34
|
const size = 20;
|
|
35
35
|
|
|
36
36
|
switch ( variant ) {
|
|
@@ -97,9 +97,9 @@ export const Notice = React.forwardRef< HTMLDivElement, NoticeProps >(
|
|
|
97
97
|
<Flex
|
|
98
98
|
sx={ {
|
|
99
99
|
mr: 3,
|
|
100
|
-
mt: 0,
|
|
100
|
+
mt: title ? 2 : 0,
|
|
101
101
|
flexShrink: 0,
|
|
102
|
-
alignSelf: 'center',
|
|
102
|
+
alignSelf: title ? undefined : 'center',
|
|
103
103
|
} }
|
|
104
104
|
>
|
|
105
105
|
<NoticeIcon color={ `notice.icon.${ variant }` } variant={ variant } />
|
package/src/system/index.js
CHANGED
|
@@ -48,7 +48,7 @@ import { OptionRow } from './OptionRow';
|
|
|
48
48
|
import { Table, TableRow, TableCell } from './Table';
|
|
49
49
|
import { Text } from './Text';
|
|
50
50
|
import theme from './theme';
|
|
51
|
-
import { Wizard, WizardStep
|
|
51
|
+
import { Wizard, WizardStep } from './Wizard';
|
|
52
52
|
import { Tabs, TabsList, TabsContent, TabsTrigger } from './Tabs';
|
|
53
53
|
|
|
54
54
|
export {
|
|
@@ -101,6 +101,5 @@ export {
|
|
|
101
101
|
Validation,
|
|
102
102
|
Wizard,
|
|
103
103
|
WizardStep,
|
|
104
|
-
WizardStepHorizontal,
|
|
105
104
|
theme,
|
|
106
105
|
};
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
## Development
|
|
2
|
-
|
|
3
|
-
### Prerequisites
|
|
4
|
-
|
|
5
|
-
Make sure you have [node.js](https://nodejs.org/) and [NPM](https://docs.npmjs.com/getting-started/what-is-npm) installed. Here's a [handy installer](https://nodejs.org/download/) for Windows, Mac, and Linux.
|
|
6
|
-
|
|
7
|
-
### Install
|
|
8
|
-
|
|
9
|
-
To get setup run the following command in the `vip-design-system` directory:
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
npm install
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Watching for changes
|
|
16
|
-
|
|
17
|
-
You can build it continuously so that every time you make a change, build files are automatically updated:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
npm run watch
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Testing
|
|
24
|
-
|
|
25
|
-
We can test two ways:
|
|
26
|
-
|
|
27
|
-
**Storybook**
|
|
28
|
-
|
|
29
|
-
For components that include storybooks, we can run `npm run storybook` to view the components in a sandbox-ed storybook environment.
|
|
30
|
-
|
|
31
|
-
**npm link**
|
|
32
|
-
|
|
33
|
-
1. Run `npm link` in your checkout of this repo.
|
|
34
|
-
2. Spin up a local copy of [the VIP Dashboard](https://github.com/automattic/vip-ui) and navigate to a page using the linked components from `@automattic/vip-design-system`
|
|
35
|
-
|
|
36
|
-
Note: it's super useful to run `npm run watch` in another process, so any changes will be almost immediately available / testable.
|
|
37
|
-
|
|
38
|
-
### Updating the Theme with VIP Design System Tokens
|
|
39
|
-
|
|
40
|
-
You need to update the tokens once the VIP Design System updates the core files.
|
|
41
|
-
|
|
42
|
-
#### How the theming works
|
|
43
|
-
|
|
44
|
-
We use the VIP Design System Tokens as our base theme structure. All colors, spaces, types should come from a dynamic token system provided by the VIP Design team, currently using Figma as the design software. When the design system is updated by the Design team, they push a file to the root of this repository: `tokens/valet-core.json`.
|
|
45
|
-
|
|
46
|
-
By using the [Token Transformer](https://docs.tokens.studio/sync/github#7-how-to-use-tokens-stored-in-github-in-development) and a custom npm script, we parse this file getting only the VIP Dashboard theme we need for the react components. The light theme is called: `wpvip-product-core`, and the dark theme is called `wpvip-product-dark`.
|
|
47
|
-
|
|
48
|
-
Once the new file is updated, we need to generate a custom theme file in `src/generated/valet-theme-light.json`. This operation generates a small json file with the colors we need already filled in.
|
|
49
|
-
|
|
50
|
-
Once the theme is updated, the file `src/system/theme/index.js` reads the colors and apply to all components.
|
|
51
|
-
|
|
52
|
-
Use the section below to run the script and update the theme.
|
|
53
|
-
|
|
54
|
-
_Important:_ If you change the `generated/valet-theme.json`, make it sure to open a new pull request with these changes and release a new version if needed.
|
|
55
|
-
|
|
56
|
-
#### Update theme script
|
|
57
|
-
|
|
58
|
-
Run this command to update the VIP Valet Theme with the latest `tokens/**` files.
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
npm run theme-update
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Publishing new version
|
|
65
|
-
|
|
66
|
-
The process to release to npm should be started when all pull requests intended for publishing have been merged and the software has been fully tested for publication. You can release either using GitHub Actions or locally.
|
|
67
|
-
|
|
68
|
-
### Versioning Guidelines
|
|
69
|
-
|
|
70
|
-
- `patch`: for non-breaking changes/bugfixes and small updates.
|
|
71
|
-
- `minor`: for some new features, bug fixes, and other non-breaking changes.
|
|
72
|
-
- `major`: for breaking changes.
|
|
73
|
-
|
|
74
|
-
### Note on NPM token
|
|
75
|
-
|
|
76
|
-
Publishing via the GitHub Action requires that the `NPM_TOKEN` be set correctly in GitHub Actions secrets. This should be an npm token generated for a bot user on [the npm @automattic org](https://www.npmjs.com/settings/automattic) that has publish access to this repo.
|
|
77
|
-
|
|
78
|
-
### GitHub Actions (Preferred)
|
|
79
|
-
|
|
80
|
-
This is the preferred method for pushing out the latest release. The workflow runs a bunch of validations, generates a build, bump versions + tags, pushes out to npm, and bumps to the next dev version.
|
|
81
|
-
|
|
82
|
-
1. Initiate the [release process here](https://github.com/Automattic/vip-design-system/actions/workflows/npm-prepare-release.yml).
|
|
83
|
-
1. On the right-hand side, select "Run Workflow".
|
|
84
|
-
1. Pick your preferred version bump.
|
|
85
|
-
1. Click `Run Workflow`.
|
|
86
|
-
1. Wait for a pull request to appear. The pull request will update the version number and shall be assigned to you.
|
|
87
|
-
1. When ready, merge the pull request. This will lead to a new version to be [published on npmjs.com](https://www.npmjs.com/package/@automattic/vip-design-system).
|
|
88
|
-
1. Another pull request will be created to bump to a development version, also assigned to you. Merge it to finish the process.
|
|
89
|
-
|
|
90
|
-
### Local
|
|
91
|
-
|
|
92
|
-
Follow these steps to publish locally:
|
|
93
|
-
|
|
94
|
-
1. Make sure you have NPM access to our @automattic organization. Ask for #vip-platform-pâtisserie help in case you need it.
|
|
95
|
-
2. Pull all the changes to your local trunk. Make sure you have the latest trunk locally.
|
|
96
|
-
3. We follow the [https://semver.org/](https://semver.org/) versioning. You should run the specific version you are trying to publish:
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
npm version major|minor|patch
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
4. You should see a version bump in the `package.json` file.
|
|
103
|
-
5. Build the application:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
npm run build
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
6. Publish the application
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
npm publish
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Note: You need to have two-factor enabled in your npm account. The publish command will request a two-factor code to complete the publishing process. You can also add `--otp=CODE` to the `npm publish` command if you already have the code.
|
|
116
|
-
|
|
117
|
-
7. Push the tags to the repository and trunk updates.
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
git push --tags
|
|
121
|
-
git push origin trunk
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
8. For major versions or breaking changes, it's recommended to [create a RELEASE](https://github.com/Automattic/vip-design-system/releases) with the published tag.
|
|
125
|
-
|
|
126
|
-
Ps: Add a `BREAKING CHANGES` section to the release. This will avoid folks trying to figure out why their code is not working on the VIP Dashboard or any other system.
|
|
127
|
-
|
|
128
|
-
## Troubleshooting
|
|
129
|
-
|
|
130
|
-
### Dialog + Dropdown usage
|
|
131
|
-
|
|
132
|
-
If you are facing a Dialog overlaping a Dropdown content, add this CSS to your application:
|
|
133
|
-
|
|
134
|
-
```css
|
|
135
|
-
div[data-radix-popper-content-wrapper][data-aria-hidden='true'] {
|
|
136
|
-
opacity: 0;
|
|
137
|
-
}
|
|
138
|
-
```
|