@machfivetechchicago/machvive-neodigm55-ux 0.0.0-stage → 0.0.1
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 +202 -0
- package/README.md +121 -2
- package/index.d.ts +7 -0
- package/index.js +22 -0
- package/package.json +74 -4
- package/src/conductor/anchor.d.ts +26 -0
- package/src/conductor/anchor.js +102 -0
- package/src/conductor/choreography.d.ts +34 -0
- package/src/conductor/choreography.js +209 -0
- package/src/conductor/index.d.ts +4 -0
- package/src/conductor/index.js +23 -0
- package/src/conductor/motion.d.ts +10 -0
- package/src/conductor/motion.js +98 -0
- package/src/conductor/theme.d.ts +30 -0
- package/src/conductor/theme.js +127 -0
- package/src/wc/neodigm-marquee/neodigm-marquee.d.ts +33 -0
- package/src/wc/neodigm-marquee/neodigm-marquee.js +252 -0
- package/src/wc/neodigm-toast/neodigm-toast.d.ts +42 -0
- package/src/wc/neodigm-toast/neodigm-toast.js +244 -0
- package/src/wc/neodigm-tulip/neodigm-tulip.d.ts +41 -0
- package/src/wc/neodigm-tulip/neodigm-tulip.js +294 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 MachFiveTech Chicago
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">machvive-neodigm55-ux</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>Remember when the Web was fun?</strong><br>
|
|
5
|
+
The UX for those that think for themselves — Neodigm 55 as dependency-free
|
|
6
|
+
Web Components, by <a href="https://github.com/Mach-Five-Group">MachFiveTech Chicago</a>.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img alt="dependencies" src="https://img.shields.io/badge/dependencies-0-brightgreen.svg">
|
|
11
|
+
<img alt="types" src="https://img.shields.io/badge/types-included-blue.svg">
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
Most component libraries give you parts. [Neodigm 55](https://www.thescottkrause.com/emerging_tech/neodigm55_ux_library/)
|
|
15
|
+
does something else: it is **aware of every themed element on the page** and can move
|
|
16
|
+
colour and attention across all of them at once — to pull a visitor toward a call to
|
|
17
|
+
action, to acknowledge that something happened, to make a page feel alive.
|
|
18
|
+
|
|
19
|
+
This package is that idea rebuilt as standards-based custom elements, with the
|
|
20
|
+
choreography kept as the product rather than discarded as an implementation detail.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { robinTheme } from '@machfivetechchicago/machvive-neodigm55-ux/conductor';
|
|
24
|
+
|
|
25
|
+
await robinTheme('brand'); // a wave of colour crosses every themed element, then recedes
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Two layers, one contract
|
|
29
|
+
|
|
30
|
+
**The conductor** owns the palette, the motion gate and the choreography. It has no
|
|
31
|
+
custom elements and never touches `HTMLElement`, so it imports in bare Node — a build
|
|
32
|
+
step, a CI check or a theme builder can use it with no DOM at all.
|
|
33
|
+
|
|
34
|
+
**The components** are instruments. They opt into choreography the same way anything
|
|
35
|
+
else does: by carrying `data-n55-theme` on the host.
|
|
36
|
+
|
|
37
|
+
That attribute is the entire contract, which is what keeps this open-ended:
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<button data-n55-theme="brand"> <!-- plain HTML -->
|
|
41
|
+
<neodigm-toast data-n55-theme="brand"> <!-- a component here -->
|
|
42
|
+
<my-lit-card data-n55-theme="brand"> <!-- a Lit component -->
|
|
43
|
+
<div data-n55-theme="brand"> <!-- React output -->
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
All four are swept by the same call. Nothing in the conductor knows what a Neodigm
|
|
47
|
+
component is, so adopting it never means adopting a framework.
|
|
48
|
+
|
|
49
|
+
> **Shadow DOM is deliberately out of reach.** `querySelectorAll` does not cross a
|
|
50
|
+
> shadow boundary, so a component is swept by its *host* attribute and styles its
|
|
51
|
+
> internals from that (`:host([data-n55-theme="brand"])`) or from the inherited
|
|
52
|
+
> custom properties. A test pins this, because it is the one way to use it wrong.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm i @machfivetechchicago/machvive-neodigm55-ux
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import '@machfivetechchicago/machvive-neodigm55-ux'; // everything
|
|
62
|
+
import '@machfivetechchicago/machvive-neodigm55-ux/toast'; // one component
|
|
63
|
+
import { robinTheme } from '@machfivetechchicago/machvive-neodigm55-ux/conductor';
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## The palette
|
|
67
|
+
|
|
68
|
+
Thirteen themes, carried over unchanged: `brand`, `primary`, `secondary`, `success`,
|
|
69
|
+
`white`, `ghost`, `danger`, `warning`, `info`, `disabled`, `night`, `marcom`, `party`.
|
|
70
|
+
|
|
71
|
+
They install as CSS custom properties rather than living in a JavaScript object, which
|
|
72
|
+
is the difference that makes a theme builder possible:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
import { installTheme, themeCss } from '@machfivetechchicago/machvive-neodigm55-ux/conductor';
|
|
76
|
+
|
|
77
|
+
installTheme(); // --n55-brand, --n55-brand-deep, --n55-brand-glyph, …
|
|
78
|
+
themeCss(myPalette, '.promo'); // or emit a stylesheet for a section, or for a build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Override `--n55-brand` on a page and every component follows, with no rebuild and no
|
|
82
|
+
component aware it happened. `disabled` doubles as the opt-out: an element themed
|
|
83
|
+
`disabled` is never choreographed.
|
|
84
|
+
|
|
85
|
+
## Toast
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<neodigm-toast></neodigm-toast>
|
|
89
|
+
<button data-n55-toast="Saved ✨" data-n55-theme="success">Save</button>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
document.querySelector('neodigm-toast')
|
|
94
|
+
.show('Saved ✨', { theme: 'success' })
|
|
95
|
+
.show('Queued behind it', { duration: 3000 });
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Queued, with the original's debounce — the same message twice in a row is the same
|
|
99
|
+
notification. `|` breaks the line. **Message text is never parsed as HTML**, unlike the
|
|
100
|
+
original's `innerHTML`, because toast text is routinely built from user input.
|
|
101
|
+
|
|
102
|
+
## What changed in the port
|
|
103
|
+
|
|
104
|
+
| | Original | Here |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| Markup | required `<div id="js-snackbar__id">` on the page | the element renders its own |
|
|
107
|
+
| Styling | global `.snackbar__cont--*` classes | scoped to a shadow root |
|
|
108
|
+
| Theme | hex values in a JS object | CSS custom properties |
|
|
109
|
+
| Sound, haptics, GTM | always on, via four other modules | opt-in, none wired by default |
|
|
110
|
+
| Reduced motion | a `// TODO` above `robinTheme` | respected; the sweep is suppressed, the signal is not |
|
|
111
|
+
| Sweep timing | each element held the colour for `index × 56ms`, so the first never visibly changed | constant `hold`, so the wave keeps its shape |
|
|
112
|
+
| Message text | `innerHTML` | text nodes |
|
|
113
|
+
|
|
114
|
+
## Browser support
|
|
115
|
+
|
|
116
|
+
Anywhere `customElements`, Shadow DOM and CSS custom properties work. No build step, no
|
|
117
|
+
framework, no runtime dependencies — the files published are the files that run.
|
|
118
|
+
|
|
119
|
+
## Licence
|
|
120
|
+
|
|
121
|
+
[Apache-2.0](LICENSE) © MachFiveTech Chicago. Ported from
|
|
122
|
+
[neodigm55](https://github.com/arcanus55/neodigm55) by Arcanus 55, Inc.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { NeodigmToast, DEFAULT_DURATION } from './src/wc/neodigm-toast/neodigm-toast.js';
|
|
2
|
+
export type { ToastOptions, QueuedToast } from './src/wc/neodigm-toast/neodigm-toast.js';
|
|
3
|
+
export { NeodigmMarquee, DEFAULT_SPEED, parseRuns, plainText } from './src/wc/neodigm-marquee/neodigm-marquee.js';
|
|
4
|
+
export type { MarqueeCell } from './src/wc/neodigm-marquee/neodigm-marquee.js';
|
|
5
|
+
export { NeodigmTulip, TULIP_DEFAULTS, readConfig, configFrom } from './src/wc/neodigm-tulip/neodigm-tulip.js';
|
|
6
|
+
export type { TulipConfig } from './src/wc/neodigm-tulip/neodigm-tulip.js';
|
|
7
|
+
export * from './src/conductor/index.js';
|
package/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bulk entry point: imports every component (registering its tag) and
|
|
3
|
+
* re-exports the conductor.
|
|
4
|
+
*
|
|
5
|
+
* Importing this evaluates `class extends HTMLElement`, so it needs a DOM.
|
|
6
|
+
* For a build step, a CI check or a theme-builder script, import
|
|
7
|
+
* `@machfivetechchicago/machvive-neodigm55-ux/conductor` instead — it has no
|
|
8
|
+
* DOM dependency and loads in bare Node.
|
|
9
|
+
*/
|
|
10
|
+
import { NeodigmToast, DEFAULT_DURATION } from './src/wc/neodigm-toast/neodigm-toast.js';
|
|
11
|
+
import { NeodigmMarquee, DEFAULT_SPEED, parseRuns, plainText } from './src/wc/neodigm-marquee/neodigm-marquee.js';
|
|
12
|
+
import { NeodigmTulip, TULIP_DEFAULTS, readConfig, configFrom } from './src/wc/neodigm-tulip/neodigm-tulip.js';
|
|
13
|
+
|
|
14
|
+
export { NeodigmToast, DEFAULT_DURATION };
|
|
15
|
+
export { NeodigmMarquee, DEFAULT_SPEED, parseRuns, plainText };
|
|
16
|
+
export { NeodigmTulip, TULIP_DEFAULTS, readConfig, configFrom };
|
|
17
|
+
export {
|
|
18
|
+
THEMES, THEME_NAMES, OPT_OUT, THEME_ATTR, PULSE_ATTR,
|
|
19
|
+
themeCss, installTheme, resolveTheme,
|
|
20
|
+
motionAllowed, setMotionAllowed, pause, play, onMotionChange, resetMotion,
|
|
21
|
+
robinTheme, pulseTheme, flashTitle, resetTitle
|
|
22
|
+
} from './src/conductor/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@machfivetechchicago/machvive-neodigm55-ux",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Neodigm 55 as dependency-free Web Components — a page-level choreographer that moves colour and attention across every themed element, plus the components it conducts.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"web-components",
|
|
7
|
+
"webcomponents",
|
|
8
|
+
"custom-elements",
|
|
9
|
+
"ux",
|
|
10
|
+
"ui",
|
|
11
|
+
"design-system",
|
|
12
|
+
"theme",
|
|
13
|
+
"toast",
|
|
14
|
+
"snackbar",
|
|
15
|
+
"neodigm",
|
|
16
|
+
"no-dependencies",
|
|
17
|
+
"esm"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "index.js",
|
|
21
|
+
"module": "index.js",
|
|
22
|
+
"types": "index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./index.d.ts",
|
|
26
|
+
"default": "./index.js"
|
|
27
|
+
},
|
|
28
|
+
"./conductor": {
|
|
29
|
+
"types": "./src/conductor/index.d.ts",
|
|
30
|
+
"default": "./src/conductor/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./toast": {
|
|
33
|
+
"types": "./src/wc/neodigm-toast/neodigm-toast.d.ts",
|
|
34
|
+
"default": "./src/wc/neodigm-toast/neodigm-toast.js"
|
|
35
|
+
},
|
|
36
|
+
"./marquee": {
|
|
37
|
+
"types": "./src/wc/neodigm-marquee/neodigm-marquee.d.ts",
|
|
38
|
+
"default": "./src/wc/neodigm-marquee/neodigm-marquee.js"
|
|
39
|
+
},
|
|
40
|
+
"./tulip": {
|
|
41
|
+
"types": "./src/wc/neodigm-tulip/neodigm-tulip.d.ts",
|
|
42
|
+
"default": "./src/wc/neodigm-tulip/neodigm-tulip.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"sideEffects": true,
|
|
47
|
+
"files": [
|
|
48
|
+
"index.js",
|
|
49
|
+
"index.d.ts",
|
|
50
|
+
"src"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"test": "node --test --import ./test/setup.js \"test/*.test.js\"",
|
|
54
|
+
"test:watch": "node --test --watch --import ./test/setup.js \"test/*.test.js\"",
|
|
55
|
+
"prepublishOnly": "npm test"
|
|
56
|
+
},
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/Mach-Five-Group/machvive-neodigm55-ux.git"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/Mach-Five-Group/machvive-neodigm55-ux#readme",
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/Mach-Five-Group/machvive-neodigm55-ux/issues"
|
|
64
|
+
},
|
|
65
|
+
"author": "MachFiveTech Chicago",
|
|
66
|
+
"license": "Apache-2.0",
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=18"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"jsdom": "^29.1.1"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface Rect { x: number; y: number; width: number; height: number }
|
|
2
|
+
export type Side = 'top' | 'right' | 'bottom' | 'left';
|
|
3
|
+
|
|
4
|
+
export interface Placement {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
/** The side actually used, which may differ from the one asked for. */
|
|
8
|
+
side: Side;
|
|
9
|
+
/** True when the preferred side did not fit and another was chosen. */
|
|
10
|
+
flipped: boolean;
|
|
11
|
+
/** True when no side fitted and the surface was pulled back on screen. */
|
|
12
|
+
clamped: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Chooses a side and position for a floating surface. Pure: no DOM. */
|
|
16
|
+
export function place(options: {
|
|
17
|
+
trigger: Rect;
|
|
18
|
+
surface: Rect;
|
|
19
|
+
viewport: { width: number; height: number };
|
|
20
|
+
position?: Side;
|
|
21
|
+
gap?: number;
|
|
22
|
+
pad?: number;
|
|
23
|
+
}): Placement;
|
|
24
|
+
|
|
25
|
+
/** Reads an element's rectangle in the shape `place` expects. */
|
|
26
|
+
export function rectOf(el: Element): Rect;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placing a floating surface next to the thing it describes.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately pure: it takes rectangles and returns coordinates, reads nothing
|
|
5
|
+
* from the DOM and touches nothing. That keeps it in the headless conductor —
|
|
6
|
+
* testable in Node, and shared by every floating surface rather than
|
|
7
|
+
* reimplemented in each. The components do the measuring; this does the
|
|
8
|
+
* deciding.
|
|
9
|
+
*
|
|
10
|
+
* The original computed `left` inline inside Tulip's `open()` from
|
|
11
|
+
* `getBoundingClientRect()` and never checked whether the result fitted on
|
|
12
|
+
* screen, so a tip on a trigger near the right edge rendered off the viewport.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** @typedef {{ x: number, y: number, width: number, height: number }} Rect */
|
|
16
|
+
/** @typedef {'top'|'right'|'bottom'|'left'} Side */
|
|
17
|
+
|
|
18
|
+
/** The order to try when a preferred side does not fit: its opposite first. */
|
|
19
|
+
const FALLBACKS = {
|
|
20
|
+
top: ['top', 'bottom', 'right', 'left'],
|
|
21
|
+
bottom: ['bottom', 'top', 'right', 'left'],
|
|
22
|
+
left: ['left', 'right', 'top', 'bottom'],
|
|
23
|
+
right: ['right', 'left', 'top', 'bottom']
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Where the surface would sit on a given side, before any clamping. */
|
|
27
|
+
function sideOffset(trigger, surface, side, gap) {
|
|
28
|
+
const midX = trigger.x + trigger.width / 2 - surface.width / 2;
|
|
29
|
+
const midY = trigger.y + trigger.height / 2 - surface.height / 2;
|
|
30
|
+
switch (side) {
|
|
31
|
+
case 'top': return { x: midX, y: trigger.y - surface.height - gap };
|
|
32
|
+
case 'bottom': return { x: midX, y: trigger.y + trigger.height + gap };
|
|
33
|
+
case 'left': return { x: trigger.x - surface.width - gap, y: midY };
|
|
34
|
+
default: return { x: trigger.x + trigger.width + gap, y: midY };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const fits = (at, surface, viewport, pad) =>
|
|
39
|
+
at.x >= pad && at.y >= pad &&
|
|
40
|
+
at.x + surface.width <= viewport.width - pad &&
|
|
41
|
+
at.y + surface.height <= viewport.height - pad;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Chooses a side and position for a floating surface.
|
|
45
|
+
*
|
|
46
|
+
* Tries the preferred side, then its opposite, then the two perpendicular ones,
|
|
47
|
+
* and takes the first that fits the viewport. If none fits — a surface larger
|
|
48
|
+
* than the space available — it keeps the preferred side and clamps, because
|
|
49
|
+
* a tip half off-screen is still readable and one placed somewhere arbitrary is
|
|
50
|
+
* confusing.
|
|
51
|
+
*
|
|
52
|
+
* @param {object} options
|
|
53
|
+
* @param {Rect} options.trigger The element being described, in viewport coordinates.
|
|
54
|
+
* @param {Rect} options.surface The floating surface's own size.
|
|
55
|
+
* @param {{ width: number, height: number }} options.viewport
|
|
56
|
+
* @param {Side} [options.position] Preferred side.
|
|
57
|
+
* @param {number} [options.gap] Space between trigger and surface.
|
|
58
|
+
* @param {number} [options.pad] Minimum distance from the viewport edge.
|
|
59
|
+
* @returns {{ x: number, y: number, side: Side, flipped: boolean, clamped: boolean }}
|
|
60
|
+
*/
|
|
61
|
+
export function place({ trigger, surface, viewport, position = 'top', gap = 8, pad = 4 }) {
|
|
62
|
+
const order = FALLBACKS[position] ?? FALLBACKS.top;
|
|
63
|
+
|
|
64
|
+
for (const side of order) {
|
|
65
|
+
const at = sideOffset(trigger, surface, side, gap);
|
|
66
|
+
if (fits(at, surface, viewport, pad)) {
|
|
67
|
+
return { ...at, side, flipped: side !== position, clamped: false };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Nothing fitted. Keep the author's chosen side and pull it back on screen.
|
|
72
|
+
const at = sideOffset(trigger, surface, position, gap);
|
|
73
|
+
const maxX = Math.max(pad, viewport.width - surface.width - pad);
|
|
74
|
+
const maxY = Math.max(pad, viewport.height - surface.height - pad);
|
|
75
|
+
return {
|
|
76
|
+
x: Math.min(Math.max(at.x, pad), maxX),
|
|
77
|
+
y: Math.min(Math.max(at.y, pad), maxY),
|
|
78
|
+
side: position,
|
|
79
|
+
flipped: false,
|
|
80
|
+
clamped: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reads a DOM element's rectangle in the shape `place` expects.
|
|
86
|
+
*
|
|
87
|
+
* The one DOM-touching function here, kept beside the maths so a component does
|
|
88
|
+
* not have to remember which coordinate space `place` works in. Returns zeroes
|
|
89
|
+
* where there is no layout engine, which is what jsdom reports anyway.
|
|
90
|
+
*
|
|
91
|
+
* @param {Element} el
|
|
92
|
+
* @returns {Rect}
|
|
93
|
+
*/
|
|
94
|
+
export function rectOf(el) {
|
|
95
|
+
const r = el?.getBoundingClientRect?.();
|
|
96
|
+
return {
|
|
97
|
+
x: r?.left ?? 0,
|
|
98
|
+
y: r?.top ?? 0,
|
|
99
|
+
width: r?.width ?? 0,
|
|
100
|
+
height: r?.height ?? 0
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface SweepOptions {
|
|
2
|
+
/** Subtree to sweep. Defaults to the whole document. */
|
|
3
|
+
context?: ParentNode;
|
|
4
|
+
/** ms between each element starting. */
|
|
5
|
+
stagger?: number;
|
|
6
|
+
/** ms each element holds the colour. Constant, unlike the original. */
|
|
7
|
+
hold?: number;
|
|
8
|
+
/** Aborting restores every element immediately. */
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
/** Also flash the tab title. */
|
|
11
|
+
flashTab?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sweeps a colour across every `[data-n55-theme]` element, then restores each.
|
|
16
|
+
*
|
|
17
|
+
* Does not cross shadow boundaries: a component is swept by its host attribute
|
|
18
|
+
* and styles its internals from that.
|
|
19
|
+
*
|
|
20
|
+
* @returns how many elements were swept.
|
|
21
|
+
*/
|
|
22
|
+
export function robinTheme(theme?: string, options?: SweepOptions): Promise<number>;
|
|
23
|
+
|
|
24
|
+
/** The slower `[data-n55-theme-pulse]` cycle. */
|
|
25
|
+
export function pulseTheme(
|
|
26
|
+
theme?: string,
|
|
27
|
+
options?: Omit<SweepOptions, 'flashTab'>
|
|
28
|
+
): Promise<number>;
|
|
29
|
+
|
|
30
|
+
/** Prefixes the tab title with a theme's glyph, then restores it. */
|
|
31
|
+
export function flashTitle(theme: string, ms?: number, options?: { doc?: Document }): boolean;
|
|
32
|
+
|
|
33
|
+
/** Test seam: drops the captured title and any pending restore. */
|
|
34
|
+
export function resetTitle(): void;
|