Skip to content

Commit be6eebb

Browse files
committed
Closes Data-theme global setting not work #52
Closes Dropdown arrow position issue - v2.2.9 #53 Releases for 2.2.10
1 parent 6ba5f39 commit be6eebb

File tree

5 files changed

+71
-45
lines changed

5 files changed

+71
-45
lines changed

README.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,22 @@ With just the right amount of everything, Pico is great starting point for a cle
5050
## Table of contents
5151

5252
1. [Yohns Updated Version](#yohns-updated-version)
53-
2. [Minimal CSS Framework for Semantic HTML](#minimal-css-framework-for-semantic-html)
54-
3. [What’s new in v2?](#whats-new-in-v2)
55-
4. [A Superpowered HTML Reset](#a-superpowered-html-reset)
56-
5. [Table of contents](#table-of-contents)
57-
6. [Quick start](#quick-start)
53+
2. [Extras Built on top of PicoCSS](#extras-built-on-top-of-picocss)
54+
3. [Minimal CSS Framework for Semantic HTML](#minimal-css-framework-for-semantic-html)
55+
4. [What’s new in v2?](#whats-new-in-v2)
56+
5. [A Superpowered HTML Reset](#a-superpowered-html-reset)
57+
6. [Table of contents](#table-of-contents)
58+
7. [Quick start](#quick-start)
5859
1. [Install manually](#install-manually)
5960
2. [Usage from CDN](#usage-from-cdn)
6061
3. [Install with NPM](#install-with-npm)
6162
4. [Starter HTML template](#starter-html-template)
62-
7. [Class-less version](#class-less-version)
63-
8. [Limitations](#limitations)
64-
9. [Documentation](#documentation)
65-
10. [Browser Support](#browser-support)
66-
11. [Contributing](#contributing)
67-
12. [Copyright and license](#copyright-and-license)
63+
8. [Class-less version](#class-less-version)
64+
9. [Limitations](#limitations)
65+
10. [Documentation](#documentation)
66+
11. [Browser Support](#browser-support)
67+
12. [Contributing](#contributing)
68+
13. [Copyright and license](#copyright-and-license)
6869

6970
## Quick start
7071

@@ -83,7 +84,7 @@ There are 4 ways to get started with pico.css:
8384
Alternatively, you can use [jsDelivr CDN](https://www.jsdelivr.com/package/npm/@yohns/picocss) to link pico.css.
8485

8586
```html
86-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.9/css/pico.min.css" />
87+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.10/css/pico.min.css" />
8788
```
8889

8990
### Install with NPM
@@ -141,7 +142,7 @@ Use the default `.classless` version if you need centered viewports:
141142
```html
142143
<link
143144
rel="stylesheet"
144-
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.9/css/pico.classless.min.css"
145+
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.10/css/pico.classless.min.css"
145146
/>
146147
```
147148

@@ -150,7 +151,7 @@ Or use the `.fluid.classless` version if you need a fluid container:
150151
```html
151152
<link
152153
rel="stylesheet"
153-
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.9/css/pico.fluid.classless.min.css"
154+
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.10/css/pico.fluid.classless.min.css"
154155
/>
155156
```
156157

@@ -165,7 +166,7 @@ Then just write pure HTML, and it should look great:
165166
<meta name="color-scheme" content="light dark" />
166167
<link
167168
rel="stylesheet"
168-
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.9/css/pico.classless.min.css"
169+
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.10/css/pico.classless.min.css"
169170
/>
170171
<title>Hello, world!</title>
171172
</head>

docs/index.html

+31-9
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@
106106
And then you'll need the js located at: js/SwitchColorMode.js
107107
-->
108108
<label>
109-
<input aria-label="Toggle Light or Dark Mode" name="color-mode-toggle" value="1" type="checkbox"
110-
role="switch">
109+
<input aria-label="Toggle Light or Dark Mode" name="color-mode-toggle" value="1" type="checkbox" role="switch">
111110
</label>
112111
</div>
113112
<!--<details class="dropdown">
@@ -187,6 +186,7 @@
187186
<aside>
188187
<nav>
189188
<ul>
189+
<li><a href="#color-mode-toggle">Color Mode Switch</a></li>
190190
<li><a href="#tables">Tables</a></li>
191191
<li><a href="#tabs">Tabs [role=tablist]</a></li>
192192
<li><a href="#hamburger-menu">Hamburger Menu</a></li>
@@ -216,7 +216,7 @@
216216
<main class="col-12 col-md-9 col-lg-10">
217217
<article>
218218
<header>
219-
<h2>Yohns PicoCSS Fork v2.2.9</h2>
219+
<h2>Yohns PicoCSS Fork v2.2.10</h2>
220220
</header>
221221
<p>I've merged some open pull requests from the <a href="https://github.com/picocss/pico">original Pico</a>
222222
repository, and then added a few more enhancements that I either needed for a project (timeline) or wanted
@@ -230,13 +230,32 @@ <h2>Yohns PicoCSS Fork v2.2.9</h2>
230230
href="https://github.com/Yohn/PicoCSS/tree/main/docs/js">Vanilla JavaScript Files</a> to work the same as
231231
the preview here. I may get a build script going to compile the javascript plugins / components later. Let
232232
me know if this feature would help you.</p>
233-
<hr>
234-
<h3>&lt;details class="hide-arrow"&gt;</h3>
235-
<p>With classes enabled, adding the <code>hide-arrow</code> class to your <code>&lt;details class="hide-arrow"&gt;</code> will hide the arrow on the <code>&lt;summary&gt;</code> tag within the accordion and dropdown components.</p>
236-
237233
<footer>If this fork has helped you, please <a href="https://github.com/Yohn/PicoCSS">Like</a> this fork!
238234
</footer>
239235
</article>
236+
<article id="color-mode-toggle">
237+
<header>
238+
<h2>Color Mode Switch</h2>
239+
<h6 class="fw-n">Classless!</h6>
240+
</header>
241+
242+
<div class="grid" style="justify-items: center;">
243+
<label>Example:</label>
244+
<label>
245+
<input aria-label="Toggle Light or Dark Mode" name="color-mode-toggle" value="1" type="checkbox" role="switch">
246+
</label>
247+
</div>
248+
<small class="pt-1" style="text-align: center; display: block;">Only the first switch on the page change the color mode currently. You can tap the other side on the left side abover the navbar to see the color modes change.</small>
249+
<hr class="m-0">
250+
<p>You will need to include the <a href="js/SwitchColorMode.js">SwitchColorMode.js</a> javascript at the end of your <code>&lt;body&gt;</code> tag.</p>
251+
<p>For the switch itself, you really need to ensure the <code>name</code> and the <code>role</code> attributes are found, with the same values.</p>
252+
<pre><code class="language-html">&lt;label&gt;
253+
&lt;input name="color-mode-toggle" role="switch" type="checkbox" value="1" aria-label="Toggle Light or Dark Mode"&gt;
254+
&lt;/label&gt;</code></pre>
255+
<p>Do not change the <code>name="color-mode-toggle"</code></p>
256+
<p>You can assign the default color mode for new visitors by adding <code>data-theme="dark"</code> to your <code>&lt;html&gt;</code> tag. The value can be 1 of the following: <code>dark</code>, <code>light</code>, <code>auto</code>. If auto is set, it will default to the viewers prefered color mode.</p>
257+
<p>Color modes are saved across page loads.</p>
258+
</article>
240259
<hr>
241260
<article id="tables">
242261
<header>
@@ -933,7 +952,7 @@ <h2>Rows</h2>
933952
<p>
934953
<code>.row</code> has a max width set to the viewport of your <code>xl</code> viewport (1300px by default)
935954
</p>
936-
<code>.row-fluid</code> max width is 100%. </>
955+
<code>.row-fluid</code> max width is 100%. </a>
937956
<div class="row-fluid">
938957
<div class="col-3">
939958
<article style="background-color:var(--pico-primary-background); color:var(--pico-primary-inverse);">col-3
@@ -1182,6 +1201,9 @@ <h2>Popover</h2>
11821201
<header>
11831202
<h2>Accordions</h2>
11841203
</header>
1204+
<h3>&lt;details class="hide-arrow"&gt;</h3>
1205+
<p>With classes enabled, adding the <code>hide-arrow</code> class to your <code>&lt;details class="hide-arrow"&gt;</code> will hide the arrow on the <code>&lt;summary&gt;</code> tag within the accordion and dropdown components.</p>
1206+
<hr>
11851207
<details name="example-accordion">
11861208
<summary>Accordion 1</summary>
11871209
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque urna diam, tincidunt nec porta
@@ -1641,7 +1663,7 @@ <h3>Modal with a Form!</h3>
16411663
function changeTheme(newTheme) {
16421664
const linkElement = document.getElementById('theme-color-ss');
16431665
if (linkElement) {
1644-
linkElement.setAttribute('href', 'https://cdn.jsdelivr.net/gh/Yohn/PicoCSS@2.2.9/css/pico.' + newTheme + '.min.css');
1666+
linkElement.setAttribute('href', 'https://cdn.jsdelivr.net/gh/Yohn/PicoCSS@2.2.10/css/pico.' + newTheme + '.min.css');
16451667
}
16461668
}
16471669

docs/js/SwitchColorMode.js

+22-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Minimal theme switcher using a checkbox
33
*
44
* Pico.css - https://picocss.com
5-
* Copyright 2019-2024 - Licensed under MIT
5+
* Copyright 2019-2025 - Licensed under MIT
66
* Modified by Yohn https://github.com/Yohn/PicoCSS
77
*/
88

@@ -20,29 +20,33 @@ const SwitchColorMode = {
2020
console.error("Theme switcher toggle not found");
2121
return;
2222
}
23-
this.scheme = this.schemeFromLocalStorage;
24-
this.initToggle();
23+
24+
// If first visit, use the theme from <html> attribute; otherwise, use stored preference
25+
this.scheme = this.schemeFromLocalStorage ?? this.schemeFromHTML;
26+
27+
// Set checkbox state based on the applied theme
28+
this.checkbox.checked = this.scheme === "dark";
29+
30+
// Listen for user changes
31+
this.checkbox.addEventListener("change", () => {
32+
this.scheme = this.checkbox.checked ? "dark" : "light";
33+
this.schemeToLocalStorage();
34+
});
2535
},
2636

2737
// Get color scheme from local storage
2838
get schemeFromLocalStorage() {
29-
return window.localStorage?.getItem(this.localStorageKey) ?? this._scheme;
39+
return window.localStorage?.getItem(this.localStorageKey);
3040
},
3141

32-
// Preferred color scheme
33-
get preferredColorScheme() {
34-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
42+
// Get the default theme from the <html> attribute
43+
get schemeFromHTML() {
44+
return document.documentElement.getAttribute(this.rootAttribute) ?? "auto";
3545
},
3646

37-
// Initialize the toggle switch
38-
initToggle() {
39-
// Set initial checkbox state based on the current scheme
40-
this.checkbox.checked = this.scheme === "dark";
41-
42-
// Listen for changes to the checkbox
43-
this.checkbox.addEventListener("change", () => {
44-
this.scheme = this.checkbox.checked ? "dark" : "light";
45-
});
47+
// Preferred color scheme from system
48+
get preferredColorScheme() {
49+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
4650
},
4751

4852
// Set scheme
@@ -53,7 +57,6 @@ const SwitchColorMode = {
5357
this._scheme = scheme;
5458
}
5559
this.applyScheme();
56-
this.schemeToLocalStorage();
5760
},
5861

5962
// Get scheme
@@ -63,7 +66,7 @@ const SwitchColorMode = {
6366

6467
// Apply scheme
6568
applyScheme() {
66-
document.querySelector("html")?.setAttribute(this.rootAttribute, this.scheme);
69+
document.documentElement.setAttribute(this.rootAttribute, this._scheme);
6770
},
6871

6972
// Store scheme to local storage
@@ -73,4 +76,4 @@ const SwitchColorMode = {
7376
};
7477

7578
// Init
76-
SwitchColorMode.init();
79+
SwitchColorMode.init();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@yohns/picocss",
3-
"version": "2.2.9",
3+
"version": "2.2.10",
44
"description": "Minimal CSS Framework for semantic HTML, updated with enhanced capabilities.",
55
"authors": [
66
{

scss/helpers/_copyright.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/*!
2-
* Pico CSS ✨ v2.2.9 (https://github.com/Yohn/PicoCSS)
2+
* Pico CSS ✨ v2.2.10 (https://github.com/Yohn/PicoCSS)
33
* Copyright 2019-2025 - Licensed under MIT
44
*/

0 commit comments

Comments
 (0)