Skip to content

Commit 3c91189

Browse files
committed
2.2.6 - cleancss fix for minifying error on on the striped tables #42
1 parent c1ef8d7 commit 3c91189

File tree

6 files changed

+16
-104
lines changed

6 files changed

+16
-104
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ There are 4 ways to get started with pico.css:
7777
Alternatively, you can use [jsDelivr CDN](https://www.jsdelivr.com/package/npm/@yohns/picocss) to link pico.css.
7878

7979
```html
80-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.5/css/pico.min.css" />
80+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.6/css/pico.min.css" />
8181
```
8282

8383
### Install with NPM
@@ -135,7 +135,7 @@ Use the default `.classless` version if you need centered viewports:
135135
```html
136136
<link
137137
rel="stylesheet"
138-
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.5/css/pico.classless.min.css"
138+
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.6/css/pico.classless.min.css"
139139
/>
140140
```
141141

@@ -144,7 +144,7 @@ Or use the `.fluid.classless` version if you need a fluid container:
144144
```html
145145
<link
146146
rel="stylesheet"
147-
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.5/css/pico.fluid.classless.min.css"
147+
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.6/css/pico.fluid.classless.min.css"
148148
/>
149149
```
150150

@@ -159,7 +159,7 @@ Then just write pure HTML, and it should look great:
159159
<meta name="color-scheme" content="light dark" />
160160
<link
161161
rel="stylesheet"
162-
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.5/css/pico.classless.min.css"
162+
href="https://cdn.jsdelivr.net/npm/@yohns/picocss@2.2.6/css/pico.classless.min.css"
163163
/>
164164
<title>Hello, world!</title>
165165
</head>

docs/index.html

+5-21
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
<main class="col-12 col-md-9 col-lg-10">
225225
<article>
226226
<header>
227-
<h2>Yohns PicoCSS Fork v2.2.5</h2>
227+
<h2>Yohns PicoCSS Fork v2.2.6</h2>
228228
<p class="mb-0">Not in npm yet, but will be soon.</p>
229229
</header>
230230
<p>I've merged some open pull requests from the <a href="https://github.com/picocss/pico">original Pico</a>
@@ -249,26 +249,10 @@ <h2>Yohns PicoCSS Fork v2.2.5</h2>
249249
<h2>Tables</h2>
250250
<h6 class="fw-n">Striped rows require .striped class</h6>
251251
</header>
252-
<h6>
253-
To have the striped rows, can be solved 2 ways.
254-
</h6>
255-
<p>
256-
The easy way is to set <code>tbody tr:nth-child(odd of :not([hidden]))</code>
257-
but unfortunetly, when we minify the CSS it remove the space between odd and of, making the striped lines fail.
258-
Until we can find a way to fix the minification of the CSS, we will use a secondary feature that does require some more CSS code.
259-
</p>
260-
<p>
261-
As a result of the minification we are resorting to use an answer that was found on StackOverflow
262-
by <a href="https://stackoverflow.com/questions/3773890/zebra-striping-a-table-with-hidden-rows-using-css3/36892714#36892714">Shaggy</a>
263-
that I converted into a sass mixin to create more or less nested hidden selectors.
264-
</p>
265-
<p>The default is currently set to <code>4</code> and can be changed with your settings, or when you include pico in your sass file.</p>
266-
<pre class="language-css"><code>@use "pico" with (
267-
$hidden-table-levels: 4
268-
);</code></pre>
269-
<p>If you do not intend to have any hidden rows you can set the <code>$hidden-table-levels</code> to 0.</p>
270252
<p>Styles for a <code>&lt;caption&gt;</code> element have been added for tables as well.</p>
271-
<nav><ul><li>When rows are toggled, the hidden rows have * around the first column.</li></ul><ul><li><button type="button" onclick="document.querySelectorAll('.hidden-table-row').forEach(row => {row.hidden = !row.hidden;});">Toggle Hidden Rows</button></li></ul></nav>
253+
<p>For rows that will be hidden, make sure to add the <code>hidden</code> attribute like so: <code>&lt;tr hidden&gt;</code></p>
254+
<p>When rows are toggled, the hidden rows have * around the first column.</p>
255+
<nav><ul><li></li></ul><ul><li><button type="button" onclick="document.querySelectorAll('.hidden-table-row').forEach(row => {row.hidden = !row.hidden;});">Toggle Hidden Rows</button></li></ul></nav>
272256
<table class="striped" id="hidden-row-example">
273257
<caption>
274258
Solar System Planets
@@ -1655,7 +1639,7 @@ <h3>Modal with a Form!</h3>
16551639
function changeTheme(newTheme) {
16561640
const linkElement = document.getElementById('theme-color-ss');
16571641
if (linkElement) {
1658-
linkElement.setAttribute('href', 'https://cdn.jsdelivr.net/gh/Yohn/PicoCSS@2.2.5/css/pico.' + newTheme + '.min.css');
1642+
linkElement.setAttribute('href', 'https://cdn.jsdelivr.net/gh/Yohn/PicoCSS@2.2.6/css/pico.' + newTheme + '.min.css');
16591643
}
16601644
}
16611645

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.5",
3+
"version": "2.2.6",
44
"description": "Minimal CSS Framework for semantic HTML, updated with enhanced capabilities.",
55
"authors": [
66
{

scss/_settings.scss

-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ $enable-transitions: true !default;
6060
// Enable overriding with !important
6161
$enable-important: true !default;
6262

63-
// How many hidden rows do you expect to have within a table?
64-
// <tr hidden> is what is accounted for striped rows.
65-
// if none, put 0 instead of 3.
66-
$hidden-table-levels: 4 !default;
67-
6863
// Optional parent selector
6964
// If defined, all HTML tags are wrapped with this selector
7065
// :root is not wrapped

scss/content/_table.scss

+5-72
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,6 @@
11
@use "sass:map";
22
@use "../settings" as *;
33

4-
// Variables for striped rows
5-
$color-dark: var(#{$css-var-prefix}table-row-stripped-background-color);
6-
$color-light: var(#{$css-var-prefix}background-color);
7-
8-
// Adjust this number to control how many <tr hidden> rows are expected.
9-
$hidden-levels: $hidden-table-levels;
10-
11-
// Do not change, or remove the following line
12-
// needed this outside of the mixin to compile, idk why
13-
// sass --version = 1.83.4 compiled with dart2js 3.6.1
14-
$selector: "& ~ tr";
15-
16-
// This is the work around because the compiler changes
17-
// :nth-child(odd of :not(:hidden)) to :nth-child(oddof:not(:hidden))
18-
// which makes the stripes fail.
19-
// Mixin to handle the hidden row with striped backgrounds patterns
20-
// Thanks Shaggy: https://stackoverflow.com/questions/3773890/zebra-striping-a-table-with-hidden-rows-using-css3/36892714#36892714
21-
@mixin hidden-row-patterns($levels: 2, $dark-color: $color-dark, $light-color: $color-light) {
22-
$current-color-odd: $light-color;
23-
$current-color-even: $dark-color;
24-
// Generate nested s electors for each level
25-
$selector: "& ~ tr";
26-
27-
&[hidden] {
28-
display: none;
29-
30-
@for $i from 1 through $levels {
31-
@if $i > 1 {
32-
// Swap colors for next iteration
33-
$temp: $current-color-odd;
34-
$current-color-odd: $current-color-even;
35-
$current-color-even: $temp;
36-
37-
// Add another level of nesting to the selector
38-
$selector: "#{$selector}[hidden] ~ tr";
39-
}
40-
#{$selector} {
41-
&:nth-child(odd) {
42-
> th,
43-
> td {
44-
background: $current-color-odd;
45-
}
46-
}
47-
48-
&:nth-child(even) {
49-
> th,
50-
> td {
51-
background: $current-color-even;
52-
}
53-
}
54-
}
55-
}
56-
}
57-
}
58-
594
@if map.get($modules, "content/table") {
605
/**
616
* Table
@@ -126,23 +71,11 @@ $selector: "& ~ tr";
12671
@if enable-classes {
12772
#{$parent-selector} table {
12873
&.striped {
129-
> tbody > tr {
130-
&:nth-child(odd) {
131-
> th,
132-
> td {
133-
background: $color-dark;
134-
}
135-
}
136-
137-
&:nth-child(even) {
138-
> th,
139-
> td {
140-
background: $color-light;
141-
}
142-
}
143-
144-
// Apply the hidden row patterns
145-
@include hidden-row-patterns($hidden-levels);
74+
/* clean-css ignore:start */
75+
tbody tr:nth-child(odd of :not([hidden])) th,
76+
tbody tr:nth-child(odd of :not([hidden])) td {
77+
/* clean-css ignore:end */
78+
background-color: var(#{$css-var-prefix}table-row-stripped-background-color);
14679
}
14780
}
14881
}

scss/helpers/_copyright.scss

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

0 commit comments

Comments
 (0)