Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom directives #165

Merged
merged 2 commits into from
Dec 30, 2023
Merged

feat: custom directives #165

merged 2 commits into from
Dec 30, 2023

Conversation

tommilligan
Copy link
Owner

Closes #99
Replaces #157
cc: @Sky9x as you've already thought a lot about this - I used a bunch of code and ideas from your branch, it was really helpful!

As I already wrote the doc page, I think this summarises the changes quite nicely:

image


The approach I took here was to write some slightly hacky Rust code to produce the small subset of CSS we need for each new variant. There's a unit test that will fail if either the Rust or SCSS code get out of step.

I think this is a good compromise between still doing the majority of complex CSS with SCSS, having runtime directive safety in Rust, and ensuring that there are some checks in place. An alternative would just have been to work out how to run an SCSS compiler inside a Rust binary, but I really did not want to do that.

This approach is also back compatible, and opt in for new users, which is great.

image


Internals wise, this changes slightly how the Directive type works internally. Basically, we standardise to a String earlier in the pipeline, at the point we resolve the title.

Uses hex_color for that concern as it's simple and looks to do the job well.

@tommilligan tommilligan added the enhancement New feature or request label Dec 30, 2023
@tommilligan tommilligan self-assigned this Dec 30, 2023
@tommilligan tommilligan force-pushed the 99-custom-admonitions branch from 46afb6b to 1e43faa Compare December 30, 2023 19:51
@Sky9x
Copy link
Contributor

Sky9x commented Dec 30, 2023

this looks cool! and better than what i threw together at 5am 😪

@tommilligan tommilligan force-pushed the 99-custom-admonitions branch from 1e43faa to 56cb846 Compare December 30, 2023 20:04
book/src/reference.md Outdated Show resolved Hide resolved
book/src/reference.md Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
@tommilligan tommilligan force-pushed the 99-custom-admonitions branch from 56cb846 to 1bb1468 Compare December 30, 2023 20:14
@tommilligan tommilligan merged commit c4a05da into main Dec 30, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding new admonishes
2 participants