-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from tommilligan/99-custom-admonitions
feat: custom directives
- Loading branch information
Showing
34 changed files
with
857 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@use "sass:color"; | ||
@use "sass:list"; | ||
|
||
@mixin from-admonitions($admonitions) { | ||
// ---------------------------------------------------------------------------- | ||
// Rules: layout | ||
// ---------------------------------------------------------------------------- | ||
|
||
// Admonition variables | ||
:root { | ||
@each $names, $props in $admonitions { | ||
--md-admonition-icon--#{nth($names, 1)}: url("data:image/svg+xml;charset=utf-8,#{nth($props, 2)}"); | ||
} | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Rules: flavours | ||
// ---------------------------------------------------------------------------- | ||
|
||
@each $names, $props in $admonitions { | ||
$name: list.nth($names, 1); | ||
$tint: list.nth($props, 1); | ||
|
||
// Admonition flavour selectors | ||
$flavours: (); | ||
|
||
@each $name in $names { | ||
$flavours: list.join($flavours, ".#{$name}", $separator: comma); | ||
} | ||
|
||
// Admonition flavour | ||
:is(.admonition):is(#{$flavours}) { | ||
border-color: $tint; | ||
} | ||
|
||
// Admonition flavour title | ||
:is(#{$flavours}) > :is(.admonition-title, summary.admonition-title) { | ||
background-color: color.adjust($tint, $alpha: -0.9); | ||
|
||
// Admonition icon | ||
&::before { | ||
background-color: $tint; | ||
mask-image: var(--md-admonition-icon--#{$name}); | ||
-webkit-mask-image: var(--md-admonition-icon--#{$name}); | ||
mask-repeat: no-repeat; | ||
-webkit-mask-repeat: no-repeat; | ||
mask-size: contain; | ||
-webkit-mask-repeat: no-repeat; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This file aims to generate the subset of CSS specific to a single admonition directive. | ||
// | ||
// This is used for unit test data in the rust css generation module. | ||
|
||
@use "sass:color"; | ||
@use "sass:list"; | ||
@use "./lib"; | ||
@import "./material-color"; | ||
|
||
$admonitions: ( | ||
admonish-note: $clr-blue-a200 | ||
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z'/></svg>", | ||
) !default; | ||
|
||
// Generate rules for each specified admonition variant | ||
@include lib.from-admonitions($admonitions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.