Skip to content

Commit

Permalink
change(text-align): align value map now allows passing title values a…
Browse files Browse the repository at this point in the history
…s third parameter

- this way the user can pass its own align value map and the icon will use
  the title otherwise it fallbacks to the name id
  • Loading branch information
ichim-david committed Oct 27, 2022
1 parent b4eade9 commit fc26773
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Widgets/TextAlign.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import alignJustifySVG from '@plone/volto/icons/align-justify.svg';
import alignCenterSVG from '@plone/volto/icons/align-center.svg';
import clearSVG from '@plone/volto/icons/clear.svg';

const VALUE_MAP = [
['left', alignLeftSVG],
['right', alignRightSVG],
['center', alignCenterSVG],
['justify', alignJustifySVG],
['', clearSVG],
export const TEXT_ALIGN_VALUE_MAP = [
['left', alignLeftSVG, 'Left align'],
['right', alignRightSVG, 'Right align'],
['center', alignCenterSVG, 'Center align'],
['justify', alignJustifySVG, 'Justify align'],
['', clearSVG, 'Clear selection'],
];

export default (props) => {
const { value, onChange, id, actions = VALUE_MAP } = props;
const { value, onChange, id, actions = TEXT_ALIGN_VALUE_MAP } = props;
return (
<FormFieldWrapper {...props}>
<div className="align-tools">
{actions.map(([name, icon], index) => (
{actions.map(([name, icon, title], index) => (
<Button.Group key={`button-group-${name}-${index}`}>
<Button
icon
Expand All @@ -33,7 +33,7 @@ export default (props) => {
onChange(id, name);
}}
>
<Icon name={icon} size="24px" />
<Icon name={icon} title={title || name} size="24px" />
</Button>
</Button.Group>
))}
Expand Down

0 comments on commit fc26773

Please sign in to comment.