From 72d7922af698288d0bc507c11f70125506b7d193 Mon Sep 17 00:00:00 2001 From: hafsahayath <44601750+hafsahayath@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:15:00 +0530 Subject: [PATCH 1/2] refactor: extend switch component --- .../src/components/Switch/switch.types.ts | 5 +++++ lib/src/components/Switch/Switch.tsx | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 examples/vanilla-extract-react/src/components/Switch/switch.types.ts diff --git a/examples/vanilla-extract-react/src/components/Switch/switch.types.ts b/examples/vanilla-extract-react/src/components/Switch/switch.types.ts new file mode 100644 index 0000000..633e678 --- /dev/null +++ b/examples/vanilla-extract-react/src/components/Switch/switch.types.ts @@ -0,0 +1,5 @@ +export interface ISwitchProps { + status: boolean; + onChange: React.Dispatch>; + isDisabled?: boolean; +} \ No newline at end of file diff --git a/lib/src/components/Switch/Switch.tsx b/lib/src/components/Switch/Switch.tsx index 5e23d5c..4a70e43 100644 --- a/lib/src/components/Switch/Switch.tsx +++ b/lib/src/components/Switch/Switch.tsx @@ -2,14 +2,18 @@ import { slider, switchInputStyle, switchLayout } from "./switch.css"; import { ISwitchProps } from "./switch.types"; import "./switch-global-styles.css"; +type SwitchProps = ISwitchProps & JSX.IntrinsicElements["input"]; + export const Switch = ({ status, onChange, isDisabled = false, -}: ISwitchProps) => { + ...nativeProps +}: SwitchProps) => { return (