-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
180 lines (179 loc) · 7.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OBK Layout Editor</title>
<script type="module" src="/src/main.ts" defer></script>
</head>
<body>
<main
class="mx-auto flex min-h-screen max-w-[calc(400vh/3)] flex-col gap-2 bg-gray-200 p-2 font-serif"
>
<div class="flex gap-2">
<div
x-data="{ isOpened: false, openedWithKeyboard: false }"
x-on:keydown.esc.window="isOpened = false, openedWithKeyboard = false"
class="relative w-fit"
>
<!-- Toggle Button -->
<button
type="button"
x-on:click="isOpened = ! isOpened"
x-on:keydown.space.prevent="openedWithKeyboard = true"
x-on:keydown.enter.prevent="openedWithKeyboard = true"
x-on:keydown.down.prevent="openedWithKeyboard = true"
class="inline-flex items-center gap-2 whitespace-nowrap rounded-sm border border-neutral-300 bg-neutral-50 px-4 py-2 text-sm font-medium tracking-wide transition hover:opacity-75 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-800 dark:border-neutral-700 dark:bg-neutral-900 dark:focus-visible:outline-neutral-300"
x-bind:class="isOpened || openedWithKeyboard ? 'text-neutral-900 dark:text-white' : 'text-neutral-600 dark:text-neutral-300'"
x-bind:aria-expanded="isOpened || openedWithKeyboard"
aria-haspopup="true"
>
New
<svg
aria-hidden="true"
fill="none"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
class="h-4 w-4 rotate-0"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M19.5 8.25l-7.5 7.5-7.5-7.5"
/>
</svg>
</button>
<!-- Dropdown Menu -->
<div
x-cloak
x-show="isOpened || openedWithKeyboard"
x-transition
x-trap="openedWithKeyboard"
x-on:click.outside="isOpened = false, openedWithKeyboard = false"
x-on:keydown.down.prevent="$focus.wrap().next()"
x-on:keydown.up.prevent="$focus.wrap().previous()"
class="absolute top-11 flex w-fit min-w-48 flex-col divide-y divide-neutral-300 overflow-hidden rounded-sm border border-neutral-300 bg-neutral-50 dark:divide-neutral-700 dark:border-neutral-700 dark:bg-neutral-900"
role="menu"
>
<div class="flex flex-col py-1.5">
<button
class="focus-visible:outline-hidden bg-neutral-50 px-4 py-2 text-start text-sm text-neutral-600 hover:bg-neutral-900/5 hover:text-neutral-900 focus-visible:bg-neutral-900/10 focus-visible:text-neutral-900 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-50/5 dark:hover:text-white dark:focus-visible:bg-neutral-50/10 dark:focus-visible:text-white"
role="menuitem"
@click="$store.main.handleMenuAction('new')"
>
Blank
</button>
</div>
<div class="flex flex-col py-1.5">
<div class="px-4 py-1 text-xs text-neutral-400">
From examples
</div>
<template x-for="example in $store.main.examples">
<button
class="focus-visible:outline-hidden bg-neutral-50 px-4 py-2 text-start text-sm text-neutral-600 hover:bg-neutral-900/5 hover:text-neutral-900 focus-visible:bg-neutral-900/10 focus-visible:text-neutral-900 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-50/5 dark:hover:text-white dark:focus-visible:bg-neutral-50/10 dark:focus-visible:text-white"
role="menuitem"
x-text="example.label"
@click="$store.main.handleMenuAction(example.key)"
></button>
</template>
</div>
</div>
</div>
<button
x-data
@click="$store.main.handleMenuAction('open')"
class="inline-flex items-center gap-2 whitespace-nowrap rounded-sm border border-neutral-300 bg-neutral-50 px-4 py-2 text-sm font-medium tracking-wide transition hover:opacity-75 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-800 dark:border-neutral-700 dark:bg-neutral-900 dark:focus-visible:outline-neutral-300"
>
Open
</button>
<button
x-data
@click="$store.main.handleMenuAction('save-as')"
class="inline-flex items-center gap-2 whitespace-nowrap rounded-sm border border-neutral-300 bg-neutral-50 px-4 py-2 text-sm font-medium tracking-wide transition hover:opacity-75 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-800 dark:border-neutral-700 dark:bg-neutral-900 dark:focus-visible:outline-neutral-300"
>
Save
</button>
</div>
<div id="kb-layout">
<svg width="900px" height="300px" class="block h-auto w-full"></svg>
</div>
<form
x-data
x-show="$store.main.editKeys === ''"
class="grid flex-grow grid-cols-3 content-start gap-2 bg-white p-5 md:grid-rows-[repeat(3,auto)1fr]"
>
<h2 class="col-span-full font-sans text-2xl">Edit layout info</h2>
<template
x-for="[path, cc] in [['layout.name', 'md:col-span-2'], ['layout.version', 'md:col-span-1'], ['layout.developer.name']]"
>
<div x-id="['text-input']" class="relative col-span-full" :class="cc">
<input
type="text"
:id="$id('text-input')"
class="text-input peer"
placeholder=" "
x-model="$getLastParent($store.main.content.info, path)[$getLastSegment(path)]"
/>
<label
:for="$id('text-input')"
x-text="$getLabel(path)"
class="floating-label top-4"
></label>
</div>
</template>
<div x-id="['text-input']" class="relative col-span-full">
<textarea
x-id="['text-input']"
class="text-input peer h-full"
placeholder=" "
x-model="$store.main.content.info.layout.developer.comment"
rows="2"
></textarea>
<label :for="$id('text-input')" class="floating-label">
Developer's comment
</label>
</div>
</form>
<form
x-data
x-cloak
x-show="$store.main.editKeys !== ''"
class="flex-grow content-start bg-white p-5"
>
<h2 class="mb-2 flex items-stretch font-sans text-2xl">
<span class="me-auto">Edit layout key</span>
<button
type="button"
@click="$store.main.editKeys = ''"
class="rounded border border-gray-300 bg-white px-5 text-sm font-medium text-gray-900 hover:bg-gray-100 focus:outline-none focus:ring-4 focus:ring-gray-200"
>
Back to Edit layout info
</button>
</h2>
<div class="grid grid-cols-4 gap-2">
<template
x-for="[label, key] in $getEditKeyVariants($store.main.editKeys)"
:key="key"
>
<div class="relative" x-id="['text-input']">
<input
type="text"
:id="$id('text-input')"
class="text-input peer"
placeholder=" "
x-model="$store.main.content.layout[key]"
/>
<label
:for="$id('text-input')"
x-text="label"
class="floating-label"
></label>
</div>
</template>
</div>
</form>
</main>
</body>
</html>