diff --git a/package.json b/package.json index 5e532fc..b72996d 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "dependencies": { "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.0.6", + "@radix-ui/react-slider": "^1.1.2", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tooltip": "^1.0.7", "@types/web-bluetooth": "^0.0.20", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 511563d..efd834a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: '@radix-ui/react-dropdown-menu': specifier: ^2.0.6 version: 2.0.6(@types/react-dom@18.2.19)(@types/react@18.2.62)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-slider': + specifier: ^1.1.2 + version: 1.1.2(@types/react-dom@18.2.19)(@types/react@18.2.62)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-slot': specifier: ^1.0.2 version: 1.0.2(@types/react@18.2.62)(react@18.2.0) @@ -1149,6 +1152,12 @@ packages: engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} dev: true + /@radix-ui/number@1.0.1: + resolution: {integrity: sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==} + dependencies: + '@babel/runtime': 7.24.0 + dev: false + /@radix-ui/primitive@1.0.1: resolution: {integrity: sha512-yQ8oGX2GVsEYMWGxcovu1uGWPCxV5BFfeeYxqPmuAzUyLT9qmaMXSAhXpb0WrspIeqYzdJpkh2vHModJPgRIaw==} dependencies: @@ -1541,6 +1550,37 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false + /@radix-ui/react-slider@1.1.2(@types/react-dom@18.2.19)(@types/react@18.2.62)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-NKs15MJylfzVsCagVSWKhGGLNR1W9qWs+HtgbmjjVUB3B9+lb3PYoXxVju3kOrpf0VKyVCtZp+iTwVoqpa1Chw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + dependencies: + '@babel/runtime': 7.24.0 + '@radix-ui/number': 1.0.1 + '@radix-ui/primitive': 1.0.1 + '@radix-ui/react-collection': 1.0.3(@types/react-dom@18.2.19)(@types/react@18.2.62)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.62)(react@18.2.0) + '@radix-ui/react-context': 1.0.1(@types/react@18.2.62)(react@18.2.0) + '@radix-ui/react-direction': 1.0.1(@types/react@18.2.62)(react@18.2.0) + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.19)(@types/react@18.2.62)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-use-controllable-state': 1.0.1(@types/react@18.2.62)(react@18.2.0) + '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.2.62)(react@18.2.0) + '@radix-ui/react-use-previous': 1.0.1(@types/react@18.2.62)(react@18.2.0) + '@radix-ui/react-use-size': 1.0.1(@types/react@18.2.62)(react@18.2.0) + '@types/react': 18.2.62 + '@types/react-dom': 18.2.19 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + /@radix-ui/react-slot@1.0.2(@types/react@18.2.62)(react@18.2.0): resolution: {integrity: sha512-YeTpuq4deV+6DusvVUW4ivBgnkHwECUu0BiN43L5UCDFgdhsRUWAghhTF5MbvNTPzmiFOx90asDSUjWuCNapwg==} peerDependencies: @@ -1646,6 +1686,20 @@ packages: react: 18.2.0 dev: false + /@radix-ui/react-use-previous@1.0.1(@types/react@18.2.62)(react@18.2.0): + resolution: {integrity: sha512-cV5La9DPwiQ7S0gf/0qiD6YgNqM5Fk97Kdrlc5yBcrF3jyEZQwm7vYFqMo4IfeHgJXsRaMvLABFtd0OVEmZhDw==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@babel/runtime': 7.24.0 + '@types/react': 18.2.62 + react: 18.2.0 + dev: false + /@radix-ui/react-use-rect@1.0.1(@types/react@18.2.62)(react@18.2.0): resolution: {integrity: sha512-Cq5DLuSiuYVKNU8orzJMbl15TXilTnJKUCltMVQg53BQOF1/C5toAaGrowkgksdBQ9H+SRL23g0HDmg9tvmxXw==} peerDependencies: diff --git a/src/components/MainContent/SelectedDevice.tsx b/src/components/MainContent/SelectedDevice.tsx index ff80a7c..440eacf 100644 --- a/src/components/MainContent/SelectedDevice.tsx +++ b/src/components/MainContent/SelectedDevice.tsx @@ -4,6 +4,7 @@ import { Pax } from '@/pax'; import { post } from '@/pax/containers/api'; import { BatteryPercentageMessage, + BrightnessMessage, ColorThemeMessage, } from '@/pax/core/messages'; import { ColorTheme } from '@/pax/shared/types'; @@ -16,6 +17,7 @@ import TemperatureProgress from '../TemperatureProgress'; import { ThemePicker } from '../ThemePicker'; import { hardcodedThemes } from '../ThemePicker/colors'; import { Button } from '../ui/button'; +import { Slider } from '../ui/slider'; import { Connect } from './SelectedDevice/Connect'; interface SelectedDeviceProps { @@ -53,6 +55,9 @@ export const SelectedDevice = ({ currentDevice }: SelectedDeviceProps) => { if (message instanceof BatteryPercentageMessage) { actions.setBatteryPercentage(message.percentage); } + if (message instanceof BrightnessMessage) { + actions.setBrightness(message.brightness); + } }) .catch(e => { if (e instanceof BaseBluetoothException) { @@ -96,6 +101,22 @@ export const SelectedDevice = ({ currentDevice }: SelectedDeviceProps) => { actualTemperature={state.actualTemperature} unit={'C'} /> + { + actions.setBrightness(value[0]); + }} + onValueCommit={value => { + const toPost = post( + BrightnessMessage.createWithBrightness(value[0]), + currentDevice, + ); + void bluetoothState.writeToMainService(toPost.packet); + }} + />

Device: {!currentDevice ? '' : currentDevice.serial}