-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make user able to change all color palette origins
- Loading branch information
1 parent
914c9c9
commit fb6d2fa
Showing
5 changed files
with
311 additions
and
236 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
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
64 changes: 57 additions & 7 deletions
64
packages/edit-site/src/components/global-styles/color-palette-panel.js
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 |
---|---|---|
@@ -1,22 +1,72 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __experimentalColorEdit as ColorEdit } from '@wordpress/components'; | ||
import { | ||
__experimentalColorEdit as ColorEdit, | ||
__experimentalVStack as VStack, | ||
} from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useSetting } from './hooks'; | ||
|
||
export default function ColorPalettePanel( { name } ) { | ||
const [ userColors, setColors ] = useSetting( | ||
'color.palette', | ||
const [ themeColors, setThemeColors ] = useSetting( | ||
'color.palette.theme', | ||
name | ||
); | ||
const [ baseThemeColors ] = useSetting( | ||
'color.palette.theme', | ||
name, | ||
'user' | ||
'base' | ||
); | ||
const [ defaultColors, setDefaultColors ] = useSetting( | ||
'color.palette.default', | ||
name | ||
); | ||
const [ baseDefaultColors ] = useSetting( | ||
'color.palette.default', | ||
name, | ||
'base' | ||
); | ||
const [ customColors, setCustomColors ] = useSetting( | ||
'color.palette.user', | ||
name | ||
); | ||
return ( | ||
<div className="edit-site-global-styles-color-palette-panel"> | ||
<ColorEdit colors={ userColors } onChange={ setColors } /> | ||
</div> | ||
<VStack | ||
className="edit-site-global-styles-color-palette-panel" | ||
spacing={ 10 } | ||
> | ||
{ !! themeColors && !! themeColors.length && ( | ||
<ColorEdit | ||
canReset={ themeColors !== baseThemeColors } | ||
canOnlyChangeValues | ||
colors={ themeColors } | ||
onChange={ setThemeColors } | ||
paletteLabel={ __( 'Theme' ) } | ||
/> | ||
) } | ||
{ !! defaultColors && !! defaultColors.length && ( | ||
<ColorEdit | ||
canReset={ defaultColors !== baseDefaultColors } | ||
canOnlyChangeValues | ||
colors={ defaultColors } | ||
onChange={ setDefaultColors } | ||
paletteLabel={ __( 'Default' ) } | ||
/> | ||
) } | ||
<ColorEdit | ||
colors={ customColors } | ||
onChange={ setCustomColors } | ||
paletteLabel={ __( 'Custom' ) } | ||
emptyMessage={ __( | ||
'Custom colors are empty! Add some colors to create your own color palette.' | ||
) } | ||
slugPrefix="custom-" | ||
/> | ||
</VStack> | ||
); | ||
} |
Oops, something went wrong.