Skip to content

Commit

Permalink
change color-switch to button
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Dec 7, 2023
1 parent 28f0f52 commit 0085e12
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe("color-switch", () => {

test("color-scheme-toggle", ({ expect }) => {
const hook = renderHook(() => useTheme());
act(() => hook.result.current.setColorSchemePref(""));
render(<ColorSwitch />);
const element = screen.getByTestId("color-switch");
act(() => fireEvent.click(element));
Expand All @@ -15,5 +16,7 @@ describe("color-switch", () => {
expect(hook.result.current.colorSchemePref).toBe("light");
act(() => fireEvent.click(element));
expect(hook.result.current.colorSchemePref).toBe("system");
act(() => fireEvent.click(element));
expect(hook.result.current.colorSchemePref).toBe("dark");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ export function ColorSwitch({ size = 25 }: ColorSwitchProps) {
}
};
return (
<div
<button
className="nextjs-themes--color-switch"
data-testid="color-switch"
onClick={toggleColorScheme}
onKeyUp={e => e.key === "Enter" && toggleColorScheme()}
role="button"
type="button"
// @ts-expect-error -- setting custom attribute
style={{ "--size": `${size}px` }}
tabIndex={0}
/>
);
}
1 change: 1 addition & 0 deletions packages/nextjs-themes/src/styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.nextjs-themes--color-switch {
all: unset;
position: relative;
box-shadow: none;
color: #aaa;
Expand Down

0 comments on commit 0085e12

Please sign in to comment.