forked from awesomestvi/navet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhvac-mode-controls.tsx
More file actions
74 lines (71 loc) · 2.38 KB
/
hvac-mode-controls.tsx
File metadata and controls
74 lines (71 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Flame, Snowflake, Wind } from 'lucide-react';
import { memo } from 'react';
import { RoundControlButton } from '@/app/components/primitives/round-control-button';
import { getCardActionControlSizes } from '@/app/components/shared/card-action-control-sizes';
import type { CardSize } from '@/app/components/shared/card-size-selector';
import { useI18n, useTheme } from '@/app/hooks';
import type { ThemeType } from '@/app/hooks/use-theme';
import { getHVACModeButtonColor } from '../../utils/hvac-styles';
interface HVACModeControlsProps {
mode: string;
isOn: boolean;
onModeChange: (mode: string) => void;
size?: CardSize;
}
export const HVACModeControls = memo(function HVACModeControls({
mode,
isOn,
onModeChange,
size = 'medium',
}: HVACModeControlsProps) {
const { theme } = useTheme();
const { t } = useI18n();
const primitiveSize = size === 'large' ? 'large' : 'medium';
const controlSizes = getCardActionControlSizes(primitiveSize);
return (
<>
<RoundControlButton
theme={theme as ThemeType}
size={primitiveSize}
variant="soft"
onClick={(e) => {
e.stopPropagation();
onModeChange('cool');
}}
aria-label={t('climate.mode.cool')}
disabled={!isOn}
className={`disabled:opacity-50 ${getHVACModeButtonColor('cool', mode, isOn, theme as ThemeType)}`}
>
<Snowflake className={controlSizes.icon} />
</RoundControlButton>
<RoundControlButton
theme={theme as ThemeType}
size={primitiveSize}
variant="soft"
onClick={(e) => {
e.stopPropagation();
onModeChange('heat');
}}
aria-label={t('climate.mode.heat')}
disabled={!isOn}
className={`disabled:opacity-50 ${getHVACModeButtonColor('heat', mode, isOn, theme as ThemeType)}`}
>
<Flame className={controlSizes.icon} />
</RoundControlButton>
<RoundControlButton
theme={theme as ThemeType}
size={primitiveSize}
variant="soft"
onClick={(e) => {
e.stopPropagation();
onModeChange('fan');
}}
aria-label={t('climate.mode.fan')}
disabled={!isOn}
className={`disabled:opacity-50 ${getHVACModeButtonColor('fan', mode, isOn, theme as ThemeType)}`}
>
<Wind className={controlSizes.icon} />
</RoundControlButton>
</>
);
});