Adding ListTile and CircleCheckbox components

This commit is contained in:
Alvaro 2023-01-25 09:54:32 -07:00 committed by GitHub
parent da0a741a36
commit 2d9cbf4795
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 497 additions and 0 deletions

View file

@ -0,0 +1,50 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { getClassNamesFor } from '../util/getClassNamesFor';
export type Props = {
id?: string;
checked?: boolean;
disabled?: boolean;
isRadio?: boolean;
name?: string;
onChange?: (value: boolean) => unknown;
onClick?: () => unknown;
};
/**
* A fancy checkbox
*
* It's only the checkbox, it does NOT produce a label.
* It is a controlled component, you must provide a value and
* update it yourself onClick/onChange.
*/
export function CircleCheckbox({
id,
checked,
disabled,
isRadio,
name,
onChange,
onClick,
}: Props): JSX.Element {
const getClassName = getClassNamesFor('CircleCheckbox');
return (
<div className={getClassName('__checkbox')}>
<input
checked={Boolean(checked)}
disabled={disabled}
aria-disabled={disabled}
id={id}
name={name}
onChange={onChange && (ev => onChange(ev.target.checked))}
onClick={onClick}
type={isRadio ? 'radio' : 'checkbox'}
/>
</div>
);
}