diff --git a/shared/common/newui/button/index.tsx b/shared/common/newui/button/index.tsx index ac00ab8b..6adc35cb 100644 --- a/shared/common/newui/button/index.tsx +++ b/shared/common/newui/button/index.tsx @@ -2,7 +2,7 @@ import cn from "@edgedb/common/utils/classNames"; import styles from "./button.module.scss"; import Spinner from "../../ui/spinner"; -import {PropsWithChildren} from "react"; +import {CSSProperties, PropsWithChildren, useEffect, useState} from "react"; interface _BaseButtonProps { className?: string; @@ -12,6 +12,7 @@ interface _BaseButtonProps { rightIcon?: JSX.Element; disabled?: boolean; loading?: boolean; + style?: CSSProperties; } export interface ButtonProps extends _BaseButtonProps { @@ -107,3 +108,31 @@ export function LinkButton({ ); } + +export function ConfirmButton({onClick, children, ...props}: ButtonProps) { + const [confirming, setConfirming] = useState(false); + + useEffect(() => { + if (confirming) { + const timer = setTimeout(() => setConfirming(false), 1000); + + return () => clearTimeout(timer); + } + }, [confirming]); + + return ( + + ); +} diff --git a/shared/common/newui/checkbox/checkbox.module.scss b/shared/common/newui/checkbox/checkbox.module.scss index 995ae8c8..2cf420b7 100644 --- a/shared/common/newui/checkbox/checkbox.module.scss +++ b/shared/common/newui/checkbox/checkbox.module.scss @@ -43,6 +43,14 @@ pointer-events: none; } + &.readonly { + pointer-events: none; + + .check { + opacity: 0.5; + } + } + @include darkTheme { color: #ccc; diff --git a/shared/common/newui/checkbox/index.tsx b/shared/common/newui/checkbox/index.tsx index 312e86f2..8822d96a 100644 --- a/shared/common/newui/checkbox/index.tsx +++ b/shared/common/newui/checkbox/index.tsx @@ -2,32 +2,40 @@ import cn from "@edgedb/common/utils/classNames"; import styles from "./checkbox.module.scss"; -export interface CheckboxProps { +export type CheckboxProps = { className?: string; label?: string | JSX.Element; checked: boolean; - onChange: (checked: boolean) => void; disabled?: boolean; -} + readOnly?: Readonly; +} & (Readonly extends true + ? { + onChange?: (checked: boolean) => void; + } + : { + onChange: (checked: boolean) => void; + }); -export function Checkbox({ +export function Checkbox({ className, label, checked, onChange, disabled, -}: CheckboxProps) { + readOnly, +}: CheckboxProps) { return (