Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bestax-mcp/data/components/Theme.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bestax-mcp/data/skills.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
{
"id": "css-variables",
"file": "references/css-variables.md",
"bytes": 26650
"bytes": 26771
},
{
"id": "themeable-components",
Expand Down
28 changes: 28 additions & 0 deletions bulma-ui/src/helpers/Theme.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,34 @@ export const BulmaPrefixedTheme = () => (
</div>
);

// Shadow: <Theme bulmaVars={{ '--bulma-shadow': ... }}> overrides the upstream
// token that `.box`/`.card` derive their own shadow variable from, so the ring
// cascades into descendant Boxes/Cards. The class-based `shadow="shadowless"`
// prop is unaffected — it still emits `is-shadowless` rather than a CSS var.
export const ShadowTheme = () => (
<Theme bulmaVars={{ '--bulma-shadow': '0 0 0 3px var(--bulma-primary)' }}>
<Title size="3">Custom shadow via --bulma-shadow</Title>
<p className="mb-4">
Passing <code>--bulma-shadow</code> through <code>bulmaVars</code>{' '}
overrides the upstream token that <code>.box</code> derives its{' '}
<code>--bulma-box-shadow</code> from, so the primary ring cascades into
every descendant Box.
</p>
<Box>
<Title size="5">Featured Box</Title>
<p>This Box inherits the custom primary-ring shadow from the Theme.</p>
</Box>
<Box mt="4" shadow="shadowless">
<Title size="5">Shadowless Box</Title>
<p>
This Box sets <code>shadow=&quot;shadowless&quot;</code>, which still
emits the <code>is-shadowless</code> helper class and opts out of the
cascaded ring.
</p>
</Box>
</Theme>
);

// Dark mode: <Theme colorMode> writes the `data-theme` attribute on <html>,
// flipping Bulma's light/dark scheme globally. `'system'` follows the OS.
export const DarkMode = () => {
Expand Down
22 changes: 20 additions & 2 deletions bulma-ui/src/helpers/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const bulmaCssVars = [
'--bulma-danger-h',
'--bulma-danger-s',
'--bulma-danger-l',
// shadow (the upstream token .box/.card/.dropdown/.panel derive their own
// shadow variables from; overriding it from an ancestor is the route that
// cascades, since those selectors re-declare their derived var on
// themselves)
'--bulma-shadow-h',
'--bulma-shadow-s',
'--bulma-shadow-l',
'--bulma-shadow',
Comment thread
bestaxbot marked this conversation as resolved.
Resolved
// typography
'--bulma-family-primary',
'--bulma-family-secondary',
Expand Down Expand Up @@ -575,9 +583,19 @@ function cssVarToProp(varName: string): string {
.join('');
}

/** Mapping of camelCase prop names to their Bulma CSS variable counterparts. */
/**
* Mapping of camelCase prop names to their Bulma CSS variable counterparts.
*
* `--bulma-shadow` is excluded: `cssVarToProp` would mint it as `shadow`,
* which already exists as a `BulmaOtherProps` prop (`shadow?: 'shadowless'`,
* applied via `useBulmaClasses`) — keeping it out of this map means that
* prop keeps its existing class-based meaning, while `--bulma-shadow` is
* still reachable through the `bulmaVars` object.
*/
const bulmaVarPropMap = Object.fromEntries(
bulmaCssVars.map(cssVar => [cssVarToProp(cssVar), cssVar])
bulmaCssVars
.map(cssVar => [cssVarToProp(cssVar), cssVar])
.filter(([prop]) => prop !== 'shadow')
) as Record<string, string>;

/**
Expand Down
42 changes: 42 additions & 0 deletions bulma-ui/src/helpers/__tests__/Theme.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,48 @@ describe('Theme', () => {
expect(() => unmount()).not.toThrow();
});

it('applies --bulma-shadow (and its h/s/l components) from bulmaVars', () => {
// Regression test for #499: --bulma-shadow is the upstream token that
// .box/.card/.dropdown/.panel derive their own shadow variables from, so
// it must be settable via bulmaVars even though it isn't exposed as an
// individual prop.
const vars = {
'--bulma-shadow': '0 0 0 2px hsl(0, 0%, 0%)',
'--bulma-shadow-h': '200deg',
'--bulma-shadow-s': '50%',
'--bulma-shadow-l': '10%',
};
const { container } = render(
<Theme bulmaVars={vars}>
<div data-testid="content">Test Content</div>
</Theme>
);

const themeDiv = container.firstChild as HTMLElement;
expect(themeDiv.style.getPropertyValue('--bulma-shadow')).toBe(
'0 0 0 2px hsl(0, 0%, 0%)'
);
expect(themeDiv.style.getPropertyValue('--bulma-shadow-h')).toBe('200deg');
expect(themeDiv.style.getPropertyValue('--bulma-shadow-s')).toBe('50%');
expect(themeDiv.style.getPropertyValue('--bulma-shadow-l')).toBe('10%');
});

it('keeps the `shadow` prop as the shadowless helper class, not a CSS var', () => {
// Regression test for #499: --bulma-shadow's minted prop name ("shadow")
// collides with the pre-existing BulmaOtherProps `shadow` prop
// (shadow="shadowless" -> is-shadowless class). The `shadow` prop must
// keep producing the class, not get diverted into --bulma-shadow.
const { container } = render(
<Theme shadow="shadowless">
<div data-testid="content">Test Content</div>
</Theme>
);

const themeDiv = container.firstChild as HTMLElement;
expect(themeDiv.className).toContain('is-shadowless');
expect(themeDiv.style.getPropertyValue('--bulma-shadow')).toBe('');
});

it('skips invalid CSS variable keys when building the local style object', () => {
// Inject a non-Bulma key via bulmaVars; the local-style branch's
// `bulmaCssVars.includes(key) && value` guard should drop it.
Expand Down
14 changes: 14 additions & 0 deletions docs/docs/api/helpers/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ function PrefixedTheme() {
- Use the `bulmaVars` prop when you need to set variables not covered by individual props
- Individual props (like `primaryH`) are converted to their corresponding CSS variable names
- `bulmaVars` also accepts the scheme surface variables — `--bulma-scheme-main`, `--bulma-scheme-main-bis`, `--bulma-scheme-main-ter`, `--bulma-scheme-invert`, `--bulma-scheme-invert-bis`, `--bulma-scheme-invert-ter` — so overriding `--bulma-scheme-main-bis`/`-ter` re-tints every scheme-background band (e.g., `<Section bgColor="scheme-main-bis">`) at once
- `bulmaVars` also accepts `--bulma-shadow` (plus `--bulma-shadow-h`/`-s`/`-l`) — the upstream token that `.box`, `.card`, `.dropdown`, and `.panel` derive their own shadow variables from. Those selectors re-declare their derived variable (e.g. `--bulma-box-shadow`) on themselves, so setting it from an ancestor `Theme` is only inherited and never wins; overriding `--bulma-shadow` itself is the one override that cascades. There is no individual `shadow` prop for this — `shadow` already names the unrelated `shadowless` helper class — so reach it through `bulmaVars`

### Performance Considerations

Expand Down Expand Up @@ -729,6 +730,19 @@ The Theme component accepts individual CSS variable props that correspond to Bul
| `dangerS` | `string` | Danger color saturation (percentage) | `--bulma-danger-s` |
| `dangerL` | `string` | Danger color lightness (percentage) | `--bulma-danger-l` |

#### Shadow Variables

Reachable only through `bulmaVars` — there is no individual prop, since `shadow` already names
the `BulmaOtherProps` `shadowless` helper class. As noted above, `--bulma-shadow` is the one
override that cascades into `.box`/`.card`/`.dropdown`/`.panel` shadows.

| CSS Variable | Description |
| ------------------ | ----------------------------------------------------------------------------------------------------- |
| `--bulma-shadow-h` | Shadow color hue (0-360) |
| `--bulma-shadow-s` | Shadow color saturation (percentage) |
| `--bulma-shadow-l` | Shadow color lightness (percentage) |
| `--bulma-shadow` | The full shadow value that `.box`/`.card`/`.dropdown`/`.panel` derive their own shadow variables from |

#### Complete CSS Variables List

The Theme component supports all 500+ Bulma CSS variables through the `bulmaVars` prop and individual props:
Expand Down
10 changes: 5 additions & 5 deletions skills/bestax-layout-scaffold/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ Centered; a collection of items → Card grid. For mixed requests, pick the domi
and `.box` re-declare `--bulma-card-shadow`/`--bulma-box-shadow` from `--bulma-shadow` on
their own selector, so setting _those_ from an ancestor never wins (same for
`--bulma-box-radius`; `--bulma-card-radius` is a literal with no ancestor route at all).
It has to be a CSS rule rather than `<Theme bulmaVars={{ '--bulma-shadow': … }}>`, because
`bulmaVars` is a closed typed record and `--bulma-shadow` is not one of its keys — that
exact call **does not compile**, and it was the single most repeated invention across this
library's cold-start evals. Either way the subtree stays theme- and dark-mode-aware.
A class-scoped CSS rule keeps the ring on just the one featured card without wrapping it in
its own `Theme`; `<Theme bulmaVars={{ '--bulma-shadow': … }}>` also compiles and is the
better fit when the override already applies to a whole scoped subtree. Either way the
subtree stays theme- and dark-mode-aware.

- **CTAs on a colored hero must stay legible in both schemes.** On a fixed-color surface
(`Hero color="primary"`, a dark banner), use **filled** buttons — `color="light"` or
Expand Down Expand Up @@ -194,7 +194,7 @@ inline `style`.
every other `Section` — never band CSS, never `bgColor="light"`/`"white"`.
- [ ] Decorative CSS ≤10 lines total incl. comments — no file-header comment (hero wash +
featured-card ring), `--bulma-*`-derived; no resets — Bulma ships one.
The ring sets `--bulma-shadow` in a CSS rule; `Theme bulmaVars` has no such key.
The ring sets `--bulma-shadow` (via a scoped CSS rule or `Theme bulmaVars`).
- [ ] Set the icon library once via `<ConfigProvider iconLibrary="…">` at the root.
- [ ] Site built? ~800 KB raw / ~82 KB gzip CSS is the expected default-flavor size — to shrink
it, run the `bestax-optimize` skill (measure first).
31 changes: 16 additions & 15 deletions skills/bestax-theming/references/css-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,27 @@ and numeric shades `--bulma-<c>-00` … `--bulma-<c>-95`.
| `--bulma-size-small` / `-normal` / `-medium` / `-large` | 0.75 / 1 / 1.25 / 1.5rem | via `bulmaVars` |
| `--bulma-weight-light/normal/medium/semibold/bold/extrabold` | 300 / 400 / 500 / 600 / 700 / 800 | via `bulmaVars` |

## Shadow — the one token `bulmaVars` cannot set
## Shadow — override the upstream token, not the derived one
Comment thread
claude[bot] marked this conversation as resolved.
Resolved

`--bulma-shadow` is a real Bulma variable (`.box` and `.card` both derive
`--bulma-box-shadow`/`--bulma-card-shadow` from it), but it is **not a key of `bulmaVars`** —
that record is a closed union built from an explicit list, and shadow was left out. Writing
`<Theme bulmaVars={{ '--bulma-shadow': … }}>` is a compile error, and it is the single most
repeated invention in this library's cold-start evals: every run on every guidance channel
tried it.
`--bulma-shadow` (plus its `--bulma-shadow-h`/`-s`/`-l` channels) is a real Bulma variable that
`.box`, `.card`, `.dropdown`, and `.panel` each derive their own shadow variable from
(`--bulma-box-shadow`, `--bulma-card-shadow`, …). It **is** a key of `bulmaVars`, so `Theme` can
set it directly:

Set it in CSS instead, then apply the class to the one element that needs it:

```css
.featured-ring {
--bulma-shadow: 0 0 0 2px var(--bulma-primary);
}
```tsx
<Theme bulmaVars={{ '--bulma-shadow': '0 0 0 2px var(--bulma-primary)' }}>
<Box>featured</Box>
</Theme>
```

There is no individual `shadow` prop for it — `shadow` already names the unrelated
`shadowless` helper class (`shadow="shadowless"` → `is-shadowless`) — so reach it through
`bulmaVars` as shown above.

Do **not** reach for `--bulma-box-shadow`/`--bulma-card-shadow` from an ancestor instead —
those are re-declared on `.box`/`.card` themselves, so an inherited value always loses (the
same rule as the extras section below).
those are re-declared on `.box`/`.card` themselves, so an inherited value always loses. Setting
`--bulma-shadow` from an ancestor `Theme` is the one override that cascades into all of them
(the same rule as the extras section below).

## Extras component variables

Expand Down
Loading