mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-02 20:21:19 +02:00
refactor: remove checkbox
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Flex, Text } from "rebass";
|
||||
import { Switch } from "@rebass/forms";
|
||||
|
||||
function CheckBox(props) {
|
||||
const [checked, setChecked] = useState(props.checked || false);
|
||||
useEffect(() => {
|
||||
setChecked(props.checked);
|
||||
}, [props.checked]);
|
||||
return (
|
||||
<Flex
|
||||
onClick={() => {
|
||||
if (props.onChecked) {
|
||||
props.onChecked(!checked);
|
||||
setChecked(!checked);
|
||||
}
|
||||
if (props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
}}
|
||||
width="full"
|
||||
alignItems="center"
|
||||
justifyContent="space-between"
|
||||
sx={{ cursor: "pointer", marginBottom: 2 }}
|
||||
>
|
||||
<Flex fontSize="body" sx={{ cursor: "pointer" }} alignItems="center">
|
||||
<props.icon size={18} />
|
||||
<Text sx={{ marginLeft: 1 }}>{props.label}</Text>
|
||||
</Flex>
|
||||
|
||||
<Switch checked={checked} />
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
export default CheckBox;
|
||||
Reference in New Issue
Block a user