Skip to content

Commit d5f816c

Browse files
committed
chore(examples): vanilla-ts
1 parent 287da40 commit d5f816c

File tree

18 files changed

+411
-17
lines changed

18 files changed

+411
-17
lines changed

examples/vanilla-ts/index.html

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,30 @@
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Vite + TS</title>
8+
<style>
9+
@import url("@zag-js/shared/src/style.css");
10+
</style>
811
</head>
9-
<body style="padding: 40px">
10-
<h1>Vanilla + Zag</h1>
11-
12-
<a href="pages/accordion.html">Accordion</a>
13-
<a href="pages/avatar.html">Avatar</a>
14-
<a href="pages/checkbox.html">Checkbox</a>
15-
<a href="pages/combobox.html">Combobox</a>
16-
<a href="pages/dialog.html">Dialog</a>
17-
<a href="pages/popover.html">Popover</a>
18-
<a href="pages/slider.html">Slider</a>
19-
<a href="pages/tabs.html">Tabs</a>
20-
<a href="pages/toggle-group.html">Toggle Group</a>
21-
<a href="pages/tooltip.html">Tooltip</a>
12+
<body>
13+
<div class="index-nav">
14+
<h2>Zag.js + Vanilla TypeScript</h2>
15+
<ul>
16+
<li><a href="pages/accordion.html">Accordion</a></li>
17+
<li><a href="pages/avatar.html">Avatar</a></li>
18+
<li><a href="pages/checkbox.html">Checkbox</a></li>
19+
<li><a href="pages/combobox.html">Combobox</a></li>
20+
<li><a href="pages/dialog.html">Dialog</a></li>
21+
<li><a href="pages/menu.html">Menu</a></li>
22+
<li><a href="pages/pin-input.html">Pin Input</a></li>
23+
<li><a href="pages/popover.html">Popover</a></li>
24+
<li><a href="pages/qr-code.html">QR Code</a></li>
25+
<li><a href="pages/radio-group.html">Radio Group</a></li>
26+
<li><a href="pages/slider.html">Slider</a></li>
27+
<li><a href="pages/switch.html">Switch</a></li>
28+
<li><a href="pages/tabs.html">Tabs</a></li>
29+
<li><a href="pages/toggle-group.html">Toggle Group</a></li>
30+
<li><a href="pages/tooltip.html">Tooltip</a></li>
31+
</ul>
32+
</div>
2233
</body>
2334
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
</head>
9+
<body style="padding: 40px">
10+
<h1>Menu</h1>
11+
12+
<div class="menu">
13+
<button class="menu-trigger">Actions</button>
14+
<div class="menu-positioner" hidden>
15+
<div class="menu-content">
16+
<div class="menu-item" data-value="edit">Edit</div>
17+
<div class="menu-item" data-value="duplicate">Duplicate</div>
18+
<div class="menu-item" data-value="delete">Delete</div>
19+
<div class="menu-item" data-value="export">Export...</div>
20+
</div>
21+
</div>
22+
</div>
23+
24+
<script type="module" src="./menu.ts"></script>
25+
</body>
26+
</html>

examples/vanilla-ts/pages/menu.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import "@zag-js/shared/src/style.css"
2+
3+
import { nanoid } from "nanoid"
4+
import { Menu } from "../src/menu"
5+
6+
document.querySelectorAll<HTMLElement>(".menu").forEach((rootEl) => {
7+
const menu = new Menu(rootEl, {
8+
id: nanoid(),
9+
})
10+
11+
menu.init()
12+
})
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
</head>
9+
<body style="padding: 40px">
10+
<h1>Pin Input</h1>
11+
12+
<div class="pin-input">
13+
<label class="pin-input-label">Enter verification code</label>
14+
<div class="pin-input-control">
15+
<input class="pin-input-field" type="text" maxlength="1" />
16+
<input class="pin-input-field" type="text" maxlength="1" />
17+
<input class="pin-input-field" type="text" maxlength="1" />
18+
<input class="pin-input-field" type="text" maxlength="1" />
19+
<input class="pin-input-field" type="text" maxlength="1" />
20+
<input class="pin-input-field" type="text" maxlength="1" />
21+
</div>
22+
<input class="pin-input-hidden" type="hidden" name="pin" />
23+
</div>
24+
25+
<script type="module" src="./pin-input.ts"></script>
26+
</body>
27+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "@zag-js/shared/src/style.css"
2+
3+
import { nanoid } from "nanoid"
4+
import { PinInput } from "../src/pin-input"
5+
6+
document.querySelectorAll<HTMLElement>(".pin-input").forEach((rootEl) => {
7+
const pinInput = new PinInput(rootEl, {
8+
id: nanoid(),
9+
placeholder: "○",
10+
})
11+
12+
pinInput.init()
13+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
</head>
9+
<body style="padding: 40px">
10+
<h1>QR Code</h1>
11+
12+
<div class="qr-code">
13+
<svg class="qr-code-frame">
14+
<path class="qr-code-pattern" />
15+
</svg>
16+
</div>
17+
18+
<script type="module" src="./qr-code.ts"></script>
19+
</body>
20+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "@zag-js/shared/src/style.css"
2+
3+
import { nanoid } from "nanoid"
4+
import { QrCode } from "../src/qr-code"
5+
6+
document.querySelectorAll<HTMLElement>(".qr-code").forEach((rootEl) => {
7+
const qrCode = new QrCode(rootEl, {
8+
id: nanoid(),
9+
value: "https://zagjs.com",
10+
})
11+
12+
qrCode.init()
13+
})
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
</head>
9+
<body style="padding: 40px">
10+
<h1>Radio Group</h1>
11+
12+
<div class="radio-group">
13+
<div class="radio-group-label">Select an option</div>
14+
15+
<label class="radio-item" data-value="option1">
16+
<div class="radio-control"></div>
17+
<span class="radio-label">Option 1</span>
18+
<input class="radio-input" type="radio" />
19+
</label>
20+
21+
<label class="radio-item" data-value="option2">
22+
<div class="radio-control"></div>
23+
<span class="radio-label">Option 2</span>
24+
<input class="radio-input" type="radio" />
25+
</label>
26+
27+
<label class="radio-item" data-value="option3">
28+
<div class="radio-control"></div>
29+
<span class="radio-label">Option 3</span>
30+
<input class="radio-input" type="radio" />
31+
</label>
32+
</div>
33+
34+
<script type="module" src="./radio-group.ts"></script>
35+
</body>
36+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "@zag-js/shared/src/style.css"
2+
3+
import { nanoid } from "nanoid"
4+
import { RadioGroup } from "../src/radio-group"
5+
6+
document.querySelectorAll<HTMLElement>(".radio-group").forEach((rootEl) => {
7+
const radioGroup = new RadioGroup(rootEl, {
8+
id: nanoid(),
9+
defaultValue: "option1",
10+
})
11+
12+
radioGroup.init()
13+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
</head>
9+
<body style="padding: 40px">
10+
<h1>Switch</h1>
11+
12+
<label class="switch">
13+
<input class="switch-input" type="checkbox" />
14+
<span class="switch-control">
15+
<span class="switch-thumb"></span>
16+
</span>
17+
<span class="switch-label">Enable notifications</span>
18+
</label>
19+
20+
<script type="module" src="./switch.ts"></script>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)