-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/182 - Reusable component for checkbox (#183)
* 182 - Create a simple and reusable checkbox component * 182 - Use the new component in ComparisonCheckbox and LastRunCheckbox * Fix Tab's hover styles * 182 - Fix tests and give a unique id for ComparisonCheckbox container
- Loading branch information
Showing
9 changed files
with
91 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { ReactComponent as Checked } from '../../images/checked.svg'; | ||
import { ReactComponent as Unchecked } from '../../images/unchecked.svg'; | ||
import { StyledCheckbox, StyledLabel } from './Checkbox.styles'; | ||
|
||
const Checkbox = ({ checked, onChange, value, label }) => { | ||
return ( | ||
<StyledLabel> | ||
<StyledCheckbox | ||
type="checkbox" | ||
value={value} | ||
checked={checked} | ||
onChange={onChange} | ||
/> | ||
<span>{checked ? <Checked /> : <Unchecked />}</span> | ||
{label} | ||
</StyledLabel> | ||
); | ||
}; | ||
|
||
export default Checkbox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const StyledLabel = styled.label` | ||
margin-right: 20px; | ||
display: block; | ||
position: relative; | ||
span { | ||
padding-right: var(--space-8); | ||
svg { | ||
position: relative; | ||
top: -1px; | ||
} | ||
} | ||
`; | ||
|
||
export const StyledCheckbox = styled.input` | ||
appearance: none; | ||
opacity: 0; | ||
position: absolute; | ||
top: 7px; | ||
height: var(--space-16); | ||
width: var(--space-16); | ||
border-radius: 2px; | ||
&:focus { | ||
opacity: 1; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters