(
(
inputRef,
) => {
const componentClassName = getComponentClassName(
+ "af-form__input-text",
className,
classModifier,
- "af-form__input-text",
);
let inputId = useId();
diff --git a/client/look-and-feel/react/src/Form/TextArea/TextArea.tsx b/client/look-and-feel/react/src/Form/TextArea/TextArea.tsx
index 9776c92f1..af7b9efbe 100644
--- a/client/look-and-feel/react/src/Form/TextArea/TextArea.tsx
+++ b/client/look-and-feel/react/src/Form/TextArea/TextArea.tsx
@@ -37,9 +37,9 @@ const TextArea = forwardRef
(
inputRef,
) => {
const componentClassName = getComponentClassName(
+ "af-form__input-textarea",
className,
classModifier,
- "af-form__input-textarea",
);
let inputId = useId();
diff --git a/client/look-and-feel/react/src/Grid/renderExampleForm.tsx b/client/look-and-feel/react/src/Grid/renderExampleForm.tsx
index ce9844d6e..ee6316b28 100644
--- a/client/look-and-feel/react/src/Grid/renderExampleForm.tsx
+++ b/client/look-and-feel/react/src/Grid/renderExampleForm.tsx
@@ -1,7 +1,16 @@
+import home from "@material-symbols/svg-400/outlined/home.svg";
import { MyFooter } from "./components/MyFooter";
import { MyHeader } from "./components/MyHeader";
-import { Button, ButtonVariants, TextInput, Title } from "..";
+import {
+ Button,
+ ButtonVariants,
+ CheckboxSelect,
+ RadioSelect,
+ Svg,
+ TextInput,
+ Title,
+} from "..";
import { DebugGrid } from "./DebugGrid";
function capitalizeFirstLetter(val: string) {
@@ -19,7 +28,7 @@ const setAttributesFields = (value: string, label: string, type = "text") => ({
placeholder: `Votre ${label}`,
description: `Saisissez un ${label}`,
error: `Un ${label} est obligatoire`,
- className: "subgrid af-form__input-text",
+ className: "subgrid",
helper: "Do you need help ?",
buttonLabel: "En savoir plus",
});
@@ -42,6 +51,61 @@ export const render = () => (
Les mentions avec * sont obligatoires
+ },
+ { label: "Femme", value: "F", icon: },
+ { label: "Les deux", value: "HF", icon: },
+ {
+ label: "Ne se prononce pas",
+ value: "N",
+ icon: ,
+ },
+ ]}
+ name="radio-name"
+ />
+ ,
+ },
+ { label: "BA", value: "F", name: "BA", icon: },
+ {
+ label: "EM",
+ value: "HF",
+ name: "EM",
+ icon: ,
+ },
+ { label: "PO", value: "A", name: "PO", icon: },
+ {
+ label: "DBA",
+ value: "Au",
+ name: "DBA",
+ icon: ,
+ },
+ {
+ label: "Scrum Master",
+ value: "P",
+ name: "Scrum Master",
+ icon: ,
+ },
+ {
+ label: "Ne se prononce pas",
+ value: "N",
+ name: "Ne se prononce pas",
+ icon: ,
+ },
+ ]}
+ />
{FIELDS.map((field) => (
{children}
;
diff --git a/client/look-and-feel/react/src/IconBg/__tests__/IconBg.test.tsx b/client/look-and-feel/react/src/IconBg/__tests__/IconBg.test.tsx
index 5a9384f5f..1d31511f4 100644
--- a/client/look-and-feel/react/src/IconBg/__tests__/IconBg.test.tsx
+++ b/client/look-and-feel/react/src/IconBg/__tests__/IconBg.test.tsx
@@ -23,7 +23,7 @@ describe("IconBg", () => {
);
expect(screen.getByText("An IconBg")).toHaveClass(
- "custom-class custom-class--modifier",
+ "af-icon-bg custom-class af-icon-bg--modifier",
);
});
@@ -35,7 +35,7 @@ describe("IconBg", () => {
);
expect(screen.getByText("An IconBg")).toHaveClass(
- "custom-class custom-class--disabled",
+ "af-icon-bg custom-class af-icon-bg--disabled",
);
});
});
diff --git a/client/look-and-feel/react/src/Link/Link.tsx b/client/look-and-feel/react/src/Link/Link.tsx
index 7397801c5..14ecedddb 100644
--- a/client/look-and-feel/react/src/Link/Link.tsx
+++ b/client/look-and-feel/react/src/Link/Link.tsx
@@ -34,9 +34,9 @@ export const Link = ({
const componentClassName = useMemo(
() =>
getComponentClassName(
+ "af-link",
className,
`${classModifier}${!className && openInNewTab ? " openInNewTab" : ""}`,
- "af-link",
),
[classModifier, className, openInNewTab],
);
diff --git a/client/look-and-feel/react/src/Link/__tests__/Link.test.tsx b/client/look-and-feel/react/src/Link/__tests__/Link.test.tsx
index 947048488..d95b82b6a 100644
--- a/client/look-and-feel/react/src/Link/__tests__/Link.test.tsx
+++ b/client/look-and-feel/react/src/Link/__tests__/Link.test.tsx
@@ -83,7 +83,7 @@ describe("Link component", () => {
expect(link).toHaveClass(className);
}
if (classModifier) {
- expect(link).toHaveClass(`${className ?? "af-link"}--${classModifier}`);
+ expect(link).toHaveClass(`af-link af-link--test-modifier`);
}
},
);
diff --git a/client/look-and-feel/react/src/List/ClickList/ClickItem/ClickItem.tsx b/client/look-and-feel/react/src/List/ClickList/ClickItem/ClickItem.tsx
index 1b613ab11..ff425fa12 100644
--- a/client/look-and-feel/react/src/List/ClickList/ClickItem/ClickItem.tsx
+++ b/client/look-and-feel/react/src/List/ClickList/ClickItem/ClickItem.tsx
@@ -24,9 +24,9 @@ export const ClickItem = ({
const componentClassName = useMemo(
() =>
getComponentClassName(
+ "af-click-item",
className,
`${classModifier}${isDisabled ? " disabled" : ""}`,
- "af-click-item",
),
[className, classModifier, isDisabled],
);
diff --git a/client/look-and-feel/react/src/List/ClickList/ClickItem/__tests__/ClickItem.test.tsx b/client/look-and-feel/react/src/List/ClickList/ClickItem/__tests__/ClickItem.test.tsx
index dd834ffaf..1ab310f3f 100644
--- a/client/look-and-feel/react/src/List/ClickList/ClickItem/__tests__/ClickItem.test.tsx
+++ b/client/look-and-feel/react/src/List/ClickList/ClickItem/__tests__/ClickItem.test.tsx
@@ -34,7 +34,7 @@ describe("ClickItem", () => {
);
expect(screen.getByRole("button", { name: label })).toHaveClass(
- `${className} ${className}--${classModifier}`,
+ `af-click-item custom-class af-click-item--modifier`,
);
});
diff --git a/client/look-and-feel/react/src/List/ContentItemDuo/ContentItemDuo.tsx b/client/look-and-feel/react/src/List/ContentItemDuo/ContentItemDuo.tsx
index fc207d1eb..2dcb80fb3 100644
--- a/client/look-and-feel/react/src/List/ContentItemDuo/ContentItemDuo.tsx
+++ b/client/look-and-feel/react/src/List/ContentItemDuo/ContentItemDuo.tsx
@@ -36,9 +36,9 @@ export const ContentItemDuo = ({
}
return getComponentClassName(
+ "af-content-item-duo",
className,
classModifiers.filter(Boolean).join(" "),
- "af-content-item-duo",
);
}, [classModifier, className, isVertical]);
diff --git a/client/look-and-feel/react/src/List/ContentItemMono/ContentItemMono.tsx b/client/look-and-feel/react/src/List/ContentItemMono/ContentItemMono.tsx
index 3d8026392..21a2cf3ae 100644
--- a/client/look-and-feel/react/src/List/ContentItemMono/ContentItemMono.tsx
+++ b/client/look-and-feel/react/src/List/ContentItemMono/ContentItemMono.tsx
@@ -35,9 +35,9 @@ export const ContentItemMono = ({
}
return getComponentClassName(
+ "af-content-item-mono",
className,
classModifiers.filter(Boolean).join(" "),
- "af-content-item-mono",
);
}, [classModifier, isDisabled, size, className]);
diff --git a/client/look-and-feel/react/src/List/ContentItemMono/__tests__/ContentItemMono.test.tsx b/client/look-and-feel/react/src/List/ContentItemMono/__tests__/ContentItemMono.test.tsx
index af032c9a7..a5518f959 100644
--- a/client/look-and-feel/react/src/List/ContentItemMono/__tests__/ContentItemMono.test.tsx
+++ b/client/look-and-feel/react/src/List/ContentItemMono/__tests__/ContentItemMono.test.tsx
@@ -34,7 +34,7 @@ describe("ContentItemMono", () => {
expect(
screen.getByText("Content").parentElement?.parentElement,
- ).toHaveClass(`${className} ${className}--m`);
+ ).toHaveClass(`af-content-item-mono custom-class af-content-item-mono--m`);
});
it("should have XL size and no tertiary text", () => {
@@ -52,7 +52,7 @@ describe("ContentItemMono", () => {
expect(
screen.getByText("Content").parentElement?.parentElement,
- ).toHaveClass(`${className} ${className}--xl`);
+ ).toHaveClass(`af-content-item-mono custom-class af-content-item-mono--xl`);
expect(screen.queryByText("tertiaryText")).not.toBeInTheDocument();
});
@@ -68,7 +68,9 @@ describe("ContentItemMono", () => {
expect(
screen.getByText("Content").parentElement?.parentElement,
- ).toHaveClass(`${className} ${className}--${classModifier}`);
+ ).toHaveClass(
+ `af-content-item-mono custom-class af-content-item-mono--modifier`,
+ );
});
it("should be disabled", () => {
@@ -82,7 +84,9 @@ describe("ContentItemMono", () => {
expect(
screen.getByText("Content").parentElement?.parentElement,
- ).toHaveClass(`${className} ${className}--disabled`);
+ ).toHaveClass(
+ `af-content-item-mono custom-class af-content-item-mono--disabled`,
+ );
});
it("should have centered left element", () => {
diff --git a/client/look-and-feel/react/src/Tag/Tag.tsx b/client/look-and-feel/react/src/Tag/Tag.tsx
index e8c912e79..c38243e4c 100644
--- a/client/look-and-feel/react/src/Tag/Tag.tsx
+++ b/client/look-and-feel/react/src/Tag/Tag.tsx
@@ -12,7 +12,7 @@ export const Tag = ({
...divProps
}: TagProps) => {
const componentClassName = useMemo(
- () => getComponentClassName(className, classModifier, "af-tag"),
+ () => getComponentClassName("af-tag", className, classModifier),
[className, classModifier],
);
diff --git a/client/look-and-feel/react/src/Title/Title.tsx b/client/look-and-feel/react/src/Title/Title.tsx
index 2dc06958b..068f5e274 100644
--- a/client/look-and-feel/react/src/Title/Title.tsx
+++ b/client/look-and-feel/react/src/Title/Title.tsx
@@ -33,9 +33,9 @@ export const Title = ({
const componentClassName = useMemo(
() =>
getComponentClassName(
+ "af-title",
className,
classModifier ? `${classModifier} ${size}` : size,
- "af-title",
),
[classModifier, className, size],
);
diff --git a/client/look-and-feel/react/src/Title/__tests__/Title.test.tsx b/client/look-and-feel/react/src/Title/__tests__/Title.test.tsx
index 4760ebaf7..5f95d1a83 100644
--- a/client/look-and-feel/react/src/Title/__tests__/Title.test.tsx
+++ b/client/look-and-feel/react/src/Title/__tests__/Title.test.tsx
@@ -44,7 +44,7 @@ describe("Title", () => {
);
expect(screen.getByText("Title").parentElement).toHaveClass(
- "custom-class custom-class--modifier",
+ "af-title custom-class af-title--modifier af-title--xl",
);
});
diff --git a/client/look-and-feel/react/src/utilities/helpers/getComponentClassName.ts b/client/look-and-feel/react/src/utilities/helpers/getComponentClassName.ts
index 3e9874c90..a16ee69de 100644
--- a/client/look-and-feel/react/src/utilities/helpers/getComponentClassName.ts
+++ b/client/look-and-feel/react/src/utilities/helpers/getComponentClassName.ts
@@ -1,11 +1,11 @@
import classNames from "classnames";
-const getLastClassName = (classNameToUse: string) => {
- if (!classNameToUse) {
+const getLastClassName = (defaultClassName: string) => {
+ if (!defaultClassName) {
return null;
}
- return classNameToUse.split(" ").filter(Boolean).at(-1);
+ return defaultClassName.split(" ").filter(Boolean).at(-1);
};
const listClassModifier = (classModifier?: string) => {
@@ -17,18 +17,16 @@ const listClassModifier = (classModifier?: string) => {
};
export const getComponentClassName = (
+ defaultClassName: string,
className?: string,
classModifier?: string,
- defaultClassName?: string,
) => {
- const classNameToUse = className || defaultClassName;
-
- // Fail fast, when no className or defaultClassName we don't want to loop on modifier
- if (!classNameToUse) {
+ // Fail fast, when no defaultClassName we don't want to loop on modifier
+ if (!defaultClassName) {
return "";
}
- const classWithoutModifier = getLastClassName(classNameToUse);
+ const classWithoutModifier = getLastClassName(defaultClassName);
const modifiers = listClassModifier(classModifier);
const modifiersObject = modifiers
@@ -37,5 +35,5 @@ export const getComponentClassName = (
return `${classWithoutModifier}--${it}`;
});
- return classNames(classNameToUse, modifiersObject);
+ return classNames(defaultClassName, className, modifiersObject);
};