Skip to content

Commit 5f9add9

Browse files
Merge branch '6.2' into 6
2 parents ecb1821 + 6966f0f commit 5f9add9

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

client/dist/js/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/components/ElementEditor/AddElementPopover.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import backend from 'lib/Backend';
1313
import Config from 'lib/Config';
1414
import { ElementEditorContext } from 'components/ElementEditor/ElementEditor';
1515
import getJsonErrorMessage from 'lib/getJsonErrorMessage';
16+
import ElementOptionButton from './ElementOptionButton';
1617

1718
/**
1819
* The AddElementPopover component used in the context of an ElementEditor shows the
@@ -77,10 +78,10 @@ const AddElementPopover = ({
7778
);
7879

7980
const buttons = elementTypes.map((elementType) => ({
80-
content: <span className="btn__title">{elementType.title}</span>,
81+
content: elementType.title,
8182
key: elementType.name,
8283
className: classNames('btn--icon-xl', 'element-editor-add-element__button'),
83-
icon: elementType.icon.replace(/^(font-icon-)/g, ''),
84+
icon: elementType.icon,
8485
onClick: getElementButtonClickHandler(elementType),
8586
}));
8687

@@ -94,6 +95,7 @@ const AddElementPopover = ({
9495
placement={placement}
9596
target={target}
9697
toggle={handleToggle}
98+
ButtonComponent={ElementOptionButton}
9799
/>
98100
);
99101
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import { Button as BaseButton } from 'reactstrap';
3+
import classnames from 'classnames';
4+
import PropTypes from 'prop-types';
5+
6+
const ElementOptionButton = ({
7+
icon,
8+
className,
9+
noText = false,
10+
children,
11+
...props
12+
}) =>
13+
(<BaseButton
14+
className={classnames(className, { 'btn--no-text': noText })}
15+
aria-label={noText ? children : undefined}
16+
{...props}
17+
>
18+
{icon && <span className={`btn__icon ${icon}`} aria-hidden="true" />}
19+
{noText ? undefined : <span className="btn__title">{children}</span>}
20+
</BaseButton>);
21+
22+
ElementOptionButton.propTypes = {
23+
...BaseButton.propTypes,
24+
noText: PropTypes.bool,
25+
icon: PropTypes.string,
26+
};
27+
28+
ElementOptionButton.defaultProps = {
29+
...BaseButton.defaultProps,
30+
noText: false
31+
};
32+
33+
export default ElementOptionButton;

0 commit comments

Comments
 (0)