-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63654cf
commit f2554fb
Showing
8 changed files
with
6,597 additions
and
14,993 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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
.gumponents-icon-picker-control { | ||
|
||
&__modal { | ||
width: 534px; | ||
height: 500px; | ||
max-height: 80%; | ||
} | ||
|
||
&__icons { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 20px; | ||
} | ||
|
||
&__icon { | ||
width: 50px; | ||
height: 50px; | ||
display: flex; | ||
place-items: center; | ||
border: 1px solid rgb(221, 221, 221); | ||
border-radius: 8px; | ||
cursor: pointer; | ||
|
||
svg { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
} |
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,132 @@ | ||
import './editor.scss'; | ||
|
||
import wp from 'wp'; | ||
|
||
const { __ } = wp.i18n; | ||
const { | ||
Modal, | ||
Button, | ||
BaseControl, | ||
Icon, | ||
} = wp.components; | ||
const { | ||
useState, | ||
} = wp.element; | ||
|
||
function IconPickerControl( { value, help, modalTitle = __( 'Select Icon' ), label = __( 'Select icon' ), buttonLabel = __( 'Select icon' ), removeLabel = __( 'Remove icon' ) } ) { | ||
const [ modalOpen, setModalOpen ] = useState( true ); | ||
|
||
/** | ||
* Open modal. | ||
*/ | ||
const openModal = () => { | ||
setModalOpen( true ); | ||
}; | ||
|
||
return ( | ||
<> | ||
<BaseControl | ||
help={ help } | ||
label={ label } | ||
className="gumponents-icon-picker-control" | ||
> | ||
<Button | ||
isSecondary | ||
onClick={ openModal } | ||
> | ||
{ buttonLabel } | ||
</Button> | ||
|
||
{ value && | ||
<Button onClick={ null } isLink isDestructive> | ||
{ removeLabel } | ||
</Button> | ||
} | ||
</BaseControl> | ||
{ modalOpen && | ||
<Modal | ||
title={modalTitle} | ||
className="gumponents-icon-picker-control__modal" | ||
onRequestClose={() => setModalOpen(false)} | ||
> | ||
<div className="gumponents-icon-picker-control__icons"> | ||
<div className="gumponents-icon-picker-control__icon" role="button"> | ||
<Icon | ||
icon={() => ( | ||
<svg> | ||
<path d="M5 4v3h5.5v12h3V7H19V4z"/> | ||
</svg> | ||
)} | ||
/> | ||
</div> | ||
<div className="gumponents-icon-picker-control__icon" role="button"> | ||
<Icon | ||
icon={() => ( | ||
<svg> | ||
<path d="M5 4v3h5.5v12h3V7H19V4z"/> | ||
</svg> | ||
)} | ||
/> | ||
</div> | ||
<div className="gumponents-icon-picker-control__icon" role="button"> | ||
<Icon | ||
icon={() => ( | ||
<svg> | ||
<path d="M5 4v3h5.5v12h3V7H19V4z"/> | ||
</svg> | ||
)} | ||
/> | ||
</div> | ||
<div className="gumponents-icon-picker-control__icon" role="button"> | ||
<Icon | ||
icon={() => ( | ||
<svg> | ||
<path d="M5 4v3h5.5v12h3V7H19V4z"/> | ||
</svg> | ||
)} | ||
/> | ||
</div> | ||
<div className="gumponents-icon-picker-control__icon" role="button"> | ||
<Icon | ||
icon={() => ( | ||
<svg> | ||
<path d="M5 4v3h5.5v12h3V7H19V4z"/> | ||
</svg> | ||
)} | ||
/> | ||
</div> | ||
<div className="gumponents-icon-picker-control__icon" role="button"> | ||
<Icon | ||
icon={() => ( | ||
<svg> | ||
<path d="M5 4v3h5.5v12h3V7H19V4z"/> | ||
</svg> | ||
)} | ||
/> | ||
</div> | ||
<div className="gumponents-icon-picker-control__icon" role="button"> | ||
<Icon | ||
icon={() => ( | ||
<svg> | ||
<path d="M5 4v3h5.5v12h3V7H19V4z"/> | ||
</svg> | ||
)} | ||
/> | ||
</div> | ||
</div> | ||
<div className="gumponents-icon-picker-control__buttons"> | ||
<Button | ||
isDefault | ||
onClick={ () => setModalOpen( false ) } | ||
> | ||
Select | ||
</Button> | ||
</div> | ||
</Modal> | ||
} | ||
</> | ||
); | ||
} | ||
|
||
export default IconPickerControl; | ||
|
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
Oops, something went wrong.