♻️(react) update Button component props and refactor related components

This commit modifies the Button component to switch the `variant` and
`color` props, ensuring consistency across various components that
utilize the Button. The changes include updates in the Alert, Modal,
Tooltip, and other components to reflect this new prop structure.
Additionally, several test and story files have been adjusted to
accommodate these changes, enhancing the overall component architecture.
This commit is contained in:
Nathan Panchout
2025-09-18 15:19:01 +02:00
committed by NathanVss
parent f93a83655c
commit 748d070bd9
27 changed files with 186 additions and 186 deletions

View File

@@ -16,8 +16,8 @@ export const AlertAdditionalExpandable = (props: AlertProps) => {
const iconButton = ( const iconButton = (
<Button <Button
variant={props.type} color={props.type}
color="tertiary" variant="tertiary"
size="nano" size="nano"
aria-label={ aria-label={
expanded expanded

View File

@@ -14,7 +14,7 @@ export const AlertWrapper = (props: AlertProps) => {
props.className, props.className,
{ {
"c__alert--hide": props.hide, "c__alert--hide": props.hide,
}, }
)} )}
> >
{props.children} {props.children}
@@ -42,8 +42,8 @@ export const AlertClose = (props: AlertProps) => {
return ( return (
props.canClose && ( props.canClose && (
<Button <Button
variant={props.type} color={props.type}
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">close</span>} icon={<span className="material-icons">close</span>}
aria-label={t("components.alert.close_aria_label")} aria-label={t("components.alert.close_aria_label")}
@@ -60,8 +60,8 @@ export const AlertButtons = (props: AlertProps) => {
<> <>
{props.tertiaryLabel && ( {props.tertiaryLabel && (
<Button <Button
color="tertiary" variant="tertiary"
variant={props.type} color={props.type}
onClick={props.tertiaryOnClick} onClick={props.tertiaryOnClick}
{...props.tertiaryProps} {...props.tertiaryProps}
> >
@@ -70,8 +70,8 @@ export const AlertButtons = (props: AlertProps) => {
)} )}
{props.primaryLabel && ( {props.primaryLabel && (
<Button <Button
variant={props.type} color={props.type}
color="secondary" variant="secondary"
onClick={props.primaryOnClick} onClick={props.primaryOnClick}
{...props.primaryProps} {...props.primaryProps}
> >

View File

@@ -17,7 +17,7 @@ describe("<Alert/>", () => {
render( render(
<CunninghamProvider> <CunninghamProvider>
<Alert type={type}>Alert component</Alert> <Alert type={type}>Alert component</Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
const $icon = document.querySelector(".c__alert__icon"); const $icon = document.querySelector(".c__alert__icon");
if (icon) { if (icon) {
@@ -32,7 +32,7 @@ describe("<Alert/>", () => {
<Alert type={VariantType.INFO} additional="Additional information"> <Alert type={VariantType.INFO} additional="Additional information">
Alert component Alert component
</Alert> </Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
expect(screen.getByText("Additional information")).toBeInTheDocument(); expect(screen.getByText("Additional information")).toBeInTheDocument();
}); });
@@ -42,7 +42,7 @@ describe("<Alert/>", () => {
<Alert type={VariantType.INFO} primaryLabel="Primary"> <Alert type={VariantType.INFO} primaryLabel="Primary">
Alert component Alert component
</Alert> </Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
screen.getByRole("button", { name: "Primary" }); screen.getByRole("button", { name: "Primary" });
}); });
@@ -52,7 +52,7 @@ describe("<Alert/>", () => {
<Alert type={VariantType.INFO} tertiaryLabel="Tertiary"> <Alert type={VariantType.INFO} tertiaryLabel="Tertiary">
Alert component Alert component
</Alert> </Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
screen.getByRole("button", { name: "Tertiary" }); screen.getByRole("button", { name: "Tertiary" });
}); });
@@ -66,7 +66,7 @@ describe("<Alert/>", () => {
> >
Alert component Alert component
</Alert> </Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
screen.getByRole("button", { name: "Primary" }); screen.getByRole("button", { name: "Primary" });
screen.getByRole("button", { name: "Tertiary" }); screen.getByRole("button", { name: "Tertiary" });
@@ -78,14 +78,14 @@ describe("<Alert/>", () => {
type={VariantType.INFO} type={VariantType.INFO}
buttons={ buttons={
<> <>
<Button color="primary">Primary Custom</Button> <Button variant="primary">Primary Custom</Button>
<Button color="secondary">Secondary Custom</Button> <Button variant="secondary">Secondary Custom</Button>
</> </>
} }
> >
Alert component Alert component
</Alert> </Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
screen.getByRole("button", { name: "Primary Custom" }); screen.getByRole("button", { name: "Primary Custom" });
screen.getByRole("button", { name: "Secondary Custom" }); screen.getByRole("button", { name: "Secondary Custom" });
@@ -96,7 +96,7 @@ describe("<Alert/>", () => {
<Alert type={VariantType.INFO} canClose={true}> <Alert type={VariantType.INFO} canClose={true}>
Alert component Alert component
</Alert> </Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
screen.getByText("Alert component"); screen.getByText("Alert component");
@@ -165,14 +165,14 @@ describe("<Alert/>", () => {
> >
Alert component Alert component
</Alert> </Alert>
</CunninghamProvider>, </CunninghamProvider>
); );
const user = userEvent.setup(); const user = userEvent.setup();
screen.getByText("Alert component"); screen.getByText("Alert component");
expect( expect(
screen.queryByText("Additional information"), screen.queryByText("Additional information")
).not.toBeInTheDocument(); ).not.toBeInTheDocument();
const $expandButton = screen.getByRole("button", { name: "Expand alert" }); const $expandButton = screen.getByRole("button", { name: "Expand alert" });
@@ -184,7 +184,7 @@ describe("<Alert/>", () => {
await user.click($shrinkButton); await user.click($shrinkButton);
expect( expect(
screen.queryByText("Additional information"), screen.queryByText("Additional information")
).not.toBeInTheDocument(); ).not.toBeInTheDocument();
}); });
it("can expand the alert controlled", async () => { it("can expand the alert controlled", async () => {
@@ -226,7 +226,7 @@ describe("<Alert/>", () => {
screen.getByText("Expanded: false"); screen.getByText("Expanded: false");
expect( expect(
screen.queryByText("Additional information"), screen.queryByText("Additional information")
).not.toBeInTheDocument(); ).not.toBeInTheDocument();
// Expand from alert. // Expand from alert.
@@ -246,14 +246,14 @@ describe("<Alert/>", () => {
screen.getByText("Expanded: false"); screen.getByText("Expanded: false");
expect( expect(
screen.queryByText("Additional information"), screen.queryByText("Additional information")
).not.toBeInTheDocument(); ).not.toBeInTheDocument();
}); });
it("renders with className", async () => { it("renders with className", async () => {
render(<Alert className="my-custom-class" />); render(<Alert className="my-custom-class" />);
expect( expect(
document.querySelector(".c__alert.my-custom-class"), document.querySelector(".c__alert.my-custom-class")
).toBeInTheDocument(); ).toBeInTheDocument();
}); });
}); });

View File

@@ -58,10 +58,10 @@ export const CustomButtons: Story = {
canClose: true, canClose: true,
buttons: ( buttons: (
<div style={{ display: "flex", gap: "0.5rem" }}> <div style={{ display: "flex", gap: "0.5rem" }}>
<Button variant="brand" color="primary"> <Button color="brand" variant="primary">
Primary Primary
</Button> </Button>
<Button variant="brand" color="secondary"> <Button color="brand" variant="secondary">
Secondary Secondary
</Button> </Button>
</div> </div>

View File

@@ -11,10 +11,10 @@ export default meta;
type Story = StoryObj<typeof Button>; type Story = StoryObj<typeof Button>;
type AllButtonsProps = ButtonProps & { type AllButtonsProps = ButtonProps & {
variant: ButtonProps["variant"]; color: ButtonProps["color"];
}; };
const AllButtons = ({ variant = "brand" }: AllButtonsProps) => { const AllButtons = ({ color = "brand" }: AllButtonsProps) => {
return ( return (
<div <div
style={{ style={{
@@ -33,24 +33,24 @@ const AllButtons = ({ variant = "brand" }: AllButtonsProps) => {
justifyContent: "start", justifyContent: "start",
}} }}
> >
<h4 className={`clr-content-semantic-${variant}-primary`}>Primary</h4> <h4 className={`clr-content-semantic-${color}-primary`}>Primary</h4>
<Button {...Primary.args} variant={variant} /> <Button {...Primary.args} color={color} />
<Button {...PrimaryDisabled.args} variant={variant} /> <Button {...PrimaryDisabled.args} color={color} />
</div> </div>
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}> <div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
<h4 className={`clr-content-semantic-${variant}-primary`}>Secondary</h4> <h4 className={`clr-content-semantic-${color}-primary`}>Secondary</h4>
<Button {...Secondary.args} variant={variant} /> <Button {...Secondary.args} color={color} />
<Button {...SecondaryDisabled.args} variant={variant} /> <Button {...SecondaryDisabled.args} color={color} />
</div> </div>
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}> <div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
<h4 className={`clr-content-semantic-${variant}-primary`}>Tertiary</h4> <h4 className={`clr-content-semantic-${color}-primary`}>Tertiary</h4>
<Button {...BrandTertiary.args} variant={variant} /> <Button {...BrandTertiary.args} color={color} />
<Button {...TertiaryDisabled.args} variant={variant} /> <Button {...TertiaryDisabled.args} color={color} />
</div> </div>
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}> <div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
<h4 className={`clr-content-semantic-${variant}-primary`}>Bordered</h4> <h4 className={`clr-content-semantic-${color}-primary`}>Bordered</h4>
<Button {...Bordered.args} variant={variant} /> <Button {...Bordered.args} color={color} />
<Button {...BrandBorderedDisabled.args} variant={variant} /> <Button {...BrandBorderedDisabled.args} color={color} />
</div> </div>
</div> </div>
); );
@@ -58,44 +58,44 @@ const AllButtons = ({ variant = "brand" }: AllButtonsProps) => {
export const AllBrands: Story = { export const AllBrands: Story = {
render: () => { render: () => {
return <AllButtons variant="brand" />; return <AllButtons color="brand" />;
}, },
}; };
export const AllNeutrals: Story = { export const AllNeutrals: Story = {
render: () => { render: () => {
return <AllButtons variant="neutral" />; return <AllButtons color="neutral" />;
}, },
}; };
export const AllWarnings: Story = { export const AllWarnings: Story = {
render: () => { render: () => {
return <AllButtons variant="warning" />; return <AllButtons color="warning" />;
}, },
}; };
export const AllErrors: Story = { export const AllErrors: Story = {
render: () => { render: () => {
return <AllButtons variant="error" />; return <AllButtons color="error" />;
}, },
}; };
export const AllSuccesses: Story = { export const AllSuccesses: Story = {
render: () => { render: () => {
return <AllButtons variant="success" />; return <AllButtons color="success" />;
}, },
}; };
export const AllInfos: Story = { export const AllInfos: Story = {
render: () => { render: () => {
return <AllButtons variant="info" />; return <AllButtons color="info" />;
}, },
}; };
const Primary: Story = { const Primary: Story = {
args: { args: {
children: "Primary", children: "Primary",
color: "primary", variant: "primary",
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
}; };
@@ -103,7 +103,7 @@ const Primary: Story = {
const PrimaryDisabled: Story = { const PrimaryDisabled: Story = {
args: { args: {
children: "Disabled", children: "Disabled",
color: "primary", variant: "primary",
disabled: true, disabled: true,
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
@@ -112,7 +112,7 @@ const PrimaryDisabled: Story = {
const Secondary: Story = { const Secondary: Story = {
args: { args: {
children: "Secondary", children: "Secondary",
color: "secondary", variant: "secondary",
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
}; };
@@ -120,7 +120,7 @@ const Secondary: Story = {
const SecondaryDisabled: Story = { const SecondaryDisabled: Story = {
args: { args: {
children: "Disabled", children: "Disabled",
color: "secondary", variant: "secondary",
disabled: true, disabled: true,
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
@@ -129,7 +129,7 @@ const SecondaryDisabled: Story = {
const BrandTertiary: Story = { const BrandTertiary: Story = {
args: { args: {
children: "Tertiary", children: "Tertiary",
color: "tertiary", variant: "tertiary",
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
}; };
@@ -137,7 +137,7 @@ const BrandTertiary: Story = {
const TertiaryDisabled: Story = { const TertiaryDisabled: Story = {
args: { args: {
children: "Disabled", children: "Disabled",
color: "tertiary", variant: "tertiary",
disabled: true, disabled: true,
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
@@ -146,7 +146,7 @@ const TertiaryDisabled: Story = {
const Bordered: Story = { const Bordered: Story = {
args: { args: {
children: "Bordered", children: "Bordered",
color: "bordered", variant: "bordered",
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
}; };
@@ -154,7 +154,7 @@ const Bordered: Story = {
const BrandBorderedDisabled: Story = { const BrandBorderedDisabled: Story = {
args: { args: {
children: " Disabled", children: " Disabled",
color: "bordered", variant: "bordered",
disabled: true, disabled: true,
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
@@ -163,14 +163,14 @@ const BrandBorderedDisabled: Story = {
export const Medium: Story = { export const Medium: Story = {
args: { args: {
children: "Primary", children: "Primary",
color: "primary", variant: "primary",
}, },
}; };
export const Small: Story = { export const Small: Story = {
args: { args: {
children: "Primary", children: "Primary",
color: "primary", variant: "primary",
size: "small", size: "small",
}, },
}; };
@@ -178,7 +178,7 @@ export const Small: Story = {
export const Nano: Story = { export const Nano: Story = {
args: { args: {
children: "Primary", children: "Primary",
color: "primary", variant: "primary",
size: "nano", size: "nano",
}, },
}; };
@@ -186,7 +186,7 @@ export const Nano: Story = {
export const FullWidth: Story = { export const FullWidth: Story = {
args: { args: {
children: "Primary", children: "Primary",
color: "primary", variant: "primary",
fullWidth: true, fullWidth: true,
}, },
}; };
@@ -194,7 +194,7 @@ export const FullWidth: Story = {
export const FullWidthWithIcon: Story = { export const FullWidthWithIcon: Story = {
args: { args: {
children: "Primary", children: "Primary",
color: "primary", variant: "primary",
fullWidth: true, fullWidth: true,
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
}, },
@@ -204,7 +204,7 @@ export const IconLeft: Story = {
args: { args: {
children: "Icon", children: "Icon",
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
color: "primary", variant: "primary",
}, },
}; };
@@ -213,7 +213,7 @@ export const IconRight: Story = {
children: "Icon", children: "Icon",
iconPosition: "right", iconPosition: "right",
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
color: "primary", variant: "primary",
}, },
}; };
@@ -221,7 +221,7 @@ export const IconOnly: Story = {
args: { args: {
"aria-label": "Button with only an icon", "aria-label": "Button with only an icon",
icon: <span className="material-icons">bolt</span>, icon: <span className="material-icons">bolt</span>,
color: "primary", variant: "primary",
}, },
}; };
@@ -229,7 +229,7 @@ export const AsLink: Story = {
args: { args: {
children: "Go to fun-mooc.fr", children: "Go to fun-mooc.fr",
icon: <span className="material-icons">link</span>, icon: <span className="material-icons">link</span>,
color: "primary", variant: "primary",
href: "https://www.fun-mooc.fr/", href: "https://www.fun-mooc.fr/",
target: "_blank", target: "_blank",
rel: "noopener noreferrer", rel: "noopener noreferrer",

View File

@@ -13,7 +13,7 @@ export type ButtonElement = HTMLButtonElement & HTMLAnchorElement;
export type ButtonProps = Omit<DomProps, "color"> & export type ButtonProps = Omit<DomProps, "color"> &
RefAttributes<ButtonElement> & { RefAttributes<ButtonElement> & {
size?: "medium" | "small" | "nano"; size?: "medium" | "small" | "nano";
variant?: color?:
| "brand" | "brand"
| "neutral" | "neutral"
| "info" | "info"
@@ -21,7 +21,7 @@ export type ButtonProps = Omit<DomProps, "color"> &
| "warning" | "warning"
| "error" | "error"
| "success"; | "success";
color?: "primary" | "secondary" | "tertiary" | "bordered"; variant?: "primary" | "secondary" | "tertiary" | "bordered";
icon?: ReactNode; icon?: ReactNode;
iconPosition?: "left" | "right"; iconPosition?: "left" | "right";
active?: boolean; active?: boolean;
@@ -30,10 +30,10 @@ export type ButtonProps = Omit<DomProps, "color"> &
export const Button = ({ export const Button = ({
children, children,
color = "primary", variant = "primary",
size = "medium", size = "medium",
iconPosition = "left", iconPosition = "left",
variant = "brand", color = "brand",
icon, icon,
active, active,
className, className,
@@ -43,8 +43,8 @@ export const Button = ({
}: ButtonProps) => { }: ButtonProps) => {
const classes = [ const classes = [
"c__button", "c__button",
"c__button--" + variant, "c__button--" + color,
["c__button--", variant, "--", color].join(""), ["c__button--", color, "--", variant].join(""),
"c__button--" + size, "c__button--" + size,
className, className,
]; ];
@@ -60,7 +60,7 @@ export const Button = ({
if (fullWidth) { if (fullWidth) {
classes.push("c__button--full-width"); classes.push("c__button--full-width");
} }
if (["primary-text", "tertiary-text"].includes(color)) { if (["primary-text", "tertiary-text"].includes(variant)) {
classes.push("c__button--text"); classes.push("c__button--text");
} }
if (props.href && props.disabled) { if (props.href && props.disabled) {
@@ -79,6 +79,6 @@ export const Button = ({
{!!icon && iconPosition === "left" && iconElement} {!!icon && iconPosition === "left" && iconElement}
{children} {children}
{!!icon && iconPosition === "right" && iconElement} {!!icon && iconPosition === "right" && iconElement}
</>, </>
); );
}; };

View File

@@ -97,7 +97,7 @@ describe("<DataGrid/>", () => {
fetchMock.mockIf( fetchMock.mockIf(
"https://example.com/?page=1&sort=lastName&sortOrder=desc", "https://example.com/?page=1&sort=lastName&sortOrder=desc",
() => deferred.promise, () => deferred.promise
); );
render(<Component />); render(<Component />);
@@ -115,8 +115,8 @@ describe("<DataGrid/>", () => {
JSON.stringify({ JSON.stringify({
rows: database.slice(0, 10), rows: database.slice(0, 10),
count: database.length, count: database.length,
}), })
), )
); );
// Make sure the loader disappears. // Make sure the loader disappears.
@@ -124,8 +124,8 @@ describe("<DataGrid/>", () => {
expect( expect(
screen.queryByRole("status", { screen.queryByRole("status", {
name: "Loading data", name: "Loading data",
}), })
).toBeNull(), ).toBeNull()
); );
// Make sure the rows are rendered. // Make sure the rows are rendered.
@@ -154,7 +154,7 @@ describe("<DataGrid/>", () => {
deferred = new Deferred(); deferred = new Deferred();
fetchMock.mockIf( fetchMock.mockIf(
"https://example.com/?page=2&sort=lastName&sortOrder=desc", "https://example.com/?page=2&sort=lastName&sortOrder=desc",
() => deferred.promise, () => deferred.promise
); );
// Go to page 2. // Go to page 2.
@@ -187,8 +187,8 @@ describe("<DataGrid/>", () => {
JSON.stringify({ JSON.stringify({
rows: database.slice(10, 20), rows: database.slice(10, 20),
count: database.length, count: database.length,
}), })
), )
); );
// Make sure the loader disappears. // Make sure the loader disappears.
@@ -196,8 +196,8 @@ describe("<DataGrid/>", () => {
expect( expect(
screen.queryByRole("status", { screen.queryByRole("status", {
name: "Loading data", name: "Loading data",
}), })
).toBeNull(), ).toBeNull()
); );
// Make sure the rows are rendered. // Make sure the rows are rendered.
@@ -248,7 +248,7 @@ describe("<DataGrid/>", () => {
id: "buttonValidator", id: "buttonValidator",
renderCell: () => ( renderCell: () => (
<Button <Button
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">delete</span>} icon={<span className="material-icons">delete</span>}
/> />
@@ -330,15 +330,15 @@ describe("<DataGrid/>", () => {
expect(tds.length).toBe(3); expect(tds.length).toBe(3);
expect(tds[0].textContent).toEqual(row.firstName); expect(tds[0].textContent).toEqual(row.firstName);
expect(Array.from(tds[0].classList)).toContain( expect(Array.from(tds[0].classList)).toContain(
"c__datagrid__row__cell--highlight", "c__datagrid__row__cell--highlight"
); );
expect(tds[1].textContent).toEqual(row.lastName); expect(tds[1].textContent).toEqual(row.lastName);
expect(Array.from(tds[1].classList)).not.toContain( expect(Array.from(tds[1].classList)).not.toContain(
"c__datagrid__row__cell--highlight", "c__datagrid__row__cell--highlight"
); );
expect(tds[2].textContent).toEqual(row.email); expect(tds[2].textContent).toEqual(row.email);
expect(Array.from(tds[2].classList)).toContain( expect(Array.from(tds[2].classList)).toContain(
"c__datagrid__row__cell--highlight", "c__datagrid__row__cell--highlight"
); );
}); });
}); });
@@ -395,10 +395,10 @@ describe("<DataGrid/>", () => {
rows={[]} rows={[]}
className="my-custom-class" className="my-custom-class"
/> />
</CunninghamProvider>, </CunninghamProvider>
); );
expect( expect(
document.querySelector(".c__datagrid.my-custom-class"), document.querySelector(".c__datagrid.my-custom-class")
).toBeInTheDocument(); ).toBeInTheDocument();
}); });

View File

@@ -43,7 +43,7 @@ export const EmptyCustomWithButton = () => {
emptyPlaceholderLabel="This table is empty, create the first object" emptyPlaceholderLabel="This table is empty, create the first object"
emptyCta={ emptyCta={
<Button <Button
color="secondary" variant="secondary"
icon={<span className="material-icons">add</span>} icon={<span className="material-icons">add</span>}
> >
Create object Create object
@@ -114,7 +114,7 @@ export const ClientSideWithoutPagination = () => {
id: "actions", id: "actions",
renderCell: () => ( renderCell: () => (
<Button <Button
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">delete</span>} icon={<span className="material-icons">delete</span>}
/> />
@@ -198,14 +198,14 @@ export const FullServerSide = () => {
setTimeout(() => { setTimeout(() => {
// Set the pagination length. // Set the pagination length.
pagination.setPagesCount( pagination.setPagesCount(
Math.ceil(sortedDatabase.length / pagination.pageSize), Math.ceil(sortedDatabase.length / pagination.pageSize)
); );
// Select the rows to display on the current page. // Select the rows to display on the current page.
setRows( setRows(
sortedDatabase.slice( sortedDatabase.slice(
(pagination.page - 1) * pagination.pageSize, (pagination.page - 1) * pagination.pageSize,
pagination.page * pagination.pageSize, pagination.page * pagination.pageSize
), )
); );
setIsLoading(false); setIsLoading(false);
}, 1000); }, 1000);
@@ -254,8 +254,8 @@ export const FullServerSide = () => {
id: "actions", id: "actions",
renderCell: () => ( renderCell: () => (
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">delete</span>} icon={<span className="material-icons">delete</span>}
/> />
@@ -286,7 +286,7 @@ export const DataListOnly = () => {
id: "actions", id: "actions",
renderCell: () => { renderCell: () => {
return ( return (
<Button size="small" color="secondary"> <Button size="small" variant="secondary">
Do it Do it
</Button> </Button>
); );
@@ -328,7 +328,7 @@ export const WithColumnWidth = () => {
size: 50, size: 50,
renderCell: () => ( renderCell: () => (
<Button <Button
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">delete</span>} icon={<span className="material-icons">delete</span>}
/> />

View File

@@ -256,8 +256,8 @@ const CalendarAux = ({
<div className="c__calendar__wrapper__header"> <div className="c__calendar__wrapper__header">
<div className="c__calendar__wrapper__header__actions"> <div className="c__calendar__wrapper__header__actions">
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">navigate_before</span>} icon={<span className="material-icons">navigate_before</span>}
{...{ {...{
@@ -272,8 +272,8 @@ const CalendarAux = ({
/> />
<Button <Button
className="c__calendar__wrapper__header__actions__dropdown" className="c__calendar__wrapper__header__actions__dropdown"
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
iconPosition="right" iconPosition="right"
icon={<span className="material-icons">arrow_drop_down</span>} icon={<span className="material-icons">arrow_drop_down</span>}
@@ -285,8 +285,8 @@ const CalendarAux = ({
)} )}
</Button> </Button>
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">navigate_next</span>} icon={<span className="material-icons">navigate_next</span>}
type="button" type="button"
@@ -302,8 +302,8 @@ const CalendarAux = ({
</div> </div>
<div className="c__calendar__wrapper__header__actions"> <div className="c__calendar__wrapper__header__actions">
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">navigate_before</span>} icon={<span className="material-icons">navigate_before</span>}
onClick={() => state.focusPreviousSection(true)} onClick={() => state.focusPreviousSection(true)}
@@ -318,8 +318,8 @@ const CalendarAux = ({
/> />
<Button <Button
className="c__calendar__wrapper__header__actions__dropdown" className="c__calendar__wrapper__header__actions__dropdown"
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
iconPosition="right" iconPosition="right"
icon={<span className="material-icons">arrow_drop_down</span>} icon={<span className="material-icons">arrow_drop_down</span>}
@@ -331,8 +331,8 @@ const CalendarAux = ({
)} )}
</Button> </Button>
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
icon={<span className="material-icons">navigate_next</span>} icon={<span className="material-icons">navigate_next</span>}
onClick={() => state.focusNextSection(true)} onClick={() => state.focusNextSection(true)}

View File

@@ -58,8 +58,8 @@ export const CalendarCell = ({ state, date }: CalendarCellProps) => {
> >
<Button <Button
size="small" size="small"
variant={isSelected ? "brand" : "neutral"} color={isSelected ? "brand" : "neutral"}
color={ variant={
( (
isRangeCalendar(state) isRangeCalendar(state)
? isSelectionStart || isSelectionEnd ? isSelectionStart || isSelectionEnd

View File

@@ -150,8 +150,8 @@ const DatePickerAux = ({
? "components.forms.date_picker.toggle_button_aria_label_close" ? "components.forms.date_picker.toggle_button_aria_label_close"
: "components.forms.date_picker.toggle_button_aria_label_open" : "components.forms.date_picker.toggle_button_aria_label_open"
)} )}
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="small" size="small"
className="c__date-picker__wrapper__toggle" className="c__date-picker__wrapper__toggle"
icon={ icon={
@@ -167,8 +167,8 @@ const DatePickerAux = ({
"c__date-picker__inner__action--hidden": "c__date-picker__inner__action--hidden":
labelAsPlaceholder || disabled, labelAsPlaceholder || disabled,
})} })}
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
size="nano" size="nano"
icon={<span className="material-icons">close</span>} icon={<span className="material-icons">close</span>}
onClick={onClear} onClick={onClear}

View File

@@ -38,8 +38,8 @@ export const FileUploaderMulti = ({
<div className="c__file-uploader__file__specs"> <div className="c__file-uploader__file__specs">
<span>{formatBytes(file.size)}</span> <span>{formatBytes(file.size)}</span>
<Button <Button
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
size="nano" size="nano"
aria-label={t( aria-label={t(
"components.forms.file_uploader.delete_file_name", "components.forms.file_uploader.delete_file_name",

View File

@@ -22,8 +22,8 @@ export const InputPassword = (props: Omit<InputProps, "rightIcon">) => {
{showPassword ? "visibility_off" : "visibility"} {showPassword ? "visibility_off" : "visibility"}
</span> </span>
} }
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
size="small" size="small"
aria-label={t( aria-label={t(
`components.forms.input.password.${showPassword ? "hide" : "show"}_password` `components.forms.input.password.${showPassword ? "hide" : "show"}_password`

View File

@@ -138,8 +138,8 @@ export const SelectMonoAux = ({
{clearable && !disabled && downshiftReturn.selectedItem && ( {clearable && !disabled && downshiftReturn.selectedItem && (
<> <>
<Button <Button
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
size="nano" size="nano"
aria-label={t( aria-label={t(
"components.forms.select.clear_button_aria_label" "components.forms.select.clear_button_aria_label"
@@ -157,8 +157,8 @@ export const SelectMonoAux = ({
)} )}
<Button <Button
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
size="nano" size="nano"
className="c__select__inner__actions__open" className="c__select__inner__actions__open"
icon={ icon={

View File

@@ -117,8 +117,8 @@ export const SelectMultiAux = ({ children, ...props }: SelectMultiAuxProps) => {
props.selectedItems.length > 0 && ( props.selectedItems.length > 0 && (
<> <>
<Button <Button
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
size="nano" size="nano"
aria-label={t( aria-label={t(
"components.forms.select.clear_all_button_aria_label" "components.forms.select.clear_all_button_aria_label"
@@ -135,8 +135,8 @@ export const SelectMultiAux = ({ children, ...props }: SelectMultiAuxProps) => {
</> </>
)} )}
<Button <Button
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
size="nano" size="nano"
className="c__select__inner__actions__open" className="c__select__inner__actions__open"
icon={ icon={

View File

@@ -39,8 +39,8 @@ const SelectedItemsChips = ({
<SelectedOption option={selectedItemForRender} {...props} /> <SelectedOption option={selectedItemForRender} {...props} />
<Button <Button
tabIndex={-1} tabIndex={-1}
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
disabled={disabled} disabled={disabled}
size="small" size="small"
aria-label={t("components.forms.select.clear_button_aria_label")} aria-label={t("components.forms.select.clear_button_aria_label")}

View File

@@ -20,7 +20,7 @@ export const ConfirmationModal = ({
actions={ actions={
<> <>
<Button <Button
color="secondary" variant="secondary"
fullWidth={true} fullWidth={true}
onClick={() => onDecide(null)} onClick={() => onDecide(null)}
> >

View File

@@ -23,7 +23,7 @@ export const DeleteConfirmationModal = ({
actions={ actions={
<> <>
<Button <Button
color="secondary" variant="secondary"
fullWidth={true} fullWidth={true}
onClick={() => onDecide(null)} onClick={() => onDecide(null)}
> >
@@ -32,7 +32,7 @@ export const DeleteConfirmationModal = ({
<Button <Button
fullWidth={true} fullWidth={true}
onClick={() => onDecide("delete")} onClick={() => onDecide("delete")}
variant="error" color="error"
> >
{t("components.modals.helpers.delete_confirmation.delete")} {t("components.modals.helpers.delete_confirmation.delete")}
</Button> </Button>

View File

@@ -57,11 +57,11 @@ export const StackedModals = {
Open Modals Open Modals
</Button> </Button>
<Modal <Modal
leftActions={<Button color="tertiary">Tertiary</Button>} leftActions={<Button variant="tertiary">Tertiary</Button>}
rightActions={ rightActions={
<> <>
<Button color="secondary">Secondary</Button> <Button variant="secondary">Secondary</Button>
<Button color="primary">Primary</Button> <Button variant="primary">Primary</Button>
</> </>
} }
size={ModalSize.LARGE} size={ModalSize.LARGE}
@@ -70,11 +70,11 @@ export const StackedModals = {
{longLorem.text} {longLorem.text}
</Modal> </Modal>
<Modal <Modal
leftActions={<Button color="tertiary">Tertiary</Button>} leftActions={<Button variant="tertiary">Tertiary</Button>}
rightActions={ rightActions={
<> <>
<Button color="secondary">Secondary</Button> <Button variant="secondary">Secondary</Button>
<Button color="primary">Primary</Button> <Button variant="primary">Primary</Button>
</> </>
} }
size={ModalSize.MEDIUM} size={ModalSize.MEDIUM}
@@ -83,11 +83,11 @@ export const StackedModals = {
{longLorem.text} {longLorem.text}
</Modal> </Modal>
<Modal <Modal
leftActions={<Button color="tertiary">Tertiary</Button>} leftActions={<Button variant="tertiary">Tertiary</Button>}
rightActions={ rightActions={
<> <>
<Button color="secondary">Secondary</Button> <Button variant="secondary">Secondary</Button>
<Button color="primary">Primary</Button> <Button variant="primary">Primary</Button>
</> </>
} }
size={ModalSize.SMALL} size={ModalSize.SMALL}

View File

@@ -97,7 +97,7 @@ export const PrimaryButton: Story = {
args: { args: {
size: ModalSize.MEDIUM, size: ModalSize.MEDIUM,
rightActions: ( rightActions: (
<Button color="primary" fullWidth={true}> <Button variant="primary" fullWidth={true}>
Primary Primary
</Button> </Button>
), ),
@@ -108,7 +108,7 @@ export const SecondaryButton: Story = {
args: { args: {
size: ModalSize.MEDIUM, size: ModalSize.MEDIUM,
rightActions: ( rightActions: (
<Button color="secondary" fullWidth={true}> <Button variant="secondary" fullWidth={true}>
Secondary Secondary
</Button> </Button>
), ),
@@ -119,12 +119,12 @@ export const TwoButtons: Story = {
args: { args: {
size: ModalSize.MEDIUM, size: ModalSize.MEDIUM,
leftActions: ( leftActions: (
<Button color="secondary" fullWidth={true}> <Button variant="secondary" fullWidth={true}>
Secondary Secondary
</Button> </Button>
), ),
rightActions: ( rightActions: (
<Button color="primary" fullWidth={true}> <Button variant="primary" fullWidth={true}>
Primary Primary
</Button> </Button>
), ),
@@ -135,16 +135,16 @@ export const ThreeButtons: Story = {
args: { args: {
size: ModalSize.MEDIUM, size: ModalSize.MEDIUM,
leftActions: ( leftActions: (
<Button color="tertiary" fullWidth={true}> <Button variant="tertiary" fullWidth={true}>
Tertiary Tertiary
</Button> </Button>
), ),
rightActions: ( rightActions: (
<> <>
<Button color="secondary" fullWidth={true}> <Button variant="secondary" fullWidth={true}>
Secondary Secondary
</Button> </Button>
<Button color="primary" fullWidth={true}> <Button variant="primary" fullWidth={true}>
Primary Primary
</Button> </Button>
</> </>
@@ -157,8 +157,8 @@ export const CenterButtons: Story = {
size: ModalSize.MEDIUM, size: ModalSize.MEDIUM,
actions: ( actions: (
<> <>
<Button color="secondary">Secondary</Button> <Button variant="secondary">Secondary</Button>
<Button color="primary">Primary</Button> <Button variant="primary">Primary</Button>
</> </>
), ),
}, },
@@ -179,7 +179,7 @@ export const ExampleApplication: Story = {
touch. touch.
</> </>
), ),
rightActions: <Button color="primary">I understand</Button>, rightActions: <Button variant="primary">I understand</Button>,
}, },
parameters: { parameters: {
docs: { docs: {
@@ -193,11 +193,11 @@ export const ExampleApplication: Story = {
export const FullWithContent: Story = { export const FullWithContent: Story = {
args: { args: {
size: ModalSize.FULL, size: ModalSize.FULL,
leftActions: <Button color="tertiary">Tertiary</Button>, leftActions: <Button variant="tertiary">Tertiary</Button>,
rightActions: ( rightActions: (
<> <>
<Button color="secondary">Secondary</Button> <Button variant="secondary">Secondary</Button>
<Button color="primary">Primary</Button> <Button variant="primary">Primary</Button>
</> </>
), ),
children: longLorem.text, children: longLorem.text,

View File

@@ -99,8 +99,8 @@ export const ModalInner = ({ closeOnEsc = true, ...props }: ModalProps) => {
<div className="c__modal__close"> <div className="c__modal__close">
<Button <Button
icon={<span className="material-icons">close</span>} icon={<span className="material-icons">close</span>}
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
size="small" size="small"
onClick={props.onClose} onClick={props.onClose}
/> />

View File

@@ -106,8 +106,8 @@ export const Pagination = ({
<div className="c__pagination"> <div className="c__pagination">
<div className="c__pagination__list"> <div className="c__pagination__list">
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
aria-label={t("components.pagination.previous_aria")} aria-label={t("components.pagination.previous_aria")}
onClick={onPreviousClick} onClick={onPreviousClick}
disabled={!canPrevious} disabled={!canPrevious}
@@ -122,8 +122,8 @@ export const Pagination = ({
)} )}
{_page === page ? ( {_page === page ? (
<Button <Button
variant="neutral" color="neutral"
color="bordered" variant="bordered"
active={true} active={true}
aria-label={t("components.pagination.current_page_aria", { aria-label={t("components.pagination.current_page_aria", {
page: _page, page: _page,
@@ -134,8 +134,8 @@ export const Pagination = ({
</Button> </Button>
) : ( ) : (
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
aria-label={t("components.pagination.goto_page_aria", { aria-label={t("components.pagination.goto_page_aria", {
page: _page, page: _page,
})} })}
@@ -148,8 +148,8 @@ export const Pagination = ({
</Fragment> </Fragment>
))} ))}
<Button <Button
variant="neutral" color="neutral"
color="tertiary" variant="tertiary"
aria-label={t("components.pagination.next_aria")} aria-label={t("components.pagination.next_aria")}
onClick={onNextClick} onClick={onNextClick}
disabled={!canNext} disabled={!canNext}

View File

@@ -97,7 +97,7 @@ describe("<Toast />", () => {
<Button <Button
onClick={() => onClick={() =>
toast("Toast content", VariantType.NEUTRAL, { toast("Toast content", VariantType.NEUTRAL, {
actions: <Button color="tertiary">Tertiary</Button>, actions: <Button variant="tertiary">Tertiary</Button>,
}) })
} }
> >

View File

@@ -78,8 +78,8 @@ export const InfoCustom: Story = {
type: VariantType.INFO, type: VariantType.INFO,
actions: ( actions: (
<> <>
<Button color="primary">Primary</Button> <Button variant="primary">Primary</Button>
<Button color="secondary">Secondary</Button> <Button variant="secondary">Secondary</Button>
</> </>
), ),
}, },

View File

@@ -45,7 +45,7 @@ export const Toast = (props: ToastProps) => {
const removeAfterAnimation = async () => { const removeAfterAnimation = async () => {
await Promise.allSettled( await Promise.allSettled(
container.current!.getAnimations().map((animation) => animation.finished), container.current!.getAnimations().map((animation) => animation.finished)
); );
props.onDelete?.(); props.onDelete?.();
}; };
@@ -71,7 +71,7 @@ export const Toast = (props: ToastProps) => {
{props.primaryLabel && ( {props.primaryLabel && (
<div className="c__toast__content__buttons"> <div className="c__toast__content__buttons">
<Button <Button
color="primary" variant="primary"
onClick={props.primaryOnClick} onClick={props.primaryOnClick}
{...props.primaryProps} {...props.primaryProps}
> >

View File

@@ -14,10 +14,10 @@ describe("<Tooltip />", () => {
it("appear on button hover and then disappear", async () => { it("appear on button hover and then disappear", async () => {
render( render(
<Tooltip content="Hi there" closeDelay={0}> <Tooltip content="Hi there" closeDelay={0}>
<Button size="nano" color="tertiary"> <Button size="nano" variant="tertiary">
</Button> </Button>
</Tooltip>, </Tooltip>
); );
const button = screen.getByRole("button"); const button = screen.getByRole("button");
@@ -33,10 +33,10 @@ describe("<Tooltip />", () => {
it("appear on button focus and then disappear", async () => { it("appear on button focus and then disappear", async () => {
render( render(
<Tooltip content="Hi there" closeDelay={0}> <Tooltip content="Hi there" closeDelay={0}>
<Button size="nano" color="tertiary"> <Button size="nano" variant="tertiary">
</Button> </Button>
</Tooltip>, </Tooltip>
); );
expect(screen.queryByText("Hi there")).not.toBeInTheDocument(); expect(screen.queryByText("Hi there")).not.toBeInTheDocument();
@@ -51,10 +51,10 @@ describe("<Tooltip />", () => {
it("sets entering and exiting class", async () => { it("sets entering and exiting class", async () => {
render( render(
<Tooltip content="Hi there" closeDelay={0}> <Tooltip content="Hi there" closeDelay={0}>
<Button size="nano" color="tertiary"> <Button size="nano" variant="tertiary">
</Button> </Button>
</Tooltip>, </Tooltip>
); );
expect(screen.queryByText("Hi there")).not.toBeInTheDocument(); expect(screen.queryByText("Hi there")).not.toBeInTheDocument();
@@ -102,10 +102,10 @@ describe("<Tooltip />", () => {
} }
closeDelay={0} closeDelay={0}
> >
<Button size="nano" color="tertiary"> <Button size="nano" variant="tertiary">
</Button> </Button>
</Tooltip>, </Tooltip>
); );
const button = screen.getByRole("button"); const button = screen.getByRole("button");
@@ -128,10 +128,10 @@ describe("<Tooltip />", () => {
closeDelay={0} closeDelay={0}
className="my-custom-class" className="my-custom-class"
> >
<Button size="nano" color="tertiary"> <Button size="nano" variant="tertiary">
</Button> </Button>
</Tooltip>, </Tooltip>
); );
const button = screen.getByRole("button"); const button = screen.getByRole("button");

View File

@@ -26,8 +26,8 @@ export const Default = {
<Button <Button
size="small" size="small"
icon={<span className="material-icons">info</span>} icon={<span className="material-icons">info</span>}
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
/> />
), ),
content: content:
@@ -40,22 +40,22 @@ export const Placements = {
return ( return (
<div> <div>
<Tooltip placement="left" content="Hi there"> <Tooltip placement="left" content="Hi there">
<Button size="nano" color="tertiary" variant="neutral"> <Button size="nano" variant="tertiary" color="neutral">
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip placement="bottom" content="Hi there"> <Tooltip placement="bottom" content="Hi there">
<Button size="nano" color="tertiary" variant="neutral"> <Button size="nano" variant="tertiary" color="neutral">
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip placement="top" content="Hi there"> <Tooltip placement="top" content="Hi there">
<Button size="nano" color="tertiary" variant="neutral"> <Button size="nano" variant="tertiary" color="neutral">
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip placement="right" content="Hi there"> <Tooltip placement="right" content="Hi there">
<Button size="nano" color="tertiary" variant="neutral"> <Button size="nano" variant="tertiary" color="neutral">
</Button> </Button>
</Tooltip> </Tooltip>
@@ -131,8 +131,8 @@ export const WithHtml = {
<Button <Button
size="small" size="small"
icon={<span className="material-icons">info</span>} icon={<span className="material-icons">info</span>}
color="tertiary" variant="tertiary"
variant="neutral" color="neutral"
/> />
), ),
placement: "right", placement: "right",