Skip to content

Commit fc26773

Browse files
committed
change(text-align): align value map now allows passing title values as 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
1 parent b4eade9 commit fc26773

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Widgets/TextAlign.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ import alignJustifySVG from '@plone/volto/icons/align-justify.svg';
88
import alignCenterSVG from '@plone/volto/icons/align-center.svg';
99
import clearSVG from '@plone/volto/icons/clear.svg';
1010

11-
const VALUE_MAP = [
12-
['left', alignLeftSVG],
13-
['right', alignRightSVG],
14-
['center', alignCenterSVG],
15-
['justify', alignJustifySVG],
16-
['', clearSVG],
11+
export const TEXT_ALIGN_VALUE_MAP = [
12+
['left', alignLeftSVG, 'Left align'],
13+
['right', alignRightSVG, 'Right align'],
14+
['center', alignCenterSVG, 'Center align'],
15+
['justify', alignJustifySVG, 'Justify align'],
16+
['', clearSVG, 'Clear selection'],
1717
];
1818

1919
export default (props) => {
20-
const { value, onChange, id, actions = VALUE_MAP } = props;
20+
const { value, onChange, id, actions = TEXT_ALIGN_VALUE_MAP } = props;
2121
return (
2222
<FormFieldWrapper {...props}>
2323
<div className="align-tools">
24-
{actions.map(([name, icon], index) => (
24+
{actions.map(([name, icon, title], index) => (
2525
<Button.Group key={`button-group-${name}-${index}`}>
2626
<Button
2727
icon
@@ -33,7 +33,7 @@ export default (props) => {
3333
onChange(id, name);
3434
}}
3535
>
36-
<Icon name={icon} size="24px" />
36+
<Icon name={icon} title={title || name} size="24px" />
3737
</Button>
3838
</Button.Group>
3939
))}

0 commit comments

Comments
 (0)