Skip to content

Commit 60024ca

Browse files
committed
Tooltip colors, width, and minifier bugfix.
- Tooltips: Use theme-independent inverted surface colors. Add comfortable width (max-content + max-width). - Add --mu-inverted-background/--mu-inverted-color variables (always opposite of page background, independent of theme). - Fix minifier stripping descendant combinator space before pseudo-classes (:is, :where, :not, etc.). - Fix tooltip top placement specificity vs PicoCSS [data-placement=top] selector.
1 parent a2d8a38 commit 60024ca

4 files changed

Lines changed: 35 additions & 3 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ These µCSS rules exist to fix PicoCSS default behaviors:
5757
- `nav details.dropdown { display: inline-block }` — Fix Firefox full-width nav dropdowns (picocss/pico#701) — remove when fixed upstream
5858
- `:where([role=group], [role=search]) + small` — Fix helper text not styled after input groups (picocss/pico#540, picocss/pico#700) — remove when fixed upstream
5959
- `[data-tooltip] { display: inline-block }` — Fix tooltip mispositioned on inline elements in Chromium (picocss/pico#678) — remove when fixed upstream
60-
- `[data-tooltip]::before { white-space: pre-line; max-width: 20rem }` — Fix tooltip overflow on long text, support explicit line breaks (picocss/pico#665, picocss/pico#715) — remove when fixed upstream
60+
- `[data-tooltip]::before/::after` use `--mu-inverted-background`/`--mu-inverted-color` instead of themed contrast — PicoCSS contrast is theme-dependent in µCSS, not always readable as tooltip background
61+
- `[data-tooltip]::before { white-space: pre-line; width: max-content; max-width: 20rem }` — Fix tooltip overflow on long text, support explicit line breaks, comfortable width (picocss/pico#665, picocss/pico#715) — remove when fixed upstream
6162
- `code, kbd, samp { padding: 0.125rem 0.375rem }` — Fix inline code vertical padding too thick (picocss/pico#651) — remove when fixed upstream
6263
- PicoCSS sets `:where(table) { width: 100% }` — all tables are fullwidth by default, no `.table-fullwidth` class needed
6364
- PicoCSS `.outline` button style (3 colors) coexists with µCSS `.btn-outline` (11 colors) — different selectors, no conflict

build/mu-build.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ function formatSize(int $b): string {
219219
// Strip all comments (including /*! */ banners)
220220
$output = preg_replace('/\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\//', '', $output);
221221
$output = preg_replace('/\s+/', ' ', $output);
222-
$output = preg_replace('/\s*([{};:,])\s*/', '$1', $output);
222+
// Strip spaces around structural tokens (but not ':' — it appears in selectors
223+
// as pseudo-class prefix where a preceding space is a descendant combinator)
224+
$output = preg_replace('/\s*([{};,])\s*/', '$1', $output);
225+
// Strip spaces around ':' only inside declaration blocks (property: value)
226+
$output = preg_replace_callback('/\{([^}]*)\}/', function ($m) {
227+
return '{' . preg_replace('/\s*:\s*/', ':', $m[1]) . '}';
228+
}, $output);
223229
$output = str_replace(';}', '}', $output);
224230
$banner = $noBanner ? '' : "/* µCSS (muCSS) - mucss.org */\n";
225231
$output = $banner . trim($output) . "\n";

build/mu-color-gen.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ function buildCss(array $theme, array $palette): string {
207207
$out[] = "\t{$name}: {$value};";
208208
}
209209
}
210+
$out[] = '';
211+
$out[] = "\t/* Inverted surface (always opposite of page background, theme-independent) */";
212+
$out[] = "\t--mu-inverted-background: #181c25;";
213+
$out[] = "\t--mu-inverted-color: #fff;";
210214
$out[] = '}';
211215
$out[] = '';
212216

@@ -223,6 +227,10 @@ function buildCss(array $theme, array $palette): string {
223227
$out[] = "\t\t{$name}: {$value};";
224228
}
225229
}
230+
$out[] = '';
231+
$out[] = "\t\t/* Inverted surface (always opposite of page background, theme-independent) */";
232+
$out[] = "\t\t--mu-inverted-background: #eff1f4;";
233+
$out[] = "\t\t--mu-inverted-color: #000;";
226234
$out[] = "\t}";
227235
$out[] = '}';
228236
$out[] = '';
@@ -239,6 +247,10 @@ function buildCss(array $theme, array $palette): string {
239247
$out[] = "\t{$name}: {$value};";
240248
}
241249
}
250+
$out[] = '';
251+
$out[] = "\t/* Inverted surface (always opposite of page background, theme-independent) */";
252+
$out[] = "\t--mu-inverted-background: #eff1f4;";
253+
$out[] = "\t--mu-inverted-color: #000;";
242254
$out[] = '}';
243255
$out[] = '';
244256

css/mu.utilities.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,23 @@ li ol {
2828
display: inline-block;
2929
}
3030

31+
/* Tooltip: use inverted surface instead of themed contrast (contrast is theme-dependent, not always readable) */
32+
/* Extra [data-placement] selector matches PicoCSS specificity for top placement */
33+
[data-tooltip]::before,
34+
[data-tooltip][data-placement]::before {
35+
background: var(--mu-inverted-background);
36+
color: var(--mu-inverted-color);
37+
}
38+
/* Caret color must match tooltip body (PicoCSS uses currentColor for the border arrow) */
39+
[data-tooltip]::after,
40+
[data-tooltip][data-placement]::after {
41+
color: var(--mu-inverted-background);
42+
}
3143
/* PicoCSS bugfix: tooltips overflow on long text (picocss/pico#665, picocss/pico#715) — remove when fixed upstream */
32-
/* pre-line preserves explicit line breaks (
) while wrapping long text */
44+
/* pre-line preserves explicit line breaks (
) while wrapping long text; width: max-content for comfortable sizing */
3345
[data-tooltip]::before {
3446
white-space: pre-line;
47+
width: max-content;
3548
max-width: 20rem;
3649
}
3750

0 commit comments

Comments
 (0)