Add help icon to recent button
MAILPOET-6331
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
cb091e0dc6
commit
cec952fbde
@@ -1,30 +1,53 @@
|
|||||||
import { Button } from '@wordpress/components';
|
import { Button } from '@wordpress/components';
|
||||||
|
import { info } from '@wordpress/icons';
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { TemplateCategory } from '../../store';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
selectedCategory?: TemplateCategory;
|
||||||
|
templateCategories: Array< { name: TemplateCategory; label: string } >;
|
||||||
|
onClickCategory: ( name: TemplateCategory ) => void;
|
||||||
|
};
|
||||||
|
|
||||||
export function TemplateCategoriesListSidebar( {
|
export function TemplateCategoriesListSidebar( {
|
||||||
selectedCategory,
|
selectedCategory,
|
||||||
templateCategories,
|
templateCategories,
|
||||||
onClickCategory,
|
onClickCategory,
|
||||||
} ) {
|
}: Props ) {
|
||||||
const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
|
const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
|
||||||
return (
|
return (
|
||||||
<div className={baseClassName}>
|
<div className={ baseClassName }>
|
||||||
<div className={`${baseClassName}__categories-list`}>
|
<div className={ `${ baseClassName }__categories-list` }>
|
||||||
{templateCategories.map(({ name, label }) => {
|
{ templateCategories.map( ( { name, label } ) => {
|
||||||
return (
|
const isRecentButton = name === 'recent';
|
||||||
<Button
|
return (
|
||||||
key={name}
|
<Button
|
||||||
label={label}
|
key={ name }
|
||||||
className={`${baseClassName}__categories-list__item`}
|
label={ label }
|
||||||
isPressed={selectedCategory === name}
|
className={ `${ baseClassName }__categories-list__item` }
|
||||||
onClick={() => {
|
isPressed={ selectedCategory === name }
|
||||||
onClickCategory(name);
|
onClick={ () => {
|
||||||
}}
|
onClickCategory( name );
|
||||||
>
|
} }
|
||||||
{label}
|
showTooltip={ isRecentButton }
|
||||||
</Button>
|
tooltipPosition="top"
|
||||||
);
|
aria-label="This is some content"
|
||||||
})}
|
icon={ isRecentButton ? info : null }
|
||||||
</div>
|
iconPosition="right"
|
||||||
</div>
|
describedBy={
|
||||||
);
|
isRecentButton
|
||||||
|
? __(
|
||||||
|
'Templates created on the legacy editor will not appear here',
|
||||||
|
'mailpoet'
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{ label }
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
} ) }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,15 @@ import {
|
|||||||
} from '@wordpress/components';
|
} from '@wordpress/components';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { Async } from './async';
|
import { Async } from './async';
|
||||||
|
import { TemplateCategory, TemplatePreview } from '../../store';
|
||||||
|
|
||||||
function TemplateListBox( { templates, onTemplateSelection } ) {
|
type Props = {
|
||||||
|
templates: TemplatePreview[];
|
||||||
|
onTemplateSelection: ( template: TemplatePreview ) => void;
|
||||||
|
selectedCategory?: TemplateCategory;
|
||||||
|
};
|
||||||
|
|
||||||
|
function TemplateListBox( { templates, onTemplateSelection }: Props ) {
|
||||||
return (
|
return (
|
||||||
<div className="block-editor-block-patterns-list" role="listbox">
|
<div className="block-editor-block-patterns-list" role="listbox">
|
||||||
{ templates.map( ( template ) => (
|
{ templates.map( ( template ) => (
|
||||||
@@ -63,7 +70,7 @@ export function TemplateList( {
|
|||||||
templates,
|
templates,
|
||||||
onTemplateSelection,
|
onTemplateSelection,
|
||||||
selectedCategory,
|
selectedCategory,
|
||||||
} ) {
|
}: Props ) {
|
||||||
const filteredTemplates = useMemo(
|
const filteredTemplates = useMemo(
|
||||||
() =>
|
() =>
|
||||||
templates.filter(
|
templates.filter(
|
||||||
|
Reference in New Issue
Block a user