Skip to content

Commit

Permalink
fix: toggle skeleton label
Browse files Browse the repository at this point in the history
  • Loading branch information
jnm2377 committed May 31, 2021
1 parent a2064cb commit d302938
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
33 changes: 32 additions & 1 deletion packages/components/src/components/toggle/_toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
}

.#{$prefix}--toggle-input__label & {
margin-top: $carbon--spacing-05;
margin-top: $carbon--spacing-03;
}
}

Expand Down Expand Up @@ -512,6 +512,9 @@
cursor: not-allowed;
}

//----------------------------------------------
// Skeleton
// ---------------------------------------------
//md toggle input
.#{$prefix}--toggle.#{$prefix}--skeleton
+ .#{$prefix}--toggle-input__label
Expand All @@ -521,6 +524,20 @@
width: 3rem;
}

//md skeleton label text
.#{$prefix}--toggle.#{$prefix}--skeleton
+ .#{$prefix}--toggle-input__label
> div {
overflow: hidden;
width: 1.5rem;
height: 0.5rem;
//hides text
font-size: 0%;
line-height: 0;

@include skeleton;
}

//small toggle input
.#{$prefix}--toggle-input--small.#{$prefix}--skeleton
+ .#{$prefix}--toggle-input__label
Expand All @@ -530,6 +547,20 @@
width: 2rem;
}

//sm skeleton label text
.#{$prefix}--toggle-input--small.#{$prefix}--skeleton
+ .#{$prefix}--toggle-input__label
> div {
overflow: hidden;
width: 1rem;
height: 0.5rem;
//hides text
font-size: 0%;
line-height: 0;

@include skeleton;
}

// on/off text skeleton
.#{$prefix}--toggle.#{$prefix}--skeleton
+ .#{$prefix}--toggle-input__label
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Toggle/Toggle.Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class ToggleSkeleton extends React.Component {
className={`${prefix}--toggle-input__label`}
htmlFor={id}
aria-label={labelText ? null : this.props['aria-label']}>
{labelText}
{labelText ? <div>{labelText}</div> : null}
<span className={`${prefix}--toggle__switch`}>
<span className={`${prefix}--toggle__text--left`} />
<span className={`${prefix}--toggle__appearance`} />
Expand Down
15 changes: 3 additions & 12 deletions packages/react/src/components/ToggleSmall/ToggleSmall.Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export default class ToggleSmallSkeleton extends React.Component {
className
)}
{...rest}>
<input
type="checkbox"
<span
id={id}
className={`${prefix}--toggle ${prefix}--toggle--small ${prefix}--skeleton`}
/>
Expand All @@ -58,17 +57,9 @@ export default class ToggleSmallSkeleton extends React.Component {
className={`${prefix}--toggle__label ${prefix}--skeleton`}
htmlFor={id}>
{labelText && (
<span className={`${prefix}--toggle__label-text`}>{labelText}</span>
<div className={`${prefix}--toggle__label-text`}>{labelText}</div>
)}
<span className={`${prefix}--toggle__appearance`}>
<svg
className={`${prefix}--toggle__check`}
width="6px"
height="5px"
viewBox="0 0 6 5">
<path d="M2.2403 2.7299L4.9245 0 6 1.1117 2.2384 5 0 2.6863 1.0612 1.511z" />
</svg>
</span>
<span className={`${prefix}--toggle__appearance`} />
</label>
</div>
);
Expand Down

0 comments on commit d302938

Please sign in to comment.