|
2 | 2 |
|
3 | 3 | A simple way to create an antd theme css file with zero configuration. |
4 | 4 |
|
5 | | -[Ant Design](https://ant.design/) provides plenty of UI components, styled with [less](http://lesscss.org/). You can customize the default theme modifying less variable, to achive this you have multiple ways ([check the doc here](https://ant.design/docs/react/customize-theme)). The problem is that you don't have a simple way to create a static `css` file with zero configuration. |
| 5 | +[Ant Design](https://ant.design/) provides plenty of UI components, styled with [less](http://lesscss.org/). |
| 6 | +You can customize the default theme modifying less variables, [check the doc](https://ant.design/docs/react/customize-theme) for multiple ways to achieve this.\ |
| 7 | +The main issue being that you don't have a simple way to create a static `css` file with zero configuration. |
6 | 8 |
|
7 | | -This project was created with `Antd Design v4.6.6` and aims to simplify the customization of your theme if you don't want to install dependencies, configurate things like `less` or eject your [React](reactjs.org) project. |
| 9 | +This package was created with `Antd Design v4.6.6` and aims to ease the theme's customization process without having to install more dependencies yourself, set up `less` or eject your [React](reactjs.org) project. |
8 | 10 |
|
9 | 11 | ## Usage |
10 | 12 |
|
11 | 13 | ### Generate custom theme styles |
12 | 14 |
|
13 | | -1. Create your own custom theme with the variables that you want to override, in a file called `./custom-theme.less`. |
| 15 | +1. Create your own custom theme overriding Antd's less variables (by default: `./custom-theme.less`). |
14 | 16 |
|
15 | | -2. To generate the `css` file with your custom theme, run this command: |
| 17 | +2. Generate theme's custom `.css` file. |
16 | 18 |
|
17 | | - - **Option A:** Without installing this plugin |
| 19 | + - **Option A:** Without installing this plugin: |
| 20 | + ```sh |
| 21 | + $ npx @emeks/antd-custom-theme-generator |
18 | 22 |
|
19 | | - ```sh |
20 | | - $ npx @emeks/antd-custom-theme-generator |
| 23 | + output > ./custom-theme.css |
| 24 | + ``` |
21 | 25 |
|
22 | | - output > ./custom-theme.css |
23 | | - ``` |
| 26 | + - **Option B:** Installing the package as a dev dependency: |
24 | 27 |
|
25 | | - - **Option B:** Installing the package as a dev dependency |
| 28 | + ```sh |
| 29 | + $ npm i -E --save-dev @emeks/antd-custom-theme-generator |
| 30 | + ``` |
26 | 31 |
|
27 | | - ```sh |
28 | | - $ npm i -E --save-dev @emeks/antd-custom-theme-generator |
29 | | - ``` |
| 32 | + Then generating your theme: |
| 33 | + ```sh |
| 34 | + $ generate-theme |
30 | 35 |
|
31 | | - Then generates your custom theme: |
| 36 | + output > ./custom-theme.css |
| 37 | + ``` |
32 | 38 |
|
33 | | - ```sh |
34 | | - $ generate-theme |
35 | | -
|
36 | | - output > ./custom-theme.css |
37 | | - ``` |
38 | | - |
39 | | -3. Replace the import of `antd/dist/antd.css` in your project, with the output file (`custom-theme.css`) generated by this plugin. |
| 39 | +3. Replace `antd/dist/antd.css` import in your project, with the output file (by default: `./custom-theme.css`) generated by this plugin. |
40 | 40 |
|
41 | 41 | ### Options |
42 | 42 |
|
43 | | -| Name | Default | Description | |
44 | | -| ---------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
45 | | -| verbose | | Print more info for debugging | |
46 | | -| customThemeFilePath | ./custom-theme.less | Path of the less file with the variables your want to override | |
47 | | -| generatedThemeFilePath | ./custom-theme.css | Output path where the script give you the css file with your new theme | |
48 | | -| antdLibraryPath | ./node_modules/antd | Path of the antd library | |
49 | | -| theme | default | Antd theme you want to override (e.g. `dark` or `compact`) - [check all available options](https://github.com/ant-design/ant-design/tree/master/components/style/themes) | |
| 43 | +| Name | Default | Description | |
| 44 | +| --- | --- | --- | |
| 45 | +| `--verbose` or `-v` | | Print more info for debugging | |
| 46 | +| `--antd` | ./node_modules/antd | Path of the antd library | |
| 47 | +| `--theme` | default | Antd theme you want to override (e.g. `dark` or `compact`) - [Check available options](https://github.com/ant-design/ant-design/tree/master/components/style/themes). | |
| 48 | +| `<customThemeFilePath>` | ./custom-theme.less | Path of the less file with the variables your want to override | |
| 49 | +| `<generatedThemeFilePath>` | ./custom-theme.css | Output path where the script give you the css file with your new theme | |
50 | 50 |
|
51 | 51 | > **Notes**: |
52 | 52 | > |
53 | | -> - The order of the options is important. |
| 53 | +> The order of the paths **is** important. |
54 | 54 | > ```sh |
55 | | -> $ generate-theme [verbose] [customThemeFilePath] [generatedThemeFilePath] [antdLibraryPath] [theme] |
| 55 | +> $ generate-theme [--verbose] [--antd] [--theme] [<customThemeFilePath>] [<generatedThemeFilePath>] |
56 | 56 | > ``` |
57 | | -> - Notice that all these paths must be defined relative to your project root path. |
| 57 | +> |
58 | 58 |
|
59 | 59 | ### Examples |
60 | 60 |
|
61 | 61 | - Generate dark theme |
62 | 62 |
|
63 | 63 | ```sh |
64 | | - $ npx @emeks/antd-custom-theme-generator ./custom-theme.less ./custom-theme.css ./node_modules/antd dark |
| 64 | + $ npx @emeks/antd-custom-theme-generator --theme dark |
65 | 65 | ``` |
66 | 66 |
|
67 | | -- Generate default theme with diferents paths |
| 67 | +- Generate default theme with non default paths |
68 | 68 | ```sh |
69 | 69 | $ npx @emeks/antd-custom-theme-generator ./styles/custom-theme.less ./styles/custom-theme.css |
70 | 70 | ``` |
71 | 71 |
|
72 | 72 | ### FAQ |
73 | 73 |
|
74 | | -**Q1: Which variables can I override?** |
| 74 | +> **Q1: Which variables can I override?** |
75 | 75 |
|
76 | | -> The variables that are exposed by antd in this file: https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less |
| 76 | +You may override any variable exposed by Antd in [this file](https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less). |
77 | 77 |
|
78 | | -**Q2: Should I run this command every time i change my `custom-theme.less` file?** |
| 78 | +> **Q2: Should I run this command every time I change my `custom-theme.less` file?** |
79 | 79 |
|
80 | | -> Yes, we don't provide hot-reload yet. |
| 80 | +Yes, we don't provide hot-reload yet. |
81 | 81 |
|
82 | 82 | ## Development |
83 | 83 |
|
84 | | -### Use the package locally: |
| 84 | +- Inside package folder, link it globally: |
85 | 85 |
|
86 | 86 | ```sh |
87 | 87 | $ npm link |
88 | 88 | ``` |
89 | 89 |
|
90 | | -Then in another project with antd already installed and with a `custom-theme.less` file created, execute: |
| 90 | +- Use the package in your project (with antd already installed and a `custom-theme.less` file created as well): |
91 | 91 |
|
92 | 92 | ```sh |
93 | 93 | $ generate-theme |
94 | 94 | ``` |
95 | 95 |
|
96 | 96 | ## TODO List: |
97 | 97 |
|
98 | | -- [ ] Add hot-reload generation |
| 98 | +- [ ] Add hot-reload generation. |
0 commit comments