Skip to content

Commit

Permalink
Refactor(exporter-assets): Copy svg exporter to assets exporter
Browse files Browse the repository at this point in the history
- preparation for renaming the svg exporter to assets exporter in the future
  • Loading branch information
pavelklibani authored and curdaj committed Oct 17, 2024
1 parent e695df8 commit 771d2cd
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ CODEOWNERS

# tokens exporter generated cjs
exporters/tokens/generated/**/*.cjs

# exporter proprietary files
*.pr
1 change: 1 addition & 0 deletions exporters/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.build
22 changes: 22 additions & 0 deletions exporters/assets/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2022 Alma Career Czechia s.r.o., formerly LMC s.r.o.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 28 additions & 0 deletions exporters/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Spirit Assets Exporter

The Spirit Assets Exporter allows you to **export a list of images** in such a way that it can be immediately used in your production codebase. This specific exporter exports assets in generic fashion, as SVG format, without any additional formatting or generated support files.

### Exporter Output

This exporter will render image assets defined inside one specific brand and will produce flat structure:

⚠️ We only output assets from `icons` directory.

### Naming

The names of icons will be constructed from the original name.

Names follow `icon-name` convention.

This behavior can be fully customized by simply modifying the path generation template file `asset_path.pr`. Simply fork, modify and upload as your version of the exporter. If you have never done this before, [follow our guide to modifying existing exporters](https://developers.supernova.io/latest/building-exporters/cloning-exporters.html).

## Installing

In order to make the Supernova SVG Asset 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).

## Useful Links

- To learn more about Supernova, [go visit our website](https://supernova.io)
- 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)
- 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/)
- 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/)
19 changes: 19 additions & 0 deletions exporters/assets/exporter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"id": "alma.career.spirit-assets-exporter",
"name": "Spirit Assets Exporter",
"description": "The Spirit Assets Exporter allows you to export a list of images",
"author": "Spirit Design System Team <team_design_system@almacareer.com>",
"organization": "Alma Career",
"source_dir": "src",
"version": "1.0.0",
"usesBrands": true,
"config": {
"sources": "sources.json",
"output": "output.json"
},
"engines": {
"pulsar": "1.0.0",
"supernova": "1.0.0"
},
"tags": ["spirit", "svg", "assets", "exporter"]
}
11 changes: 11 additions & 0 deletions exporters/assets/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"blueprints": [],
"assets": [
{
"write_using": "asset_path.pr",
"scale": "1x",
"format": "svg",
"type": "image"
}
]
}
1 change: 1 addition & 0 deletions exporters/assets/sources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
9 changes: 9 additions & 0 deletions exporters/assets/src/asset_path.pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{[ let extension = asset.format /]}

{* Generate name as [originalName][-numberOfDuplicates][extension] *}
{[ let duplicateExtension = (asset.previouslyDuplicatedNames > 0 ? ("-" + asset.previouslyDuplicatedNames) : "") /]}
{[ let name = (asset.originalName.lowercased().replacing(" ", "-") + duplicateExtension + "." + asset.format) /]}

{[ if asset.group.name.equals("Icons") ]}
{{ name }}
{[/]}

0 comments on commit 771d2cd

Please sign in to comment.