feat: support selecting only some themes
Some checks are pending
Tests / build (push) Waiting to run

This commit is contained in:
Roberto Alsina 2024-10-14 13:11:22 -03:00
parent e11775040c
commit c16b139fa3
2 changed files with 40 additions and 1 deletions

View File

@ -101,6 +101,32 @@ Dependencies are satisfied
Building: tartrazine Building: tartrazine
``` ```
## Choosing what themes you want
Themes come from two places, tartrazine itself and [Sixteen](https://github.com/ralsina/sixteen).
To only embed selected themes, build your project with the `-Dnothemes` option, and
you can set two environment variables to control which themes are included:
* `TT_THEMES` is a comma-separated list of themes to include from tartrazine (see the styles directory in the source)
* `SIXTEEN_THEMES` is a comma-separated list of themes to include from Sixteen (see the base16 directory in the sixteen source)
For example (using the tartrazine CLI as the project):
```bash
$ TT_THEMES=colorful,autumn SIXTEEN_THEMES=pasque,pico shards build -Dnothemes
Dependencies are satisfied
Building: tartrazine
$ ./bin/tartrazine --list-themes
autumn
colorful
pasque
pico
```
Be careful not to build without any themes at all, nothing will work.
## Contributing ## Contributing
1. Fork it (<https://github.com/ralsina/tartrazine/fork>) 1. Fork it (<https://github.com/ralsina/tartrazine/fork>)

View File

@ -11,7 +11,20 @@ module Tartrazine
struct ThemeFiles struct ThemeFiles
extend BakedFileSystem extend BakedFileSystem
macro bake_selected_themes
{% if env("TT_THEMES") %}
{% for theme in env("TT_THEMES").split "," %}
bake_file {{ theme }}+".xml", {{ read_file "#{__DIR__}/../styles/" + theme + ".xml" }}
{% end %}
{% end %}
end
{% if flag?(:nothemes) %}
bake_selected_themes
{% else %}
bake_folder "../styles", __DIR__ bake_folder "../styles", __DIR__
{% end %}
end end
def self.theme(name : String) : Theme def self.theme(name : String) : Theme