|
1 |
| -# ARC - Arduino React Components |
2 |
| - |
3 |
| -This library contains a React-based implementation of the [Arduino Component Library](https://www.figma.com/file/euysycI6QhSSbN7Qvguce8/🎛UI-Controls). |
4 |
| - |
5 |
| -Storybook is publicly accessible via github pages [here](https://arduino.github.io/arc/) |
6 |
| - |
7 |
| -## Usage |
8 |
| - |
9 |
| -```sh |
10 |
| -npm i @arduino/arc |
11 |
| -``` |
12 |
| - |
13 |
| -Please note that this package has a peer dependecy on `react`, `react-dom` and `react-aria`, you might need to install. |
14 |
| - |
15 |
| -```sh |
16 |
| -npm i react@^17.0.2 react-dom@^17.0.2 [email protected] |
17 |
| -``` |
18 |
| - |
19 |
| -## Develop |
20 |
| - |
21 |
| -1. Install dependencies with |
22 |
| - |
23 |
| - ```sh |
24 |
| - npm i |
25 |
| - ``` |
26 |
| - |
27 |
| -2. Build the project with |
28 |
| - |
29 |
| - ```sh |
30 |
| - npm run build |
31 |
| - ``` |
32 |
| - |
33 |
| -3. to test the components locally, run storybook |
34 |
| - |
35 |
| - ```sh |
36 |
| - npm run storybook |
37 |
| - ``` |
38 |
| - |
39 |
| -4. to reference a WIP branch from another repo, set the package.json of the other repo to |
40 |
| - ```json |
41 |
| - "dependencies": { |
42 |
| - "@arduino/arc": "github:arduino/arc#your-branch", |
43 |
| - ... |
44 |
| - ``` |
45 |
| - |
46 |
| -## Versioning |
47 |
| - |
48 |
| -Versioning is automated, and managed via [semantic-release](https://github.com/semantic-release/) |
49 |
| - |
50 |
| -All the commits that lands to `main` must stick with the Angular Commit Message Conventions (which is **CaseSensitive!**): |
51 |
| - |
52 |
| -- feat: A new feature |
53 |
| -- fix: A bug fix |
54 |
| -- docs: Documentation only changes |
55 |
| -- style: Changes that do not affect the meaning of the code (white-space, - formatting, missing semi-colons, etc) |
56 |
| -- refactor: A code change that neither fixes a bug nor adds a feature |
57 |
| -- perf: A code change that improves performance |
58 |
| -- test: Adding missing or correcting existing tests |
59 |
| -- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation |
60 |
| - |
61 |
| -Given the form above in the commits, semantic-release will automatically generate the changelog and bump the version of the libs. |
62 |
| - |
63 |
| -**IMPORTANT** |
64 |
| -If you squash merge your commits, only the message in the squashed commit will be read from semantic-release. |
65 |
| -Please stick to the convention above ☝️ when squash-merging your PRs. |
66 |
| - |
67 |
| -## Deployment Process |
68 |
| - |
69 |
| -Deployment is handled automatically by the CI when your changes are merged into master. Sit back and relax ☺️ |
| 1 | +# ARC - Arduino React Components |
| 2 | + |
| 3 | +This library contains a React-based implementation of the [Arduino Component Library](https://www.figma.com/file/euysycI6QhSSbN7Qvguce8/🎛UI-Controls). |
| 4 | + |
| 5 | +Storybook is publicly accessible via github pages [here](https://arduino.github.io/arc/) |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +```sh |
| 10 | +npm i @arduino/arc |
| 11 | +``` |
| 12 | + |
| 13 | +Please note that this package has a peer dependecy on `react`, `react-dom` and `react-aria`, you might need to install. |
| 14 | + |
| 15 | +```sh |
| 16 | +npm i react@^17.0.2 react-dom@^17.0.2 [email protected] |
| 17 | +``` |
| 18 | + |
| 19 | +### Themes Usage |
| 20 | +This package also offers Arduino color themes, provided in the `themes/themes.css` file. |
| 21 | + |
| 22 | + |
| 23 | +Themes are directly pulled from Figma using the Figma API. As reported on the [website](https://www.figma.com/developers/api) "The Figma API supports read access and interactions with Figma files. This gives you the ability to view and extract any objects or layers, and their properties." |
| 24 | + |
| 25 | +This data is fetched as a `.json` file with the following structure: |
| 26 | +- `core` contains the colors library which defines the hex value for each color name, e.g.: `'tealscale-teal0': '#7fcbcd'` |
| 27 | +- `ide-default`, `ide-dark`, ..., are the different themes available, each containing two types of information: |
| 28 | + - mapping between color name and semantic value, e.g.: `'accent-strong': 'tealscale-teal0'` |
| 29 | + - mapping between variable name of an element and the semantic value, e.g.: `'button-primary-bg-hover': 'accent-strong'` |
| 30 | + |
| 31 | +This file is parsed to generate a ColorLibrary, a list of colors associated with their hex value, and DesignTokens, an object in which each variable is associated with all the available themes and each theme is associated with a color defined in the ColorLibrary. |
| 32 | + |
| 33 | +A workflow has been implemented to pull themes weekly from Figma. It is also possible to do it manually. |
| 34 | + |
| 35 | +#### Pull themes manually |
| 36 | + |
| 37 | +Whenever you need to update themes manually, follow these steps: |
| 38 | + |
| 39 | +1. Get the `FIGMA_THEME_FILE_ID` from the [URL of the Figma file](https://www.figma.com/file/c9ZP7fwbfB5GWwr2hWXzwe/Colors---Figma-Tokens?node-id=0%3A1) |
| 40 | + |
| 41 | +2. Generate your `FIGMA_API_ACCESS_TOKEN` from [Figma](https://www.figma.com/developers/api#authentication) |
| 42 | + |
| 43 | +3. Export the environment variables |
| 44 | + |
| 45 | + ```sh |
| 46 | + export FIGMA_API_ACCESS_TOKEN=xxxxxx && export FIGMA_THEME_FILE_ID=xxxxxx |
| 47 | + ``` |
| 48 | + |
| 49 | +4. Run the script |
| 50 | + ```sh |
| 51 | + npm run update-json-themes |
| 52 | + ``` |
| 53 | + |
| 54 | + |
| 55 | +#### Generate `themes/themes.css` file |
| 56 | + |
| 57 | +Once the updated themes are pulled from Figma it's possible to generate the `themes/themes.css` file using: |
| 58 | + ```sh |
| 59 | + npm run build |
| 60 | + ``` |
| 61 | +The generated file will be available in the `dist` folder. This file will contain a `css` rule for each theme with internal mapping between all Arduino variables and their values. |
| 62 | + |
| 63 | +An example: |
| 64 | +```sh |
| 65 | +:root .arc-dark { |
| 66 | + --arduino-button-primary-bg: #0ca1a6; |
| 67 | + --arduino-button-primary-bg-hover: #7fcbcd; |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Develop |
| 72 | + |
| 73 | +1. Install dependencies with |
| 74 | + |
| 75 | + ```sh |
| 76 | + npm i |
| 77 | + ``` |
| 78 | + |
| 79 | +2. Build the project with |
| 80 | + |
| 81 | + ```sh |
| 82 | + npm run build |
| 83 | + ``` |
| 84 | + |
| 85 | +3. to test the components locally, run storybook |
| 86 | + |
| 87 | + ```sh |
| 88 | + npm run storybook |
| 89 | + ``` |
| 90 | + |
| 91 | +4. to reference a WIP branch from another repo, set the package.json of the other repo to |
| 92 | + ```json |
| 93 | + "dependencies": { |
| 94 | + "@arduino/arc": "github:arduino/arc#your-branch", |
| 95 | + ... |
| 96 | + ``` |
| 97 | + |
| 98 | +## Versioning |
| 99 | + |
| 100 | +Versioning is automated, and managed via [semantic-release](https://github.com/semantic-release/) |
| 101 | + |
| 102 | +All the commits that lands to `main` must stick with the Angular Commit Message Conventions (which is **CaseSensitive!**): |
| 103 | + |
| 104 | +- feat: A new feature |
| 105 | +- fix: A bug fix |
| 106 | +- docs: Documentation only changes |
| 107 | +- style: Changes that do not affect the meaning of the code (white-space, - formatting, missing semi-colons, etc) |
| 108 | +- refactor: A code change that neither fixes a bug nor adds a feature |
| 109 | +- perf: A code change that improves performance |
| 110 | +- test: Adding missing or correcting existing tests |
| 111 | +- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation |
| 112 | + |
| 113 | +Given the form above in the commits, semantic-release will automatically generate the changelog and bump the version of the libs. |
| 114 | + |
| 115 | +**IMPORTANT** |
| 116 | +If you squash merge your commits, only the message in the squashed commit will be read from semantic-release. |
| 117 | +Please stick to the convention above ☝️ when squash-merging your PRs. |
| 118 | + |
| 119 | +## Deployment Process |
| 120 | + |
| 121 | +Deployment is handled automatically by the CI when your changes are merged into master. Sit back and relax ☺️ |
0 commit comments