-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(theme-toolbar): add theme selection toolbar for customizable themes
- Loading branch information
1 parent
38f9995
commit 868041f
Showing
3 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useBoard } from '@plait/react-board'; | ||
import classNames from 'classnames'; | ||
import { | ||
ATTACHED_ELEMENT_CLASS_NAME, | ||
BoardTransforms, | ||
ThemeColorMode, | ||
} from '@plait/core'; | ||
import { Island } from '../island'; | ||
|
||
export const ThemeToolbar = () => { | ||
const board = useBoard(); | ||
const theme = board.theme; | ||
return ( | ||
<Island | ||
padding={1} | ||
className={classNames('theme-toolbar', ATTACHED_ELEMENT_CLASS_NAME)} | ||
> | ||
<select | ||
onChange={(e) => { | ||
const value = (e.target as HTMLSelectElement).value; | ||
BoardTransforms.updateThemeColor(board, value as ThemeColorMode); | ||
}} | ||
value={theme.themeColorMode} | ||
> | ||
<option value="default">默认</option> | ||
<option value="colorful">缤纷</option> | ||
<option value="soft">柔和</option> | ||
<option value="retro">复古</option> | ||
<option value="dark">暗夜</option> | ||
<option value="starry">星空</option> | ||
</select> | ||
</Island> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters