Skip to content

Commit 501bb7a

Browse files
authored
Switch with primary color (#620)
1 parent e034f09 commit 501bb7a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/components/switch/Switch.stories.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ import theme from "../../theme";
9090
checked={checked}
9191
readOnly
9292
/>
93+
<Spacer height="1rem" />
94+
<Switch
95+
name="label4"
96+
severity="primary"
97+
labelText="My Switch Button Notification"
98+
onClick={toggle}
99+
checked={checked}
100+
readOnly
101+
/>
93102
</GnuiContainer>
94103
);
95104
}}

src/components/switch/Switch.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import styled, { css } from "styled-components";
33
import theme from "../../theme";
44
import { setColor } from "../../utils/setcolor";
55

6-
export type SwitchProps = {
6+
export type SwitchProps = React.ComponentPropsWithoutRef<"input"> & {
77
labelText?: string;
8-
severity?: "danger" | "notification" | "warning" | "success";
8+
severity?: "danger" | "notification" | "primary" | "success" | "warning";
99
position?: "left" | "right";
10-
} & React.ComponentPropsWithoutRef<"input">;
10+
};
1111

1212
type SwitchInputProps = Pick<SwitchProps, "severity">;
1313

@@ -21,7 +21,9 @@ const SwitchInput = styled.input<SwitchInputProps>`
2121
${({ severity }) =>
2222
severity &&
2323
css`
24-
background-color: ${setColor(severity)};
24+
background-color: ${severity === "primary"
25+
? theme.color.interactive.primary
26+
: setColor(severity)};
2527
`}
2628
2729
&:before {

0 commit comments

Comments
 (0)