Skip to content

Commit 14938d4

Browse files
author
eriviere
committed
feat: allow custom icons in call outs
1 parent 82120e8 commit 14938d4

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dataesr/react-dsfr",
3-
"version": "3.4.3",
3+
"version": "3.5.0",
44
"private": false,
55
"description": "A React implementation of the french government design system.",
66
"license": "MIT",

src/components/interface/Callout/Callout.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ import '@gouvfr/dsfr/dist/component/callout/callout.css';
1212
* @visibleName Callout
1313
*/
1414
const Callout = ({
15-
hasInfoIcon, children, className, colorFamily, colors, ...remainingProps
15+
hasInfoIcon, icon, children, className, colorFamily, colors, ...remainingProps
1616
}) => {
17+
if (!hasInfoIcon) { // TODO Delete deprecated prop hasInfoIcon when reaching major version 4.0.0
18+
// eslint-disable-next-line no-console
19+
console.warn("'hasInfoIcon' is deprecated and will be deleted in version 4.0.0. Please use 'icon' instead", hasInfoIcon);
20+
// eslint-disable-next-line no-param-reassign
21+
icon = undefined;
22+
}
23+
1724
const theme = useTheme();
1825
const [color, backgroundColor] = colors;
1926
const calloutRef = useRef();
2027
const _className = classNames('fr-callout', className, {
21-
'fr-fi-information-line': hasInfoIcon,
28+
[`fr-fi-${icon}`]: icon,
2229
[`fr-callout--${colorFamily}`]: colorFamily,
2330
});
2431

@@ -45,13 +52,15 @@ const Callout = ({
4552
};
4653

4754
Callout.defaultProps = {
55+
icon: 'information-line',
4856
hasInfoIcon: true,
4957
className: '',
5058
colors: [],
5159
colorFamily: '',
5260
};
5361

5462
Callout.propTypes = {
63+
icon: PropTypes.string,
5564
hasInfoIcon: PropTypes.bool,
5665
colorFamily: PropTypes.oneOf([...colorFamilies, '']),
5766
/**

0 commit comments

Comments
 (0)