Skip to content

Commit f09aa1f

Browse files
committed
fix(demo): improve extended demo — article grouping, stable nav buttons, dark mode init
1 parent 2c570f7 commit f09aa1f

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

site/demo/extended.html

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<header>
4444
<h1 style="display:inline-flex;align-items:start;gap:0.3em"><img src="../static/logo.svg" alt="" style="height:1em">Nimble.css — Extended Demo</h1>
4545
<p>Showcasing layout modes, utility classes, button variants, form patterns, surface hierarchy, dark mode toggling, and <a href="#no-nimble"><code>.no-nimble</code> component isolation</a>. See also: <a href="index.html">HTML5 Test Page</a>.</p>
46-
<nav>
46+
<nav style="display:flex;flex-direction:column;align-items:start">
4747
<button id="theme-toggle" type="button">Toggle Dark Mode</button>
4848
<button id="shadow-toggle" type="button">Toggle Shadow</button>
4949
</nav>
@@ -314,15 +314,18 @@ <h2>Typography</h2>
314314
<!-- COMPONENT ISOLATION (.no-nimble) -->
315315
<!-- ============================================================ -->
316316
<section id="no-nimble">
317-
<h2>Component Isolation (<code>.no-nimble</code>)</h2>
318-
<p>The <code>.no-nimble</code> class opts an element out of nimble.css typography, form, and component styles. This requires <code>no-nimble.js</code> which wraps scopeable rules in <code>@scope</code> at runtime. Layout utilities (<code>.container</code>, <code>.grid</code>, <code>.bleed-edge</code>, <code>.bleed-wide</code>, <code>.bleed-full</code>) remain global and still work on <code>.no-nimble</code> elements.</p>
319-
<p>Compare the elements below with the styled versions above — these should render in browser defaults.</p>
320-
321-
<div class="no-nimble">
322-
<h3>Heading Inside .no-nimble</h3>
323-
<p>This paragraph is inside a <code>.no-nimble</code> container. It should use browser-default font sizing, margins, and line-height instead of nimble.css typography.</p>
324-
325-
<h4>Buttons</h4>
317+
<article>
318+
<header>
319+
<h2>Component Isolation (<code>.no-nimble</code>)</h2>
320+
<p>The <code>.no-nimble</code> class opts an element out of nimble.css typography, form, and component styles. This requires <code>no-nimble.js</code> which wraps scopeable rules in <code>@scope</code> at runtime. Layout utilities (<code>.container</code>, <code>.grid</code>, <code>.bleed-edge</code>, <code>.bleed-wide</code>, <code>.bleed-full</code>) remain global and still work on <code>.no-nimble</code> elements.</p>
321+
<p>Compare the elements below with the styled versions above — these should render in browser defaults.</p>
322+
</header>
323+
324+
<div class="no-nimble">
325+
<h3>Heading Inside .no-nimble</h3>
326+
<p>This paragraph is inside a <code>.no-nimble</code> container. It should use browser-default font sizing, margins, and line-height instead of nimble.css typography.</p>
327+
328+
<h4>Buttons</h4>
326329
<p>
327330
<button>Default Button</button>
328331
<button class="secondary">Secondary</button>
@@ -361,7 +364,8 @@ <h4>Blockquote</h4>
361364
<summary>Details/Summary</summary>
362365
<p>This should also render without nimble.css details styling.</p>
363366
</details>
364-
</div>
367+
</div>
368+
</article>
365369
</section>
366370

367371
</main>
@@ -399,8 +403,14 @@ <h4>Blockquote</h4>
399403
<script>
400404
// Theme toggle
401405
const toggle = document.getElementById('theme-toggle');
406+
const html = document.documentElement;
407+
408+
// Initialize: set data-theme to match current appearance so first click flips it
409+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
410+
html.setAttribute('data-theme', prefersDark ? 'dark' : 'light');
411+
toggle.textContent = prefersDark ? 'Toggle Light Mode' : 'Toggle Dark Mode';
412+
402413
toggle.addEventListener('click', () => {
403-
const html = document.documentElement;
404414
const current = html.getAttribute('data-theme');
405415
if (current === 'dark') {
406416
html.setAttribute('data-theme', 'light');

0 commit comments

Comments
 (0)