From 6fddbd677667fc987baa35ba6553dbab43e3b677 Mon Sep 17 00:00:00 2001 From: Tristan B Date: Thu, 7 Sep 2023 10:52:50 -0600 Subject: [PATCH 01/13] Add `ClimateModeMenu` --- .../ui/thermostat/ClimateModeMenu.stories.tsx | 32 +++++ src/lib/ui/thermostat/ClimateModeMenu.tsx | 109 +++++++++++++++++ src/lib/ui/thermostat/FanModeMenu.tsx | 8 +- src/styles/_thermostat.scss | 114 ++++++++++-------- 4 files changed, 210 insertions(+), 53 deletions(-) create mode 100644 src/lib/ui/thermostat/ClimateModeMenu.stories.tsx create mode 100644 src/lib/ui/thermostat/ClimateModeMenu.tsx diff --git a/src/lib/ui/thermostat/ClimateModeMenu.stories.tsx b/src/lib/ui/thermostat/ClimateModeMenu.stories.tsx new file mode 100644 index 000000000..d1d700a40 --- /dev/null +++ b/src/lib/ui/thermostat/ClimateModeMenu.stories.tsx @@ -0,0 +1,32 @@ +import { Box } from '@mui/material' +import { useArgs } from '@storybook/preview-api' +import type { Meta, StoryObj } from '@storybook/react' + +import { ClimateModeMenu } from './ClimateModeMenu.js' + +const meta: Meta = { + title: 'Library/ClimateModeMenu', + tags: ['autodocs'], + component: ClimateModeMenu, +} + +type Story = StoryObj + +export const Content: Story = { + render: (props) => { + const [, setArgs] = useArgs() + + return ( + + { + setArgs({ mode }) + }} + /> + + ) + }, +} + +export default meta diff --git a/src/lib/ui/thermostat/ClimateModeMenu.tsx b/src/lib/ui/thermostat/ClimateModeMenu.tsx new file mode 100644 index 000000000..24b589ba3 --- /dev/null +++ b/src/lib/ui/thermostat/ClimateModeMenu.tsx @@ -0,0 +1,109 @@ +import { CheckBlackIcon } from 'lib/icons/CheckBlack.js' +import { ChevronDownIcon } from 'lib/icons/ChevronDown.js' +import { FanIcon } from 'lib/icons/Fan.js' +import { FanOutlineIcon } from 'lib/icons/FanOutline.js' +import { OffIcon } from 'lib/icons/Off.js' +import { ThermostatCoolIcon } from 'lib/icons/ThermostatCool.js' +import { ThermostatHeatIcon } from 'lib/icons/ThermostatHeat.js' +import { ThermostatHeatCoolIcon } from 'lib/icons/ThermostatHeatCool.js' +import { Menu } from 'lib/ui/Menu/Menu.js' +import { MenuItem } from 'lib/ui/Menu/MenuItem.js' + +type Mode = 'heat' | 'cool' | 'heatcool' | 'off' + +interface ClimateModeMenuProps { + mode: Mode + onChange: (mode: Mode) => void +} + +export function ClimateModeMenu({ + mode, + onChange, +}: ClimateModeMenuProps): JSX.Element { + return ( + ( + + )} + verticalOffset={-180} + horizontalOffset={-32} + backgroundProps={{ + className: 'seam-climate-mode-menu-bg seam-thermo-mode-menu', + }} + > + + ) +} + +interface OptionProps { + mode: Mode + onClick: () => void + isSelected: boolean +} + +function Option({ mode, isSelected, onClick }: OptionProps): JSX.Element { + return ( + +
+
+ {getModeIcon(mode)} + {mode} +
+
+ {isSelected && } +
+
+
+ ) +} + +function getModeIcon(mode: Mode): JSX.Element { + switch (mode) { + case 'heat': + return + case 'cool': + return + case 'heatcool': + return + case 'off': + return + } +} + +const t = { + auto: 'Auto', + on: 'On', +} diff --git a/src/lib/ui/thermostat/FanModeMenu.tsx b/src/lib/ui/thermostat/FanModeMenu.tsx index 67ef386e9..79c574cde 100644 --- a/src/lib/ui/thermostat/FanModeMenu.tsx +++ b/src/lib/ui/thermostat/FanModeMenu.tsx @@ -29,7 +29,7 @@ export function FanModeMenu({ mode, onChange }: FanModeMenuProps): JSX.Element { verticalOffset={-180} horizontalOffset={-32} backgroundProps={{ - className: 'seam-fan-mode-menu-bg', + className: 'seam-fan-mode-menu-bg seam-thermo-mode-menu', }} >