Locaft/src/components/Radio.js

68 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-03-03 22:58:00 -08:00
import React from "react";
import styled from "styled-components";
const RadioWrapper = styled.div`
`;
const Mark = styled.span`
position: relative;
border: 1px solid #777777;
width: 14px;
height: 14px;
left: 0;
border-radius: 50%;
margin-right: 5px;
vertical-align: middle;
&::after {
content: "";
display: block;
width: 0;
height: 0;
border-radius: 50%;
background-color: #03a9f4;
opacity: 0;
left: 50%;
top: 50%;
position: absolute;
transition: all 110ms;
}
`;
const Input = styled.input`
position: absolute;
visibility: hidden;
display: none;
&:checked + ${Mark} {
&::after {
width: 10px;
height: 10px;
opacity: 1;
left: 12%;
top: 12%;
}
}
`;
const Label = styled.label`
cursor: pointer;
position: relative;
${props =>
props.disabled &&
`
cursor: not-allowed;
opacity: 0.4;
`}
`;
const Radio = ({ name, children }) => (
<RadioWrapper>
<Label>
<Input name={name} type="radio" />
<Mark />
{children}
</Label>
</RadioWrapper>
);
export default Radio;