Skip to content
Merged
37 changes: 37 additions & 0 deletions create-bestax/src/__tests__/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
MESSAGES,
PROMPTS,
LAUNCH_JSON,
CLAUDE_MD,
} = await import('../constants.js');

describe('constants', () => {
Expand Down Expand Up @@ -227,6 +228,42 @@ describe('constants', () => {
});
});

describe('CLAUDE_MD house style', () => {
const md = CLAUDE_MD('my-app', {
bulmaFlavor: 'complete',
iconLibrary: 'none',
});

it('maps common inline-style patterns to concrete helper props', () => {
// the never-inline rule ships with a lookup table, not just a prohibition (#350)
expect(md).toContain('Never inline `style={{}}`');
expect(md).toContain('Helper props instead');
expect(md).toContain('`mt="4"`');
expect(md).toContain('`4`=1rem');
expect(md).toContain('`textAlign="centered"`');
expect(md).toContain('`textColor`');
expect(md).toContain('`bgColor`');
expect(md).toContain('`textSize="1"`');
expect(md).toContain('`textWeight`');
expect(md).toContain('`display="flex"`');
expect(md).toContain('`flexGrow="1"`');
expect(md).toContain('`displayMobile`');
});

it('states the no-helper fallback: a named class in the stylesheet, never inline style', () => {
expect(md).toContain('No helper matches');
expect(md).toContain('`src/App.css`');
expect(md).toContain('pass it via `className`');
expect(md).toContain('still never inline `style`');
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

it('documents the gap exception: no flex gap helper, but Grid/Columns take a gap prop', () => {
expect(md).toContain('Flex layouts have no `gap` helper');
expect(md).toContain('`Grid` and `Columns`');
expect(md).toContain('take a `gap` prop');
});
});

describe('DEFAULT_PROJECT_NAME', () => {
it('should be a valid project name', () => {
expect(DEFAULT_PROJECT_NAME).toBeDefined();
Expand Down
25 changes: 22 additions & 3 deletions create-bestax/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,29 @@ ${setupLines.join('\n')}

## House style

- Never inline \`style={{}}\` — use the helper props every component accepts (\`m*\`/\`p*\`
spacing, \`textColor\`/\`bgColor\`, \`display="flex"\`, \`flexDirection\`, \`alignItems\`).
Flex layouts have no \`gap\` helper — space children with margins (\`Grid\` and \`Columns\`
**Never inline \`style={{}}\`** — the components accept helper props that cover the common
cases. Before writing \`style\`, translate each declaration with this table:

| Inline style you're about to write | Helper props instead |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| \`marginTop: '1rem'\` (any margin/padding) | \`mt="4"\` — \`m\`/\`mt\`/\`mx\`/\`p\`/\`py\`/… scale: \`1\`=0.25rem, \`2\`=0.5rem, \`3\`=0.75rem, \`4\`=1rem, \`5\`=1.5rem, \`6\`=3rem (nearest step) |
| \`textAlign: 'center'\` | \`textAlign="centered"\` (also \`left\`, \`right\`, \`justified\`) |
| \`color: '#…'\` | \`textColor\` with the nearest Bulma color: \`primary\`, \`link\`, \`info\`, \`success\`, \`warning\`, \`danger\`, \`white\`, \`black\`, \`grey\` (+ \`grey-light\`, \`grey-dark\`, …) |
| \`backgroundColor: '#…'\` | \`bgColor\` (same palette) |
| \`fontSize: …\` | \`textSize="1"\`…\`"7"\` (\`1\` largest) — for headings use \`Title\`/\`SubTitle\` \`size\` |
| \`fontWeight: …\` | \`textWeight\`: \`light\`, \`normal\`, \`medium\`, \`semibold\`, \`bold\` |
| \`textTransform\`, italics | \`textTransform\`: \`uppercase\`, \`lowercase\`, \`capitalized\`, \`italic\` |
| \`display: 'flex'\` + flex properties | same-named props: \`display="flex"\`, \`flexDirection\`, \`justifyContent\`, \`alignItems\`, \`flexWrap\` |
| \`height: '100%'\` on a flex child | \`flexGrow="1"\` |
| \`display: 'none'\` | \`visibility="hidden"\`, or responsive \`display*\` props (\`displayMobile\`, \`displayTablet\`, …) |

- Spacing, typography, and flex helpers are on every component; \`textColor\`/\`bgColor\` are
on the content components (\`Box\`, \`Block\`, \`Title\`, \`Content\`, \`Hero\`, \`Card\`, …) — the
few with a semantic \`color\` variant (\`Tag\`, \`Tabs\`, \`Panel\`) take \`color\` instead.
- Flex layouts have no \`gap\` helper — space children with margins (\`Grid\` and \`Columns\`
take a \`gap\` prop, so prefer that there).
- No helper matches (e.g. \`maxWidth\`, a one-off gradient)? Add a named class to
\`src/App.css\` and pass it via \`className\` — still never inline \`style\`.
- Compose existing components before writing custom CSS; theme via \`Theme\` and \`--bulma-*\`
variables, never hardcoded colors.
- There is no test runner or Storybook in this app — don't assume one.
Expand Down
29 changes: 26 additions & 3 deletions skills/bestax-custom-component/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,30 @@ free. `references/api.md` documents the helpers.
## Styling ladder — use the lowest rung that works

**Rung 1 — helper props only (default).** House rules: never `style={{}}`. Layout with
`Block`/`Box` and `display="flex"`, `flexDirection`, `alignItems`, `justifyContent`. There is
**no `gap` helper** — space children with `m*`/`p*` margins instead.
`Block`/`Box` and `display="flex"`, `flexDirection`, `alignItems`, `justifyContent`. Flex
layouts have **no `gap` helper** — space children with `m*`/`p*` margins instead (`Grid` and
`Columns` take a `gap` prop). Before writing `style={{ … }}` anywhere, translate each
declaration:

| Inline style you're about to write | Helper props instead |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `marginTop: '1rem'` (any margin/padding) | `mt="4"` — `m`/`mt`/`mx`/`p`/`py`/… scale: `1`=0.25rem, `2`=0.5rem, `3`=0.75rem, `4`=1rem, `5`=1.5rem, `6`=3rem (nearest step) |
| `textAlign: 'center'` | `textAlign="centered"` (also `left`, `right`, `justified`) |
| `color: '#…'` | `textColor` with the nearest Bulma color: `primary`, `link`, `info`, `success`, `warning`, `danger`, `white`, `black`, `grey` (+ `grey-light`, `grey-dark`, …) |
| `backgroundColor: '#…'` | `bgColor` (same palette) |
| `fontSize: …` | `textSize="1"`…`"7"` (`1` largest) — for headings use `Title`/`SubTitle` `size` |
| `fontWeight: …` | `textWeight`: `light`, `normal`, `medium`, `semibold`, `bold` |
| `textTransform`, italics | `textTransform`: `uppercase`, `lowercase`, `capitalized`, `italic` |
| `display: 'flex'` + flex properties | same-named props: `display="flex"`, `flexDirection`, `justifyContent`, `alignItems`, `flexWrap` |
| `height: '100%'` on a flex child | `flexGrow="1"` |
| `display: 'none'` | `visibility="hidden"`, or responsive `display*` props (`displayMobile`, `displayTablet`, …) |

Spacing, typography, and flex helpers are on every component; `textColor`/`bgColor` are on
the content components you'll compose with (`Box`, `Block`, `Title`, `Content`, `Card`, …) —
the few with a semantic `color` variant (`Tag`, `Tabs`, `Panel`) take `color` instead.

A value with no helper equivalent (`maxWidth: 720`, a one-off gradient) moves you to rung 2 —
a named class in a stylesheet — never to inline `style`.

**Rung 2 — a plain CSS file**, scoped under the component's class, consuming `--bulma-*`
variables — never literal colors, so `Theme` and dark mode keep working:
Expand Down Expand Up @@ -153,7 +175,8 @@ render, prop→class mapping, helper-prop passthrough (`m="3"` → `m-3`), and t
- [ ] Inventory checked (catalog + bestax.io/docs/api) and the decision surfaced to the user.
- [ ] All imports from `@allxsmith/bestax-bulma` (no deep/internal paths).
- [ ] Composition first — existing components + helper props before any CSS.
- [ ] No inline `style={{}}` anywhere.
- [ ] No inline `style={{}}` anywhere — translate via the rung-1 mapping table; values with
no helper equivalent get a named class (rung 2).
- [ ] Lowest sufficient ladder rung (helper props → scoped CSS vars → Sass).
- [ ] All colors/radii derived from `--bulma-*` variables — no literals.
- [ ] Renders correctly via `npm run dev`, including dark mode.
35 changes: 31 additions & 4 deletions skills/bestax-layout-scaffold/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Centered; a collection of items → Card grid. For mixed requests, pick the domi
mobile. Add responsive `size*` props only to tune the breakpoints.
- For a `fixed="top"` `Navbar`, add the `has-navbar-fixed-top` class to `<html>` so content is not
hidden behind it — the library does not do this automatically.
- **Style with helper props, not inline `style`.** Use `m`/`p` spacing (`mt="4"` = 1rem),
`textAlign="centered"`, and `textColor`/`bgColor` instead of `style={{ marginTop, textAlign,
color }}`. Set the app-wide icon library once with `<ConfigProvider iconLibrary="…">` at the root
- **Style with helper props, not inline `style`.** Before writing `style={{ … }}` anywhere,
translate each declaration with the mapping table below — the helper props cover the common
cases. Set the app-wide icon library once with `<ConfigProvider iconLibrary="…">` at the root
rather than `library` on every `<Icon>`.
- **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 All @@ -59,6 +59,32 @@ color }}`. Set the app-wide icon library once with `<ConfigProvider iconLibrary=
`<Theme isRoot colorMode="light">` — so a visitor's OS dark mode can't flip Bulma's text
colors out from under the fixed palette (details: the `bestax-theming` skill's contrast rules).

## Inline style → helper prop mapping

Look up the declaration you were about to inline. The spacing, typography, and flex helpers
below are on every component; `textColor`/`bgColor` are on the content components you'll
target (`Box`, `Block`, `Title`, `Content`, `Notification`, `Hero`, `Card`, …) — the few with
a semantic `color` variant (`Tag`, `Tabs`, `Panel`) take `color` instead; wrap content in a
`Block` if you need a text color there.

| Inline style you're about to write | Helper props instead |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `marginTop: '1rem'` (any margin/padding) | `mt="4"` — `m`/`mt`/`mx`/`p`/`py`/… scale: `1`=0.25rem, `2`=0.5rem, `3`=0.75rem, `4`=1rem, `5`=1.5rem, `6`=3rem (nearest step) |
| `textAlign: 'center'` | `textAlign="centered"` (also `left`, `right`, `justified`) |
| `color: '#…'` | `textColor` with the nearest Bulma color: `primary`, `link`, `info`, `success`, `warning`, `danger`, `white`, `black`, `grey` (+ `grey-light`, `grey-dark`, …) |
| `backgroundColor: '#…'` | `bgColor` (same palette) |
| `fontSize: …` | `textSize="1"`…`"7"` (`1` largest) — for headings use `Title`/`SubTitle` `size` |
| `fontWeight: …` | `textWeight`: `light`, `normal`, `medium`, `semibold`, `bold` |
| `textTransform`, italics | `textTransform`: `uppercase`, `lowercase`, `capitalized`, `italic` |
| `display: 'flex'` + flex properties | same-named props: `display="flex"`, `flexDirection`, `justifyContent`, `alignItems`, `flexWrap` |
| `height: '100%'` on a flex child | `flexGrow="1"` |
| `display: 'none'` | `visibility="hidden"`, or responsive `display*` props (`displayMobile`, `displayTablet`, …) |
| `gap: …` in a flex layout | no `gap` helper exists — space children with `m*` margins; `Grid` and `Columns` take a `gap` prop, so prefer those there |

No helper matches (e.g. `maxWidth`, a one-off gradient)? Add a named class to the project
stylesheet (`src/App.css` in a scaffolded app) and pass it via `className` — still never
inline `style`.

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
## References

- `references/layout-components.md` — the layout component inventory: real prop names, types, and
Expand All @@ -84,5 +110,6 @@ color }}`. Set the app-wide icon library once with `<ConfigProvider iconLibrary=
cards must match height.
- [ ] For a fixed navbar, add `has-navbar-fixed-top` to `<html>`.
- [ ] Do not use `Tile` — it is not shipped.
- [ ] Style with helper props (`mt`/`p`, `textAlign`, `textColor`), not inline `style`.
- [ ] Style with helper props, not inline `style` — translate via the mapping table; values
with no helper get a named class in the stylesheet, never `style={{}}`.
- [ ] Set the icon library once via `<ConfigProvider iconLibrary="…">` at the root.
Loading