Skip to content

[BOOKINGSG-9112][Jaz] Checkbox — Migrate styles to Linaria#1094

Open
Jazsley wants to merge 5 commits intopre-release/v4from
BOOKINGSG-9112
Open

[BOOKINGSG-9112][Jaz] Checkbox — Migrate styles to Linaria#1094
Jazsley wants to merge 5 commits intopre-release/v4from
BOOKINGSG-9112

Conversation

@Jazsley
Copy link
Copy Markdown
Contributor

@Jazsley Jazsley commented Apr 15, 2026

[BOOKINGSG-9112][Jaz] Checkbox — Migrate styles to Linaria

Summary

Migrated the checkbox component from styled-components to Linaria css tags, replacing V3 design tokens with V4 equivalents and removing all function interpolations in favour of clsx-based conditional class application.

Changes:

  • Renamed checkbox.style.tsx → checkbox.styles.ts
  • Replaced V3_Colour / V3_Motion tokens with Colour / Motion from theme
  • Converted all styled tags to Linaria css tags (@linaria/core)
  • Icon components (SquareIcon, SquareTickFillIcon, etc.) rendered directly with className applied via clsx
  • Replaced styled-components sibling selector references with &:not([disabled]):hover + svg
  • Added functional E2E tests covering all visual states, hover, keyboard, and focus-visible ring
  • Added 21 unit tests covering rendering, input behaviour, and Linaria class application

Checklist

  • Migrated the component styles
  • className is chained correctly with clsx
  • User style prop is set as CSS variable
  • Changes follow the project guidelines in CONVENTIONS_V4.md
  • Updated Storybook documentation
  • Added/updated unit tests
  • Added visual tests
  • Listed breaking changes

Notes:

  • No user style props (displaySize is handled via a containerSmall CSS class — no CSS variable needed)
  • Storybook stories are pre-existing and unchanged; no new doc updates were required
  • No breaking changes — public API (CheckboxProps) is identical; consuming component (data-table) verified unaffected

@Jazsley Jazsley changed the title Bookingsg 9112 [BOOKINGSG-9112][Jaz] Checkbox — Migrate styles to Linaria Apr 15, 2026
@Jazsley Jazsley self-assigned this Apr 15, 2026
@Jazsley Jazsley requested review from qroll and zhaoyanxzy April 15, 2026 02:53
Comment thread e2e/tests/components/checkbox/checkbox.e2e.spec.ts Outdated
Comment thread tests/checkbox/checkbox.spec.tsx Outdated
@qroll
Copy link
Copy Markdown
Contributor

qroll commented Apr 16, 2026

for future PRs: do separate the commits for the different css migration steps. this lets the reviewer view individual commits and makes it easier to spot diffs

Comment thread tests/checkbox/checkbox.spec.tsx Outdated
Comment thread tests/checkbox/checkbox.spec.tsx Outdated
Comment thread tests/checkbox/checkbox.spec.tsx
Comment thread tests/checkbox/checkbox.spec.tsx Outdated
Comment thread tests/checkbox/checkbox.spec.tsx Outdated
Comment thread src/checkbox/checkbox.tsx
Comment thread src/checkbox/types.ts Outdated
Comment thread e2e/tests/components/checkbox/checkbox.e2e.spec.ts Outdated
Comment thread e2e/tests/components/checkbox/checkbox.e2e.spec.ts Outdated
Comment thread e2e/tests/components/checkbox/checkbox.e2e.spec.ts Outdated
@qroll qroll added the type: chore For technical improvements or refactoring. label Apr 16, 2026
@qroll qroll added this to the v4.0.0-alpha.2 milestone Apr 16, 2026
Comment thread src/checkbox/checkbox.styles.ts Outdated
height: 100%;
cursor: pointer;

&[disabled] {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hold up. there's a slight discrepancy here with the logic in master branch

when focusableWhenDisabled is true, the checkbox receives disabled={false} and aria-disabled={true}. meaning this style won't be applied. but we should be expecting 1) no hover style and 2) cursor not-allowed but 3) focus ring preserved

verify with this example

<Checkbox disabled focusableWhenDisabled />

Comment thread tests/checkbox/checkbox.spec.tsx Outdated
Comment on lines +12 to +15
// =========================================================================
// Input behaviour
// =========================================================================
describe("input behaviour", () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this header and this describe block

await compareScreenshot(story, "variants");

await expect(story.layout).toMatchAriaSnapshot(`
- checkbox "Default"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update for the small variant too

Comment thread src/checkbox/checkbox.styles.ts Outdated
color: ${Colour["icon-primary-subtlest"]};
`;

export const uncheckedDisabledIcon = css`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncheckedDisabledIcon and iconDisabled have the same styling. We should just keep to iconDisabled

…led and removing uncheckedDisabledIcon style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: chore For technical improvements or refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants