File size: 1,522 Bytes
77fd7a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31c44ac
77fd7a1
 
 
 
 
 
ad06c9a
77fd7a1
 
 
 
 
 
 
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
import React, { useState } from "react";
import styles from "./Checkbox.module.css";
import Text from "../Text/Text";

interface CheckboxProps {
  label: React.ReactNode;
  size?: string;
}

function Checkbox(props: Readonly<CheckboxProps>) {
  const [isChecked, setIsChecked] = useState(false);

  const { size = "14px" } = props;

  const checkboxInlineStyles: React.CSSProperties = {
    width: size,
    height: size,
  };

  const fontInlineStyles: React.CSSProperties = {
    fontSize: size,
  };

  const handleCheckboxChange = () => {
    setIsChecked(!isChecked);
  };

  return (
    <div className={styles.checkboxWrapper}>
      <label className={styles.checkboxLabel}>
        <input
          type={"checkbox"}
          className={styles.checkbox}
          checked={isChecked}
          onChange={handleCheckboxChange}
        />
        <span className={styles.customCheckbox} style={checkboxInlineStyles}>
          <svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 24 24"
            className={styles.checkmarkIcon}
          >
            <path
              className={styles.checkmarkPath}
              fill="none"
              stroke="var(--text-color-button)"
              strokeWidth="3"
              d="M4 12.6111L8.92308 17.5L20 6.5"
            />
          </svg>
        </span>
        <span className={styles.labelText} style={fontInlineStyles}>
          <Text>{props.label}</Text>
        </span>
      </label>
    </div>
  );
}

export default Checkbox;