Skip to content

Commit

Permalink
Merge pull request #435 from pixiv/feat/remove-charcoal-styled-from-s…
Browse files Browse the repository at this point in the history
…witch

Feat/remove-charcoal-styled-from-switch
  • Loading branch information
toshusai authored Jan 9, 2024
2 parents 45b2844 + e0d0f0d commit a1c0ade
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ exports[`Storyshots DropdownSelector/ListItem Basic 1`] = `
}

.c3:disabled,
.c3[aria-disabled]:not([aria-disabled=false]) {
.c3[aria-disabled]:not([aria-disabled='false']) {
opacity: 0.32;
cursor: default;
}

.c3:active > input {
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
}

.c3:disabled,
.c3[aria-disabled]:not([aria-disabled=false]) {
cursor: default;
}

.c4 {
-webkit-appearance: none;
-moz-appearance: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ exports[`Storyshots Switch Labelled 1`] = `
}

.c0:disabled,
.c0[aria-disabled]:not([aria-disabled=false]) {
.c0[aria-disabled]:not([aria-disabled='false']) {
opacity: 0.32;
cursor: default;
}

.c0:active > input {
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
}

.c0:disabled,
.c0[aria-disabled]:not([aria-disabled=false]) {
cursor: default;
}

.c2 {
font-size: 14px;
line-height: 22px;
Expand Down Expand Up @@ -168,19 +164,15 @@ exports[`Storyshots Switch Playground 1`] = `
}

.c0:disabled,
.c0[aria-disabled]:not([aria-disabled=false]) {
.c0[aria-disabled]:not([aria-disabled='false']) {
opacity: 0.32;
cursor: default;
}

.c0:active > input {
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
}

.c0:disabled,
.c0[aria-disabled]:not([aria-disabled=false]) {
cursor: default;
}

.c2 {
font-size: 14px;
line-height: 22px;
Expand Down Expand Up @@ -322,19 +314,15 @@ exports[`Storyshots Switch Unlabelled 1`] = `
}

.c0:disabled,
.c0[aria-disabled]:not([aria-disabled=false]) {
.c0[aria-disabled]:not([aria-disabled='false']) {
opacity: 0.32;
cursor: default;
}

.c0:active > input {
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
}

.c0:disabled,
.c0[aria-disabled]:not([aria-disabled=false]) {
cursor: default;
}

.c1 {
-webkit-appearance: none;
-moz-appearance: none;
Expand Down
25 changes: 10 additions & 15 deletions packages/react/src/components/Switch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useMemo, memo, forwardRef } from 'react'
import * as React from 'react'
import { useToggleState } from 'react-stately'
import styled from 'styled-components'
import { theme } from '../../styled'
import { disabledSelector } from '@charcoal-ui/utils'
import { useObjectRef } from '@react-aria/utils'

export type SwitchProps = {
Expand Down Expand Up @@ -68,28 +66,25 @@ const Label = styled.label`
cursor: pointer;
outline: 0;
${theme((o) => o.disabled)}
&:disabled,
&[aria-disabled]:not([aria-disabled='false']) {
opacity: 0.32;
cursor: default;
}
:active > input {
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
}
${disabledSelector} {
cursor: default;
}
`

const LabelInner = styled.div`
${theme((o) => [
o.typography(14).preserveHalfLeading,
o.font.text2,
o.margin.left(4),
])}
font-size: 14px;
line-height: 22px;
color: var(--charcoal-text2);
margin-left: 4px;
`

const SwitchInput = styled.input.attrs({
type: 'checkbox',
})`
const SwitchInput = styled.input.attrs({ type: 'checkbox' })`
appearance: none;
display: inline-flex;
position: relative;
Expand Down

0 comments on commit a1c0ade

Please sign in to comment.