Skip to content

Commit

Permalink
refactor: make switch styling similar to checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
evad1n committed May 23, 2024
1 parent ef7f3c1 commit 2724c2a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
7 changes: 3 additions & 4 deletions src/components/switch/Switch.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
}

.aminoSwitchWrapper {
margin-right: 16px;
width: 32px;
height: 16px;
min-width: 32px;
Expand All @@ -60,10 +59,10 @@
&.checked {
background: theme.$amino-primary;
}
}

&.withoutLabel {
margin-right: 0;
}
.infoWrapper {
margin-left: 16px;
}

.aminoSwitchWrapperWithIcons.aminoSwitchWrapperWithIcons {
Expand Down
2 changes: 1 addition & 1 deletion src/components/switch/Switch.module.scss.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export declare const aminoSwitchWrapper: string;
export declare const aminoSwitchWrapperWithIcons: string;
export declare const checked: string;
export declare const disabled: string;
export declare const infoWrapper: string;
export declare const labelWrapper: string;
export declare const left: string;
export declare const styledLabel: string;
export declare const styledLabelDescription: string;
export declare const styledSubtitle: string;
export declare const switchContainer: string;
export declare const switchIcon: string;
export declare const withoutLabel: string;
43 changes: 20 additions & 23 deletions src/components/switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const Switch = ({
styles.aminoSwitchWrapper,
styles.aminoSwitchWrapperWithIcons,
checked && styles.checked,
!hasLabel && styles.withoutLabel,
)}
>
<div
Expand All @@ -73,36 +72,34 @@ export const Switch = ({
</div>
) : (
<div
className={clsx(
styles.aminoSwitchWrapper,
checked && styles.checked,
!hasLabel && styles.withoutLabel,
)}
className={clsx(styles.aminoSwitchWrapper, checked && styles.checked)}
>
<div
className={clsx(styles.aminoSwitch, checked && styles.checked)}
id={labelAsHtmlAttribute}
/>
</div>
)}
<div>
<div className={styles.labelWrapper}>
{labelIcon}
<Text className={styles.styledLabel} type="input-label">
{label}
{labelDescription && (
<span className={styles.styledLabelDescription}>
{labelDescription}
</span>
)}
</Text>
{hasLabel && (
<div className={styles.infoWrapper}>
<div className={styles.labelWrapper}>
{labelIcon}
<Text className={styles.styledLabel} type="input-label">
{label}
{labelDescription && (
<span className={styles.styledLabelDescription}>
{labelDescription}
</span>
)}
</Text>
</div>
{subtitle && (
<Text className={styles.styledSubtitle} type="subtitle">
{subtitle}
</Text>
)}
</div>
{subtitle && (
<Text className={styles.styledSubtitle} type="subtitle">
{subtitle}
</Text>
)}
</div>
)}
</label>
);
};

0 comments on commit 2724c2a

Please sign in to comment.