Skip to content

Commit

Permalink
Merge pull request #2255 from Codeinwp/fix/issue-208
Browse files Browse the repository at this point in the history
Experiment with formats in the toolbar
  • Loading branch information
HardeepAsrani authored Jul 30, 2024
2 parents edf69f5 + 0350644 commit b0e3302
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 19 deletions.
16 changes: 16 additions & 0 deletions src/blocks/plugins/dynamic-content/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ o-dynamic-link {
cursor: pointer;
}

.components-toolbar {
.o-dynamic-button {
opacity: 1;

&.is-pressed {
&::before {
background: rgba(237, 111, 87, 0.1);
}
}

svg {
fill: #ED6F57;
}
}
}

.wp-block.is-selected o-dynamic,
.wp-block:not(.is-selected) o-dynamic:not([data-preview]),
.wp-block:not(.is-selected) o-dynamic[data-preview=""] {
Expand Down
29 changes: 19 additions & 10 deletions src/blocks/plugins/dynamic-content/link/edit.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/**
* External dependencies.
*/
import { globe } from '@wordpress/icons';
import { link } from '@wordpress/icons';

/**
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';

import { RichTextToolbarButton } from '@wordpress/block-editor';
import { BlockControls } from '@wordpress/block-editor';

import { Modal } from '@wordpress/components';
import {
Modal,
ToolbarButton,
ToolbarGroup
} from '@wordpress/components';

import { useSelect } from '@wordpress/data';

Expand Down Expand Up @@ -92,13 +96,18 @@ const Edit = ({

return (
<Fragment>
<RichTextToolbarButton
icon={ globe }
title={ __( 'Dynamic Link', 'otter-blocks' ) }
onClick={ () => setOpen( true ) }
isDisabled={ isActive }
isActive={ isActive }
/>
<BlockControls>
<ToolbarGroup>
<ToolbarButton
icon={ link }
title={ __( 'Dynamic Link', 'otter-blocks' ) }
onClick={ () => setOpen( true ) }
isDisabled={ isActive }
isActive={ isActive }
className="o-dynamic-button"
/>
</ToolbarGroup>
</BlockControls>

{ isOpen && (
<Modal
Expand Down
27 changes: 18 additions & 9 deletions src/blocks/plugins/dynamic-content/value/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import { globe } from '@wordpress/icons';
*/
import { __ } from '@wordpress/i18n';

import { RichTextToolbarButton } from '@wordpress/block-editor';
import { BlockControls } from '@wordpress/block-editor';

import { Modal } from '@wordpress/components';
import {
Modal,
ToolbarButton,
ToolbarGroup
} from '@wordpress/components';

import { useSelect } from '@wordpress/data';

Expand Down Expand Up @@ -109,13 +113,18 @@ const Edit = ({

return (
<Fragment>
<RichTextToolbarButton
icon={ globe }
title={ __( 'Dynamic Value', 'otter-blocks' ) }
onClick={ () => setOpen( true ) }
isDisabled={ isActive }
isActive={ isActive }
/>
<BlockControls>
<ToolbarGroup>
<ToolbarButton
icon={ globe }
title={ __( 'Dynamic Value', 'otter-blocks' ) }
onClick={ () => setOpen( true ) }
isDisabled={ isActive }
isActive={ isActive }
className="o-dynamic-button"
/>
</ToolbarGroup>
</BlockControls>

{ isOpen && (
<Modal
Expand Down

0 comments on commit b0e3302

Please sign in to comment.