From 0365325c8e398cc572a4bf398a706846fc25bbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchrisshank=E2=80=9D?= Date: Mon, 23 Dec 2024 20:28:23 -0800 Subject: [PATCH] console inspector element --- labs/folk-rope.ts | 6 +++--- labs/folk-spreadsheet.ts | 17 +++++++++++++++++ labs/folk-transformed-space.ts | 1 - lib/folk-gizmos.ts | 8 +++++--- website/canvas/html-spreadsheet.html | 15 ++++++++++++++- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/labs/folk-rope.ts b/labs/folk-rope.ts index 5e4fab7..fad726a 100644 --- a/labs/folk-rope.ts +++ b/labs/folk-rope.ts @@ -48,7 +48,7 @@ export class FolkRope extends FolkBaseConnection implements AnimationFrameContro `, ]; - // TODO: stop simulation when energy approaches 0 + // TODO: stop simulation when energy approaches 0 #rAF = new AnimationFrameController(this, 10000); #svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); @@ -107,7 +107,7 @@ export class FolkRope extends FolkBaseConnection implements AnimationFrameContro } else { source = { x: sourceRect.x + sourceRect.width / 2, - y: sourceRect.y + sourceRect.height / 2, + y: sourceRect.y + sourceRect.height, }; } @@ -116,7 +116,7 @@ export class FolkRope extends FolkBaseConnection implements AnimationFrameContro } else { target = { x: targetRect.x + targetRect.width / 2, - y: targetRect.y + targetRect.height / 2, + y: targetRect.y + targetRect.height, }; } diff --git a/labs/folk-spreadsheet.ts b/labs/folk-spreadsheet.ts index 80b4891..d935480 100644 --- a/labs/folk-spreadsheet.ts +++ b/labs/folk-spreadsheet.ts @@ -266,6 +266,23 @@ export class FolkSpreadsheet extends HTMLElement { return this.querySelector(`folk-cell[column="${column}"][row="${row}"]`); } + getCells() { + return Array.from(this.querySelectorAll(`folk-cell`)); + } + + getValues() { + const cells = this.getCells(); + const data: Record = {}; + + for (const cell of cells) { + if (cell.value !== undefined) { + data[cell.name] = cell.value; + } + } + + return data; + } + handleEvent(event: Event) { switch (event.type) { case 'keydown': { diff --git a/labs/folk-transformed-space.ts b/labs/folk-transformed-space.ts index f5ed955..19c04d2 100644 --- a/labs/folk-transformed-space.ts +++ b/labs/folk-transformed-space.ts @@ -1,7 +1,6 @@ import { FolkElement, type Point } from '@lib'; import { Gizmos } from '@lib/folk-gizmos'; import { html } from '@lib/tags'; -import { TransformEvent } from '@lib/TransformEvent'; import { css } from '@lit/reactive-element'; export class FolkTransformedSpace extends FolkElement { diff --git a/lib/folk-gizmos.ts b/lib/folk-gizmos.ts index d403a17..2560142 100644 --- a/lib/folk-gizmos.ts +++ b/lib/folk-gizmos.ts @@ -45,6 +45,7 @@ interface VectorOptions extends LineOptions { */ export class Gizmos extends FolkElement { static override tagName = 'folk-gizmos'; + static #layers = new Map< string, { @@ -53,8 +54,11 @@ export class Gizmos extends FolkElement { hidden: boolean; } >(); + static #defaultLayer = 'default'; + static #hasLoggedDrawWarning = false; + static #hasLoggedInitMessage = false; static styles = css` @@ -288,6 +292,4 @@ export class Gizmos extends FolkElement { } } -if (!customElements.get('folk-gizmos')) { - customElements.define('folk-gizmos', Gizmos); -} +Gizmos.define(); diff --git a/website/canvas/html-spreadsheet.html b/website/canvas/html-spreadsheet.html index 5f2c284..75b658d 100644 --- a/website/canvas/html-spreadsheet.html +++ b/website/canvas/html-spreadsheet.html @@ -1,4 +1,4 @@ - + @@ -122,9 +122,22 @@ + + + + + +