Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 770 | Rev 1821 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 770 Rev 1273
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useState } from 'react'
2
import styled, { css } from 'styled-components'
2
import styled, { css } from 'styled-components'
Línea -... Línea 3...
-
 
3
 
-
 
4
const SwitchContainer = styled.label`
-
 
5
  display: inline-flex;
-
 
6
  flex-direction: column;
-
 
7
`
3
 
8
 
4
const StyledSwitch = styled.label`
9
const StyledSwitch = styled.div`
5
  position: relative;
10
  position: relative;
6
  display: inline-block;
11
  display: inline-block;
7
  width: 60px;
12
  width: 60px;
8
  height: 34px;
13
  height: 34px;
Línea 54... Línea 59...
54
        transform: translateX(26px);
59
        transform: translateX(26px);
55
      }
60
      }
56
    `}
61
    `}
57
`
62
`
Línea -... Línea 63...
-
 
63
 
-
 
64
const SwitchInput = ({
58
 
65
  label = '',
-
 
66
  isChecked: initialValue = false,
-
 
67
  setValue = () => null
59
const SwitchInput = ({ isChecked: initialValue, setValue = () => null }) => {
68
}) => {
Línea 60... Línea 69...
60
  const [isChecked, setIsChecked] = useState(initialValue)
69
  const [isChecked, setIsChecked] = useState(initialValue)
61
 
70
 
62
  const handleToggle = () => {
71
  const handleToggle = () => {
63
    setIsChecked(!isChecked)
72
    setIsChecked(!isChecked)
Línea 64... Línea 73...
64
    setValue(!isChecked)
73
    setValue(!isChecked)
-
 
74
  }
-
 
75
 
-
 
76
  return (
65
  }
77
    <SwitchContainer>
66
 
78
      {label}
67
  return (
79
 
68
    <StyledSwitch isChecked={isChecked}>
80
      <StyledSwitch isChecked={isChecked}>
-
 
81
        <input type='checkbox' checked={isChecked} onChange={handleToggle} />
69
      <input type='checkbox' checked={isChecked} onChange={handleToggle} />
82
        <span className='slider round'></span>
70
      <span className='slider round'></span>
83
      </StyledSwitch>
Línea 71... Línea 84...
71
    </StyledSwitch>
84
    </SwitchContainer>