Skip to content

Commit a71c9fc

Browse files
authored
feat(root): add shadow root support (#52)
1 parent c85049b commit a71c9fc

File tree

134 files changed

+1709
-711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1709
-711
lines changed

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github: lowlighter
1+
github: lowlighter

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
- name: Run npm publish
2929
run: |
3030
deno task build
31-
deno run --allow-all jsr:@libs/bundle/ts/cli/publish deno.jsonc --loglevel debug --npm.registry 'https://registry.npmjs.org' --npm.token '${{ secrets.NPM_TOKEN }}' --npm.access public
31+
deno run --allow-all jsr:@libs/bundle/ts/cli/publish deno.jsonc --loglevel debug --npm.registry 'https://registry.npmjs.org' --npm.token '${{ secrets.NPM_TOKEN }}' --npm.access public

app/build/ssg.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export async function ssg() {
2323
console.log("Created .pages/mod.svg")
2424
await copy(new URL("app/mod.css", root), new URL(".pages/mod.css", root))
2525
console.log("Created .pages/mod.css")
26+
// Copy examples
27+
await copy(fromFileUrl(new URL("app/examples", root)), new URL(".pages/examples", root))
28+
console.log(`Created .pages/examples`)
2629
// Generate CSS
2730
const dist = fromFileUrl(new URL("dist", root)).replaceAll("\\", "/")
2831
await ensureDir(new URL(".pages/v/main", root))

app/examples/shadow-root/styles.css

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.example-shadow-root-content {
2+
display: flex;
3+
justify-content: space-around;
4+
}
5+
6+
section {
7+
margin-bottom: 0;
8+
}
9+
10+
img {
11+
max-width: 100px;
12+
flex-shrink: 1;
13+
box-shadow: var(--shadow);
14+
margin: 1rem;
15+
}
16+
17+
aside {
18+
margin: 0;
19+
flex-grow: 1;
20+
border-left: none;
21+
}
22+
23+
aside b {
24+
color: var(--default);
25+
}
26+
27+
audio {
28+
margin-top: 0.25rem;
29+
border-radius: var(--bd-radius);
30+
width: 100%;
31+
}

app/mod.css

+17-12
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ details summary a {
8282
}
8383

8484
.matcha-build .variables input[name$="opacity"] {
85-
margin-left: .25rem;
85+
margin-left: 0.25rem;
8686
width: 3rem;
8787
text-align: center;
8888
}
@@ -106,7 +106,7 @@ details summary a {
106106
}
107107

108108
.matcha-build .styling label small {
109-
opacity: .75;
109+
opacity: 0.75;
110110
}
111111

112112
.matcha-build .styling > div {
@@ -170,13 +170,13 @@ details summary a {
170170
font-size: 85%;
171171
font-weight: normal;
172172
list-style: circle;
173-
margin: 0 .5rem;
173+
margin: 0 0.5rem;
174174
}
175175

176176
.css-compatibility-table.details :is(td, th) > :nth-child(1) {
177177
border-bottom: 1px solid var(--bg-contrast);
178-
padding-bottom: .5rem;
179-
margin-bottom: .5rem;
178+
padding-bottom: 0.5rem;
179+
margin-bottom: 0.5rem;
180180
}
181181

182182
.css-compatibility-table.details :is(td, th) > :nth-child(n+2) {
@@ -281,7 +281,7 @@ details summary a {
281281
justify-content: end;
282282
margin-bottom: 0;
283283
border-bottom: none;
284-
margin: .5rem 0 .25rem;
284+
margin: 0.5rem 0 0.25rem;
285285
}
286286

287287
.example-tabs > li {
@@ -366,12 +366,12 @@ details summary a {
366366
width: 1.5em;
367367
}
368368

369-
.example input:is([type="datetime-local"],[type="date"],[type="month"],[type="week"],[type="time"]) {
369+
.example input:is([type="datetime-local"], [type="date"], [type="month"], [type="week"], [type="time"]) {
370370
max-width: 100px;
371371
}
372372

373373
@media (min-width: 640px) {
374-
.example input:is([type="datetime-local"],[type="date"],[type="month"],[type="week"],[type="time"]) {
374+
.example input:is([type="datetime-local"], [type="date"], [type="month"], [type="week"], [type="time"]) {
375375
max-width: none;
376376
}
377377
}
@@ -380,6 +380,11 @@ details summary a {
380380
z-index: 200;
381381
}
382382

383+
.example .example-shadow-root {
384+
border: 2px dotted var(--bg-contrast);
385+
border-radius: var(--bd-radius);
386+
}
387+
383388
/* Layout structure */
384389
.layout-structure, .layout-structure ul {
385390
padding-left: 1rem;
@@ -405,7 +410,7 @@ details summary a {
405410
left: 0;
406411
width: 100%;
407412
height: 100%;
408-
background-color: rgba(100, 0, 0, .2);
413+
background-color: rgba(100, 0, 0, 0.2);
409414
backdrop-filter: brightness(50%) blur(5px);
410415
}
411416

@@ -418,15 +423,15 @@ details summary a {
418423
}
419424

420425
.easter-egg.glitch.blue, .easter-egg.glitch.red {
421-
opacity: .1;
426+
opacity: 0.1;
422427
animation: 1s glitch infinite;
423428
}
424429

425430
@keyframes glitch {
426-
1%{
431+
1% {
427432
transform: rotateX(10deg) skewX(90deg);
428433
}
429-
2%{
434+
2% {
430435
transform: rotateX(0deg) skewX(0deg);
431436
}
432437
}

app/mod.html

+175-54
Large diffs are not rendered by default.

app/mod.ts

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ switch (Deno.args[0]) {
3939
return api_minify(request)
4040
case new URLPattern("/api/preview", url.origin).test(url.href.replace(url.search, "")):
4141
return api_preview(request)
42+
case new URLPattern("/examples/shadow-root/styles.css", url.origin).test(url.href.replace(url.search, "")):
43+
return new Response(await Deno.readFile(new URL("examples/shadow-root/styles.css", import.meta.url)), { headers: { "Content-Type": "text/css" } })
4244
case new URLPattern("/highlight.js", url.origin).test(url.href.replace(url.search, "")):
4345
return fetch(highlight)
4446
case new URLPattern("/v/*", url.origin).test(url.href.replace(url.search, "")):

app/sections/preset-build.html

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<section>
22
<h3 id="preset-builds"><a href="#preset-builds">Preset builds</a></h3>
33
<p>
4-
<em>matcha.css</em> provides preset builds for added convenience.
5-
If you need a specific set of features, you can also use the <a href="#custom-build">custom builder</a>.
4+
<em>matcha.css</em> provides preset builds for added convenience. If you need a specific set of features, you can also use the <a href="#custom-build">custom builder</a>.
65
</p>
76
<ul>
8-
<li>Default <code data-matcha-size="matcha.css"></code>
7+
<li>
8+
Default <code data-matcha-size="matcha.css"></code>
99
<ul>
1010
<li>
1111
All semantic styling and extra features except <code>@istanbul-coverage</code>.
1212
</li>
1313
<li><code class="usage-snippet" data-hl="html">&lt;link rel="stylesheet" href="https://matcha.mizu.sh/matcha.css"&gt;</code></li>
1414
</ul>
1515
</li>
16-
<li>Lite <code data-matcha-size="matcha.lite.css"></code>
16+
<li>
17+
Lite <code data-matcha-size="matcha.lite.css"></code>
1718
<ul>
1819
<li>
1920
All semantic styling,
@@ -23,7 +24,8 @@ <h3 id="preset-builds"><a href="#preset-builds">Preset builds</a></h3>
2324
<li><code class="usage-snippet" data-hl="html">&lt;link rel="stylesheet" href="https://matcha.mizu.sh/matcha.lite.css"&gt;</code></li>
2425
</ul>
2526
</li>
26-
<li>Utility classes <code data-matcha-size="matcha.utilities.css"></code>
27+
<li>
28+
Utility classes <code data-matcha-size="matcha.utilities.css"></code>
2729
<ul>
2830
<li>
2931
<a href="/@root.css"><code>@root</code></a> and
@@ -32,7 +34,8 @@ <h3 id="preset-builds"><a href="#preset-builds">Preset builds</a></h3>
3234
<li><code class="usage-snippet" data-hl="html">&lt;link rel="stylesheet" href="https://matcha.mizu.sh/matcha.utilities.css"&gt;</code></li>
3335
</ul>
3436
</li>
35-
<li>Istanbul coverage <code data-matcha-size="matcha.istanbul.css"></code>
37+
<li>
38+
Istanbul coverage <code data-matcha-size="matcha.istanbul.css"></code>
3639
<ul>
3740
<li>
3841
<a href="/@root.css"><code>@root</code></a>,
@@ -43,4 +46,4 @@ <h3 id="preset-builds"><a href="#preset-builds">Preset builds</a></h3>
4346
</ul>
4447
</li>
4548
</ul>
46-
</section>
49+
</section>

app/sections/preview-website.html

+15-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ <h3><a href="#preview-website">🕵️ Preview a Website</a></h3>
1010
<label for="url">
1111
Website URL:
1212
<small>
13-
Please note that the previewed site will be stripped of its <code data-hl="html">&lt;style&gt;</code> and <code data-hl="html">&lt;script&gt;</code> tags.
14-
External resources may not load properly.
15-
This form is intended for quick previews only.
13+
Please note that the previewed site will be stripped of its <code data-hl="html">&lt;style&gt;</code> and <code data-hl="html">&lt;script&gt;</code> tags. External resources may not load
14+
properly. This form is intended for quick previews only.
1615
</small>
1716
<input list="preview-datalist" type="url" placeholder="https://example.com" value="https://example.com" required>
1817
<datalist id="preview-datalist">
@@ -26,10 +25,20 @@ <h3><a href="#preview-website">🕵️ Preview a Website</a></h3>
2625
</form>
2726
<menu class="example-tabs">
2827
<li class="color-scheme">
29-
<svg class="light" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 12a4 4 0 1 1 0-8 4 4 0 0 1 0 8Zm0-1.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm5.657-8.157a.75.75 0 0 1 0 1.061l-1.061 1.06a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l1.06-1.06a.75.75 0 0 1 1.06 0Zm-9.193 9.193a.75.75 0 0 1 0 1.06l-1.06 1.061a.75.75 0 1 1-1.061-1.06l1.06-1.061a.75.75 0 0 1 1.061 0ZM8 0a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0ZM3 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 3 8Zm13 0a.75.75 0 0 1-.75.75h-1.5a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 16 8Zm-8 5a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0v-1.5A.75.75 0 0 1 8 13Zm3.536-1.464a.75.75 0 0 1 1.06 0l1.061 1.06a.75.75 0 0 1-1.06 1.061l-1.061-1.06a.75.75 0 0 1 0-1.061ZM2.343 2.343a.75.75 0 0 1 1.061 0l1.06 1.061a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-1.06-1.06a.75.75 0 0 1 0-1.06Z"></path></svg>
30-
<svg class="dark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M9.598 1.591a.749.749 0 0 1 .785-.175 7.001 7.001 0 1 1-8.967 8.967.75.75 0 0 1 .961-.96 5.5 5.5 0 0 0 7.046-7.046.75.75 0 0 1 .175-.786Zm1.616 1.945a7 7 0 0 1-7.678 7.678 5.499 5.499 0 1 0 7.678-7.678Z"></path></svg>
28+
<svg class="light" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
29+
<path
30+
d="M8 12a4 4 0 1 1 0-8 4 4 0 0 1 0 8Zm0-1.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm5.657-8.157a.75.75 0 0 1 0 1.061l-1.061 1.06a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l1.06-1.06a.75.75 0 0 1 1.06 0Zm-9.193 9.193a.75.75 0 0 1 0 1.06l-1.06 1.061a.75.75 0 1 1-1.061-1.06l1.06-1.061a.75.75 0 0 1 1.061 0ZM8 0a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0ZM3 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 3 8Zm13 0a.75.75 0 0 1-.75.75h-1.5a.75.75 0 0 1 0-1.5h1.5A.75.75 0 0 1 16 8Zm-8 5a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0v-1.5A.75.75 0 0 1 8 13Zm3.536-1.464a.75.75 0 0 1 1.06 0l1.061 1.06a.75.75 0 0 1-1.06 1.061l-1.061-1.06a.75.75 0 0 1 0-1.061ZM2.343 2.343a.75.75 0 0 1 1.061 0l1.06 1.061a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-1.06-1.06a.75.75 0 0 1 0-1.06Z"
31+
>
32+
</path>
33+
</svg>
34+
<svg class="dark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
35+
<path
36+
d="M9.598 1.591a.749.749 0 0 1 .785-.175 7.001 7.001 0 1 1-8.967 8.967.75.75 0 0 1 .961-.96 5.5 5.5 0 0 0 7.046-7.046.75.75 0 0 1 .175-.786Zm1.616 1.945a7 7 0 0 1-7.678 7.678 5.499 5.499 0 1 0 7.678-7.678Z"
37+
>
38+
</path>
39+
</svg>
3140
</li>
3241
</menu>
3342
<iframe class="matcha-preview" loading="lazy" title="preview" height="420" class="bd-muted"></iframe>
3443
<script data-script="/app/sections/preview-website.js"></script>
35-
</details>
44+
</details>

app/sections/supported-browsers.html

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,22 @@ <h3><a href="#supported-browsers">☑️ Supported browsers</a></h3>
2222
</ol>
2323
<b>Notes:</b>
2424
<ul>
25-
<li>Browser list adheres to <code>defaults</code> (<code>&gt; 0.5%, last 2 versions, Firefox ESR, not dead</code>).</li>
25+
<li>
26+
Browser list adheres to <code>defaults</code> (<code>&gt; 0.5%, last 2 versions, Firefox ESR, not dead</code>).
27+
</li>
2628
<li>The first row displays the overall support for each browser.</li>
2729
<li>Please note that the auto-generated table may contain minor inaccuracies due to the complexity of mapping CSS features against compatibility data.</li>
2830
<li>Thus, browsers scoring 90% and above are considered fully supported.</li>
2931
</ul>
3032
<p>
3133
You can toggle verbosity to display additional information, such as specific CSS features and rules reported as partially supported or unsupported.
3234
</p>
33-
<button class="variant" onclick="event.preventDefault();document.querySelectorAll('table.css-compatibility-table,ul.css-compatibility-legend').forEach(element => element.classList.toggle('details'))">Toggle verbosity</button>
35+
<button
36+
class="variant"
37+
onclick="event.preventDefault();document.querySelectorAll('table.css-compatibility-table,ul.css-compatibility-legend').forEach(element => element.classList.toggle('details'))"
38+
>
39+
Toggle verbosity
40+
</button>
3441
<ul class="css-compatibility-legend">
3542
<li class="danger">Unsupported feature</li>
3643
<li class="warning">Partially supported feature</li>
@@ -41,4 +48,4 @@ <h3><a href="#supported-browsers">☑️ Supported browsers</a></h3>
4148
<div class="table-responsive">
4249
<!--/.pages/compatibility.html-->
4350
</div>
44-
</details>
51+
</details>

styles/@code-editor/mod.html

+21-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@
22
<em>matcha.css</em> provides classes that can be used to create a simple code editor with syntax highlighting.
33
</p>
44
<p>
5-
<b>Required structure:</b><br>
5+
<b>Required structure:</b>
6+
<br>
67
<small class="muted">Elements marked with <code class="danger">*</code> are required.</small>
78
</p>
89
<ul class="layout-structure">
9-
<li><code data-hl="css">.editor</code><span class="danger">*</span>
10+
<li>
11+
<code data-hl="css">.editor</code>
12+
<span class="danger">*</span>
1013
<ul>
11-
<li><code data-hl="css">&gt; textarea</code><span class="danger">*</span></li>
12-
<li><code data-hl="css">&gt; div.highlight</code><span class="danger">*</span></li>
14+
<li>
15+
<code data-hl="css">&gt; textarea</code>
16+
<span class="danger">*</span>
17+
</li>
18+
<li>
19+
<code data-hl="css">&gt; div.highlight</code>
20+
<span class="danger">*</span>
21+
</li>
1322
</ul>
1423
</li>
1524
</ul>
1625
<section>
1726
<div class="example">
1827
<div class="editor">
19-
<textarea rows="6">// This element is editable and highlights TypeScript code
28+
<textarea
29+
rows="6"
30+
>
31+
// This element is editable and highlights TypeScript code
2032
import * as mizu from "https://mizu.sh/mizu.js"
2133

2234
const { version } = mizu
@@ -27,9 +39,10 @@
2739
<script data-keep data-script="/styles/@code-editor/mod.js"></script>
2840
</div>
2941
<p class="flash attention">
30-
These extra styles does not actually perform syntax highlighting, it is only for styling the code editor.
31-
It is required to include a syntax highlighting library like <a href="https://highlightjs.org" target="_blank">highlight.js</a>.
32-
See the example code above for a simple implementation.
42+
These extra styles does not actually perform syntax highlighting, it is only for styling the code editor. It is required to include a syntax highlighting library like <a
43+
href="https://highlightjs.org"
44+
target="_blank"
45+
>highlight.js</a>. See the example code above for a simple implementation.
3346
</p>
3447
<p class="flash accent">
3548
Use with <a href="#syntax-highlighting"><em>matcha.css</em>'s syntax highlighting classes</a> for a extra synergy!

styles/@discrete-scrollbars/mod.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
::-webkit-scrollbar {
2-
width: .5rem;
3-
height: .5rem;
2+
width: 0.5rem;
3+
height: 0.5rem;
44
background-color: transparent;
55
}
66

77
::-webkit-scrollbar-thumb {
88
border-radius: var(--bd-radius);
99
background-color: var(--muted);
10-
}
10+
}

styles/@form-validation/mod.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
textarea:user-invalid,
22
select:user-invalid,
3-
input:not([type="radio"],[type="checkbox"],[type="range"],[type="submit"],[type="image"]):user-invalid {
3+
input:not([type="radio"], [type="checkbox"], [type="range"], [type="submit"], [type="image"]):user-invalid {
44
border: 1px solid var(--danger);
55
}
66

77
textarea:user-valid,
88
select:user-valid,
9-
input:not([type="radio"],[type="checkbox"],[type="range"],[type="submit"],[type="image"]):user-valid {
9+
input:not([type="radio"], [type="checkbox"], [type="range"], [type="submit"], [type="image"]):user-valid {
1010
border: 1px solid var(--success);
11-
}
11+
}

styles/@form-validation/mod.html

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
<em>matcha.css</em> provides rules that automatically colors the borders of inputs based on their validation status.
33
</p>
44
<ul>
5-
<li><code data-hl="css">:user-valid</code> has <code><span class="success"></span> --success</code> borders.</li>
6-
<li><code data-hl="css">:user-invalid</code> has <code><span class="danger"></span> --danger</code> borders.</li>
5+
<li>
6+
<code data-hl="css">:user-valid</code> has <code><span class="success"></span> --success</code> borders.
7+
</li>
8+
<li>
9+
<code data-hl="css">:user-invalid</code> has <code><span class="danger"></span> --danger</code> borders.
10+
</li>
711
</ul>
812
<div class="example">
913
<p class="note">*No validation except the ones operated by the browser are performed.</p>
1014
<form method="get" onsubmit="event.preventDefault()">
1115
<label>
1216
URL:
13-
<small>Type an URL below. If it is valid, it'll appear in <code><span class="success"></span> --success</code> while it'll appear in <code><span class="danger"></span> --danger</code> if not.</small>
17+
<small>Type an URL below. If it is valid, it'll appear in <code><span class="success"></span> --success</code> while it'll appear in <code><span class="danger"></span> --danger</code> if
18+
not.</small>
1419
<input required type="url" placeholder="https://example.com">
1520
</label>
1621
</form>
17-
</div>
22+
</div>

styles/@istanbul-coverage/mod.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ span.cline-neutral {
9292
}
9393
.cover-empty {
9494
background: var(--bg-muted);
95-
}
95+
}

0 commit comments

Comments
 (0)