|
43 | 43 | <header> |
44 | 44 | <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> |
45 | 45 | <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"> |
47 | 47 | <button id="theme-toggle" type="button">Toggle Dark Mode</button> |
48 | 48 | <button id="shadow-toggle" type="button">Toggle Shadow</button> |
49 | 49 | </nav> |
@@ -314,15 +314,18 @@ <h2>Typography</h2> |
314 | 314 | <!-- COMPONENT ISOLATION (.no-nimble) --> |
315 | 315 | <!-- ============================================================ --> |
316 | 316 | <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> |
326 | 329 | <p> |
327 | 330 | <button>Default Button</button> |
328 | 331 | <button class="secondary">Secondary</button> |
@@ -361,7 +364,8 @@ <h4>Blockquote</h4> |
361 | 364 | <summary>Details/Summary</summary> |
362 | 365 | <p>This should also render without nimble.css details styling.</p> |
363 | 366 | </details> |
364 | | - </div> |
| 367 | + </div> |
| 368 | + </article> |
365 | 369 | </section> |
366 | 370 |
|
367 | 371 | </main> |
@@ -399,8 +403,14 @@ <h4>Blockquote</h4> |
399 | 403 | <script> |
400 | 404 | // Theme toggle |
401 | 405 | 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 | + |
402 | 413 | toggle.addEventListener('click', () => { |
403 | | - const html = document.documentElement; |
404 | 414 | const current = html.getAttribute('data-theme'); |
405 | 415 | if (current === 'dark') { |
406 | 416 | html.setAttribute('data-theme', 'light'); |
|
0 commit comments