Skip to content

Commit fb856e6

Browse files
committed
Auto opening of targeted feature examples
1 parent f2751b5 commit fb856e6

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

site/index.html

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,18 @@ <h3>Internationalization</h3>
155155
></iframe>
156156
</details>
157157

158-
<h3 id="styling">Styling</h3>
158+
<h3 id="styling" data-example="styling-example">Styling</h3>
159159

160160
<p>
161161
Orejime provides default styles that are easily customizable,
162162
either via CSS variables, or by overriding the styles with
163163
plain CSS.
164164
</p>
165165

166-
<details>
166+
<details id="styling-example">
167167
<summary>Example</summary>
168168
<iframe
169+
style="min-height: 20lh"
169170
data-src="./features/styling.html"
170171
title="Example of styling"
171172
loading="lazy"
@@ -395,6 +396,27 @@ <h3>Migrating from V2 to V3</h3>
395396
document.querySelectorAll('details[open]').forEach(loadFeatureExample);
396397
</script>
397398

399+
<!-- Auto opening of targeted feature examples. -->
400+
<script>
401+
const openFeatureExample = () => {
402+
const hash = window.location.hash;
403+
const target = document.getElementById(hash.slice(1));
404+
405+
if (!target) {
406+
return;
407+
}
408+
409+
const example = document.getElementById(target.dataset.example);
410+
411+
if (example) {
412+
example.setAttribute('open', true);
413+
}
414+
};
415+
416+
openFeatureExample();
417+
window.addEventListener('hashchange', openFeatureExample);
418+
</script>
419+
398420
<!-- Migration form. -->
399421
<script>
400422
const migrationForm = document.querySelector('.MigrationForm--2-to-3');

0 commit comments

Comments
 (0)