Skip to content

[BOOKINGSG-9157] refactor: migrate dropdown-list to linaria and v4 tokens#1107

Open
ziggyzet wants to merge 5 commits intopre-release/v4from
ZZ/B9157
Open

[BOOKINGSG-9157] refactor: migrate dropdown-list to linaria and v4 tokens#1107
ziggyzet wants to merge 5 commits intopre-release/v4from
ZZ/B9157

Conversation

@ziggyzet
Copy link
Copy Markdown

@ziggyzet ziggyzet commented Apr 17, 2026

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

Additional information

  • For some reason, the tokens doesn't work if it's formatted in the following way: calc(var(<TOKEN>))
  • Not sure if applying style for Virtuoso components using the useApplyStyles hook is a must
  • Updated the usage in language-switcher
  • There was an error before the migration regarding the Virtuoso component while running the unit test. It doesn't fail the tests and haven't made changes to fix it.

@ghazwan-gt
Copy link
Copy Markdown

image There's a different result on `RangeSelect`

);
max-height: min(
27rem,
var(--fds-internal-dropdown-list-container-available-height, 9999px)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can check whether this is related to the one in ElementWithDropdown:191


useApplyStyle(nodeRef, {
...floatingStyles,
...containerWidthStyle,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

useApplyStyle will applied the value as string and containerWidthStyle seems to be a pure number, this will make the resulting value missing unit.

// =========================================================================

useApplyStyle(nodeRef, {
...floatingStyles,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inside floatingStyles, we have zIndex and useApplyStyle currently not able to map camelCase zIndex to z-index. We likely don't have it in the result

<BasicInput
ref={ref}
value={value}
variant={variant}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shouldn't we keep this to handle small variant font?

Comment on lines +49 to +54
export const secondaryText = css`
${tokens.secondaryText.maxLines}: 2;
color: ${Colour["text-subtlest"]};
width: 100%;
overflow-wrap: break-word;
`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maxLines token, width, and overflow-wrap can be extracted to a general text class name

Comment on lines +14 to +16
xSpacing: "--fds-internal-dropdown-list-container-x-spacing",
availableWidth: "--fds-internal-dropdown-list-container-available-width",
availableHeight: "--fds-internal-dropdown-list-container-available-height",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
xSpacing: "--fds-internal-dropdown-list-container-x-spacing",
availableWidth: "--fds-internal-dropdown-list-container-available-width",
availableHeight: "--fds-internal-dropdown-list-container-available-height",
xSpacing: "--fds-internal-dropdownList-container-xSpacing",
availableWidth: "--fds-internal-dropdownList-container-availableWidth",
availableHeight: "--fds-internal-dropdownList-container-availableHeight",

Comment on lines +134 to +136
flex-shrink: 0;
height: 1lh;
width: 1rem;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can extract these three attributes as a general indicator class name, then have another variants for adding the color

Comment on lines +179 to +183
cursor: pointer;
overflow: hidden;
color: ${Colour["text-primary"]};
font-size: inherit;
${Font["body-baseline-semibold"]}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similar to selectAllButton, can have another class name for padded one

Comment on lines +122 to +126
const containerWidthStyle: React.CSSProperties = width
? { width }
: matchElementWidth && elementWidth
? { width: elementWidth }
: {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we avoid having a nested ternary, it has bad readability

className={clsx(
styles.listItem,
disabled && styles.listItemDisabled,
active && selected && styles.listItemActiveSelected,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can't we have selected as the only condition?

$disabled={!selected && hasSelectedMax}
className={clsx(
styles.listItem,
disabled && styles.listItemDisabled,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should also check when it is not active.

On this limit selection example of MultiSelect, disabled option still have that active background on hover
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants