diff --git a/package-lock.json b/package-lock.json index f34582281..b2f1fabc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@tanstack/react-query": "^4.28.0", "classnames": "^2.3.2", "luxon": "^3.3.0", - "seamapi": "^8.10.1", + "seamapi": "^8.11.0", "uuid": "^9.0.0" }, "devDependencies": { @@ -21692,9 +21692,9 @@ } }, "node_modules/seamapi": { - "version": "8.10.2", - "resolved": "https://registry.npmjs.org/seamapi/-/seamapi-8.10.2.tgz", - "integrity": "sha512-r1VJnXEwQ5VPM59iecjnee+oLhTg/1sCK4XgLmkrnSoZvfmWq8QS6CiO+hubhfmfJpBSGI9x1PRP434QN7J+0A==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/seamapi/-/seamapi-8.11.0.tgz", + "integrity": "sha512-DjG8Cg5aE+Qu2OhqbBkLooANQJ2l+AHGqKLFOiYDFt8iPIpx6c0T9EnL5mbpEFPgGEn8766tT6rMgMH/AkQokg==", "dependencies": { "axios": "0.25.0", "axios-retry": "3.2.5", diff --git a/package.json b/package.json index 9f5ed48ca..5ba806801 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "@tanstack/react-query": "^4.28.0", "classnames": "^2.3.2", "luxon": "^3.3.0", - "seamapi": "^8.10.1", + "seamapi": "^8.11.0", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/src/lib/ui/thermostat/ClimateModeMenu.stories.tsx b/src/lib/ui/thermostat/ClimateModeMenu.stories.tsx new file mode 100644 index 000000000..67b7c2422 --- /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..d8474e196 --- /dev/null +++ b/src/lib/ui/thermostat/ClimateModeMenu.tsx @@ -0,0 +1,71 @@ +import type { HvacModeSetting } from 'seamapi' + +import { ChevronDownIcon } from 'lib/icons/ChevronDown.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 { ThermoModeMenuOption } from 'lib/ui/thermostat/ThermoModeMenuOption.js' + +const modes: HvacModeSetting[] = ['heat', 'cool', 'heat_cool', 'off'] + +interface ClimateModeMenuProps { + mode: HvacModeSetting + onChange: (mode: HvacModeSetting) => void +} + +export function ClimateModeMenu({ + mode, + onChange, +}: ClimateModeMenuProps): JSX.Element { + return ( + ( + + )} + verticalOffset={-180} + horizontalOffset={-32} + backgroundProps={{ + className: 'seam-thermo-mode-menu', + }} + > + {modes.map((m) => ( + { + onChange(m) + }} + /> + ))} + + ) +} + +function ModeIcon(mode: HvacModeSetting): JSX.Element { + switch (mode) { + case 'heat': + return + case 'cool': + return + case 'heat_cool': + return + case 'off': + return + } +} + +const t = { + heat: 'Heat', + cool: 'Cool', + heat_cool: 'Heat & Cool', + off: 'Off', +} diff --git a/src/lib/ui/thermostat/FanModeMenu.tsx b/src/lib/ui/thermostat/FanModeMenu.tsx index 67ef386e9..2bacbc3a1 100644 --- a/src/lib/ui/thermostat/FanModeMenu.tsx +++ b/src/lib/ui/thermostat/FanModeMenu.tsx @@ -1,15 +1,16 @@ -import { CheckBlackIcon } from 'lib/icons/CheckBlack.js' +import type { FanModeSetting } from 'seamapi' + import { ChevronDownIcon } from 'lib/icons/ChevronDown.js' import { FanIcon } from 'lib/icons/Fan.js' import { FanOutlineIcon } from 'lib/icons/FanOutline.js' import { Menu } from 'lib/ui/Menu/Menu.js' -import { MenuItem } from 'lib/ui/Menu/MenuItem.js' +import { ThermoModeMenuOption } from 'lib/ui/thermostat/ThermoModeMenuOption.js' -type Mode = 'auto' | 'on' +const modes: FanModeSetting[] = ['auto', 'on'] interface FanModeMenuProps { - mode: Mode - onChange: (mode: Mode) => void + mode: FanModeSetting + onChange: (mode: FanModeSetting) => void } export function FanModeMenu({ mode, onChange }: FanModeMenuProps): JSX.Element { @@ -29,49 +30,24 @@ export function FanModeMenu({ mode, onChange }: FanModeMenuProps): JSX.Element { verticalOffset={-180} horizontalOffset={-32} backgroundProps={{ - className: 'seam-fan-mode-menu-bg', + className: 'seam-thermo-mode-menu', }} > -