themes
themes copied to clipboard
Feature/382 refactor theme panel component
Description
Main changes:
- Allow passing optional
openandonOpenChangeprops to theThemePanelcomponent using theuseControllableStatehook - Simplify setup by merging
ThemePanelandThemePanelImplcomponents. Remove redundant interfaces - Move common logic related to hotkeys into a custom
useHotKeyhook (no external dependencies) - Allow overriding default open/appearance hotkeys using optional
openHotkeyandtoogleAppearanceHotkeyprops - Allow passing
nullorfalseto disable a hotkey - Hide the top-right open hotkey button when
openHotkeyis null
Things to improve in the future:
- Allow passing combination of keys like
Control + ForShift + H -
useHotKeyimplementation is very barebones. Consider using a library like react-hotkeys-hook
Testing steps
Use cases:
- Controlled behaviour:
const [open, setOpen] = useState(false);
return <ThemePanel open={open} onOpenChange={setOpen} />
- Custom hotkeys:
return <ThemePanel openHotkey="P" toogleAppearanceHotkey="/" />
- Disabling hotkeys:
return <ThemePanel openHotkey={null} toogleAppearanceHotkey={false} />
Relates issues / PRs
Refs #382
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| themes-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Mar 20, 2024 10:24am |
Hi! Just wanted to weigh in here since we've had a little maintainer shuffle since this PR was opened.
Any chance we could break this into two separate, stacked PRs? I'd like to consider each new feature independently since there's a little unresolved feedback. Specifically it'd be nice to see it broken into three:
- Making
ThemePaneluse controllable state - New
useHotKeyhook - Allow for customizing/disabling hotkeys (and hiding the hotkey button accordingly)
I know it's been a while, so totally understand if you've moved on. Happy to take this as a feature request and re-implement if we decide to move forward.