Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cssStyler option to use typed CSSStyleDeclaration props #148

Merged
merged 1 commit into from
Nov 5, 2023

Conversation

ghiscoding
Copy link
Owner

@ghiscoding ghiscoding commented Nov 5, 2023

deprecate styler in favor of a new cssStyler which have better typing support and can use direct assignment. The previous use of innerHTML made it easier to use styler but now that we switched to pure HTML Element, it is better to use CSSStyleDeclaration props. Since we moved to pure HTML Element, the styler is requiring a bit more logic, since we now have to do string split of semicolon ;, then use toCamelCase for CSS assignment... which is why the new cssStyler is better since we can simply loop through all styling props and assign directly

Styler (deprecated)

styler: (row: OptionRowData | OptGroupRowData) => {
      if (row?.type === 'optgroup') {
          return 'color: #777; font-weight: normal;';
      }
}

CssStyler (new)

styler: (row: OptionRowData | OptGroupRowData) => {
      if (row?.type === 'optgroup') {
          return { backgroundColor: '#972727', color: '#fff' } as CSSStyleDeclaration;
      }
}

Copy link

github-actions bot commented Nov 5, 2023

🎭 Playwright Summary - Success 🎉

Playwright Report

[email protected] test:e2e /home/runner/work/multiple-select-vanilla/multiple-select-vanilla
playwright test --config playwright/playwright.config.ts

Running 67 tests using 1 worker
···································································
67 passed (2.4m)

@ghiscoding ghiscoding merged commit 8ad2b28 into main Nov 5, 2023
2 checks passed
@ghiscoding ghiscoding deleted the feat/css-styler branch November 5, 2023 07:42
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.

1 participant