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

Commit 042b268

Browse files
init Zephyr (#1)
* feat: cleanup readme w/ base info * feat: update exporter information * feat: add exports for measures to spacing * chore: readme updates * chore: update name * chore: update default logo * feat: add rendering for screen variables
1 parent 2f67e09 commit 042b268

File tree

6 files changed

+43
-215
lines changed

6 files changed

+43
-215
lines changed

README.md

+5-191
Original file line numberDiff line numberDiff line change
@@ -1,194 +1,8 @@
1-
<img src="./readme-icon.png" alt="Supernova Logo" style="max-width:100%;">
1+
# Zephyr
22

3-
[Supernova](https://supernova.io) is a design system platform that manages your assets, tokens, components and allows you to write spectacular documentations for your entire teams. And because you found your way here, you are probably interested in its most advanced functionality - automatic hand-off of design and development assets, tokens and data in general. To learn everything Supernova, please check out our [developer documentation](https://developers.supernova.io/).
3+
An opinionated Tailwind exporter to be used for all things frontend built by DeepSource.
44

5+
## Credits
56

6-
# Tailwind Exporter
7-
8-
9-
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**.
10-
11-
## How to import your variables into your Tailwind config - Example :
12-
13-
Here is a project architecture example :
14-
15-
```bash
16-
# Project architecture example
17-
18-
app
19-
├── styles
20-
│ └── designsystem # Output folder of the exporter
21-
│ ├── colors.css
22-
│ ├── # Other
23-
│ ├── # css
24-
│ ├── # files...
25-
│ └── tailwind-variables.js
26-
└── tailwind.config.js
27-
```
28-
29-
The idea is to import `tailwind-variables.js` in `tailwind.config.js`
30-
31-
```css
32-
/* File: styles/designsystem/colors.css */
33-
/* This file is automatically generated by the tailwind exporter */
34-
35-
:root {
36-
--color-primary-dark2: #1c7a44;
37-
--color-primary-dark1: #25a35a;
38-
--color-primary-main: #2ecc71;
39-
--color-primary-light1: #6ddb9c;
40-
--color-primary-light2: #abebc6;
41-
--color-primary-light3: #d5f5e3;
42-
--color-primary-border: #29b866;
43-
--color-secondary-dark2: #0e4290;
44-
--color-secondary-dark1: #1358c0;
45-
--color-secondary-main: #186ef0;
46-
--color-secondary-light1: #5d9af5;
47-
--color-secondary-light2: #a3c5f9;
48-
--color-secondary-light3: #d1e2fc;
49-
--color-secondary-border: #1663d8;
50-
}
51-
```
52-
53-
```js
54-
// styles/designsystem/tailwind-variables.js
55-
// This file is automatically generated by the tailwind exporter
56-
57-
module.exports = {
58-
'colors': {
59-
'primary': {
60-
'dark2': 'var(--color-primary-dark2)',
61-
'dark1': 'var(--color-primary-dark1)',
62-
'DEFAULT': 'var(--color-primary-main)',
63-
'light1': 'var(--color-primary-light1)',
64-
'light2': 'var(--color-primary-light2)',
65-
'light3': 'var(--color-primary-light3)',
66-
'border': 'var(--color-primary-border)',
67-
},
68-
'secondary': {
69-
'border': 'var(--color-secondary-border)',
70-
'dark2': 'var(--color-secondary-dark2)',
71-
'dark1': 'var(--color-secondary-dark1)',
72-
'DEFAULT': 'var(--color-secondary-main)',
73-
'light1': 'var(--color-secondary-light1)',
74-
'light2': 'var(--color-secondary-light2)',
75-
'light3': 'var(--color-secondary-light3)',
76-
},
77-
}
78-
}
79-
```
80-
81-
```js
82-
// tailwind.config.js
83-
84-
const designSystemVariables = require('./styles/designsystem/tailwind-variables'); // Add this line
85-
86-
module.exports = {
87-
purge: [],
88-
darkMode: false,
89-
theme: {
90-
extend: designSystemVariables, // Add this line to extend tailwind theme with your design system
91-
},
92-
variants: {
93-
extend: {},
94-
},
95-
plugins: [],
96-
}
97-
```
98-
99-
That's it ! You can now use the **Tailwind variables** in your templates :
100-
101-
```html
102-
<section class="container mx-auto mt-24">
103-
104-
<h1 class="text-2xl text-primary">Supernova x Tailwind exporter x Tailwind</h1>
105-
<p class="text-secondary mt-2">Importing your design system</p>
106-
<ul class="flex mt-2 text-white">
107-
<li class="p-2 mr-3 rounded bg-primary-dark2">Dark 2</li>
108-
<li class="p-2 mr-3 rounded bg-primary-dark1">Dark 1</li>
109-
<li class="p-2 mr-3 rounded bg-primary">Main</li>
110-
<li class="p-2 mr-3 rounded bg-primary-light1">Light 1</li>
111-
<li class="p-2 mr-3 rounded bg-primary-light2">Light 2</li>
112-
<li class="p-2 mr-3 rounded bg-primary-light3">Light 3</li>
113-
</ul>
114-
115-
</section>
116-
```
117-
118-
<img src="./result-example.png" alt="Result example" style="width:600px;max-width:100%;">
119-
120-
Tokens supported by Tailwind exporter :
121-
122-
- [x] Color definitions
123-
- [ ] Text Styles
124-
- [ ] Gradients
125-
- [x] Shadows
126-
- [ ] Borders
127-
- [ ] Radii
128-
- [ ] Measures
129-
130-
You can generate all production ready-code either manually using Supernova's [VS Code extension](https://marketplace.visualstudio.com/items?itemName=SupernovaIO.pulsar-vsc-extension), or automate your code delivery pipeline using Supernova [Design Continuous Delivery](https://supernova.io/automated-code-delivery).
131-
132-
## Installing
133-
134-
In order to make the Supernova Tailwind exporter available for your organization so you can start generating code from your design system, please follow the installation guide in our [developer documentation](https://developers.supernova.io/using-exporters/installing-exporters).
135-
136-
137-
## Reporting Bugs or Requesting Features
138-
139-
In order to faciliate easy communication and speed up delivery of fixes and features for this exporter, we require everyone to log all issues and feature requests through the issue tracking of this repository.
140-
141-
Please read through the [existing issues](../../issues) before you open a new issue! It might be that we have already discussed it before. If you are sure your request wasn't mentioned just yet, proceed to [open a new issue](../../issues) and fill in the required information. Thank you!
142-
143-
144-
## Contributing
145-
146-
If you have an idea for improving this exporter package or want a specific issue fixed quickly, we would love to see you contribute to its development!
147-
148-
There are multiple ways you can contribute, so we have written a [contribution guide](https://developers.supernova.io/building-exporters/contribution-and-requests) that will walk your through the process. Any pull requests to this repository are very welcome.
149-
150-
Would love to help us build more but maybe need a little bit of support? [Join our community](https://community.supernova.io) and drop us a message, we will support any of your wild ideas!
151-
152-
153-
## License
154-
155-
This exporter is distributed under the [MIT license](./LICENSE.md). [We absolutely encourage you](https://developers.supernova.io/building-exporters/cloning-exporters) to clone it and modify it for your purposes, so it fits the requirements of your stack. If you see that you have created something amazing in the process that others would benefit from, we strongly recommend you consider [publishing it back to the community](https://developers.supernova.io/building-exporters/sharing-exporters-with-others) as well.
156-
157-
158-
## Useful Links
159-
160-
- To learn more about Supernova, [go visit our website](https://supernova.io)
161-
- To join our community of fellow developers where we try to push what is possible with design systems and code automation, join our [community discord](https://community.supernova.io)
162-
- To understand everything you can do with Supernova and how much time and resources it can save you, go read our [product documentation](https://learn.supernova.io/)
163-
- Finally, to learn everything about what exporters are and how you can integrate with your codebase, go read our [developer documentation](https://developers.supernova.io/)
164-
165-
166-
## Supernova Maintained Exporters
167-
168-
We are developing and maintaining exporters for many major technologies. Here are all the official exporters maintained by Supernova:
169-
170-
- [iOS Token & Style Exporter](https://github.com/Supernova-Studio/exporter-ios)
171-
- [iOS Localization Exporter](https://github.com/Supernova-Studio/exporter-ios-localization)
172-
- [Android Token & Style Exporter](https://github.com/Supernova-Studio/exporter-android)
173-
- [React Token & Style Exporter](https://github.com/Supernova-Studio/exporter-react)
174-
- [Flutter Token & Style Exporter](https://github.com/Supernova-Studio/exporter-flutter)
175-
- [Angular Token & Style Exporter](https://github.com/Supernova-Studio/exporter-angular)
176-
- [Typescript Token & Style Exporter](https://github.com/Supernova-Studio/exporter-typescript)
177-
- [CSS Token & Style Exporter](https://github.com/Supernova-Studio/exporter-css)
178-
- [LESS Token & Style Exporter](https://github.com/Supernova-Studio/exporter-less)
179-
- [SCSS Token & Style Exporter](https://github.com/Supernova-Studio/exporter-scss)
180-
- [Style Dictionary Exporter](https://github.com/Supernova-Studio/exporter-style-dictionary)
181-
182-
Additionally, you can also use asset exporters for all major targets, enjoy!:
183-
184-
- [SVG Asset Exporter](https://github.com/Supernova-Studio/exporter-svg-assets)
185-
- [PDF Asset Exporter](https://github.com/Supernova-Studio/exporter-pdf-assets)
186-
- [PNG Asset Exporter](https://github.com/Supernova-Studio/exporter-png-assets)
187-
- [iOS Asset Catalogue Exporter](https://github.com/Supernova-Studio/exporter-ios-asset-catalogue)
188-
- [React Native Asset Exporter](https://github.com/Supernova-Studio/exporter-react-native-assets)
189-
- [Android Asset Exporter](https://github.com/Supernova-Studio/exporter-android-assets)
190-
- [Flutter PNG Asset Exporter](https://github.com/Supernova-Studio/exporter-flutter-png-assets)
191-
- [Flutter SVG Asset Exporter](https://github.com/Supernova-Studio/exporter-flutter-svg-assets)
192-
193-
To browse all exporters created by our amazing community, please visit the [Supernova](https://supernova.io) Exporter Store.
194-
7+
- [torresf/exporter-tailwind](https://github.com/torresf/exporter-tailwind)
8+
- [supernova/exporter-css](https://github.com/Supernova-Studio/exporter-css)

exporter.json

+20-24
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
{
2-
"id": "io.supernova.tailwind",
3-
"name": "Tailwind",
4-
"description": "Tailwind CSS exporter",
5-
"author": "Florian Torres & Ivan Terpugov & Jiri Trecak",
6-
"organization": "Ascanio",
7-
"homepage": "https://ascan.io",
8-
"source_dir": "src",
9-
"version": "1.2",
10-
"usesBrands": true,
11-
"config": {
12-
"sources": "sources.json",
13-
"output": "output.json",
14-
"js": "src/js/helpers.js"
15-
},
16-
"engines": {
17-
"pulsar": "1.0.0",
18-
"supernova": "1.0.0"
19-
},
20-
"tags": [
21-
"TailwindCSS",
22-
"Tokens",
23-
"Styles"
24-
]
25-
}
2+
"id": "io.deepsource.zephyr",
3+
"name": "Zephyr",
4+
"description": "Tailwind CSS exporter for things built by DeepSource.",
5+
"author": "DeepSource & Florian Torres & Ivan Terpugov & Jiri Trecak",
6+
"organization": "DeepSource",
7+
"homepage": "https://deepsource.io",
8+
"source_dir": "src",
9+
"version": "0.1",
10+
"usesBrands": true,
11+
"config": {
12+
"sources": "sources.json",
13+
"output": "output.json",
14+
"js": "src/js/helpers.js"
15+
},
16+
"engines": {
17+
"pulsar": "1.0.0",
18+
"supernova": "1.0.0"
19+
},
20+
"tags": ["TailwindCSS", "Tokens", "Styles"]
21+
}

icon.png

-2.9 KB
Loading

readme-icon.png

-49.8 KB
Binary file not shown.

result-example.png

-25.3 KB
Binary file not shown.

src/main-renderers/tailwind-variables.pr

+18
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,23 @@ module.exports = {
2222
'{{ ((tokenName === "main") ? "DEFAULT" : tokenName) }}': 'var(--{[ inject "rendered-name" context token /]})', {[ inject "rendered-description" context token /]}
2323

2424
{[/]}
25+
},
26+
'spacing': {
27+
{[ const spacingTokens = ds.tokensByType("Measure", brand.id) /]}
28+
{[ for token in spacingTokens ]}
29+
{[ let tokenName = token.name.replacing("$", "").replacing(" ", "-") /]}
30+
'{{ tokenName }}': 'var(--{[ inject "rendered-name" context token /]})', {[ inject "rendered-description" context token /]}
31+
32+
{[/]}
33+
{[ const customSpacingTokens = ds.tokensByType("Strings", brand.id) /]}
34+
{[ traverse customSpacingTokens property subgroups into subgroup ]}
35+
{[ if @and(!subgroup.isRoot,subgroup.name.lowercased() === "screens") ]}
36+
{[ const screenCustomSpacingTokens = ds.tokensByGroupId(subgroup.id) /]}
37+
{[ for screenCustomSpacingToken in screenCustomSpacingTokens ]}
38+
{[ let tokenName = token.name.replacing("$", "").replacing(" ", "-") ]}
39+
'{{ tokenName }}': '{[ inject "rendered-token-var" context tokenName ]}'
40+
{[/]}
41+
{[/]}
42+
{[/]}
2543
}
2644
}

0 commit comments

Comments
 (0)