mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 20:45:39 +01:00
implemented the user view type and website sharing
This commit is contained in:
parent
7a3443cd06
commit
66e67c7a3b
19 changed files with 260 additions and 68 deletions
|
|
@ -1,18 +1,23 @@
|
|||
import React, { useRef } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Icon from 'components/common/Icon';
|
||||
import Check from 'assets/check.svg';
|
||||
import styles from './Checkbox.module.css';
|
||||
|
||||
function Checkbox({ name, value, label, onChange }) {
|
||||
function Checkbox({ name, value, label, onChange, valueArray }) {
|
||||
const ref = useRef();
|
||||
const [isChecked, setIsChecked] = useState();
|
||||
|
||||
const onClick = () => ref.current.click();
|
||||
|
||||
useEffect(() => {
|
||||
setIsChecked((valueArray && valueArray.includes(value)) || (!valueArray && value));
|
||||
}, [valueArray, value]);
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.checkbox} onClick={onClick}>
|
||||
{value && <Icon icon={<Check />} size="small" />}
|
||||
{isChecked && <Icon icon={<Check />} size="small" />}
|
||||
</div>
|
||||
<label className={styles.label} htmlFor={name} onClick={onClick}>
|
||||
{label}
|
||||
|
|
@ -22,7 +27,8 @@ function Checkbox({ name, value, label, onChange }) {
|
|||
className={styles.input}
|
||||
type="checkbox"
|
||||
name={name}
|
||||
defaultChecked={value}
|
||||
value={valueArray ? value : isChecked}
|
||||
defaultChecked={isChecked}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue