From dd12d57552d6a526f197682089521dfc6cb93c5d Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 1 May 2022 15:35:20 +0200 Subject: [PATCH] Added light UI entity component --- .../src/components/panels/Entities/Light.vue | 212 ++++++++++++++++++ .../src/components/panels/Light/color.js | 17 ++ 2 files changed, 229 insertions(+) create mode 100644 platypush/backend/http/webapp/src/components/panels/Entities/Light.vue diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Light.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Light.vue new file mode 100644 index 0000000000..9c7dc7b41d --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Light.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/panels/Light/color.js b/platypush/backend/http/webapp/src/components/panels/Light/color.js index f74464346b..775df1b94a 100644 --- a/platypush/backend/http/webapp/src/components/panels/Light/color.js +++ b/platypush/backend/http/webapp/src/components/panels/Light/color.js @@ -211,4 +211,21 @@ export class ColorConverter { console.debug('Could not determine color space') console.debug(color) } + + hexToRgb(hex) { + return [ + hex.slice(1, 3), + hex.slice(3, 5), + hex.slice(5, 7), + ].map(_ => parseInt(_, 16)) + } + + rgbToHex(rgb) { + return '#' + rgb.map((x) => { + let hex = x.toString(16) + if (hex.length < 2) + hex = '0' + hex + return hex + }).join('') + } }