Skip to content

Commit e0df02d

Browse files
committed
test with web-components
1 parent 0dd8fd1 commit e0df02d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

apps/vps-web/src/app/custom-nodes/classes/draw-grid-node.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ import { BaseRectNode } from './rect-node-class';
99

1010
import './style.css';
1111

12+
class Label extends HTMLElement {
13+
constructor() {
14+
super();
15+
const shadow = this.attachShadow({ mode: 'open' });
16+
const wrapper = document.createElement('label');
17+
wrapper.setAttribute('part', 'label'); // uses ::part pseudo-element
18+
const text = this.getAttribute('text') || 'Label';
19+
wrapper.textContent = text;
20+
shadow.appendChild(wrapper);
21+
}
22+
}
23+
24+
customElements.define('draw-grid-label', Label);
25+
1226
interface GridDrawSettings {
1327
fadeRadius: number;
1428
fadePower: number;
@@ -132,6 +146,7 @@ class GridDraw {
132146
controlsContainer.className = 'controls-container';
133147
controlsContainer.innerHTML = `
134148
<div class="control-group">
149+
<draw-grid-label text="Draw Grid"></draw-grid-label>
135150
<label>Brush Color</label>
136151
<input type="color" id="colorPicker" value="#000000">
137152
<div class="color-presets">

apps/vps-web/src/app/custom-nodes/classes/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,7 @@
194194
right: 50%;
195195
transform: translate(50%, -50%);
196196
}
197+
198+
draw-grid-label::part(label) {
199+
@apply text-black mb-5;
200+
}

0 commit comments

Comments
 (0)