diff --git a/.changeset/fresh-dots-happen.md b/.changeset/fresh-dots-happen.md new file mode 100644 index 0000000..05ad483 --- /dev/null +++ b/.changeset/fresh-dots-happen.md @@ -0,0 +1,5 @@ +--- +"@openfun/cunningham-react": patch +--- + +Apply disable style to disabled button link diff --git a/packages/react/src/components/Button/_index.scss b/packages/react/src/components/Button/_index.scss index b26aa2a..bd0eed4 100644 --- a/packages/react/src/components/Button/_index.scss +++ b/packages/react/src/components/Button/_index.scss @@ -32,7 +32,7 @@ border-color: currentColor; } - &:disabled { + &:disabled, &.c__button--disabled { background-color: var(--c--theme--colors--greyscale-200); color: var(--c--theme--colors--greyscale-600); cursor: not-allowed; diff --git a/packages/react/src/components/Button/index.spec.tsx b/packages/react/src/components/Button/index.spec.tsx index 5f46e32..b715ea8 100644 --- a/packages/react/src/components/Button/index.spec.tsx +++ b/packages/react/src/components/Button/index.spec.tsx @@ -60,11 +60,22 @@ describe(", ); const button = screen.getByRole("button", { name: "Test button" }); + expect(button).toHaveAttribute("disabled"); expect(handleClick).not.toBeCalled(); await act(async () => user.click(button)); expect(handleClick).not.toHaveBeenCalled(); }); + it("renders disabled link", async () => { + render( + , + ); + const button = screen.getByRole("link", { name: "Test button link" }); + expect(button.classList).toContain("c__button--disabled"); + }); + it("renders as link when href is used", () => { render(