-
Notifications
You must be signed in to change notification settings - Fork 90
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
POC: feat: add mode updater to SaltTheme #3237
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { window, ...contextWithoutWindow } = useContext(ThemeContext); | ||
|
||
return contextWithoutWindow; | ||
return contextWithoutWindow as ThemeContextValue; |
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.
setMode
should always be available from useTheme
.
() => ({ | ||
theme: themeName, | ||
mode, | ||
window: targetWindow, | ||
themeNext: Boolean(themeNext), | ||
UNSTABLE_corner: corner, | ||
setMode, |
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.
I don't think we need to include this in the dep array as React guarantees stable refs for useState setters
dc4f795
to
7b415b1
Compare
Storybook Preview Link https://1623b85b.saltdesignsystem-storybook.pages.dev |
const breakpoints = breakpointsProp ?? DEFAULT_BREAKPOINTS; | ||
const corner = cornerProp ?? inheritedCorner ?? DEFAULT_CORNER; | ||
const [mode, setMode] = useState<Mode>(modeProp ?? inheritedMode); |
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.
Should this be made using useControlled
....?
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.
sure I can switch to that
7b415b1
to
ab0e3a3
Compare
ab0e3a3
to
f4fe967
Compare
Provide user's with the ability to update the theme mode.
The
SaltProvider
keeps the thememode
in state and injectssetMode
into the theme context value.This allows the mode to be changed via a setter pulled from
useTheme()
Marked as POC as I am a bit unsure about the TS types. Have a look at those please.