-
Notifications
You must be signed in to change notification settings - Fork 93
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: migrate theme popover to v9 #3442
Conversation
}; | ||
return ( | ||
<RadioGroup layout="horizontal" aria-labelledby='theme-chooser' | ||
defaultValue={availableThemes.find(theme => theme.key === appTheme)?.displayName} |
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.
Fantastic work so far!
There's a console warning that draws attention to the implementation you have here
My understanding is that you can't use defaultValue
and checked
at the same time. My recomendation here is to:
- use the
onChange
listener onRadioGroup
and remove thedefaultValue
forvalue
. - You can then create a state
value
which defaults to theappTheme
, and use all the implementation ofhandleChangeTheme
aftersetValue(data.value)
. Something like this:
const [value, setValue] = useState(appTheme);
// some stuff
<RadioGroup value={value} onChange={(_, data) =>{
const newTheme: string = data.value
setValue(newTheme)
// Applies the theme to the Fluent UI components
dispatch(changeTheme(newTheme));
loadGETheme(newTheme); //Remove when cleaning up
telemetry.trackEvent(eventTypes.BUTTON_CLICK_EVENT, {
ComponentName: componentNames.SELECT_THEME_BUTTON,
SelectedTheme: newTheme.replace('-', ' ').toSentenceCase()
});
}}>
// other stuff
- Remove
checked
andonClick
onRadio
.
Borrowed this from https://react.fluentui.dev/?path=/docs/components-radiogroup--docs#controlled-value
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'm currently unable to test this locally, but I'm curious if removing the Radio Checked on ln 71 in current implementation would have a similar warning. Per https://react.fluentui.dev/?path=/docs/components-radiogroup--docs#default-value, only either the default Value or the checked can be used
Noticed the close button is no longer there, shouldn't we still keep it? but just as a regular button? |
@ElinorW since clicking outside the popover closes it, I wonder if we should keep it. |
Hmm good point, the same behaviour is there in the current version as well. |
import { translateMessage } from '../../../utils/translate-messages'; | ||
import { BrightnessHighRegular, WeatherMoonFilled, CircleHalfFillFilled } from '@fluentui/react-icons'; | ||
|
||
const availableThemes = [ |
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.
Since you've added system theme support, make it an option and probably the default selected.
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.
It's the default selected ln70-75
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.
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.
In App.tsx
, we want to do two things:
- Get the current theme or load the system theme and set it. Allows us to set the theme on app load.
- Create a listener to the theme changes. Allows us to change our theme if a user changes the theme from their system. Something like this:
const mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)'); // Add the listener for theme changes mediaQueryList.addEventListener('change', handleThemeChange);
What do you think?
Yeah @musale, I noticed the theme was only picked when interacting with theme chooser, currently implementing this. |
Quality Gate passedIssues Measures |
Overview
Brief description of what this PR does, and why it is needed.
Closes #3439
Closes #3383
Demo
Optional. Screenshots,
curl
examples, etc.Notes
Optional. Ancillary topics, caveats, alternative strategies that didn't work out, anything else.
Testing Instructions