Skip to content

Commit

Permalink
fix(toggle): Types (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
hachiojidev authored Feb 15, 2021
1 parent 0f88b92 commit 18186af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/Toggle/StyledToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from "styled-components";
import { scales } from "../Checkbox/types";
import { ToggleProps, HandleProps, InputProps, ScaleKeys } from "./types";

const scaleKeyValues = {
Expand All @@ -22,7 +23,7 @@ const scaleKeyValues = {
},
};

const getScale = (property: ScaleKeys) => ({ scale }: ToggleProps) => {
const getScale = (property: ScaleKeys) => ({ scale = scales.MD }: ToggleProps) => {
return scaleKeyValues[scale][property];
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import StyledToggle, { Input, Handle } from "./StyledToggle";
import { ToggleProps, scales } from "./types";

const Toggle: React.FC<ToggleProps> = ({ checked, scale, ...props }) => {
const Toggle: React.FC<ToggleProps> = ({ checked, scale = scales.MD, ...props }) => {
const isChecked = !!checked;

return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/Toggle/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ export const scales = {

export type Scales = typeof scales[keyof typeof scales];

export interface ToggleProps {
scale: Scales;
export interface ToggleProps extends InputHTMLAttributes<HTMLInputElement> {
scale?: Scales;
checked?: boolean;
}

export interface HandleProps {
scale: Scales;
}

export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
export interface InputProps {
scale: Scales;
}

Expand Down

0 comments on commit 18186af

Please sign in to comment.