Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
fix: remove spacing left to the checkbox icon in FF (#283)
Browse files Browse the repository at this point in the history
* fix(checkbox): fix spacing in ff

* fix(radio): fix spacing in ff

* fix(switch): fix spacing in ff
  • Loading branch information
Mohammer5 authored and varl committed Jun 15, 2019
1 parent 812ad24 commit 33165a5
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/Checkbox/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Input extends Component {
} = this.props

return (
<Fragment>
<div>
<input
ref={this.ref}
type="checkbox"
Expand All @@ -38,15 +38,13 @@ export class Input extends Component {
/>

<style jsx>{`
input {
display: block;
opacity: 0;
div {
width: 0;
height: 0;
outline: 0;
overflow: hidden;
}
`}</style>
</Fragment>
</div>
)
}
}
Expand Down
33 changes: 31 additions & 2 deletions src/Radio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,36 @@ const icons = css.resolve`
}
`

const Input = React.forwardRef(
(
{ name, value, checked, disabled, tabIndex, onChange, onFocus, onBlur },
ref
) => (
<div>
<input
type="radio"
ref={ref}
name={name}
value={value}
checked={checked}
disabled={disabled}
tabIndex={tabIndex}
onChange={onChange}
onFocus={onFocus}
onBlur={onBlur}
/>

<style jsx>{`
div {
height: 0;
width: 0;
overflow: hidden;
}
`}</style>
</div>
)
)

class Radio extends Component {
ref = createRef()

Expand Down Expand Up @@ -113,9 +143,8 @@ class Radio extends Component {
disabled,
})}
>
<input
<Input
ref={this.ref}
type="radio"
name={name}
value={value}
checked={checked}
Expand Down
34 changes: 29 additions & 5 deletions src/Switch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ import { SwitchIcon } from '../icons/Switch.js'

import styles from './styles'

const Input = React.forwardRef(
({ name, disabled, checked, onChange, onFocus, onBlur }, ref) => (
<div>
<input
type="checkbox"
ref={ref}
name={name}
disabled={disabled}
checked={checked}
onChange={onChange}
onFocus={onFocus}
onBlur={onBlur}
/>

<style jsx>{`
div {
height: 0;
width: 0;
overflow: hidden;
}
`}</style>
</div>
)
)

class Switch extends Component {
ref = createRef()
state = {
Expand Down Expand Up @@ -56,15 +81,14 @@ class Switch extends Component {
focus,
})}
>
<input
<Input
ref={this.ref}
type="checkbox"
disabled={disabled}
name={name}
onBlur={this.onBlur}
onFocus={this.onFocus}
checked={checked}
disabled={disabled}
onChange={onChange}
onFocus={this.onFocus}
onBlur={this.onBlur}
/>

<SwitchIcon
Expand Down

0 comments on commit 33165a5

Please sign in to comment.