UNPKG

@cxy227/dark-mode-js

Version:

Add dark mode to your website quickly

185 lines (175 loc) 5.9 kB
<!-- MVP.css quickstart template: https://github.com/andybrewer/mvp/ --> <!DOCTYPE html> <html lang="en"> <head> <link rel="icon" href="https://via.placeholder.com/70x70"> <link rel="stylesheet" href="./mvp.css"> <meta charset="utf-8"> <meta name="description" content="My description"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My title</title> <script src="https://cdn.jsdelivr.net/npm/us-utils-asyncloadscript@1.1.3/index.js"></script> <script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.5.7/lib/darkmode-js.min.js"></script> </head> <body> <header> <nav> <a href="/"><img alt="Logo" src="https://via.placeholder.com/200x70?text=Logo" height="70"></a> <ul> <li>Menu Item 1</li> <li><a href="#">Menu Item 2</a></li> <li><a href="#">Dropdown Menu Item</a> <ul> <li><a href="#">Sublink with a long name</a></li> <li><a href="#">Short sublink</a></li> </ul> </li> </ul> </nav> <img src="https://static.uskid.com/uskid-official-site/static/aboutus-3.4be98053.jpg" /> <h1>切换暗黑模式</h1> <p>Page Subheading with <mark>highlighting</mark></p> <p> <a id="toggleCss" href="#" class="href"><i>通过 css 控制</i></a> <a id="toggleJs" href="#" class="href"><b>通过 js 控制</b></a> </p> </header> <main> <hr> <section> <header> <h2>Section Heading</h2> <p>Section Subheading</p> </header> <aside> <h3>Card heading</h3> <p>Card content*</p> <p><small>*with small content</small></p> </aside> <aside> <h3>Card heading</h3> <p>Card content <sup>with notification</sup></p> </aside> <aside> <h3>Card heading</h3> <p>Card content</p> </aside> </section> <hr> <section> <blockquote> "Quote" <footer><i>- Attribution</i></footer> </blockquote> </section> <hr> <section> <table> <thead> <tr> <th></th> <th>Col A</th> <th>Col B</th> <th>Col C</th> </tr> </thead> <tr> <td>Row 1</td> <td>Cell A1</td> <td>Cell B1</td> <td>Cell C1</td> </tr> <tr> <td>Row 2</td> <td>Cell A2</td> <td>Cell B2</td> <td>Cell C2</td> </tr> </table> </section> <hr> <article> <h2>Left-aligned header</h2> <p>Left-aligned paragraph</p> <aside> <p>Article callout</p> </aside> <ul> <li>List item 1</li> <li>List item 2</li> </ul> <figure> <img alt="Stock photo" src="https://via.placeholder.com/1080x500?text=Amazing+stock+photo"> <figcaption><i>Image caption</i></figcaption> </figure> </article> <hr> <div> <details> <summary>Expandable title</summary> <p>Revealed content</p> </details> <details> <summary>Another expandable title</summary> <p>More revealed content</p> </details> <br> <p>Inline <code>code</code> snippets</p> <pre> <code> // preformatted code block </code> </pre> </div> <hr> <section> <form> <header> <h2>Form title</h2> </header> <label for="input1">Input label:</label> <input type="text" id="input1" name="input1" size="20" placeholder="Input1"> <label for="select1">Select label:</label> <select id="select1"> <option value="option1">option1</option> <option value="option2">option2</option> </select> <label for="textarea1">Textarea label:</label> <textarea cols="40" rows="5" id="textarea1"></textarea> <button type="submit">Submit</button> </form> </section> </main> <footer> <hr> <p> <small>Contact info</small> </p> </footer> <script> function init() { console.log('darkModeJs: ', darkModeJs) const Widget = darkModeJs.darkHue const darkmode = new Widget() darkmode.showWidget() darkmode.defaultTheme() } window.addEventListener('load', () => { if (window.GlobalLoadScript) { window.GlobalLoadScript()('http://127.0.0.1:8080/dist/index.js', init) } }); // --color: #0097fc; // --color-accent: #0097fc4f; // --color-bg: #333; // --color-bg-secondary: #555; // --color-link: #0097fc; // --color-secondary: #e20de9; // --color-secondary-accent: #e20de94f; // --color-shadow: #bbbbbb20; // --color-table: #0097fc; // --color-text: #f7f7f7; // --color-text-secondary: #aaa; </script> </body> </html>