@axa-fr/design-system-slash-react 0.2.0-beta.281 → 0.2.0-beta.283
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IconBg/IconBg.client.js +1 -1
- package/dist/List/ContentItemDuo/ContentItemDuo.d.ts +13 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.js +18 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.stories.d.ts +28 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.stories.js +86 -0
- package/dist/List/ContentItemDuo/__tests__/ContentItemDuo.test.js +40 -0
- package/dist/List/ContentItemDuo/index.d.ts +2 -0
- package/dist/List/ContentItemDuo/index.js +2 -0
- package/dist/List/ContentTabList/ContentTabList.client.js +1 -1
- package/dist/Title/{Title.agent.d.ts → Agent/Title.d.ts} +1 -1
- package/dist/Title/{Title.agent.js → Agent/Title.js} +2 -2
- package/dist/Title/{Title.agent.stories.d.ts → Agent/Title.stories.d.ts} +1 -1
- package/dist/Title/{Title.agent.stories.js → Agent/Title.stories.js} +2 -2
- package/dist/Title/Agent/__tests__/Title.test.d.ts +1 -0
- package/dist/Title/{__tests__ → Agent/__tests__}/Title.test.js +1 -1
- package/dist/Title/Client/Title.d.ts +13 -0
- package/dist/Title/Client/Title.js +11 -0
- package/dist/Title/Client/Title.stories.d.ts +6 -0
- package/dist/Title/Client/Title.stories.js +45 -0
- package/dist/Title/Client/TitleWithSubtitles.d.ts +8 -0
- package/dist/Title/Client/TitleWithSubtitles.js +2 -0
- package/dist/Title/Client/__tests__/Title.test.d.ts +1 -0
- package/dist/Title/Client/__tests__/Title.test.js +28 -0
- package/dist/Title/Client/__tests__/TitleWithSubtitles.test.d.ts +1 -0
- package/dist/Title/Client/__tests__/TitleWithSubtitles.test.js +14 -0
- package/dist/Title/Client/constants.d.ts +4 -0
- package/dist/Title/Client/constants.js +5 -0
- package/dist/Title/Client/index.d.ts +3 -0
- package/dist/Title/Client/index.js +3 -0
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/client.d.ts +2 -0
- package/dist/client.js +2 -0
- package/package.json +2 -2
- /package/dist/{Title/__tests__/Title.test.d.ts → List/ContentItemDuo/__tests__/ContentItemDuo.test.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { getComponentClassName } from "../
|
|
3
|
+
import { getComponentClassName } from "../Form/core";
|
|
4
4
|
export const IconBg = ({ children, className, classModifier, isDisabled = false, }) => {
|
|
5
5
|
const componentClassName = useMemo(() => {
|
|
6
6
|
let newClassModifier = classModifier;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ContentItemDuoProps = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
isVertical?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
classModifier?: string;
|
|
7
|
+
isShowingDoneIcon?: boolean;
|
|
8
|
+
isShowingCloseIcon?: boolean;
|
|
9
|
+
buttonText?: string;
|
|
10
|
+
onButtonClick?: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const ContentItemDuo: ({ label, value, isVertical, className, classModifier, isShowingDoneIcon, isShowingCloseIcon, buttonText, onButtonClick, }: ContentItemDuoProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import checkIcon from "@material-symbols/svg-400/outlined/check.svg";
|
|
3
|
+
import closeIcon from "@material-symbols/svg-400/outlined/close.svg";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { Variants } from "../../Button/Button.client";
|
|
6
|
+
import { getComponentClassName } from "../../Form/core";
|
|
7
|
+
import { Button, Svg } from "../../client";
|
|
8
|
+
export const ContentItemDuo = ({ label, value, isVertical = false, className, classModifier, isShowingDoneIcon = false, isShowingCloseIcon = false, buttonText, onButtonClick, }) => {
|
|
9
|
+
const componentClassName = useMemo(() => {
|
|
10
|
+
const classModifiers = [classModifier];
|
|
11
|
+
if (isVertical) {
|
|
12
|
+
classModifiers.push("vertical");
|
|
13
|
+
}
|
|
14
|
+
return getComponentClassName(className, classModifiers.filter(Boolean).join(" "), "af-content-item-duo");
|
|
15
|
+
}, [classModifier, className, isVertical]);
|
|
16
|
+
const iconContainerModifier = useMemo(() => ` af-content-item-duo__icon--${isShowingDoneIcon ? "done" : "close"}`, [isShowingDoneIcon]);
|
|
17
|
+
return (_jsxs("div", { className: componentClassName, children: [(isShowingDoneIcon || isShowingCloseIcon) && (_jsxs("div", { className: `af-content-item-duo__icon${iconContainerModifier}`, children: [isShowingDoneIcon && _jsx(Svg, { src: checkIcon }), isShowingCloseIcon && _jsx(Svg, { src: closeIcon })] })), _jsx("p", { className: "af-content-item-duo__label", children: label }), _jsx("p", { className: "af-content-item-duo__value", children: value }), buttonText && (_jsx("div", { className: "af-content-item-duo__button", children: _jsx(Button, { variant: Variants.ghost, onClick: onButtonClick, children: buttonText }) }))] }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
import { ContentItemDuo } from ".";
|
|
4
|
+
import { List } from "../List";
|
|
5
|
+
declare const meta: Meta<typeof ContentItemDuo>;
|
|
6
|
+
export default meta;
|
|
7
|
+
export declare const Default: StoryObj<Omit<ComponentProps<typeof ContentItemDuo>, "classModifier"> & {
|
|
8
|
+
classModifier: string[];
|
|
9
|
+
}>;
|
|
10
|
+
export declare const Vertical: StoryObj<Omit<ComponentProps<typeof ContentItemDuo>, "classModifier"> & {
|
|
11
|
+
classModifier: string[];
|
|
12
|
+
}>;
|
|
13
|
+
export declare const DefaultContentItemDuoList: StoryObj<{
|
|
14
|
+
items: Array<Omit<ComponentProps<typeof ContentItemDuo>, "classModifier"> & {
|
|
15
|
+
id: string;
|
|
16
|
+
classModifier: string[];
|
|
17
|
+
}>;
|
|
18
|
+
} & Omit<ComponentProps<typeof List>, "classModifier"> & {
|
|
19
|
+
classModifier: string[];
|
|
20
|
+
}>;
|
|
21
|
+
export declare const VerticalContentItemDuoList: StoryObj<{
|
|
22
|
+
items: Array<Omit<ComponentProps<typeof ContentItemDuo>, "classModifier"> & {
|
|
23
|
+
id: string;
|
|
24
|
+
classModifier: string[];
|
|
25
|
+
}>;
|
|
26
|
+
} & Omit<ComponentProps<typeof List>, "classModifier"> & {
|
|
27
|
+
classModifier: string[];
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ContentItemDuo } from ".";
|
|
3
|
+
import { List } from "../List";
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Client/Components/List/ContentItemDuo",
|
|
6
|
+
component: ContentItemDuo,
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
const defaultArgs = {
|
|
10
|
+
isVertical: false,
|
|
11
|
+
label: "Libellé",
|
|
12
|
+
value: "Réponse",
|
|
13
|
+
isShowingDoneIcon: true,
|
|
14
|
+
isShowingCloseIcon: false,
|
|
15
|
+
buttonText: "En savoir plus",
|
|
16
|
+
classModifier: [],
|
|
17
|
+
};
|
|
18
|
+
const verticalArgs = {
|
|
19
|
+
isVertical: true,
|
|
20
|
+
label: "Le choc de véhicules terrestres à moteur, (voiture, trottinette à moteur…) ou la chute d’appareils aériens (avions, hélicoptères…) avec un propriétaire du véhicule adverse identifié ?",
|
|
21
|
+
value: "Les incendies, explosions, implosions, fumée et foudre",
|
|
22
|
+
isShowingDoneIcon: true,
|
|
23
|
+
isShowingCloseIcon: false,
|
|
24
|
+
buttonText: "En savoir plus",
|
|
25
|
+
classModifier: [],
|
|
26
|
+
};
|
|
27
|
+
export const Default = {
|
|
28
|
+
name: "Default",
|
|
29
|
+
render: ({ classModifier, ...args }) => (_jsx(ContentItemDuo, { classModifier: classModifier.join(" "), ...args })),
|
|
30
|
+
args: defaultArgs,
|
|
31
|
+
argTypes: {
|
|
32
|
+
classModifier: {
|
|
33
|
+
options: ["large"],
|
|
34
|
+
control: { type: "multi-select" },
|
|
35
|
+
defaultValue: [],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const Vertical = {
|
|
40
|
+
name: "Vertical",
|
|
41
|
+
render: ({ classModifier, ...args }) => (_jsx(ContentItemDuo, { classModifier: classModifier.join(" "), ...args })),
|
|
42
|
+
args: verticalArgs,
|
|
43
|
+
argTypes: {
|
|
44
|
+
classModifier: {
|
|
45
|
+
options: ["large"],
|
|
46
|
+
control: { type: "multi-select" },
|
|
47
|
+
defaultValue: [],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export const DefaultContentItemDuoList = {
|
|
52
|
+
name: "Default ContentItemDuo List",
|
|
53
|
+
render: ({ classModifier, items }) => (_jsx(List, { classModifier: classModifier.join(" "), children: items.map(({ classModifier: itemClassModifier, ...itemArgs }) => (_jsx(ContentItemDuo, { classModifier: itemClassModifier.join(" "), ...itemArgs }, itemArgs.id))) })),
|
|
54
|
+
args: {
|
|
55
|
+
items: Array.from({ length: 3 }, (_, i) => ({
|
|
56
|
+
id: i.toString(),
|
|
57
|
+
...defaultArgs,
|
|
58
|
+
})),
|
|
59
|
+
classModifier: ["extra-padding"],
|
|
60
|
+
},
|
|
61
|
+
argTypes: {
|
|
62
|
+
classModifier: {
|
|
63
|
+
options: ["extra-padding", "large"],
|
|
64
|
+
control: { type: "multi-select" },
|
|
65
|
+
defaultValue: ["extra-padding"],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export const VerticalContentItemDuoList = {
|
|
70
|
+
name: "Vertical ContentItemDuo List",
|
|
71
|
+
render: ({ classModifier, items }) => (_jsx(List, { classModifier: classModifier.join(" "), children: items.map(({ classModifier: itemClassModifier, ...itemArgs }) => (_jsx(ContentItemDuo, { classModifier: itemClassModifier.join(" "), ...itemArgs }, itemArgs.id))) })),
|
|
72
|
+
args: {
|
|
73
|
+
items: Array.from({ length: 3 }, (_, i) => ({
|
|
74
|
+
id: i.toString(),
|
|
75
|
+
...verticalArgs,
|
|
76
|
+
})),
|
|
77
|
+
classModifier: ["extra-padding"],
|
|
78
|
+
},
|
|
79
|
+
argTypes: {
|
|
80
|
+
classModifier: {
|
|
81
|
+
options: ["extra-padding", "large"],
|
|
82
|
+
control: { type: "multi-select" },
|
|
83
|
+
defaultValue: ["extra-padding"],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { ContentItemDuo } from "../ContentItemDuo";
|
|
5
|
+
describe("ContentItemDuo", () => {
|
|
6
|
+
const label = "Sample Label";
|
|
7
|
+
const value = "Sample Value";
|
|
8
|
+
it("should render label and value correctly", () => {
|
|
9
|
+
render(_jsx(ContentItemDuo, { label: label, value: value }));
|
|
10
|
+
expect(screen.getByText(label)).toBeInTheDocument();
|
|
11
|
+
expect(screen.getByText(value)).toBeInTheDocument();
|
|
12
|
+
});
|
|
13
|
+
it("should render button with correct text and call onClick handler", async () => {
|
|
14
|
+
const buttonText = "button";
|
|
15
|
+
const onButtonClick = vi.fn();
|
|
16
|
+
render(_jsx(ContentItemDuo, { label: label, value: value, buttonText: buttonText, onButtonClick: onButtonClick }));
|
|
17
|
+
const buttonElement = screen.getByText(buttonText);
|
|
18
|
+
expect(buttonElement).toBeInTheDocument();
|
|
19
|
+
userEvent.click(buttonElement);
|
|
20
|
+
await waitFor(() => {
|
|
21
|
+
expect(onButtonClick).toHaveBeenCalled();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
it("should render vertical layout when isVertical prop is true", () => {
|
|
25
|
+
render(_jsx(ContentItemDuo, { label: label, value: value, isVertical: true }));
|
|
26
|
+
expect(screen.getByText(label).parentElement).toHaveClass("af-content-item-duo--vertical");
|
|
27
|
+
});
|
|
28
|
+
it("should render done icon when isShowingDoneIcon prop is true", () => {
|
|
29
|
+
const { container } = render(_jsx(ContentItemDuo, { label: label, value: value, isShowingDoneIcon: true }));
|
|
30
|
+
const svgElement = container.querySelector("svg");
|
|
31
|
+
expect(svgElement).toBeInTheDocument();
|
|
32
|
+
expect(svgElement?.parentElement).toHaveClass("af-content-item-duo__icon--done");
|
|
33
|
+
});
|
|
34
|
+
it("should render close icon when isShowingCloseIcon prop is true", () => {
|
|
35
|
+
const { container } = render(_jsx(ContentItemDuo, { label: label, value: value, isShowingCloseIcon: true }));
|
|
36
|
+
const svgElement = container.querySelector("svg");
|
|
37
|
+
expect(svgElement).toBeInTheDocument();
|
|
38
|
+
expect(svgElement?.parentElement).toHaveClass("af-content-item-duo__icon--close");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -6,5 +6,5 @@ import { ContentTabItem } from "./ContentTabItem";
|
|
|
6
6
|
const BREAKPOINT_SMALL = 668;
|
|
7
7
|
export const ContentTabList = ({ items, classModifier, }) => {
|
|
8
8
|
const isMobile = useIsSmallScreen(BREAKPOINT_SMALL);
|
|
9
|
-
return (_jsx(List, { classModifier: `list large content-tab-list ${classModifier}`, tabIndex: -1, children: items.map(({ id, ...item }) => (_jsx(ContentTabItem, { ...item, isMobile: isMobile }, id ?? item.title))) }));
|
|
9
|
+
return (_jsx(List, { classModifier: `list large extra-padding content-tab-list ${classModifier}`, tabIndex: -1, children: items.map(({ id, ...item }) => (_jsx(ContentTabItem, { ...item, isMobile: isMobile }, id ?? item.title))) }));
|
|
10
10
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "@axa-fr/design-system-slash-css/dist/Title/Title.
|
|
1
|
+
import "@axa-fr/design-system-slash-css/dist/Title/Agent/Title.scss";
|
|
2
2
|
import { ComponentPropsWithRef, PropsWithChildren } from "react";
|
|
3
3
|
type Headings = "h2" | "h3" | "h4";
|
|
4
4
|
type TitleProps = ComponentPropsWithRef<"h2"> & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import "@axa-fr/design-system-slash-css/dist/Title/Title.
|
|
2
|
+
import "@axa-fr/design-system-slash-css/dist/Title/Agent/Title.scss";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
-
import { getComponentClassName } from "
|
|
4
|
+
import { getComponentClassName } from "../../Form/core";
|
|
5
5
|
export const Title = forwardRef(({ className, classModifier, children, heading: Heading = "h2", ...otherProps }, ref) => {
|
|
6
6
|
const componentClassName = getComponentClassName(className, classModifier, "af-title");
|
|
7
7
|
return (_jsx(Heading, { ref: ref, className: componentClassName, ...otherProps, children: children }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Title } from "./Title
|
|
2
|
+
import { Title } from "./Title";
|
|
3
3
|
declare const meta: Meta<typeof Title>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type StoryProps = Omit<React.ComponentProps<typeof Title>, "classModifier" | "children"> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ButtonAgent as Button } from "../../Button/Button.agent";
|
|
3
|
+
import { Title } from "./Title";
|
|
4
4
|
const meta = {
|
|
5
5
|
title: "Agent/Components/Title",
|
|
6
6
|
component: Title,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from "@testing-library/react";
|
|
3
3
|
import { axe } from "jest-axe";
|
|
4
|
-
import { Title } from "../Title
|
|
4
|
+
import { Title } from "../Title";
|
|
5
5
|
describe("Title", () => {
|
|
6
6
|
it("should render children", () => {
|
|
7
7
|
render(_jsx(Title, { children: "A title" }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { TitleSize } from "./constants";
|
|
3
|
+
type TitleProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
firstSubtitle: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
classModifier?: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
secondSubtitle?: string;
|
|
10
|
+
size?: TitleSize;
|
|
11
|
+
};
|
|
12
|
+
export declare const Title: ({ children: title, className, classModifier, firstSubtitle, icon, secondSubtitle, size, }: TitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo, } from "react";
|
|
3
|
+
import { IconBg } from "../../client";
|
|
4
|
+
import { getComponentClassName } from "../../Form/core";
|
|
5
|
+
import { TitleSize } from "./constants";
|
|
6
|
+
import { TitleWithSubtitles } from "./TitleWithSubtitles";
|
|
7
|
+
export const Title = ({ children: title, className, classModifier, firstSubtitle, icon, secondSubtitle, size = TitleSize.XL, }) => {
|
|
8
|
+
const componentClassName = useMemo(() => getComponentClassName(className, classModifier ? `${classModifier} ${size}` : size, "af-title"), [classModifier, className, size]);
|
|
9
|
+
const TitleWithSubtitlesPart = useCallback(({ ...args }) => (_jsx(TitleWithSubtitles, { title: title, firstSubtitle: firstSubtitle, ...args })), [title, firstSubtitle]);
|
|
10
|
+
return (_jsx("div", { className: componentClassName, children: icon && size === TitleSize.XL ? (_jsxs(_Fragment, { children: [_jsx(IconBg, { className: "af-title__icon af-icon-bg", children: icon }), _jsx("div", { className: "af-title__text-container", children: _jsx(TitleWithSubtitlesPart, { secondSubtitle: secondSubtitle }) })] })) : (_jsx(TitleWithSubtitlesPart, {})) }));
|
|
11
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Title } from ".";
|
|
3
|
+
declare const meta: Meta<typeof Title>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const TitleWithIcon: StoryObj<typeof Title>;
|
|
6
|
+
export declare const TitleWithoutIcon: StoryObj<typeof Title>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import article from "@material-symbols/svg-400/outlined/article-fill.svg";
|
|
3
|
+
import { Title } from ".";
|
|
4
|
+
import { Svg } from "../../Svg";
|
|
5
|
+
import { TitleSize } from "./constants";
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Client/Components/Title",
|
|
8
|
+
component: Title,
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const TitleWithIcon = {
|
|
12
|
+
name: "Title With Icon",
|
|
13
|
+
render: (args) => _jsx(Title, { ...args }),
|
|
14
|
+
args: {
|
|
15
|
+
children: "Titre de la page",
|
|
16
|
+
firstSubtitle: "Sous-titre 1",
|
|
17
|
+
secondSubtitle: "Sous-titre 2",
|
|
18
|
+
icon: _jsx(Svg, { src: article }),
|
|
19
|
+
size: TitleSize.XL,
|
|
20
|
+
},
|
|
21
|
+
argTypes: {
|
|
22
|
+
size: {
|
|
23
|
+
options: Object.values(TitleSize),
|
|
24
|
+
control: { type: "select" },
|
|
25
|
+
defaultValue: TitleSize.XL,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const TitleWithoutIcon = {
|
|
30
|
+
name: "Title Without Icon",
|
|
31
|
+
render: (args) => _jsx(Title, { ...args }),
|
|
32
|
+
args: {
|
|
33
|
+
children: "Titre de la page",
|
|
34
|
+
firstSubtitle: "Sous-titre 1",
|
|
35
|
+
secondSubtitle: "Sous-titre 2",
|
|
36
|
+
size: TitleSize.XL,
|
|
37
|
+
},
|
|
38
|
+
argTypes: {
|
|
39
|
+
size: {
|
|
40
|
+
options: Object.values(TitleSize),
|
|
41
|
+
control: { type: "select" },
|
|
42
|
+
defaultValue: TitleSize.XL,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type TitleTextProps = {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
firstSubtitle?: string;
|
|
5
|
+
secondSubtitle?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const TitleWithSubtitles: ({ title, firstSubtitle, secondSubtitle, }: TitleTextProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const TitleWithSubtitles = ({ title, firstSubtitle, secondSubtitle, }) => (_jsxs(_Fragment, { children: [_jsx("h1", { className: "af-title__title", children: title }), firstSubtitle && (_jsx("span", { className: "af-title__subtitle", children: firstSubtitle })), secondSubtitle && (_jsx("span", { className: "af-title__subtitle", children: secondSubtitle }))] }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Title } from "..";
|
|
4
|
+
import { TitleSize } from "../constants";
|
|
5
|
+
describe("Title", () => {
|
|
6
|
+
it("should render correctly", () => {
|
|
7
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", secondSubtitle: "secondSubtitle", icon: "icon", children: "Title" }));
|
|
8
|
+
expect(screen.getByRole("heading", { name: "Title", level: 1 })).toBeInTheDocument();
|
|
9
|
+
expect(screen.getByText("firstSubtitle")).toBeInTheDocument();
|
|
10
|
+
expect(screen.getByText("secondSubtitle")).toBeInTheDocument();
|
|
11
|
+
expect(screen.getByText("icon")).toBeInTheDocument();
|
|
12
|
+
});
|
|
13
|
+
it("should have custom class", () => {
|
|
14
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", className: "custom-class", children: "Title" }));
|
|
15
|
+
expect(screen.getByText("Title").parentElement).toHaveClass("custom-class");
|
|
16
|
+
});
|
|
17
|
+
it("should have custom class with modifier", () => {
|
|
18
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", className: "custom-class", classModifier: "modifier", children: "Title" }));
|
|
19
|
+
expect(screen.getByText("Title").parentElement).toHaveClass("custom-class custom-class--modifier");
|
|
20
|
+
});
|
|
21
|
+
it('should not display icon and second subtitle when size is "L"', () => {
|
|
22
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", secondSubtitle: "secondSubtitle", icon: "icon", size: TitleSize.L, children: "Title" }));
|
|
23
|
+
expect(screen.getByRole("heading", { name: "Title", level: 1 })).toBeInTheDocument();
|
|
24
|
+
expect(screen.getByText("firstSubtitle")).toBeInTheDocument();
|
|
25
|
+
expect(screen.queryByText("secondSubtitle")).not.toBeInTheDocument();
|
|
26
|
+
expect(screen.queryByText("icon")).not.toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { TitleWithSubtitles } from "../TitleWithSubtitles";
|
|
4
|
+
describe("TitleWithSubtitles", () => {
|
|
5
|
+
it("should render title and the two subtitles", () => {
|
|
6
|
+
const title = "Sample Title";
|
|
7
|
+
const firstSubtitle = "First Subtitle";
|
|
8
|
+
const secondSubtitle = "Second Subtitle";
|
|
9
|
+
render(_jsx(TitleWithSubtitles, { title: title, firstSubtitle: firstSubtitle, secondSubtitle: secondSubtitle }));
|
|
10
|
+
screen.getByRole("heading", { name: title, level: 1 });
|
|
11
|
+
expect(screen.getByText(firstSubtitle)).toBeInTheDocument();
|
|
12
|
+
expect(screen.getByText(secondSubtitle)).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
});
|
package/dist/agent.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { Badge } from "./Badge/Badge";
|
|
|
6
6
|
export { ButtonAgent as Button } from "./Button/Button.agent";
|
|
7
7
|
export { Checkbox, CheckboxInput, CheckboxItem, CheckboxModes, } from "./Form/Checkbox/Agent";
|
|
8
8
|
export { Choice, ChoiceInput } from "./Form/Choice";
|
|
9
|
+
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
9
10
|
export { Date, DateInput } from "./Form/Date";
|
|
10
11
|
export { MultiSelect, MultiSelectInput } from "./Form/MultiSelect";
|
|
11
12
|
export { Number, NumberInput } from "./Form/Number";
|
|
@@ -14,12 +15,11 @@ export { Select, SelectBase, SelectInput } from "./Form/Select/Agent";
|
|
|
14
15
|
export { Slider, SliderInput } from "./Form/Slider";
|
|
15
16
|
export { Text, TextInput } from "./Form/Text/Agent";
|
|
16
17
|
export { Textarea, TextareaInput } from "./Form/Textarea";
|
|
17
|
-
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
18
18
|
export { Footer } from "./Layout/Footer/Agent";
|
|
19
19
|
export { HeaderAgent as Header, Infos, Name, NavBar, NavBarBase, NavBarItem, NavBarItemBase, NavBarItemLink, TitleHeader, ToggleButton, User, } from "./Layout/Header/Agent";
|
|
20
20
|
export { BooleanModal, Modal, ModalBody, ModalFooter, ModalHeader, ModalHeaderBase, } from "./ModalAgent";
|
|
21
21
|
export { Step, StepBase, Steps } from "./Steps";
|
|
22
22
|
export { Svg } from "./Svg";
|
|
23
23
|
export { Tabs } from "./Tabs/Agent/Tabs.agent";
|
|
24
|
-
export { Title } from "./Title/Title
|
|
24
|
+
export { Title } from "./Title/Agent/Title";
|
|
25
25
|
export * from "./Table";
|
package/dist/agent.js
CHANGED
|
@@ -6,6 +6,7 @@ export { Badge } from "./Badge/Badge";
|
|
|
6
6
|
export { ButtonAgent as Button } from "./Button/Button.agent";
|
|
7
7
|
export { Checkbox, CheckboxInput, CheckboxItem, CheckboxModes, } from "./Form/Checkbox/Agent";
|
|
8
8
|
export { Choice, ChoiceInput } from "./Form/Choice";
|
|
9
|
+
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
9
10
|
export { Date, DateInput } from "./Form/Date";
|
|
10
11
|
export { MultiSelect, MultiSelectInput } from "./Form/MultiSelect";
|
|
11
12
|
export { Number, NumberInput } from "./Form/Number";
|
|
@@ -14,12 +15,11 @@ export { Select, SelectBase, SelectInput } from "./Form/Select/Agent";
|
|
|
14
15
|
export { Slider, SliderInput } from "./Form/Slider";
|
|
15
16
|
export { Text, TextInput } from "./Form/Text/Agent";
|
|
16
17
|
export { Textarea, TextareaInput } from "./Form/Textarea";
|
|
17
|
-
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
18
18
|
export { Footer } from "./Layout/Footer/Agent";
|
|
19
19
|
export { HeaderAgent as Header, Infos, Name, NavBar, NavBarBase, NavBarItem, NavBarItemBase, NavBarItemLink, TitleHeader, ToggleButton, User, } from "./Layout/Header/Agent";
|
|
20
20
|
export { BooleanModal, Modal, ModalBody, ModalFooter, ModalHeader, ModalHeaderBase, } from "./ModalAgent";
|
|
21
21
|
export { Step, StepBase, Steps } from "./Steps";
|
|
22
22
|
export { Svg } from "./Svg";
|
|
23
23
|
export { Tabs } from "./Tabs/Agent/Tabs.agent";
|
|
24
|
-
export { Title } from "./Title/Title
|
|
24
|
+
export { Title } from "./Title/Agent/Title";
|
|
25
25
|
export * from "./Table";
|
package/dist/client.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { HeaderClient as Header } from "./Layout/Header/Client";
|
|
|
15
15
|
export { Link } from "./Link/Link.client";
|
|
16
16
|
export { List } from "./List";
|
|
17
17
|
export { ClickList } from "./List/ClickList";
|
|
18
|
+
export { ContentItemDuo } from "./List/ContentItemDuo";
|
|
18
19
|
export { ContentTabList } from "./List/ContentTabList";
|
|
19
20
|
export { Loader } from "./Loader/Client";
|
|
20
21
|
export { Modal } from "./ModalClient/Modal.client";
|
|
@@ -24,3 +25,4 @@ export { Stepper } from "./Stepper/Stepper.client";
|
|
|
24
25
|
export { Svg } from "./Svg";
|
|
25
26
|
export { TabsClient as Tabs, Direction as TabsDirection, } from "./Tabs/Client/Tabs.client";
|
|
26
27
|
export { Tag } from "./Tag";
|
|
28
|
+
export { Title, TitleSize } from "./Title/Client";
|
package/dist/client.js
CHANGED
|
@@ -14,6 +14,7 @@ export { HeaderClient as Header } from "./Layout/Header/Client";
|
|
|
14
14
|
export { Link } from "./Link/Link.client";
|
|
15
15
|
export { List } from "./List";
|
|
16
16
|
export { ClickList } from "./List/ClickList";
|
|
17
|
+
export { ContentItemDuo } from "./List/ContentItemDuo";
|
|
17
18
|
export { ContentTabList } from "./List/ContentTabList";
|
|
18
19
|
export { Loader } from "./Loader/Client";
|
|
19
20
|
export { Modal } from "./ModalClient/Modal.client";
|
|
@@ -22,3 +23,4 @@ export { Stepper } from "./Stepper/Stepper.client";
|
|
|
22
23
|
export { Svg } from "./Svg";
|
|
23
24
|
export { TabsClient as Tabs, Direction as TabsDirection, } from "./Tabs/Client/Tabs.client";
|
|
24
25
|
export { Tag } from "./Tag";
|
|
26
|
+
export { Title, TitleSize } from "./Title/Client";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-slash-react",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.283",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./agent": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@axa-fr/design-system-slash-css": "0.2.0-beta.
|
|
48
|
+
"@axa-fr/design-system-slash-css": "0.2.0-beta.283",
|
|
49
49
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
50
50
|
"react": ">= 18"
|
|
51
51
|
},
|
|
File without changes
|