feat(ott-37): added checkbox, radio and arrow components

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
mirlan.maksitaliev 6 years ago
parent 56e99e6291
commit 1dfc96e809
  1. 6
      public/images/arrowLeft.svg
  2. 6
      public/images/arrowRight.svg
  3. 24
      public/images/checkboxChecked.svg
  4. 17
      public/images/checkboxUnchecked.svg
  5. 34
      public/images/radioChecked.svg
  6. 17
      public/images/radioUnchecked.svg
  7. 28
      src/features/Components/Arrows/index.tsx
  8. 21
      src/features/Components/Arrows/stories.tsx
  9. 38
      src/features/Components/Checkbox/index.tsx
  10. 28
      src/features/Components/Checkbox/stories.tsx
  11. 40
      src/features/Components/Checkbox/styled.tsx
  12. 38
      src/features/Components/Radio/index.tsx
  13. 30
      src/features/Components/Radio/stories.tsx
  14. 40
      src/features/Components/Radio/styled.tsx
  15. 3
      src/features/Components/index.tsx

@ -0,0 +1,6 @@
<svg width="40" height="40" viewBox="0 0 40 40" fill="none"
xmlns="http://www.w3.org/2000/svg">
<g opacity="0.3">
<path fill-rule="evenodd" clip-rule="evenodd" d="M40 20C40 31.0457 31.0457 40 20 40C8.9543 40 0 31.0457 0 20C0 8.9543 8.9543 0 20 0C31.0457 0 40 8.9543 40 20ZM18.6569 27.0711L12.2929 20.7071C11.9024 20.3166 11.9024 19.6834 12.2929 19.2929L18.6569 12.9289C19.0474 12.5384 19.6805 12.5384 20.0711 12.9289C20.4616 13.3195 20.4616 13.9526 20.0711 14.3431L15.4142 19L25 19C25.5523 19 26 19.4477 26 20C26 20.5523 25.5523 21 25 21L15.4142 21L20.0711 25.6569C20.4616 26.0474 20.4616 26.6805 20.0711 27.0711C19.6805 27.4616 19.0474 27.4616 18.6569 27.0711Z" fill="white"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 695 B

@ -0,0 +1,6 @@
<svg width="40" height="40" viewBox="0 0 40 40" fill="none"
xmlns="http://www.w3.org/2000/svg">
<g opacity="0.3">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 20C0 31.0457 8.95431 40 20 40C31.0457 40 40 31.0457 40 20C40 8.9543 31.0457 0 20 0C8.95431 0 0 8.9543 0 20ZM21.3431 27.0711L27.7071 20.7071C28.0976 20.3166 28.0976 19.6834 27.7071 19.2929L21.3431 12.9289C20.9526 12.5384 20.3195 12.5384 19.9289 12.9289C19.5384 13.3195 19.5384 13.9526 19.9289 14.3431L24.5858 19L15 19C14.4477 19 14 19.4477 14 20C14 20.5523 14.4477 21 15 21L24.5858 21L19.9289 25.6569C19.5384 26.0474 19.5384 26.6805 19.9289 27.0711C20.3195 27.4616 20.9526 27.4616 21.3431 27.0711Z" fill="white"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 696 B

@ -0,0 +1,24 @@
<svg width="26" height="27" viewBox="0 0 26 27" fill="none"
xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_d)">
<rect x="2" y="2" width="22" height="22" rx="2" fill="#005EDD"/>
<rect x="2" y="2" width="22" height="22" rx="2" fill="url(#paint0_linear)"/>
</g>
<path d="M13.1197 17.7526L11.4442 19.4281C11.109 19.7633 10.5825 19.7633 10.2473 19.4281L4.23937 13.4441C3.90426 13.109 3.90426 12.5824 4.23937 12.2473L5.9149 10.5718C6.25001 10.2367 6.7766 10.2367 7.11171 10.5718L13.1197 16.5797C13.4548 16.8909 13.4548 17.4414 13.1197 17.7526Z" fill="#222222"/>
<path d="M20.0849 6.23936L21.7605 7.91489C22.0956 8.25 22.0956 8.77659 21.7605 9.1117L11.444 19.4521C11.1089 19.7872 10.5823 19.7872 10.2472 19.4521L8.57164 17.7766C8.23654 17.4415 8.23654 16.9149 8.57164 16.5798L18.8881 6.23936C19.2232 5.92819 19.7498 5.92819 20.0849 6.23936Z" fill="#222222"/>
<defs>
<filter id="filter0_d" x="0" y="0.5" width="26" height="26" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
<feOffset dy="0.5"/>
<feGaussianBlur stdDeviation="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
</filter>
<linearGradient id="paint0_linear" x1="13" y1="2" x2="13" y2="24" gradientUnits="userSpaceOnUse">
<stop stop-color="#005EDD"/>
<stop offset="1" stop-color="#0033CC"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -0,0 +1,17 @@
<svg width="26" height="27" viewBox="0 0 26 27" fill="none"
xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_d)">
<rect x="3" y="3" width="20" height="20" rx="1" stroke="#005EDD" stroke-width="2"/>
</g>
<defs>
<filter id="filter0_d" x="0" y="0.5" width="26" height="26" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
<feOffset dy="0.5"/>
<feGaussianBlur stdDeviation="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 860 B

@ -0,0 +1,34 @@
<svg width="28" height="28" viewBox="0 0 28 28" fill="none"
xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_d)">
<circle cx="14" cy="13.0001" r="12" fill="#005EDD"/>
<circle cx="14" cy="13.0001" r="12" fill="url(#paint0_radial)" fill-opacity="0.88"/>
</g>
<g filter="url(#filter1_d)">
<circle cx="14" cy="13.0001" r="4" fill="#0F0F0F"/>
</g>
<defs>
<filter id="filter0_d" x="0" y="0.00012207" width="28" height="28" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
<feOffset dy="1"/>
<feGaussianBlur stdDeviation="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
</filter>
<filter id="filter1_d" x="7" y="6.00012" width="14" height="14" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
<feOffset/>
<feGaussianBlur stdDeviation="1.5"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
</filter>
<radialGradient id="paint0_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(14 13.0001) rotate(90) scale(21)">
<stop offset="0.427083" stop-color="#005EDD"/>
<stop offset="1"/>
</radialGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -0,0 +1,17 @@
<svg width="28" height="28" viewBox="0 0 28 28" fill="none"
xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_d)">
<circle cx="14" cy="13.0001" r="11" stroke="#005EDD" stroke-width="2"/>
</g>
<defs>
<filter id="filter0_d" x="0" y="0.00012207" width="28" height="28" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
<feOffset dy="1"/>
<feGaussianBlur stdDeviation="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 853 B

@ -0,0 +1,28 @@
import styled from 'styled-components/macro'
const ArrowStyled = styled.button`
width: 40px;
height: 40px;
padding: 0;
border: 1px solid transparent;
border-radius: 50%;
background-color: transparent;
background-position: center;
outline: none;
:active {
background-color: rgba(117, 117, 117, 1);
}
:hover, :focus {
background-color: rgba(117, 117, 117, 0.5);
}
`
export const ArrowLeft = styled(ArrowStyled)`
background-image: url(/images/arrowLeft.svg);
`
export const ArrowRight = styled(ArrowStyled)`
background-image: url(/images/arrowRight.svg);
`

@ -0,0 +1,21 @@
import React from 'react'
import { ArrowLeft, ArrowRight } from 'features/Components'
export default {
component: ArrowLeft,
title: 'Arrows',
}
const backgroundStyles = {
backgroundColor: '#333',
height: '200px',
padding: '20px',
}
export const Group = () => (
<div style={backgroundStyles}>
<ArrowLeft />
<ArrowRight />
</div>
)

@ -0,0 +1,38 @@
import React, { InputHTMLAttributes } from 'react'
import {
Wrapper,
Input,
Label,
} from './styled'
type TCheckbox = Pick<InputHTMLAttributes<HTMLInputElement>, (
| 'checked'
| 'id'
| 'name'
| 'value'
| 'onChange'
)> & {
label?: string,
}
export const Checkbox = ({
checked,
id,
label,
name,
onChange,
value,
}: TCheckbox) => (
<Wrapper>
<Input
id={id}
type='checkbox'
name={name}
value={value}
checked={checked}
onChange={onChange}
/>
<Label htmlFor={id}>{label}</Label>
</Wrapper>
)

@ -0,0 +1,28 @@
import React from 'react'
import { Checkbox } from 'features/Components'
export default {
component: Checkbox,
title: 'Checkbox',
}
const backgroundStyles = {
backgroundColor: '#333',
height: '200px',
padding: '20px',
}
export const Group = () => (
<div style={backgroundStyles}>
<Checkbox
id='primeraDivisión'
label='Primera División'
checked
/>
<Checkbox
id='manchesterUnited'
label='Manchester United'
/>
</div>
)

@ -0,0 +1,40 @@
import styled from 'styled-components/macro'
export const Wrapper = styled.div`
`
export const Label = styled.label`
color: ${({ theme: { colors } }) => colors.text};
font-style: normal;
font-weight: bold;
font-size: 18px;
line-height: 21px;
`
export const Input = styled.input`
position: absolute;
z-index: -1;
opacity: 0;
&+${Label} {
display: inline-flex;
align-items: center;
user-select: none;
}
&+${Label}::before {
content: '';
display: inline-block;
width: 24px;
height: 24px;
margin-right: 22px;
background-repeat: no-repeat;
background-position: center center;
background-image: url(/images/checkboxUnchecked.svg);
}
&:checked+${Label}::before {
background-image: url(/images/checkboxChecked.svg);
}
`

@ -0,0 +1,38 @@
import React, { InputHTMLAttributes } from 'react'
import {
Wrapper,
Input,
Label,
} from './styled'
type TCheckbox = Pick<InputHTMLAttributes<HTMLInputElement>, (
| 'checked'
| 'id'
| 'name'
| 'value'
| 'onChange'
)> & {
label?: string,
}
export const Radio = ({
checked,
id,
label,
name,
onChange,
value,
}: TCheckbox) => (
<Wrapper>
<Input
id={id}
type='radio'
name={name}
value={value}
checked={checked}
onChange={onChange}
/>
<Label htmlFor={id}>{label}</Label>
</Wrapper>
)

@ -0,0 +1,30 @@
import React from 'react'
import { Radio } from 'features/Components'
export default {
component: Radio,
title: 'Radio',
}
const backgroundStyles = {
backgroundColor: '#333',
height: '200px',
padding: '20px',
}
export const Group = () => (
<div style={backgroundStyles}>
<Radio
id='primeraDivisión'
label='Primera División'
name='team'
checked
/>
<Radio
id='manchesterUnited'
label='Manchester United'
name='team'
/>
</div>
)

@ -0,0 +1,40 @@
import styled from 'styled-components/macro'
export const Wrapper = styled.div`
`
export const Label = styled.label`
color: ${({ theme: { colors } }) => colors.text};
font-style: normal;
font-weight: bold;
font-size: 18px;
line-height: 21px;
`
export const Input = styled.input`
position: absolute;
z-index: -1;
opacity: 0;
&+${Label} {
display: inline-flex;
align-items: center;
user-select: none;
}
&+${Label}::before {
content: '';
display: inline-block;
width: 26px;
height: 26px;
margin-right: 22px;
background-repeat: no-repeat;
background-position: center center;
background-image: url(/images/radioUnchecked.svg);
}
&:checked+${Label}::before {
background-image: url(/images/radioChecked.svg);
}
`

@ -1,2 +1,5 @@
export * from './Input'
export * from './Button'
export * from './Radio'
export * from './Checkbox'
export * from './Arrows'

Loading…
Cancel
Save