diff --git a/packages/js/email-editor/src/components/personalization-tags/index.scss b/packages/js/email-editor/src/components/personalization-tags/index.scss index e06699d49e..ba0d92c673 100644 --- a/packages/js/email-editor/src/components/personalization-tags/index.scss +++ b/packages/js/email-editor/src/components/personalization-tags/index.scss @@ -1,3 +1,5 @@ +@import '~@wordpress/base-styles/colors'; + .mailpoet-personalization-tags-modal { p:first-child { margin-top: 0; @@ -17,7 +19,7 @@ .mailpoet-personalization-tags-modal__category-group-item { align-items: stretch; - border-bottom: 1px solid #ddd; + border-bottom: 1px solid var(--wp-components-color-gray-300, #ddd); display: flex; padding: 16px 0; @@ -39,4 +41,33 @@ } } } + + .mailpoet-personalization-tags-modal__menu { + div[role="group"] { + display: flex; + } + + .mailpoet-personalization-tags-modal__menu-item-active { + color: black; + font-weight: bold; + } + + button { + align-items: center; + color: #0a7aff; + display: flex; + gap: 8px; + padding: 6px; + width: auto; + span { + min-width: auto; + } + } + .mailpoet-personalization-tags-modal__menu-separator { + background-color: var(--wp-components-color-gray-700, #757575); + height: 16px; + margin: 10px 4px; + width: 1px; + } + } } diff --git a/packages/js/email-editor/src/components/personalization-tags/personalization-tags-modal.tsx b/packages/js/email-editor/src/components/personalization-tags/personalization-tags-modal.tsx index 44942ed7e4..ff965faa1e 100644 --- a/packages/js/email-editor/src/components/personalization-tags/personalization-tags-modal.tsx +++ b/packages/js/email-editor/src/components/personalization-tags/personalization-tags-modal.tsx @@ -1,11 +1,15 @@ -import { Modal, Button } from '@wordpress/components'; +import * as React from '@wordpress/element'; +import { Modal, Button, MenuGroup, MenuItem } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { PersonalizationTag, storeName } from '../../store'; import { useDispatch, useSelect } from '@wordpress/data'; import { external, Icon } from '@wordpress/icons'; import './index.scss'; +import { useState } from '@wordpress/element'; const PersonalizationTagsModal = () => { + const [ activeCategory, setActiveCategory ] = useState( null ); + const { togglePersonalizationTagsModal } = useDispatch( storeName ); const { isModalOpened, list } = useSelect( @@ -29,6 +33,11 @@ const PersonalizationTagsModal = () => { {} as Record< string, PersonalizationTag[] > ); + const getMenuItemClass = ( category ) => + category === activeCategory + ? 'mailpoet-personalization-tags-modal__menu-item-active' + : ''; + return ( { personalize your emails. Learn more{ ' ' }

- { Object.entries( groupedTags ).map( ( [ category, items ] ) => ( -
+ + setActiveCategory( null ) } + className={ `${ getMenuItemClass( null ) }` } + > + { __( 'All' ) } + + + { Object.entries( groupedTags ).map( + ( [ category ], index, array ) => ( + + setActiveCategory( category ) } + className={ `${ getMenuItemClass( + category + ) }` } + > + { category } + + { index < array.length - 1 && ( + + ) } + + ) + ) } + + { activeCategory === null ? ( + // Render all categories + Object.entries( groupedTags ).map( ( [ category, items ] ) => ( +
+
+ { category } +
+
+ { items.map( ( item ) => ( +
+
+ { item.name } + { item.token } +
+ +
+ ) ) } +
+
+ ) ) + ) : ( + // Render selected category +
- { category } + { activeCategory }
- { items.map( ( item ) => ( + { groupedTags[ activeCategory ]?.map( ( item ) => (
{ ) ) }
- ) ) } + ) } ); };