From b9dfd552a62a46449532d49adc0773589076c808 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Thu, 21 Nov 2019 19:40:02 +0200 Subject: feat: add blink demo --- demo/src/led.ts | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 demo/src/led.ts (limited to 'demo/src/led.ts') diff --git a/demo/src/led.ts b/demo/src/led.ts new file mode 100644 index 0000000..8c6deb4 --- /dev/null +++ b/demo/src/led.ts @@ -0,0 +1,102 @@ +const led = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; + +export interface ILEDOptions { + color: string; + lightColor?: string; +} + +const ON_CLASS = 'led-on'; +export class LED { + readonly el = document.createElement('span'); + private readonly lightEl: SVGElement; + constructor({ color, lightColor }: ILEDOptions) { + this.el.innerHTML = led + .replace('{{color}}', color) + .replace('{{lightColor}}', lightColor || color); + this.lightEl = this.el.querySelector('.light'); + this.lightEl.style.display = 'none'; + } + + get value() { + return this.lightEl.style.display !== 'none'; + } + + set value(value: boolean) { + this.lightEl.style.display = value ? '' : 'none'; + } +} -- cgit v1.2.3