Skip to content

Commit bf0dc3c

Browse files
committed
refactor(demo): use LED from @wokwi/elements
1 parent 92898c6 commit bf0dc3c

File tree

5 files changed

+33
-108
lines changed

5 files changed

+33
-108
lines changed

demo/src/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
<body>
1111
<h2>AVR8js LED Demo</h2>
1212
<div class="app-container">
13-
<div class="leds"></div>
13+
<div class="leds">
14+
<wokwi-led color="green"></wokwi-led>
15+
<wokwi-led color="red"></wokwi-led>
16+
</div>
1417
<div class="toolbar">
1518
<button id="run-button">Run</button>
1619
<button id="stop-button" disabled>Stop</button>

demo/src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import '@wokwi/elements';
12
import { buildHex } from './compile';
23
import { AVRRunner } from './execute';
34
import { formatTime } from './format-time';
45
import './index.css';
5-
import { LED } from './led';
66
import { CPUPerformance } from './cpu-performance';
7+
import { LEDElement } from '@wokwi/elements';
78

89
let editor: any;
910
const BLINK_CODE = `
@@ -38,11 +39,8 @@ window.require(['vs/editor/editor.main'], () => {
3839
});
3940

4041
// Set up LEDs
41-
const leds = document.querySelector('.leds');
42-
const led13 = new LED({ color: 'green', lightColor: '#80ff80' });
43-
const led12 = new LED({ color: 'red', lightColor: '#ff8080' });
44-
leds.appendChild(led13.el);
45-
leds.appendChild(led12.el);
42+
const led13 = document.querySelector<LEDElement>('wokwi-led[color=green]');
43+
const led12 = document.querySelector<LEDElement>('wokwi-led[color=red]');
4644

4745
// Set up toolbar
4846
let runner: AVRRunner;

demo/src/led.ts

Lines changed: 0 additions & 101 deletions
This file was deleted.

package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@types/jest": "^24.0.23",
2525
"@types/node": "^12.12.7",
2626
"@types/prettier": "^1.19.0",
27+
"@wokwi/elements": "^0.1.0",
2728
"husky": "^3.0.9",
2829
"jest": "^24.9.0",
2930
"lint-staged": "^9.4.2",

0 commit comments

Comments
 (0)