From 5bd50c4a325b077b2b8ab50e5715c432f2451159 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 3 Jun 2019 07:08:21 +0000 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=8C=9B=20=20fixed=20the=20breaking=20r?= =?UTF-8?q?gb=20svg=20color=20bug=20=F0=9F=95=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ts/common/componentManager/componentManager.ts | 12 +++++++++++- src/ts/common/pin/pin.ts | 8 ++++---- src/ts/main.ts | 11 +++++------ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/ts/common/componentManager/componentManager.ts b/src/ts/common/componentManager/componentManager.ts index 5676e31..cdbd552 100644 --- a/src/ts/common/componentManager/componentManager.ts +++ b/src/ts/common/componentManager/componentManager.ts @@ -23,6 +23,7 @@ export class ComponentManager { public components: Component[] = [] public svgs = new Subject() public placeholder = new BehaviorSubject("Create simulation") + public saves = new BehaviorSubject(["hello world"]) private temporaryCommnad = "" private onTop: Component @@ -162,6 +163,9 @@ export class ComponentManager { }) this.wireManager.update.subscribe(val => this.update()) + this.saves.next(this.store.ls()) + //if (this.saves.value.length === 0) + // this.save() } preInput() { @@ -218,7 +222,12 @@ All you work will be lost!` } public switchTo(name: string) { - //TODO: implement + const data = this.store.get(name) + if (!data) + error(`An error occured when trying to load ${name}`,"",this.alertOptions) + + else + this.loadState(data) } eval(command: string) { @@ -402,6 +411,7 @@ All you work will be lost!` this.commandHistoryStore.set(i.toString(), element) } this.store.set(name || this.name, this.state) + this.saves.next(this.store.ls()) success("Saved the simulation succesfully!", "", this.alertOptions) } } \ No newline at end of file diff --git a/src/ts/common/pin/pin.ts b/src/ts/common/pin/pin.ts index be35394..d7ac859 100644 --- a/src/ts/common/pin/pin.ts +++ b/src/ts/common/pin/pin.ts @@ -16,7 +16,7 @@ export class Pin { public valueChanges = new Subject() public svgColor = this.color.pipe(map(val => - `rgb(${val.join(",")})` + `rgba(${val.join(",")})` )) constructor(public allowWrite = true, public of: Component) { @@ -38,10 +38,10 @@ export class Pin { this._value = clamp(value, 0, 1) this.valueChanges.next(this._value) - const color: [number, number, number, number] = (value > 0.5) ? - [255, 216, 20, 1] : + const color: [number, number, number, number] = (value > 0.5) ? + [255, 216, 20, 1] : [90, 90, 90, 1] - + this.color.next((this.pair) ? color : [0,0,0,0]) } diff --git a/src/ts/main.ts b/src/ts/main.ts index 69cd7fa..94618a9 100644 --- a/src/ts/main.ts +++ b/src/ts/main.ts @@ -83,12 +83,11 @@ render(html`
`, document.body)