Skip to content

Commit c506c33

Browse files
committed
Enable style prop on every component
1 parent 669bfdd commit c506c33

29 files changed

+216
-73
lines changed

src/Accordion.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
"use client";
22

3-
import React, { forwardRef, memo, ReactNode, useId, useState } from "react";
3+
import React, {
4+
forwardRef,
5+
memo,
6+
useId,
7+
useState,
8+
type ReactNode,
9+
type CSSProperties
10+
} from "react";
411
import { assert } from "tsafe";
512
import type { Equals } from "tsafe";
613
import { fr } from "./fr";
@@ -16,6 +23,7 @@ export namespace AccordionProps {
1623
titleAs?: `h${2 | 3 | 4 | 5 | 6}`;
1724
label: ReactNode;
1825
classes?: Partial<Record<"root" | "accordion" | "title" | "collapse", string>>;
26+
style?: CSSProperties;
1927
children: NonNullable<ReactNode>;
2028
};
2129

@@ -46,6 +54,7 @@ export const Accordion = memo(
4654
titleAs: HtmlTitleTag = "h3",
4755
label,
4856
classes = {},
57+
style,
4958
children,
5059
expanded: expandedProp,
5160
defaultExpanded = false,
@@ -69,7 +78,12 @@ export const Accordion = memo(
6978
);
7079

7180
return (
72-
<section className={cx(fr.cx("fr-accordion"), className)} ref={ref} {...rest}>
81+
<section
82+
className={cx(fr.cx("fr-accordion"), className)}
83+
style={style}
84+
ref={ref}
85+
{...rest}
86+
>
7387
<HtmlTitleTag className={cx(fr.cx("fr-accordion__title"), classes.title)}>
7488
<button
7589
className={fr.cx("fr-accordion__btn")}

src/Alert.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
"use client";
22

3-
import React, { memo, forwardRef, useState, useEffect, useRef } from "react";
4-
import type { ReactNode } from "react";
3+
import React, {
4+
memo,
5+
forwardRef,
6+
useState,
7+
useEffect,
8+
useRef,
9+
type ReactNode,
10+
type CSSProperties
11+
} from "react";
512
import type { FrClassName } from "./fr/generatedFromCss/classNames";
613
import { symToStr } from "tsafe/symToStr";
714
import { fr } from "./fr";
@@ -17,6 +24,7 @@ export type AlertProps = {
1724
/** Default h3 */
1825
as?: `h${2 | 3 | 4 | 5 | 6}`;
1926
classes?: Partial<Record<"root" | "title" | "description" | "close", string>>;
27+
style?: CSSProperties;
2028
} & (AlertProps.DefaultSize | AlertProps.Small) &
2129
(AlertProps.NonClosable | AlertProps.Closable);
2230

@@ -74,6 +82,7 @@ export const Alert = memo(
7482
severity,
7583
as: HtmlTitleTag = "h3",
7684
classes = {},
85+
style,
7786
small: isSmall,
7887
title,
7988
description,
@@ -144,6 +153,7 @@ export const Alert = memo(
144153
classes.root,
145154
className
146155
)}
156+
style={style}
147157
{...(refShouldSetRole.current && { "role": "alert" })}
148158
ref={ref}
149159
{...rest}

src/Badge.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, forwardRef, ReactNode } from "react";
1+
import React, { memo, forwardRef, type ReactNode, type CSSProperties } from "react";
22
import { symToStr } from "tsafe/symToStr";
33
import { assert } from "tsafe/assert";
44
import type { Equals } from "tsafe";
@@ -8,6 +8,7 @@ import type { AlertProps } from "./Alert";
88

99
export type BadgeProps = {
1010
className?: string;
11+
style?: CSSProperties;
1112
severity?: AlertProps.Severity | "new";
1213
small?: boolean;
1314
noIcon?: boolean;
@@ -19,6 +20,7 @@ export const Badge = memo(
1920
forwardRef<HTMLDivElement, BadgeProps>((props, ref) => {
2021
const {
2122
className,
23+
style,
2224
severity,
2325
small: isSmall = false,
2426
noIcon = false,
@@ -39,6 +41,7 @@ export const Badge = memo(
3941
),
4042
className
4143
)}
44+
style={style}
4245
ref={ref}
4346
{...rest}
4447
>

src/Breadcrumb.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, forwardRef, useId, ReactNode } from "react";
1+
import React, { memo, forwardRef, useId, type ReactNode, type CSSProperties } from "react";
22
import { symToStr } from "tsafe/symToStr";
33
import { assert } from "tsafe/assert";
44
import type { Equals } from "tsafe";
@@ -17,6 +17,7 @@ export type BreadcrumbProps = {
1717
}[];
1818
currentPageLabel: ReactNode;
1919
classes?: Partial<Record<"root" | "button" | "collapse" | "list" | "link" | "text", string>>;
20+
style?: CSSProperties;
2021
};
2122

2223
/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-breadcrumb> */
@@ -28,6 +29,7 @@ export const Breadcrumb = memo(
2829
segments,
2930
currentPageLabel,
3031
classes = {},
32+
style,
3133
...rest
3234
} = props;
3335

@@ -43,6 +45,7 @@ export const Breadcrumb = memo(
4345
ref={ref}
4446
role="navigation"
4547
className={cx(fr.cx("fr-breadcrumb"), classes.root, className)}
48+
style={style}
4649
aria-label={`${t("navigation label")} :`}
4750
{...rest}
4851
>

src/Button.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import React, { memo, forwardRef } from "react";
2-
import type {
3-
ReactNode,
4-
RefAttributes,
5-
MemoExoticComponent,
6-
ForwardRefExoticComponent
1+
import React, {
2+
memo,
3+
forwardRef,
4+
type ReactNode,
5+
type RefAttributes,
6+
type MemoExoticComponent,
7+
type ForwardRefExoticComponent,
8+
type CSSProperties
79
} from "react";
810
import { fr } from "./fr";
911
import { cx } from "./tools/cx";
@@ -24,6 +26,7 @@ export namespace ButtonProps {
2426
priority?: "primary" | "secondary" | "tertiary" | "tertiary no outline";
2527
/** Default medium */
2628
size?: "small" | "medium" | "large";
29+
style?: CSSProperties;
2730
};
2831

2932
export type IconOnly = {
@@ -91,6 +94,7 @@ export const Button = memo(
9194
nativeButtonProps,
9295
disabled,
9396
type,
97+
style,
9498
...rest
9599
} = props;
96100

@@ -127,6 +131,7 @@ export const Button = memo(
127131
{...linkProps}
128132
title={title ?? linkProps.title}
129133
className={className}
134+
style={style}
130135
ref={ref as React.ForwardedRef<HTMLAnchorElement>}
131136
{...rest}
132137
>
@@ -136,6 +141,7 @@ export const Button = memo(
136141
<button
137142
{...nativeButtonProps}
138143
className={className}
144+
style={style}
139145
type={type}
140146
title={title}
141147
onClick={onClick}

src/ButtonsGroup.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, forwardRef } from "react";
1+
import React, { memo, forwardRef, type CSSProperties } from "react";
22
import { Button } from "./Button";
33
import { ButtonProps } from "./Button";
44
import { symToStr } from "tsafe/symToStr";
@@ -20,6 +20,7 @@ export namespace ButtonsGroupProps {
2020
/** Default: false */
2121
buttonsEquisized?: boolean;
2222
buttons: [ButtonProps, ButtonProps, ...ButtonProps[]];
23+
style?: CSSProperties;
2324
};
2425

2526
export type AlwaysStacked = Common & {
@@ -56,6 +57,7 @@ export const ButtonsGroup = memo(
5657
buttonsEquisized = false,
5758
isReverseOrder = false,
5859
buttons,
60+
style,
5961
...rest
6062
} = props;
6163

@@ -95,7 +97,7 @@ export const ButtonsGroup = memo(
9597
);
9698

9799
return (
98-
<ul className={buttonsGroupClassName} ref={ref} {...rest}>
100+
<ul className={buttonsGroupClassName} style={style} ref={ref} {...rest}>
99101
{buttons.map((buttonProps, i) => (
100102
<li key={i}>
101103
<Button {...buttonProps} />

src/CallOut.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, forwardRef, ReactNode } from "react";
1+
import React, { memo, forwardRef, ReactNode, type CSSProperties } from "react";
22
import { symToStr } from "tsafe/symToStr";
33
import { assert } from "tsafe/assert";
44
import type { Equals } from "tsafe";
@@ -19,6 +19,7 @@ export type CallOutProps = {
1919
buttonProps?: ButtonProps;
2020
colorVariant?: CallOutProps.ColorVariant;
2121
classes?: Partial<Record<"root" | "title" | "text" | "button", string>>;
22+
style?: CSSProperties;
2223
children: ReactNode;
2324
};
2425

@@ -41,6 +42,7 @@ export const CallOut = memo(
4142
colorVariant,
4243
classes = {},
4344
children,
45+
style,
4446
...rest
4547
} = props;
4648

@@ -58,6 +60,7 @@ export const CallOut = memo(
5860
className
5961
)}
6062
ref={ref}
63+
style={style}
6164
{...rest}
6265
>
6366
{title !== undefined && (

src/Card.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React, { memo, forwardRef } from "react";
2-
import type { ReactNode } from "react";
1+
import React, { memo, forwardRef, type ReactNode, type CSSProperties } from "react";
32
import { symToStr } from "tsafe/symToStr";
43
import { assert } from "tsafe/assert";
54
import type { Equals } from "tsafe";
@@ -56,6 +55,7 @@ export type CardProps = {
5655
string
5756
>
5857
>;
58+
style?: CSSProperties;
5959
/** Default false */
6060
horizontal?: boolean;
6161
} & (CardProps.EnlargedLink | CardProps.NotEnlargedLink);
@@ -96,6 +96,7 @@ export const Card = memo(
9696
shadow = false,
9797
grey = false,
9898
iconId,
99+
style,
99100
...rest
100101
} = props;
101102

@@ -129,6 +130,7 @@ export const Card = memo(
129130
classes.root,
130131
className
131132
)}
133+
style={style}
132134
ref={ref}
133135
{...rest}
134136
>

src/Display.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, forwardRef, useId } from "react";
1+
import React, { memo, forwardRef, useId, type CSSProperties } from "react";
22
import { fr } from "./fr";
33
import { symToStr } from "tsafe/symToStr";
44
import { createComponentI18nApi } from "./i18n";
@@ -14,6 +14,7 @@ import type { FooterProps } from "./Footer";
1414

1515
export type DisplayProps = {
1616
className?: string;
17+
style?: CSSProperties;
1718
};
1819

1920
const dialogId = "fr-theme-modal";
@@ -39,7 +40,7 @@ export const headerFooterDisplayItem: HeaderProps.QuickAccessItem.Button &
3940
/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-display> */
4041
export const Display = memo(
4142
forwardRef<HTMLDialogElement, DisplayProps>((props, ref) => {
42-
const { className, ...rest } = props;
43+
const { className, style, ...rest } = props;
4344

4445
assert<Equals<keyof typeof rest, never>>();
4546

@@ -52,6 +53,7 @@ export const Display = memo(
5253
role="dialog"
5354
aria-labelledby={dialogTitleId}
5455
ref={ref}
56+
style={style}
5557
{...rest}
5658
>
5759
<div className={fr.cx("fr-container", "fr-container--fluid", "fr-container-md")}>

src/Footer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React, { memo, forwardRef } from "react";
2-
import type { ReactNode } from "react";
1+
import React, { memo, forwardRef, type ReactNode, type CSSProperties } from "react";
32
import { getLink } from "./link";
43
import type { RegisteredLinkProps } from "./link";
54
import { symToStr } from "tsafe/symToStr";
@@ -55,6 +54,7 @@ export type FooterProps = {
5554
string
5655
>
5756
>;
57+
style?: CSSProperties;
5858
};
5959

6060
export namespace FooterProps {
@@ -99,6 +99,7 @@ export const Footer = memo(
9999
bottomItems = [],
100100
operatorLogo,
101101
license,
102+
style,
102103
...rest
103104
} = props;
104105

@@ -114,6 +115,7 @@ export const Footer = memo(
114115
role="contentinfo"
115116
id="footer"
116117
ref={ref}
118+
style={style}
117119
{...rest}
118120
>
119121
<div className={fr.cx("fr-container")}>

0 commit comments

Comments
 (0)