Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/src/components/Callout/Callout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const CalloutExample = () => (
</Callout>
</Col>
<Col n="12" spacing="py-2w">
<Callout>
<Callout icon={null}>
<CalloutTitle>Mise en avant</CalloutTitle>
<CalloutText>Callout text that might be short and concise.</CalloutText>
</Callout>
Expand Down
4 changes: 4 additions & 0 deletions src/components/interface/Callout/Callout.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export type CalloutColorFamily = 'green-tilleul-verveine' | 'green-bourgeon' | '
export type CalloutChildren = React.ReactNode[] | React.ReactNode;

export interface CalloutProps {
/**
* @deprecated The method should not be used
*/
hasInfoIcon?: boolean;
icon?: Nullable<string>;
colorFamily?: CalloutColorFamily;
/**
* first color is color of the border, second is background
Expand Down
16 changes: 14 additions & 2 deletions src/components/interface/Callout/Callout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ import '@gouvfr/dsfr/dist/component/callout/callout.css';
* @visibleName Callout
*/
const Callout = ({
hasInfoIcon, children, className, colorFamily, colors, ...remainingProps
hasInfoIcon, icon, children, className, colorFamily, colors, ...remainingProps
}) => {
if (!hasInfoIcon) { // TODO Delete deprecated prop hasInfoIcon when reaching major version 4.0.0
// eslint-disable-next-line no-console
console.warn("'hasInfoIcon' is deprecated and will be deleted in version 4.0.0. Please use 'icon' instead", hasInfoIcon);
// eslint-disable-next-line no-param-reassign
icon = undefined;
}

const theme = useTheme();
const [color, backgroundColor] = colors;
const calloutRef = useRef();
const _className = classNames('fr-callout', className, {
'fr-fi-information-line': hasInfoIcon,
[icon]: icon,
[`fr-callout--${colorFamily}`]: colorFamily,
});

Expand All @@ -45,13 +52,18 @@ const Callout = ({
};

Callout.defaultProps = {
icon: 'fr-fi-information-line',
hasInfoIcon: true,
className: '',
colors: [],
colorFamily: '',
};

Callout.propTypes = {
icon: PropTypes.oneOfType([
PropTypes.oneOf([null]),
PropTypes.string,
]),
hasInfoIcon: PropTypes.bool,
colorFamily: PropTypes.oneOf([...colorFamilies, '']),
/**
Expand Down
12 changes: 11 additions & 1 deletion src/components/interface/Callout/Callout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,24 @@ ButtonCallout.storyName = 'Mise en avant avec bouton';

export const WithoutIconCallout = Template.bind({});
WithoutIconCallout.args = {
hasInfoIcon: false,
icon: null,
children: [
<CalloutTitle as="h3">Callout title</CalloutTitle>,
<CalloutText>Callout text that might be short and concise.</CalloutText>,
],
};
WithoutIconCallout.storyName = 'Mise en avant sans icone';

export const DifferentIconCallout = Template.bind({});
DifferentIconCallout.args = {
icon: 'fr-fi-lock-line',
children: [
<CalloutTitle as="h3">Callout title</CalloutTitle>,
<CalloutText>Callout text that might be short and concise.</CalloutText>,
],
};
DifferentIconCallout.storyName = 'Mise en avant avec une autre icone';

export const ColoredCallout = Template.bind({});
ColoredCallout.args = {
colors: ['#f13d3d', '#ffb0b0'],
Expand Down