Skip to content

Commit 16a2519

Browse files
committed
docs(site): updates
- add no support alert - update intro heading structure
1 parent c78b78d commit 16a2519

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Or via CDN
7070
<img src="https://web-platform-dx.github.io/web-features/assets/img/baseline-limited-word.svg" width="224" height="63" alt="Baseline limited availability wordmark">
7171
</picture>
7272

73-
- [CSS Custom Highlight API][MDN_CSS_Custom_Highlight_API]
73+
- [CSS Custom Highlight API][caniuse_mdn-api_highlight]
7474

7575
## Credits
7676

@@ -87,3 +87,4 @@ Distributed under the MIT license. See LICENSE for details.
8787
[bramus_github]: https://github.com/bramus
8888
[bramus_blog_post]: https://www.bram.us/2024/02/18/custom-highlight-api-for-syntax-highlighting
8989
[MDN_CSS_Custom_Highlight_API]: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API
90+
[caniuse_mdn-api_highlight]: https://caniuse.com/mdn-api_highlight

docs/index.html

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<script type="module" async blocking="render" src="https://unpkg.com/color-scheme-switch-element@latest/dist/color-scheme-switch-element.js"></script>
4141
</head>
4242
<body>
43+
<div class="alert" data-alert="no-support" hidden>
44+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M16 16s-1.5-2-4-2-4 2-4 2"/><line x1="9" x2="9.01" y1="9" y2="9"/><line x1="15" x2="15.01" y1="9" y2="9"/></svg>
45+
<p>The <a href="https://caniuse.com/mdn-api_highlight" target="_blank" rel="noreferrer">CSS Custom Highlight API</a> is not supported in this browser.</p>
46+
</div>
4347
<header>
4448
<div class="header-links">
4549
<a href="https://andreruffert.com" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="1.2em" height="1.2em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m12 19-7-7 7-7"/><path d="M19 12H5"/></svg>Made by André Ruffert</a>
@@ -52,11 +56,8 @@
5256
<main>
5357
<section data-section="intro">
5458
<span class="emoji" aria-hidden="true">👓</span>
55-
<h1 class="heading">
56-
<span>&lt;syntax-highlight&gt;</span>
57-
web component
58-
</h1>
59-
<p class="tagline">A custom element that uses the CSS Custom Highlight API for syntax highlighting</p>
59+
<span class="heading">&lt;syntax-highlight&gt;</span>
60+
<h1 class="tagline">A custom element that uses the CSS Custom Highlight API for syntax highlighting</h1>
6061
<p class="badges">
6162
<img src="https://img.shields.io/badge/Release%20Candidate-32A9C3" alt="Release Candidate" />
6263
<a href="https://www.npmjs.com/package/syntax-highlight-element">
@@ -83,6 +84,7 @@ <h1 class="heading">
8384
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 2v2"/><path d="M14 2v4"/><path d="M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z"/><path d="M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1"/></svg>
8485
<select aria-label="Theme" id="theme-preset-select"></select>
8586
</div>
87+
<div class="menubar__item" style="margin-inline-start: auto"><small>Playground</small></div>
8688
</div>
8789
<div class="playground">
8890
<syntax-highlight language="html"></syntax-highlight>
@@ -140,8 +142,8 @@ <h2>Attributes</h2>
140142
<article>
141143
<h1>Credits</h1>
142144
<ul>
143-
<li><a href="https://github.com/bramus" target="_blank">Bramus Van Damme</a> and his <a href="https://www.bram.us/2024/02/18/custom-highlight-api-for-syntax-highlighting" target="_blank">blog post</a> where I first read about using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API" target="_blank">CSS Custom Highlight API</a> for syntax highlighting.
144-
<li><a href="https://github.com/PrismJS/prism" target="_blank">Prism</a>'s tokenizer
145+
<li><a href="https://github.com/bramus" target="_blank" rel="noreferrer">Bramus Van Damme</a> and his <a href="https://www.bram.us/2024/02/18/custom-highlight-api-for-syntax-highlighting" target="_blank">blog post</a> where I first read about using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API" target="_blank">CSS Custom Highlight API</a> for syntax highlighting.
146+
<li><a href="https://github.com/PrismJS/prism" target="_blank" rel="noreferrer">Prism</a>'s tokenizer
145147
</ul>
146148
</article>
147149
</section>
@@ -174,9 +176,12 @@ <h1>Credits</h1>
174176
import { languageExamples } from './language-examples.js'
175177
import { themePresets } from './theme-presets.js';
176178

179+
const DEFAULT_LANGUAGE_EXAMPLE = 'JS';
177180
const SUPPORTS_CSS_HIGHLIGHTS = CSS.highlights;
178181

179-
const DEFAULT_LANGUAGE_EXAMPLE = 'JS';
182+
if (!SUPPORTS_CSS_HIGHLIGHTS) {
183+
document.querySelector('[data-alert="no-support"]').removeAttribute('hidden')
184+
}
180185

181186
/**
182187
* Language example switcher

docs/style.css

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
body {
1010
margin: 0;
1111
}
12+
[hidden] {
13+
display: none !important;
14+
}
1215
}
1316

1417
@layer layout {
@@ -156,6 +159,22 @@
156159
border-color: light-dark(var(--light-accent), var(--dark-accent));
157160
}
158161

162+
.alert {
163+
display: flex;
164+
flex-direction: column;
165+
align-items: center;
166+
text-align: center;
167+
text-wrap: balance;
168+
gap: var(--spacing-2);
169+
padding: var(--spacing-6) var(--spacing-4);
170+
border-block-end: 3px solid
171+
light-dark(var(--light-accent), var(--dark-accent));
172+
173+
p {
174+
margin: 0;
175+
}
176+
}
177+
159178
header {
160179
display: flex;
161180
align-items: center;
@@ -275,19 +294,18 @@
275294
}
276295

277296
.heading {
278-
font-size: clamp(1.5rem, 2vw + 1rem, 2.75rem);
297+
color: light-dark(var(--light-accent), var(--dark-accent));
298+
font-size: clamp(1.5rem, 2vw + 1.5rem, 3rem);
299+
font-weight: bold;
279300
line-height: 1.1;
280301
display: flex;
281302
flex-direction: column;
282303
margin: 0;
283304
}
284305

285-
.heading span {
286-
color: light-dark(var(--light-accent), var(--dark-accent));
287-
}
288-
289306
.tagline {
290307
font-size: clamp(1rem, 2vw, 1.25rem);
308+
font-weight: normal;
291309
margin: 0;
292310
}
293311

0 commit comments

Comments
 (0)