All files / src/components/search_item SearchItemIsRentButton.tsx

0% Statements 0/18
100% Branches 1/1
100% Functions 1/1
0% Lines 0/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                                                                                                                                       
import { Dispatch, SetStateAction } from 'react';
import styled from 'styled-components';
 
type Props = {
  setIsRent: Dispatch<SetStateAction<boolean>>;
};
 
const StyledDescription = styled.p`
  font-size: 1.6rem;
  text-align: center;
`;
 
const StyledLabelWrapper = styled.div`
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 0;
`;
 
const StyledLabel = styled.label`
  display: inline-block;
  position: relative;
  width: 80px;
  height: 35px;
  border-radius: 50px;
  background-color: #f6f6f6;
  border: 1px solid #b3b3b3;
  cursor: pointer;
  transition: background-color 0.4s;
  &:has(:checked) {
    background-color: #c7d01c;
  }
  &::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 31px;
    height: 31px;
    border-radius: 50%;
    box-shadow: 0 0 5px rgb(0 0 0 / 20%);
    background-color: #ffffff;
    content: '';
    transition: left 0.4s;
  }
  &:has(:checked)::after {
    left: 46.5px;
  }
`;
 
const StyledInput = styled.input`
  display: none;
`;
 
const SearchItemIsRentButton = (props: Props) => {
  return (
    <>
      <StyledDescription>貸し出し可能物品フィルター</StyledDescription>
      <StyledLabelWrapper>
        <StyledLabel>
          <StyledInput type="checkbox" onChange={() => props.setIsRent((prev) => !prev)} />
        </StyledLabel>
      </StyledLabelWrapper>
    </>
  );
};
export default SearchItemIsRentButton;