Skip to content

Commit a78bce6

Browse files
refactor: change prop name from hashoverstyle to hidehoverstyles
1 parent a496a4a commit a78bce6

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

Diff for: src/components/Button/Button.scss

+10-9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ $black-outline-hover: rgba(0, 0, 0, 0.08);
2424
cursor: not-allowed;
2525
}
2626

27+
&.deriv-button__hover--disabled {
28+
pointer-events: none;
29+
cursor: default;
30+
31+
&:hover {
32+
background-color: inherit;
33+
color: inherit;
34+
}
35+
}
36+
2737
&__size {
2838
&--sm {
2939
height: 2.4rem;
@@ -197,13 +207,4 @@ $black-outline-hover: rgba(0, 0, 0, 0.08);
197207
}
198208
}
199209

200-
&.deriv-button__disable-hover {
201-
pointer-events: none;
202-
cursor: default;
203-
204-
&:hover {
205-
background-color: inherit;
206-
color: inherit;
207-
}
208-
}
209210
}

Diff for: src/components/Button/__test__/Button.spec.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ describe("Button component", () => {
9090
expect(screen.queryByText("Test Button")).toBeNull();
9191
});
9292

93-
it("hover styles are applied when hasHoverStyle is true", () => {
93+
it("hover styles are applied when hideHoverStyles is true", () => {
9494
render(
95-
<Button hasHoverStyle={true}>Hover Button</Button>
95+
<Button hideHoverStyles={true}>Hover Button</Button>
9696
);
9797
const button = screen.getByRole("button");
98-
expect(button).not.toHaveClass("deriv-button__disable-hover");
98+
expect(button).not.toHaveClass("deriv-button__hover--disabled");
9999
});
100100

101-
it("hover styles are not applied when hasHoverStyle is false", () => {
101+
it("hover styles are not applied when hideHoverStyles is false", () => {
102102
render(
103-
<Button hasHoverStyle={false}>Hover Button</Button>
103+
<Button>Hover Button</Button>
104104
);
105105
const button = screen.getByRole("button");
106-
expect(button).toHaveClass("deriv-button__disable-hover");
106+
expect(button).toHaveClass("deriv-button__hover--disabled");
107107
});
108108

109109
});

Diff for: src/components/Button/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface ButtonProps extends ComponentProps<"button"> {
1515
isLoading?: boolean;
1616
rounded?: Extract<TGenericSizes, "lg" | "md" | "sm">;
1717
size?: Extract<TGenericSizes, "lg" | "md" | "sm">;
18-
hasHoverStyle?:boolean;
18+
hideHoverStyles?:boolean;
1919
textSize?: ComponentProps<typeof Text>["size"];
2020
variant?: TVariant;
2121
}
@@ -66,7 +66,7 @@ export const Button = ({
6666
isLoading = false,
6767
rounded = "sm",
6868
size = "md",
69-
hasHoverStyle=true,
69+
hideHoverStyles=false,
7070
textSize,
7171
variant = "contained",
7272
...rest
@@ -82,7 +82,7 @@ export const Button = ({
8282
ButtonRounded[rounded],
8383
{
8484
"deriv-button__full-width": isFullWidth,
85-
"deriv-button__disable-hover": !hasHoverStyle,
85+
"deriv-button__hover--disabled": hideHoverStyles,
8686
},
8787
className,
8888
)}

Diff for: stories/Button.stories.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const meta = {
1515
isLoading: false,
1616
disabled: false,
1717
size: "md",
18-
hasHoverStyle:true,
18+
hideHoverStyles:false,
1919
isFullWidth: false,
2020
rounded: "sm",
2121
type: "button",
@@ -36,7 +36,7 @@ const meta = {
3636
options: ["true", "false"],
3737
control: { type: "boolean" },
3838
},
39-
hasHoverStyle: {
39+
hideHoverStyles: {
4040
options: ["true", "false"],
4141
control: { type: "boolean" },
4242
},
@@ -91,10 +91,10 @@ export const ContainedPrimary: Story = {
9191
};
9292

9393
export const ContainedPrimaryWithNoHover: Story = {
94-
name: "Contained (Primary No Hover)",
94+
name: "Contained (Primary No Hover Style)",
9595
args: {
9696
...meta.args,
97-
hasHoverStyle:false,
97+
hideHoverStyles:true,
9898
},
9999
};
100100

0 commit comments

Comments
 (0)