1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
////
/// Copyright (c) 2016-2023 Martin Donath <martin.donath@squidfunk.com>
///
/// 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 NON-INFRINGEMENT. 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
////
@use "sass:color";
@use "sass:list";
// ----------------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------------
/// Admonition flavours
$admonitions: (
"note": pencil-circle $clr-blue-a200,
"abstract": clipboard-text $clr-light-blue-a400,
"info": information $clr-cyan-a700,
"tip": fire $clr-teal-a700,
"success": check $clr-green-a700,
"question": help-circle $clr-light-green-a700,
"warning": alert $clr-orange-a400,
"failure": close $clr-red-a200,
"danger": lightning-bolt-circle $clr-red-a400,
"bug": shield-bug $clr-pink-a400,
"example": test-tube $clr-deep-purple-a200,
"quote": format-quote-close $clr-grey
) !default;
// ----------------------------------------------------------------------------
// Rules: layout
// ----------------------------------------------------------------------------
// Admonition variables
:root {
@each $name, $props in $admonitions {
--md-admonition-icon--#{$name}:
svg-load("material/#{list.nth($props, 1)}.svg");
}
}
// ----------------------------------------------------------------------------
// Scoped in typesetted content to match specificity of regular content
.md-typeset {
// Admonition - note that all styles also apply to details tags, which are
// rendered as collapsible admonitions with summary elements as titles.
.admonition {
display: flow-root;
padding: 0 px2rem(12px);
margin: px2em(20px, 12.8px) 0;
font-size: px2rem(12.8px);
color: var(--md-admonition-fg-color);
background-color: var(--md-admonition-bg-color);
border: px2rem(1.5px) solid $clr-blue-a200;
border-radius: px2rem(4px);
box-shadow: var(--md-shadow-z1);
transition: box-shadow 125ms;
page-break-inside: avoid;
// [print]: Omit shadow as it may lead to rendering errors
@media print {
box-shadow: none;
}
// Admonition on focus
&:focus-within {
box-shadow: 0 0 0 px2rem(4px) color.adjust($clr-blue-a200, $alpha: -0.9);
}
// Hack: Chrome exhibits a weird issue where it will set nested elements to
// content-box. Doesn't happen in other browsers, so looks like a bug.
> * {
box-sizing: border-box;
}
// Adjust vertical spacing for nested admonitions
.admonition {
margin-top: 1em;
margin-bottom: 1em;
}
// Adjust spacing for contained table wrappers
.md-typeset__scrollwrap {
margin: 1em px2rem(-12px);
}
// Adjust spacing for contained tables
.md-typeset__table {
padding: 0 px2rem(12px);
}
// Adjust spacing for single-child tabbed block container
> .tabbed-set:only-child {
margin-top: 0;
}
// Adjust spacing on last child
html & > :last-child {
margin-bottom: px2rem(12px);
}
}
// Admonition title
.admonition-title {
position: relative;
padding-block: px2rem(8px);
padding-inline: px2rem(40px) px2rem(12px);
margin-block: 0;
margin-inline: px2rem(-12px);
font-weight: 700;
background-color: color.adjust($clr-blue-a200, $alpha: -0.9);
border: none;
border-inline-start-width: px2rem(4px);
border-start-start-radius: px2rem(2px);
border-start-end-radius: px2rem(2px);
// Adjust spacing for title-only admonitions
html &:last-child {
margin-bottom: 0;
}
// Admonition icon
&::before {
position: absolute;
top: px2em(10px);
width: px2rem(20px);
height: px2rem(20px);
content: "";
background-color: $clr-blue-a200;
inset-inline-start: px2rem(12px);
mask-image: var(--md-admonition-icon--note);
mask-position: center;
mask-repeat: no-repeat;
mask-size: contain;
}
// Inline code block
code {
box-shadow: 0 0 0 px2rem(1px) var(--md-default-fg-color--lightest);
}
}
}
// ----------------------------------------------------------------------------
// Rules: flavours
// ----------------------------------------------------------------------------
// Define admonition flavors
@each $name, $props in $admonitions {
$tint: list.nth($props, 2);
// Admonition flavour
.md-typeset .admonition.#{$name} {
border-color: $tint;
// Admonition on focus
&:focus-within {
box-shadow: 0 0 0 px2rem(4px) color.adjust($tint, $alpha: -0.9);
}
}
// Admonition flavour title
.md-typeset .#{$name} > .admonition-title {
background-color: color.adjust($tint, $alpha: -0.9);
// Admonition icon
&::before {
background-color: $tint;
mask-image: var(--md-admonition-icon--#{$name});
}
// Details marker
&::after {
color: $tint;
}
}
}
|