Skip to content

Commit c9b0040

Browse files
author
Julien Bouquillon
committed
accentColor
1 parent 58ed41e commit c9b0040

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/Quote.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { cx } from "./lib/tools/cx";
1010
// we could stop requiring users to import the hole CSS and only import on a
1111
// per component basis.
1212
import "./dsfr/component/quote/quote.css";
13+
import { FrClassName } from "./lib/generatedFromCss/classNames";
1314

1415
export type QuoteProps = {
1516
className?: string;
@@ -19,18 +20,33 @@ export type QuoteProps = {
1920
sourceUrl?: string;
2021
image?: string;
2122
size?: "md" | "lg" | "xl";
23+
accentColor?: QuoteProps.AccentColor;
2224
};
2325

26+
export namespace QuoteProps {
27+
type ExtractAccentColor<FrClassName> = FrClassName extends `fr-quote--${infer AccentColor}`
28+
? AccentColor
29+
: never;
30+
31+
export type AccentColor = ExtractAccentColor<FrClassName>;
32+
}
33+
2434
/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-quote> */
2535
export const Quote = memo(
2636
forwardRef<HTMLDivElement, QuoteProps>((props, ref) => {
27-
const { className, text, author, source, sourceUrl, image, size, ...rest } = props;
37+
const { className, text, author, source, sourceUrl, image, size, accentColor, ...rest } =
38+
props;
2839

2940
assert<Equals<keyof typeof rest, never>>();
3041

3142
return (
3243
<figure
33-
className={cx(fr.cx("fr-quote"), image && fr.cx("fr-quote--column"), className)}
44+
className={cx(
45+
fr.cx("fr-quote"),
46+
image && fr.cx("fr-quote--column"),
47+
accentColor && `fr-quote--${accentColor}`,
48+
className
49+
)}
3450
ref={ref}
3551
>
3652
<blockquote cite={sourceUrl}>

stories/Quote.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const QuoteMediumAndAccent = getStory({
6363
),
6464
image: "//www.systeme-de-design.gouv.fr/img/placeholder.1x1.png",
6565
size: "md",
66-
className: "fr-quote--green-emeraude"
66+
accentColor: "pink-macaron"
6767
});
6868

6969
export const QuoteWithoutDetails = getStory({
@@ -103,6 +103,6 @@ export const QuoteWithoutIllustration = getStory({
103103
export const QuoteWithAccent = getStory({
104104
text: "Lorem [...] elit ut. ",
105105
image: "//www.systeme-de-design.gouv.fr/img/placeholder.1x1.png",
106-
className: "fr-quote--green-emeraude",
106+
accentColor: "yellow-moutarde",
107107
author: "Someone"
108108
});

0 commit comments

Comments
 (0)