mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 00:44:14 +00:00
fix: fix button disabled and reset to 0
This commit is contained in:
parent
0517c31fc1
commit
58bf28bb24
3 changed files with 17 additions and 1 deletions
|
|
@ -26,4 +26,9 @@
|
|||
&.smallIcon {
|
||||
font-size: var(--font-xsm);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,17 +5,25 @@ import { cn } from '@/helpers/styles';
|
|||
import styles from './button.module.css';
|
||||
|
||||
interface ButtonProps {
|
||||
disabled?: boolean;
|
||||
icon: React.ReactElement;
|
||||
onClick: () => void;
|
||||
smallIcon?: boolean;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
export function Button({ icon, onClick, smallIcon, tooltip }: ButtonProps) {
|
||||
export function Button({
|
||||
disabled = false,
|
||||
icon,
|
||||
onClick,
|
||||
smallIcon,
|
||||
tooltip,
|
||||
}: ButtonProps) {
|
||||
return (
|
||||
<Tooltip content={tooltip} placement="bottom" showDelay={0}>
|
||||
<button
|
||||
className={cn(styles.button, smallIcon && styles.smallIcon)}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
>
|
||||
{icon}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ export function SleepTimerModal({ onClose, show }: SleepTimerModalProps) {
|
|||
const handleReset = () => {
|
||||
if (timerId.current) clearInterval(timerId.current);
|
||||
setTimeLeft(0);
|
||||
setHours('0');
|
||||
setMinutes('0');
|
||||
setRunning(false);
|
||||
};
|
||||
|
||||
|
|
@ -114,6 +116,7 @@ export function SleepTimerModal({ onClose, show }: SleepTimerModalProps) {
|
|||
/>
|
||||
{!running && (
|
||||
<Button
|
||||
disabled={calculateTotalSeconds() <= 0}
|
||||
icon={<FaPlay />}
|
||||
smallIcon
|
||||
tooltip={'Start'}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue