-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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(react-swatch-picker): Added borderColor prop and fixed styles #31358
feat(react-swatch-picker): Added borderColor prop and fixed styles #31358
Conversation
3674ecb
to
46e3bfc
Compare
📊 Bundle size report
🤖 This report was generated against 79b73d920ef1a89e5daff165f28f0afe966afb01 |
packages/react-components/react-swatch-picker-preview/src/utils/contrastUtils.ts
Outdated
Show resolved
Hide resolved
...nts/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerContrastBorders.stories.tsx
Outdated
Show resolved
Hide resolved
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
change/@fluentui-react-swatch-picker-preview-3c1d6888-87ae-4c23-8e52-31fd298123de.json
Show resolved
Hide resolved
...nts/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerContrastBorders.stories.tsx
Outdated
Show resolved
Hide resolved
packages/react-components/react-swatch-picker-preview/src/utils/contrastUtils.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's ensure that we have the best possible behavior built-in, at least for
ColorSwatch
it seems to be achievable - We need to have color computations under
useEffect
(probablyuseLayoutEffect()
to avoid flickering)- I would propose something like that (we will avoid state updates i.e. re-renders 👍 ):
const { color } = props const ref = React.useRef(); React.useLayoutEffect(() => { const constrastColor = DO_SOMETHING(color); ref.current.style.setProperty('--fui-switch-SMTH', constrastColor); }, [color])
- We need to handle scenarios with CSS variables
- We need more powerful color parsing to handle cases not only for
rgb()
or HEX values. color-parse looks promising (5kb minified)
...nts/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerContrastBorders.stories.tsx
Outdated
Show resolved
Hide resolved
...nts/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerContrastBorders.stories.tsx
Outdated
Show resolved
Hide resolved
Yeah, it's a good idea. We'll add those after going stable |
New Behavior
Added contrast utils and testsdisabled
iconAdded example with low contrast colors