very early frontend wip + small fixes.
This commit is contained in:
+2
-6
@@ -72,13 +72,9 @@ func (s State) Interpolate(s2 State, f float64) State {
|
|||||||
if s.Power != nil && s2.Power != nil {
|
if s.Power != nil && s2.Power != nil {
|
||||||
if *s.Power == *s2.Power {
|
if *s.Power == *s2.Power {
|
||||||
newState.Power = s.Power
|
newState.Power = s.Power
|
||||||
}
|
} else if *s.Power {
|
||||||
|
|
||||||
// With power, interpolate strongly in the direction of power
|
|
||||||
if *s.Power {
|
|
||||||
newState.Power = gentools.Ptr(f < 0.95)
|
newState.Power = gentools.Ptr(f < 0.95)
|
||||||
}
|
} else {
|
||||||
if *s2.Power {
|
|
||||||
newState.Power = gentools.Ptr(f > 0.05)
|
newState.Power = gentools.Ptr(f > 0.05)
|
||||||
}
|
}
|
||||||
} else if s.Power != nil {
|
} else if s.Power != nil {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
/build
|
||||||
|
/.svelte-kit
|
||||||
|
/package
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Ignore files for PNPM, NPM and YARN
|
||||||
|
pnpm-lock.yaml
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
|
||||||
|
plugins: ['svelte3', '@typescript-eslint'],
|
||||||
|
ignorePatterns: ['*.cjs'],
|
||||||
|
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
|
||||||
|
settings: {
|
||||||
|
'svelte3/typescript': () => require('typescript')
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
sourceType: 'module',
|
||||||
|
ecmaVersion: 2020
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es2017: true,
|
||||||
|
node: true
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
/build
|
||||||
|
/.svelte-kit
|
||||||
|
/package
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
vite.config.js.timestamp-*
|
||||||
|
vite.config.ts.timestamp-*
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
engine-strict=true
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
/build
|
||||||
|
/.svelte-kit
|
||||||
|
/package
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Ignore files for PNPM, NPM and YARN
|
||||||
|
pnpm-lock.yaml
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"useTabs": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"printWidth": 100,
|
||||||
|
"plugins": ["prettier-plugin-svelte"],
|
||||||
|
"pluginSearchDirs": ["."],
|
||||||
|
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# create-svelte
|
||||||
|
|
||||||
|
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
|
||||||
|
|
||||||
|
## Creating a project
|
||||||
|
|
||||||
|
If you're seeing this, you've probably already done this step. Congrats!
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# create a new project in the current directory
|
||||||
|
npm create svelte@latest
|
||||||
|
|
||||||
|
# create a new project in my-app
|
||||||
|
npm create svelte@latest my-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# or start the server and open the app in a new browser tab
|
||||||
|
npm run dev -- --open
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
To create a production version of your app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
You can preview the production build with `npm run preview`.
|
||||||
|
|
||||||
|
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
||||||
Generated
+4804
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite dev",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
|
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
||||||
|
"format": "prettier --plugin-search-dir . --write ."
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sveltejs/adapter-auto": "^1.0.0",
|
||||||
|
"@sveltejs/kit": "^1.0.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
||||||
|
"@typescript-eslint/parser": "^5.45.0",
|
||||||
|
"eslint": "^8.28.0",
|
||||||
|
"eslint-config-prettier": "^8.5.0",
|
||||||
|
"eslint-plugin-svelte3": "^4.0.0",
|
||||||
|
"prettier": "^2.8.0",
|
||||||
|
"prettier-plugin-svelte": "^2.8.1",
|
||||||
|
"svelte": "^3.54.0",
|
||||||
|
"svelte-check": "^2.9.2",
|
||||||
|
"tslib": "^2.4.1",
|
||||||
|
"typescript": "^4.9.3",
|
||||||
|
"vite": "^4.0.0"
|
||||||
|
},
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
Vendored
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// See https://kit.svelte.dev/docs/types#app
|
||||||
|
// for information about these interfaces
|
||||||
|
// and what to do when importing types
|
||||||
|
declare namespace App {
|
||||||
|
// interface Error {}
|
||||||
|
// interface Locals {}
|
||||||
|
// interface PageData {}
|
||||||
|
// interface Platform {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width" />
|
||||||
|
<style>
|
||||||
|
body, html {
|
||||||
|
background: #111114;
|
||||||
|
color: #ccc;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
%sveltekit.head%
|
||||||
|
</head>
|
||||||
|
<body data-sveltekit-preload-data="hover">
|
||||||
|
<div style="display: contents">%sveltekit.body%</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { ColorRGB } from "../models/color";
|
||||||
|
|
||||||
|
export let selected: boolean = false;
|
||||||
|
export let title: string;
|
||||||
|
export let color: ColorRGB;
|
||||||
|
export let intensity: number;
|
||||||
|
|
||||||
|
let displayTitle: string;
|
||||||
|
$: {
|
||||||
|
if (title.length > 12) {
|
||||||
|
let last = title.split(" ").pop() || title;
|
||||||
|
if (last.length > 4) {
|
||||||
|
last = last.slice(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
displayTitle = `${(title.split(" ").shift()||"").slice(0, 10 - last.length)}... ${last}`
|
||||||
|
} else {
|
||||||
|
displayTitle = title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="lamp" class:selected>
|
||||||
|
<div class="row">
|
||||||
|
<div style="background-color: rgb({color.red*255},{color.green*255},{color.blue*255})" class="roundboi"></div>
|
||||||
|
<div class="title">{displayTitle}</div>
|
||||||
|
</div>
|
||||||
|
<div class="flatboi">
|
||||||
|
<div style="width: {intensity*100}%; background-color: rgb({color.red*255},{color.green*255},{color.blue*255})" class="flatboi2"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div.lamp {
|
||||||
|
width: 15ch;
|
||||||
|
height: 2em;
|
||||||
|
margin: 0.25em;
|
||||||
|
background: #18181c;
|
||||||
|
color: #84888f;
|
||||||
|
border-radius: 0.25em;
|
||||||
|
border-top-right-radius: 1em;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
div.lamp.selected {
|
||||||
|
background: #282833;
|
||||||
|
color: #cde;
|
||||||
|
}
|
||||||
|
div.lamp > div.row {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
div.lamp > div.row > div.roundboi {
|
||||||
|
width: 1.25em;
|
||||||
|
height: 1.25em;
|
||||||
|
margin-left: 0.25em;
|
||||||
|
margin-top: 0.30em;
|
||||||
|
border-radius: 2em;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 0.5px solid #000;
|
||||||
|
}
|
||||||
|
div.lamp > div.row > div.title {
|
||||||
|
font-size: 0.9em;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 0.4em;
|
||||||
|
margin-left: 0.75ch;
|
||||||
|
margin-right: 1ch;
|
||||||
|
height: 1.6em;
|
||||||
|
}
|
||||||
|
div.lamp > div.flatboi {
|
||||||
|
height: 0.2em;
|
||||||
|
background-color: #040408;
|
||||||
|
}
|
||||||
|
div.lamp > div.flatboi > div.flatboi2 {
|
||||||
|
height: 0.2em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export interface ColorRGB {
|
||||||
|
red: number
|
||||||
|
green: number
|
||||||
|
blue: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rgb(red: number, green: number, blue: number): ColorRGB {
|
||||||
|
return {red, green, blue};
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Lamp from "$lib/components/Lamp.svelte";
|
||||||
|
import { rgb } from "$lib/models/color";
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
<Lamp title="Hexagon 1" color={rgb(1.000,0.541,0.071)} intensity={0.3} />
|
||||||
|
<Lamp title="Hexagon 2" color={rgb(1.000,0.541,0.071)} intensity={0.4} />
|
||||||
|
<Lamp title="Hexagon 3" color={rgb(1.000,0.541,0.071)} intensity={0.5} />
|
||||||
|
<Lamp title="Hexagon 4" color={rgb(1.000,0.631,0.282)} selected intensity={0.1} />
|
||||||
|
<Lamp title="Lamp with an equally absurd name" color={rgb(0.500,0.542,1.000)} selected intensity={0.3} />
|
||||||
|
<Lamp title="Hexagon 5" color={rgb(1.000,0.631,0.282)} selected intensity={0.66} />
|
||||||
|
<Lamp title="Hexagon 6" color={rgb(1.000,0.700,0.408)} selected intensity={0.92} />
|
||||||
|
<Lamp title="Hexagon 7" color={rgb(1.000,0.700,0.408)} intensity={1} />
|
||||||
|
<Lamp title="Hexagon 8" color={rgb(1.000,0.700,0.408)} intensity={0.9} />
|
||||||
|
<Lamp title="Hexagon 9" color={rgb(1.000,0.700,0.408)} intensity={0.5} />
|
||||||
|
<Lamp title="Signe Table Lamp 1" color={rgb(0.765,0.820,1.000)} selected intensity={0.79} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div.page {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 100ch;
|
||||||
|
max-width: 95%;
|
||||||
|
margin-top: 1em;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,15 @@
|
|||||||
|
import adapter from '@sveltejs/adapter-auto';
|
||||||
|
import { vitePreprocess } from '@sveltejs/kit/vite';
|
||||||
|
|
||||||
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
|
const config = {
|
||||||
|
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
||||||
|
// for more information about preprocessors
|
||||||
|
preprocess: vitePreprocess(),
|
||||||
|
|
||||||
|
kit: {
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": "./.svelte-kit/tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true
|
||||||
|
}
|
||||||
|
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||||
|
//
|
||||||
|
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
||||||
|
// from the referenced tsconfig.json - TypeScript does not merge them in
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
|
|
||||||
|
/** @type {import('vite').UserConfig} */
|
||||||
|
const config = {
|
||||||
|
plugins: [sveltekit()]
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -445,7 +445,10 @@ func (b *Bridge) makeCongruentLoop(ctx context.Context) {
|
|||||||
|
|
||||||
// Handle power first
|
// Handle power first
|
||||||
if desired.Power != nil && active.Power != nil && *desired.Power != *active.Power {
|
if desired.Power != nil && active.Power != nil && *desired.Power != *active.Power {
|
||||||
updates["light/"+*lightID] = ResourceUpdate{Power: gentools.Ptr(*desired.Power)}
|
updates["light/"+*lightID] = ResourceUpdate{
|
||||||
|
Power: gentools.Ptr(*desired.Power),
|
||||||
|
TransitionDuration: gentools.Ptr(time.Millisecond * 101),
|
||||||
|
}
|
||||||
|
|
||||||
newActiveState := activeStates[id]
|
newActiveState := activeStates[id]
|
||||||
newActiveState.Power = gentools.Ptr(*desired.Power)
|
newActiveState.Power = gentools.Ptr(*desired.Power)
|
||||||
|
|||||||
Reference in New Issue
Block a user