@@ -2,25 +2,23 @@ import React, { memo, forwardRef, ReactNode } from "react";
22import { symToStr } from "tsafe/symToStr" ;
33import { assert } from "tsafe/assert" ;
44import type { Equals } from "tsafe" ;
5- import { fr } from "./lib" ;
5+
6+ import { FrClassName } from "./lib/generatedFromCss/classNames" ;
67import { cx } from "./lib/tools/cx" ;
8+ import { fr } from "./lib" ;
79
8- // We make users import dsfr.css, so we don't need to import the scoped CSS
9- // but in the future if we have a complete component coverage it
10- // we could stop requiring users to import the hole CSS and only import on a
11- // per component basis.
1210import "./dsfr/component/quote/quote.css" ;
13- import { FrClassName } from "./lib/generatedFromCss/classNames" ;
1411
1512export type QuoteProps = {
1613 className ?: string ;
17- text : string ;
18- author ?: string ;
14+ text : ReactNode ;
15+ author ?: ReactNode ;
1916 source ?: ReactNode ;
2017 sourceUrl ?: string ;
21- image ?: string ;
22- size ?: "md " | "lg " | "xl " ;
18+ imageUrl ?: string ;
19+ size ?: "medium " | "large " | "xlarge " ;
2320 accentColor ?: QuoteProps . AccentColor ;
21+ classes ?: Partial < Record < "root" | "author" | "source" | "image" | "imageTag" | "text" , string > > ;
2422} ;
2523
2624export namespace QuoteProps {
@@ -34,37 +32,57 @@ export namespace QuoteProps {
3432/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-quote> */
3533export const Quote = memo (
3634 forwardRef < HTMLDivElement , QuoteProps > ( ( props , ref ) => {
37- const { className, text, author, source, sourceUrl, image, size, accentColor, ...rest } =
38- props ;
35+ const {
36+ className,
37+ text,
38+ author,
39+ source,
40+ sourceUrl,
41+ imageUrl,
42+ size = "xlarge" ,
43+ accentColor,
44+ classes = { } ,
45+ ...rest
46+ } = props ;
3947
4048 assert < Equals < keyof typeof rest , never > > ( ) ;
4149
4250 return (
4351 < figure
4452 className = { cx (
4553 fr . cx ( "fr-quote" ) ,
46- image && fr . cx ( "fr-quote--column" ) ,
54+ imageUrl && fr . cx ( "fr-quote--column" ) ,
4755 accentColor && `fr-quote--${ accentColor } ` ,
56+ classes . root ,
4857 className
4958 ) }
5059 ref = { ref }
5160 >
5261 < blockquote cite = { sourceUrl } >
5362 < p
5463 className = { cx (
55- size === "lg" && fr . cx ( "fr-text--lg" ) ,
56- size === "md" && fr . cx ( "fr-text--md" )
64+ size === "large" && fr . cx ( "fr-text--lg" ) ,
65+ size === "medium" && fr . cx ( "fr-text--md" ) ,
66+ classes . text
5767 ) }
5868 >
5969 « { text } »
6070 </ p >
6171 </ blockquote >
6272 < figcaption >
63- { author && < p className = "fr-quote__author" > { author } </ p > }
64- { source && < ul className = "fr-quote__source" > { source } </ ul > }
65- { image !== undefined && (
66- < div className = "fr-quote__image" >
67- < img src = { image } className = "fr-responsive-img" alt = "" />
73+ { author !== undefined && (
74+ < p className = { cx ( fr . cx ( "fr-quote__author" ) , classes . author ) } > { author } </ p >
75+ ) }
76+ { source !== undefined && (
77+ < ul className = { cx ( fr . cx ( "fr-quote__source" ) , classes . source ) } > { source } </ ul >
78+ ) }
79+ { imageUrl !== undefined && (
80+ < div className = { cx ( "fr-quote__image" , classes . image ) } >
81+ < img
82+ src = { imageUrl }
83+ className = { cx ( fr . cx ( "fr-responsive-img" ) , classes . imageTag ) }
84+ alt = ""
85+ />
6886 </ div >
6987 ) }
7088 </ figcaption >
0 commit comments