-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Souptik Datta <[email protected]>
- Loading branch information
1 parent
ee97861
commit 9c9d05c
Showing
3 changed files
with
66 additions
and
0 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,18 @@ | ||
{ | ||
"name": "example/color-settings-example", | ||
"title": "Color Settings Component Example", | ||
"description": "Example Block to show the Color settings component", | ||
"icon": "smiley", | ||
"category": "common", | ||
"example": {}, | ||
"supports": { | ||
"html": false | ||
}, | ||
"attributes": { | ||
"color": { | ||
"type": "string" | ||
} | ||
}, | ||
"variations": [], | ||
"editorScript": "file:./index.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import { InspectorControls } from '@wordpress/block-editor'; | ||
import { PanelBody } from '@wordpress/components'; | ||
|
||
import { ColorSetting } from '@10up/block-components'; | ||
|
||
export const BlockEdit = (props) => { | ||
const { | ||
attributes: { color }, | ||
setAttributes | ||
} = props; | ||
|
||
const colors = [ | ||
{ name: 'red', color: '#f00' }, | ||
{ name: 'white', color: '#fff' }, | ||
{ name: 'blue', color: '#00f' }, | ||
]; | ||
return ( | ||
<> | ||
<InspectorControls> | ||
<PanelBody title={ __( 'Post Picker', 'example' ) }> | ||
<ColorSetting | ||
label={ __( 'Color Setting - Label', 'example' ) } | ||
help={ __( 'Color Setting - Help Text', 'example' ) } | ||
colors={ colors } | ||
value={ color } | ||
onChange={ ( val ) => setAttributes( { color: val } ) } | ||
/> | ||
</PanelBody> | ||
</InspectorControls> | ||
<ColorSetting | ||
label={ __( 'Color Setting - Label', 'example' ) } | ||
help={ __( 'Color Setting - Help Text', 'example' ) } | ||
colors={ colors } | ||
value={ color } | ||
onChange={ ( val ) => setAttributes( { color: val } ) } | ||
/> | ||
</> | ||
) | ||
} |
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,8 @@ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
import metadata from './block.json'; | ||
import { BlockEdit } from './edit'; | ||
|
||
registerBlockType( metadata, { | ||
edit: BlockEdit, | ||
save: () => null | ||
} ); |