Skip to content
This repository was archived by the owner on Dec 28, 2022. It is now read-only.

Commit 79e4c7a

Browse files
author
Florian Torres
committed
Readme updated - Added example
1 parent 78da8ce commit 79e4c7a

File tree

1 file changed

+120
-1
lines changed

1 file changed

+120
-1
lines changed

README.md

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,128 @@
44
[Supernova](https://supernova.io) is a design system platform that allows you to seamlessly translate your design system data to production-ready code. Supernova works with any platform or tech stack, is used by many developers and organizations around the world, and can help you save time by replacing manual and repetitive tasks that all developers hate. To learn everything Supernova, please check out our [developer documentation](https://developers.supernova.io/).
55

66

7-
# CSS Exporter
7+
# Tailwind Exporter
88

99

10+
This Tailwind exporter is an extension to the CSS exporter. It generates an additional file, `tailwind-variables.js` that contains the css variables as a `js` object, in order to import them directly into your **Tailwind config**.
11+
12+
## How to import your variables into your Tailwind config - Example :
13+
14+
Here is a project architecture example :
15+
16+
```bash
17+
# Project architecture example
18+
19+
app
20+
├── styles
21+
│ └── designsystem # Output folder of the exporter
22+
│ ├── colors.css
23+
│ ├── # Other
24+
│ ├── # css
25+
│ ├── # files...
26+
│ └── tailwind-variables.js
27+
└── tailwind.config.js
28+
```
29+
30+
The idea is to import `tailwind-variables.js` in `tailwind.config.js`
31+
32+
```css
33+
/* File: styles/designsystem/colors.css */
34+
/* This file is automatically generated by the tailwind exporter */
35+
36+
:root {
37+
--color-primary-dark2: #1c7a44;
38+
--color-primary-dark1: #25a35a;
39+
--color-primary-main: #2ecc71;
40+
--color-primary-light1: #6ddb9c;
41+
--color-primary-light2: #abebc6;
42+
--color-primary-light3: #d5f5e3;
43+
--color-primary-border: #29b866;
44+
--color-secondary-dark2: #0e4290;
45+
--color-secondary-dark1: #1358c0;
46+
--color-secondary-main: #186ef0;
47+
--color-secondary-light1: #5d9af5;
48+
--color-secondary-light2: #a3c5f9;
49+
--color-secondary-light3: #d1e2fc;
50+
--color-secondary-border: #1663d8;
51+
}
52+
```
53+
54+
```js
55+
// styles/designsystem/tailwind-variables.js
56+
// This file is automatically generated by the tailwind exporter
57+
58+
module.exports = {
59+
'colors': {
60+
'primary': {
61+
'dark2': 'var(--color-primary-dark2)',
62+
'dark1': 'var(--color-primary-dark1)',
63+
'DEFAULT': 'var(--color-primary-main)',
64+
'light1': 'var(--color-primary-light1)',
65+
'light2': 'var(--color-primary-light2)',
66+
'light3': 'var(--color-primary-light3)',
67+
'border': 'var(--color-primary-border)',
68+
},
69+
'secondary': {
70+
'border': 'var(--color-secondary-border)',
71+
'dark2': 'var(--color-secondary-dark2)',
72+
'dark1': 'var(--color-secondary-dark1)',
73+
'DEFAULT': 'var(--color-secondary-main)',
74+
'light1': 'var(--color-secondary-light1)',
75+
'light2': 'var(--color-secondary-light2)',
76+
'light3': 'var(--color-secondary-light3)',
77+
},
78+
}
79+
}
80+
```
81+
82+
```js
83+
// tailwind.config.js
84+
85+
const designSystemVariables = require('./styles/designsystem/tailwind-variables'); // Add this line
86+
87+
module.exports = {
88+
purge: [],
89+
darkMode: false,
90+
theme: {
91+
extend: designSystemVariables, // Add this line
92+
},
93+
variants: {
94+
extend: {},
95+
},
96+
plugins: [],
97+
}
98+
```
99+
100+
Eventually, you can use the **Tailwind variables** in your templates :
101+
102+
```html
103+
<section class="container mx-auto mt-24">
104+
105+
<h1 class="text-2xl text-primary">Supernova x Tailwind exporter x Tailwind</h1>
106+
<p class="text-secondary mt-2">Tailwind setup</p>
107+
<ul class="flex mt-2 text-white">
108+
<li class="p-2 mr-3 rounded bg-primary-dark2">Dark 2</li>
109+
<li class="p-2 mr-3 rounded bg-primary-dark1">Dark 1</li>
110+
<li class="p-2 mr-3 rounded bg-primary">Main</li>
111+
<li class="p-2 mr-3 rounded bg-primary-light1">Light 1</li>
112+
<li class="p-2 mr-3 rounded bg-primary-light2">Light 2</li>
113+
<li class="p-2 mr-3 rounded bg-primary-light3">Light 3</li>
114+
</ul>
115+
116+
</section>
117+
```
118+
119+
Tokens supported for tailwind exporter :
120+
121+
- [x] Color definitions
122+
- [ ] Text Styles
123+
- [ ] Gradients
124+
- [ ] Shadows
125+
- [ ] Borders
126+
- [ ] Radii
127+
- [ ] Measures
128+
10129
The CSS allows you to **produce a CSS definitions** in such a way that it can be immediately used in your production codebase to style all your visual elements. Specifically, this exporter is capable of exporting the previews of:
11130

12131
- [x] Color definitions

0 commit comments

Comments
 (0)