@hattoriai/poney-element 0.0.0-stage → 0.3.0-stage.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -2
- package/dist/browser/poney.css +244 -0
- package/dist/browser/poney.js +111158 -0
- package/dist/browser/poney.min.js +76 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +349 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rui Freitas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @hattoriai/poney-element
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`<poney-diagram>`: a custom element that draws a Poney view or walkthrough scene in any web page, with no framework. The page gives the document and says what to draw. The element lays the view out, draws it, frames it, and sends events when the reader points at or clicks a part.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<link rel="stylesheet" href="poney.css">
|
|
7
|
+
<script type="module" src="poney.js"></script>
|
|
8
|
+
|
|
9
|
+
<poney-diagram walkthrough="payment-retry" scene="checkout" mode="change">
|
|
10
|
+
<script type="application/json">{ "poneyVersion": "0.2.0", … }</script>
|
|
11
|
+
</poney-diagram>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`poney.js` and `poney.css` are in this package, in `dist/browser/` (also `poney.min.js`). `poney.js` is one ES module with no imports: the format, the layout (ELK), the renderers and the element, with the ownership and security extensions. Copy it into your app's assets; it needs no Node at run time. With a bundler, import the package instead and call `definePoneyDiagram()`.
|
|
15
|
+
|
|
16
|
+
## Attributes
|
|
17
|
+
|
|
18
|
+
| Attribute | What it does |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `view` | Draws a view on its own, as an explorer does |
|
|
21
|
+
| `walkthrough`, `scene` | Draws a walkthrough scene (`overview` for the overview). With neither, the first walkthrough's overview, else the document's default view |
|
|
22
|
+
| `mode` | `before`, `change` (default) or `after` |
|
|
23
|
+
| `hot` | A ref key to light up, for example from a sentence the reader points at |
|
|
24
|
+
| `selection` | A ref key to show as selected |
|
|
25
|
+
| `trace-step` | The trace step to show (from 0); the camera follows it. Empty: not playing |
|
|
26
|
+
| `theme` | `light` or `dark`; the element then paints its own background |
|
|
27
|
+
| `still` | A picture: no controls and no interaction |
|
|
28
|
+
| `fill` | Fill the element's box. Without it, the element is as wide as its container and as high as the scene |
|
|
29
|
+
|
|
30
|
+
Set the document with the `document` property (an object or JSON text), or put it in a `<script type="application/json">` child.
|
|
31
|
+
|
|
32
|
+
## Events
|
|
33
|
+
|
|
34
|
+
All events bubble.
|
|
35
|
+
|
|
36
|
+
| Event | `detail` |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `poney-select` | `{ ref }`: the reader clicked a part, or pressed Enter on it |
|
|
39
|
+
| `poney-hover` | `{ ref }`: the reader points at a part; `null` when they leave it |
|
|
40
|
+
| `poney-ready` | `{ title, view }`: a new view is drawn |
|
|
41
|
+
| `poney-error` | `{ message, issues? }`: the document is not valid, or the target does not exist |
|
|
42
|
+
|
|
43
|
+
## Styles and fonts
|
|
44
|
+
|
|
45
|
+
`poney.css` has the `--poney-*` tokens and the `.poney-*` classes, in the cascade layer `poney`, so your styles win. To give the diagrams your colours and fonts, set the tokens on the element or on a parent. The element measures text with `--poney-font-sans` and `--poney-font-mono`, so the fonts that you set must be loaded on the page.
|
|
46
|
+
|
|
47
|
+
Part of [Poney](https://github.com/hattoriai/poney): the format, the renderers, and tools to explain software. MIT licensed.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/* ../diagrams/src/styles/tokens.css */
|
|
2
|
+
@layer poney {
|
|
3
|
+
:where(:root),
|
|
4
|
+
:where([data-poney-theme=light]) {
|
|
5
|
+
--poney-plaster: #eef0ec;
|
|
6
|
+
--poney-paper: #fbfbf9;
|
|
7
|
+
--poney-paper-raised: #ffffff;
|
|
8
|
+
--poney-sunken: #e5e8e3;
|
|
9
|
+
--poney-ink: #1d2230;
|
|
10
|
+
--poney-ink-2: #4e5566;
|
|
11
|
+
--poney-ink-3: #848a97;
|
|
12
|
+
--poney-ink-4: #b3b8c1;
|
|
13
|
+
--poney-rule: #dcdfd8;
|
|
14
|
+
--poney-rule-strong: #c8ccc4;
|
|
15
|
+
--poney-accent: #b24a32;
|
|
16
|
+
--poney-accent-wash: #f7ebe7;
|
|
17
|
+
--poney-accent-ring: #b24a3240;
|
|
18
|
+
--poney-lapis: #3a5a9e;
|
|
19
|
+
--poney-malachite: #2e7656;
|
|
20
|
+
--poney-ochre: #a8761c;
|
|
21
|
+
--poney-umber: #7d5a43;
|
|
22
|
+
--poney-tyrian: #7a4a88;
|
|
23
|
+
--poney-slate: #56627a;
|
|
24
|
+
--poney-verdigris: #26807f;
|
|
25
|
+
--poney-success: #2e7656;
|
|
26
|
+
--poney-failure: #9c3554;
|
|
27
|
+
--poney-new: #1d8a4e;
|
|
28
|
+
--poney-new-wash: #ecf8f0;
|
|
29
|
+
--poney-changed: #b86e0b;
|
|
30
|
+
--poney-changed-wash: #fdf5e6;
|
|
31
|
+
--poney-removed: #c03550;
|
|
32
|
+
--poney-removed-wash: #fcf0f2;
|
|
33
|
+
--poney-story-node: #ffffff;
|
|
34
|
+
--poney-story-line: #8c939e;
|
|
35
|
+
--poney-story-rule: #d7dade;
|
|
36
|
+
--poney-font-sans:
|
|
37
|
+
"Hanken Grotesk Variable",
|
|
38
|
+
"Hanken Grotesk",
|
|
39
|
+
ui-sans-serif,
|
|
40
|
+
system-ui,
|
|
41
|
+
sans-serif;
|
|
42
|
+
--poney-font-mono:
|
|
43
|
+
"JetBrains Mono Variable",
|
|
44
|
+
"JetBrains Mono",
|
|
45
|
+
ui-monospace,
|
|
46
|
+
monospace;
|
|
47
|
+
}
|
|
48
|
+
:where([data-poney-theme=dark]) {
|
|
49
|
+
--poney-plaster: #15181e;
|
|
50
|
+
--poney-paper: #1b1f27;
|
|
51
|
+
--poney-paper-raised: #212631;
|
|
52
|
+
--poney-sunken: #12151a;
|
|
53
|
+
--poney-ink: #e6e8ec;
|
|
54
|
+
--poney-ink-2: #aeb4c0;
|
|
55
|
+
--poney-ink-3: #7c8391;
|
|
56
|
+
--poney-ink-4: #535a67;
|
|
57
|
+
--poney-rule: #2a2f39;
|
|
58
|
+
--poney-rule-strong: #3a404c;
|
|
59
|
+
--poney-accent: #e2765b;
|
|
60
|
+
--poney-accent-wash: #3a2621;
|
|
61
|
+
--poney-accent-ring: #e2765b4d;
|
|
62
|
+
--poney-lapis: #7f9ce0;
|
|
63
|
+
--poney-malachite: #5fb68d;
|
|
64
|
+
--poney-ochre: #d6a64c;
|
|
65
|
+
--poney-umber: #c19a7f;
|
|
66
|
+
--poney-tyrian: #b98ac8;
|
|
67
|
+
--poney-slate: #98a3b9;
|
|
68
|
+
--poney-verdigris: #58bcba;
|
|
69
|
+
--poney-success: #5fb68d;
|
|
70
|
+
--poney-failure: #e07a98;
|
|
71
|
+
--poney-new: #4fc887;
|
|
72
|
+
--poney-new-wash: #15281f;
|
|
73
|
+
--poney-changed: #e3a54a;
|
|
74
|
+
--poney-changed-wash: #2b2416;
|
|
75
|
+
--poney-removed: #ef7f97;
|
|
76
|
+
--poney-removed-wash: #2e1a20;
|
|
77
|
+
--poney-story-node: #1f242d;
|
|
78
|
+
--poney-story-line: #7d8592;
|
|
79
|
+
--poney-story-rule: #363c48;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* ../diagrams/src/styles/diagrams.css */
|
|
84
|
+
@layer poney {
|
|
85
|
+
:where(.poney-el) {
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
transition: opacity 180ms ease;
|
|
88
|
+
}
|
|
89
|
+
:where(.poney-fade) {
|
|
90
|
+
transition: opacity 180ms ease;
|
|
91
|
+
}
|
|
92
|
+
:where(.poney-dim) {
|
|
93
|
+
opacity: 0.3;
|
|
94
|
+
}
|
|
95
|
+
:where(.poney-control) {
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
}
|
|
98
|
+
:where(.poney-row:hover) {
|
|
99
|
+
fill: var(--poney-sunken);
|
|
100
|
+
}
|
|
101
|
+
:where(.poney-numbers) {
|
|
102
|
+
font-variant-numeric: tabular-nums;
|
|
103
|
+
}
|
|
104
|
+
:where(svg [data-ref]:focus-visible) {
|
|
105
|
+
outline: none;
|
|
106
|
+
}
|
|
107
|
+
:where(.poney-focus) {
|
|
108
|
+
opacity: 0;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
}
|
|
111
|
+
:where(svg [data-ref]:focus-visible .poney-focus) {
|
|
112
|
+
opacity: 1;
|
|
113
|
+
}
|
|
114
|
+
:where(svg [data-ref]:focus-visible:not(:has(.poney-focus))) {
|
|
115
|
+
filter: drop-shadow(0 0 0.6px var(--poney-accent)) drop-shadow(0 0 3px var(--poney-accent));
|
|
116
|
+
}
|
|
117
|
+
:where(.poney-edge) {
|
|
118
|
+
transition:
|
|
119
|
+
stroke 160ms ease,
|
|
120
|
+
stroke-width 160ms ease,
|
|
121
|
+
opacity 180ms ease;
|
|
122
|
+
}
|
|
123
|
+
:where(.poney-flowing) {
|
|
124
|
+
stroke-dasharray: 6 4;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* ../diagrams/src/styles/stories.css */
|
|
129
|
+
@layer poney {
|
|
130
|
+
:where(.poney-story-el) {
|
|
131
|
+
transition: opacity 420ms ease, transform 420ms ease;
|
|
132
|
+
}
|
|
133
|
+
:where(.poney-story-el *) {
|
|
134
|
+
transition:
|
|
135
|
+
fill 320ms ease,
|
|
136
|
+
stroke 320ms ease,
|
|
137
|
+
opacity 320ms ease;
|
|
138
|
+
}
|
|
139
|
+
:where(.poney-story-hidden) {
|
|
140
|
+
opacity: 0;
|
|
141
|
+
pointer-events: none;
|
|
142
|
+
}
|
|
143
|
+
:where(.poney-story-dim) {
|
|
144
|
+
opacity: 0.16;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* ../diagrams/src/styles/motion.css */
|
|
149
|
+
@layer poney {
|
|
150
|
+
:where(.poney-flowing) {
|
|
151
|
+
animation: poney-dash 0.9s linear infinite;
|
|
152
|
+
}
|
|
153
|
+
:where(.poney-flow) {
|
|
154
|
+
animation: poney-flow 1.1s linear infinite;
|
|
155
|
+
}
|
|
156
|
+
:where(.poney-pulse) {
|
|
157
|
+
animation: poney-pulse 1.8s ease-in-out infinite;
|
|
158
|
+
}
|
|
159
|
+
@keyframes poney-dash {
|
|
160
|
+
to {
|
|
161
|
+
stroke-dashoffset: -20;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
@keyframes poney-flow {
|
|
165
|
+
to {
|
|
166
|
+
stroke-dashoffset: -11.1;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
@keyframes poney-pulse {
|
|
170
|
+
0%, 100% {
|
|
171
|
+
opacity: 1;
|
|
172
|
+
}
|
|
173
|
+
50% {
|
|
174
|
+
opacity: 0.35;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
@media (prefers-reduced-motion: reduce) {
|
|
178
|
+
:where(.poney-flowing, .poney-flow, .poney-pulse) {
|
|
179
|
+
animation: none;
|
|
180
|
+
}
|
|
181
|
+
:where(.poney-el, .poney-fade, .poney-edge, .poney-story-el, .poney-story-el *) {
|
|
182
|
+
transition: none;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* ../diagrams/src/styles/legend.css */
|
|
188
|
+
@layer poney {
|
|
189
|
+
:where(.poney-legend) {
|
|
190
|
+
display: grid;
|
|
191
|
+
gap: 6px;
|
|
192
|
+
}
|
|
193
|
+
:where(.poney-legend-row) {
|
|
194
|
+
display: flex;
|
|
195
|
+
align-items: center;
|
|
196
|
+
gap: 10px;
|
|
197
|
+
font-size: 12px;
|
|
198
|
+
color: var(--poney-ink-2);
|
|
199
|
+
}
|
|
200
|
+
:where(.poney-legend-mark) {
|
|
201
|
+
flex-shrink: 0;
|
|
202
|
+
}
|
|
203
|
+
:where(.poney-legend-note) {
|
|
204
|
+
margin: 0;
|
|
205
|
+
padding-top: 4px;
|
|
206
|
+
font-size: 12px;
|
|
207
|
+
color: var(--poney-ink-3);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* ../diagrams/src/styles/index.css */
|
|
212
|
+
|
|
213
|
+
/* src/element.css */
|
|
214
|
+
@layer poney {
|
|
215
|
+
:where(poney-diagram) {
|
|
216
|
+
display: block;
|
|
217
|
+
position: relative;
|
|
218
|
+
min-height: 1px;
|
|
219
|
+
}
|
|
220
|
+
:where(poney-diagram[data-poney-theme]) {
|
|
221
|
+
background: var(--poney-paper);
|
|
222
|
+
}
|
|
223
|
+
:where(poney-diagram) > :where(.poney-diagram-svg) {
|
|
224
|
+
font-family: var(--poney-font-sans);
|
|
225
|
+
display: block;
|
|
226
|
+
width: 100%;
|
|
227
|
+
height: 100%;
|
|
228
|
+
overflow: hidden;
|
|
229
|
+
}
|
|
230
|
+
:where(poney-diagram) > :where(script) {
|
|
231
|
+
display: none;
|
|
232
|
+
}
|
|
233
|
+
:where(.poney-diagram-message) {
|
|
234
|
+
margin: 0;
|
|
235
|
+
padding: 12px 14px;
|
|
236
|
+
font: 13px/1.5 var(--poney-font-sans);
|
|
237
|
+
color: var(--poney-failure);
|
|
238
|
+
background: var(--poney-paper-raised);
|
|
239
|
+
border: 1px solid var(--poney-rule);
|
|
240
|
+
border-radius: 8px;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* scripts/poney.css */
|