@addiscorp/kit 0.0.0-stage → 0.2.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 +202 -0
- package/README.md +100 -2
- package/dist/footer/index.d.ts +18 -0
- package/dist/footer/index.js +14 -0
- package/dist/header/index.d.ts +82 -0
- package/dist/header/index.js +101 -0
- package/dist/header/menu.d.ts +72 -0
- package/dist/header/menu.js +210 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -0
- package/dist/kit.css +126 -0
- package/dist/theme/index.d.ts +7 -0
- package/dist/theme/index.js +42 -0
- package/dist/tool/copy.d.ts +3 -0
- package/dist/tool/copy.js +13 -0
- package/dist/tool/index.d.ts +103 -0
- package/dist/tool/index.js +57 -0
- package/dist/tool/marks.d.ts +5 -0
- package/dist/tool/marks.js +30 -0
- package/dist/tool/tools.d.ts +10 -0
- package/dist/tool/tools.js +15 -0
- package/dist/tool.css +174 -0
- package/package.json +42 -4
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 [yyyy] [name of copyright owner]
|
|
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,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @addiscorp/kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The header, footer and theme every Addis site shares.
|
|
4
|
+
|
|
5
|
+
**Menu structure = kit. Menu content = per app.** The kit owns how the
|
|
6
|
+
header, menu, footer and theme are built and how they behave; each app only
|
|
7
|
+
says what's in them (its groups, items, buttons) and sets its brand colours.
|
|
8
|
+
Nothing about one app's menu belongs in the kit.
|
|
9
|
+
|
|
10
|
+
## Use it
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install github:addiscorp/kit#v0.1.0
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import '@addiscorp/kit/kit.css';
|
|
18
|
+
import { Header, Footer, HeaderButton, PersonIcon, themeBoot } from '@addiscorp/kit';
|
|
19
|
+
|
|
20
|
+
// In <head>, before paint: <script dangerouslySetInnerHTML={{ __html: themeBoot }} />
|
|
21
|
+
|
|
22
|
+
<Header
|
|
23
|
+
brand={{ name: 'simien', mark: <img src="/mark.png" alt="" /> }}
|
|
24
|
+
groups={[
|
|
25
|
+
{ id: 'docs', label: 'docs', items: [{ id: 'start', title: 'Start an app', href: '/docs/start/' }] },
|
|
26
|
+
{ id: 'menu', label: 'menu', items: [{ id: 'github', title: 'GitHub', href: 'https://github.com/simienapp' }] },
|
|
27
|
+
{ id: 'more', label: 'Matches', searchOnly: true, items: [/* found only by searching */] },
|
|
28
|
+
]}
|
|
29
|
+
pathname={pathname}
|
|
30
|
+
navigate={(href) => router.push(href)}
|
|
31
|
+
Link={Link} // your framework's link; a plain <a> by default
|
|
32
|
+
start={<HeaderButton name="account" label="Account" variant="profile" icon={<PersonIcon />}>…</HeaderButton>}
|
|
33
|
+
end={<>{/* notifications, settings, anything */}</>}
|
|
34
|
+
placeholder="Search the docs"
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
<Footer site="simien.dev" />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## What the kit does, so no app has to
|
|
41
|
+
|
|
42
|
+
- **The menu**: the brand button opens it; ⌘M / Ctrl+M opens and closes it; ⌘S, Ctrl+S or `/` opens it on search; typing anywhere searches; ↑ ↓ move, Enter opens, 1–9 open a numbered tile, Esc closes, `?` lists the shortcuts. A click outside or a navigation closes it.
|
|
43
|
+
- **Groups** are tiles (numbered 1–9 in order across groups) or rows (`layout: 'list'`); a `searchOnly` group appears only as search matches. An item has a `href` or an `onSelect`, an optional `icon`, `detail` and `keywords`.
|
|
44
|
+
- **`HeaderButton`**: a round button with a popover, one popover open at a time with the menu: account, notifications (`badge`), settings, or anything else.
|
|
45
|
+
- **`Footer`**: who makes the site (Addis Corp by default; `owner` changes it), the site's name, the light/dark switch.
|
|
46
|
+
- **Theme**: `themeBoot` sets light or dark before paint (a `theme` cookie wins, else the system); `ThemeToggle` switches and remembers.
|
|
47
|
+
|
|
48
|
+
## Make it yours
|
|
49
|
+
|
|
50
|
+
- **Colours and fonts** are variables. Set your brand's after importing `kit.css`:
|
|
51
|
+
```css
|
|
52
|
+
:root { --ak-accent: #9a6b0c; --ak-ground: #fafaf8; --ak-display: var(--font-display); }
|
|
53
|
+
:root[data-theme="dark"] { --ak-accent: #e2b54a; --ak-ground: #0b0c0e; }
|
|
54
|
+
```
|
|
55
|
+
`--ak-ground`, `--ak-panel`, `--ak-menu`, `--ak-tile`, `--ak-ink`, `--ak-soft`, `--ak-accent`, `--ak-edge`, `--ak-header-bg`, `--ak-font`, `--ak-display`, `--ak-width`, `--ak-topbar-h`.
|
|
56
|
+
- **One item drawn your way**: `renderItem={(item, { active, current, shortcut, layout }) => …}`; return `undefined` to keep the kit's.
|
|
57
|
+
- **A different layout entirely**: `useMenu({ groups, pathname, navigate })` is all the behaviour as a hook; wrap your own markup in `<HeaderProvider menu={menu}>` and use `Launcher`, `MenuPanel`, `MenuItems`, `HeaderButton` and `ShortcutsHelp` as you need them.
|
|
58
|
+
|
|
59
|
+
## A tool's site
|
|
60
|
+
|
|
61
|
+
Every Addis tool (rixse, mirab, woreda, kebele, gelada, harar, p8) gets the
|
|
62
|
+
same site, after zega.dev: a hero with the install commands under the
|
|
63
|
+
headline and a demo reel beside it, three benefits, the family of tools; and
|
|
64
|
+
docs after rixse.dev. **Structure = kit, content = per site**: a site passes
|
|
65
|
+
words, commands and demo lines, never markup of its own. The tools' marks and
|
|
66
|
+
colours live here too, so every site and the family list agree.
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import '@addiscorp/kit/kit.css';
|
|
70
|
+
import '@addiscorp/kit/tool.css';
|
|
71
|
+
import { ToolSite, Hero, Why, DocsLayout, Code, Step, Callout } from '@addiscorp/kit';
|
|
72
|
+
|
|
73
|
+
<ToolSite tool="mirab" Link={Link}>
|
|
74
|
+
<Hero
|
|
75
|
+
headline={{ before: 'Agents in VMs on ', accent: 'your own machine', after: '.' }}
|
|
76
|
+
sub="The agent never holds a credential."
|
|
77
|
+
github="https://github.com/addiscorp/mirab"
|
|
78
|
+
installs={[{ label: 'install the cli', command: 'curl -fsSL https://mirab.addis.gg/install.sh | sh' }]}
|
|
79
|
+
reel={[{ title: '~/ops', caption: 'an agent is a folder', lines: [{ text: 'mirab init ops', kind: 'command' }] }]}
|
|
80
|
+
/>
|
|
81
|
+
<Why tool="mirab" benefits={[…three…]} />
|
|
82
|
+
</ToolSite>
|
|
83
|
+
|
|
84
|
+
<DocsLayout tool="mirab" pages={[{ href: '/docs/', title: 'Overview' }]} pathname={pathname} title="Overview" lede="…" Link={Link}>
|
|
85
|
+
…
|
|
86
|
+
</DocsLayout>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- **The header** is the mark, the name and `docs`; nothing else until a tool needs it.
|
|
90
|
+
- **The reel** is CSS only: its scenes play in turn, 5 s each, and each scene's lines appear one after another. With reduced motion it shows the first scene, still.
|
|
91
|
+
- **Colours**: `data-tool` picks the tool's palette (`src/tool/palettes.css`, generated from its colour layout): one pale ground in light mode, a ground tinted with the brand in dark. The kit's footer and theme switch take the same colours.
|
|
92
|
+
- **Marks** (`MARKS`, `<Mark tool size />`) are inline SVG for light and dark; the cut-outs between parts are `var(--ak-cut)`, set to whatever is behind the mark.
|
|
93
|
+
- **Fonts**: the site loads Urbanist, Instrument Sans and JetBrains Mono.
|
|
94
|
+
|
|
95
|
+
## Develop
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
npm install
|
|
99
|
+
npm run typecheck
|
|
100
|
+
npm test # builds dist/, then drives the header and footer in a DOM (jsdom)
|
|
101
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type Owner = {
|
|
3
|
+
name: string;
|
|
4
|
+
href: string;
|
|
5
|
+
logo: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/** Addis Corp, the default owner. */
|
|
8
|
+
export declare const ADDIS: Owner;
|
|
9
|
+
export type FooterProps = {
|
|
10
|
+
/** The site's name, shown at the end: `simien.dev`. */
|
|
11
|
+
site: string;
|
|
12
|
+
owner?: Owner;
|
|
13
|
+
/** The year in the copyright line; this year by default. */
|
|
14
|
+
year?: number;
|
|
15
|
+
/** Anything else for the end of the footer, before the theme switch. */
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
export declare function Footer({ site, owner, year, children }: FooterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeToggle } from '../theme/index.js';
|
|
3
|
+
/** Addis Corp, the default owner. */
|
|
4
|
+
export const ADDIS = {
|
|
5
|
+
name: 'Addis Corp',
|
|
6
|
+
href: 'https://addis.gg',
|
|
7
|
+
logo: _jsx(AddisMark, {}),
|
|
8
|
+
};
|
|
9
|
+
export function Footer({ site, owner = ADDIS, year = new Date().getFullYear(), children }) {
|
|
10
|
+
return (_jsxs("footer", { className: "ak-foot", children: [_jsxs("a", { className: "ak-credit", href: owner.href, children: [owner.logo, "\u00A9 ", year, " ", owner.name] }), _jsxs("span", { className: "ak-foot-end", children: [children, _jsx("span", { children: site }), _jsx(ThemeToggle, {})] })] }));
|
|
11
|
+
}
|
|
12
|
+
function AddisMark() {
|
|
13
|
+
return (_jsx("svg", { className: "ak-owner-mark", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64", width: 32, height: 32, "aria-hidden": "true", dangerouslySetInnerHTML: { __html: '<circle cx="32" cy="32" r="31" fill="#1b1914"/><path fill="#f3efe3" d="M28.48 41L23.89 41L29.63 28.07Q26.87 27.73 25.60 26.27Q24.33 24.82 24.33 22.28L24.33 22.28L24.33 18.87L28.73 18.87L28.73 21.44Q28.73 23.27 29.52 23.95Q30.31 24.63 32.11 24.63L32.11 24.63L35.70 24.63L28.48 41ZM40.17 41L35.55 41Q35.52 38.21 35.08 36.51Q34.65 34.80 33.81 33.85Q32.98 32.91 31.74 32.38L31.74 32.38L33.19 28.91Q35.39 29.69 36.93 31.11Q38.46 32.54 39.28 34.92Q40.11 37.31 40.17 41L40.17 41Z"/><rect x="20" y="47.5" width="8" height="3" fill="#078930"/><rect x="28" y="47.5" width="8" height="3" fill="#fcdd09"/><rect x="36" y="47.5" width="8" height="3" fill="#da121a"/>' } }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes, type ComponentType, type ReactNode } from 'react';
|
|
2
|
+
import { type Menu, type MenuGroup, type MenuItem } from './menu.js';
|
|
3
|
+
export { useMenu, matches, type Menu, type MenuGroup, type MenuItem, type MenuConfig } from './menu.js';
|
|
4
|
+
/** A link component (Next's or vinext's `Link`); a plain <a> by default. */
|
|
5
|
+
export type LinkComponent = ComponentType<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
6
|
+
href: string;
|
|
7
|
+
}>;
|
|
8
|
+
type Context = {
|
|
9
|
+
menu: Menu;
|
|
10
|
+
Link: LinkComponent;
|
|
11
|
+
};
|
|
12
|
+
/** The menu's state and the link component, for anything inside a Header. */
|
|
13
|
+
export declare function useHeader(): Context;
|
|
14
|
+
/** Shares a menu built with useMenu with the blocks inside, for a header an app lays out itself. */
|
|
15
|
+
export declare function HeaderProvider({ menu, Link, children }: {
|
|
16
|
+
menu: Menu;
|
|
17
|
+
Link?: LinkComponent;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export type ItemContext = {
|
|
21
|
+
active: boolean;
|
|
22
|
+
current: boolean;
|
|
23
|
+
shortcut?: string;
|
|
24
|
+
layout: 'tiles' | 'list';
|
|
25
|
+
};
|
|
26
|
+
export type HeaderProps = {
|
|
27
|
+
brand: {
|
|
28
|
+
name: string;
|
|
29
|
+
mark?: ReactNode;
|
|
30
|
+
};
|
|
31
|
+
groups: MenuGroup[];
|
|
32
|
+
pathname: string;
|
|
33
|
+
navigate: (href: string) => void;
|
|
34
|
+
/** Beside the brand on the left: an account button, say. */
|
|
35
|
+
start?: ReactNode;
|
|
36
|
+
/** On the right: notifications, settings, anything. */
|
|
37
|
+
end?: ReactNode;
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
Link?: LinkComponent;
|
|
40
|
+
/** Draws an item your way; return undefined to keep the kit's. */
|
|
41
|
+
renderItem?: (item: MenuItem, context: ItemContext) => ReactNode;
|
|
42
|
+
};
|
|
43
|
+
export declare function Header({ brand, groups, pathname, navigate, start, end, placeholder, Link, renderItem }: HeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
/** The brand button that opens the menu. */
|
|
45
|
+
export declare function Launcher({ name, mark }: {
|
|
46
|
+
name: string;
|
|
47
|
+
mark?: ReactNode;
|
|
48
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
/** The menu: search, then each group as tiles or rows. */
|
|
50
|
+
export declare function MenuPanel({ placeholder, renderItem }: {
|
|
51
|
+
placeholder?: string;
|
|
52
|
+
renderItem?: HeaderProps['renderItem'];
|
|
53
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
54
|
+
/** One group of the menu. */
|
|
55
|
+
export declare function MenuItems({ group, renderItem }: {
|
|
56
|
+
group: MenuGroup;
|
|
57
|
+
renderItem?: HeaderProps['renderItem'];
|
|
58
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* A round button in the header with a popover under it: account,
|
|
61
|
+
* notifications, settings, or anything an app needs. `name` keeps one popover
|
|
62
|
+
* open at a time, with the menu.
|
|
63
|
+
*/
|
|
64
|
+
export declare function HeaderButton({ name, label, icon, badge, variant, align, children, }: {
|
|
65
|
+
name: string;
|
|
66
|
+
label: string;
|
|
67
|
+
icon: ReactNode;
|
|
68
|
+
badge?: number;
|
|
69
|
+
variant?: 'icon' | 'profile';
|
|
70
|
+
align?: 'start' | 'end';
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
73
|
+
/** The `?` overlay listing the shortcuts. */
|
|
74
|
+
export declare function ShortcutsHelp(): import("react/jsx-runtime").JSX.Element | null;
|
|
75
|
+
export declare function Chevron({ open }: {
|
|
76
|
+
open: boolean;
|
|
77
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
export declare function SearchIcon(): import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
export declare function PersonIcon(): import("react/jsx-runtime").JSX.Element;
|
|
80
|
+
export declare function BellIcon(): import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
export declare function GearIcon(): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
export declare function PlusIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
// The header every Addis site shares: a launcher in the middle that opens the
|
|
4
|
+
// menu, and two slots for whatever the app puts beside it. The structure and
|
|
5
|
+
// behaviour are the kit's; the content and look of every item are the app's.
|
|
6
|
+
import { createContext, useContext, } from 'react';
|
|
7
|
+
import { useMenu } from './menu.js';
|
|
8
|
+
export { useMenu, matches } from './menu.js';
|
|
9
|
+
const PlainLink = (props) => _jsx("a", { ...props });
|
|
10
|
+
const HeaderContext = createContext(null);
|
|
11
|
+
/** The menu's state and the link component, for anything inside a Header. */
|
|
12
|
+
export function useHeader() {
|
|
13
|
+
const context = useContext(HeaderContext);
|
|
14
|
+
if (!context)
|
|
15
|
+
throw new Error('useHeader needs a <Header> (or <HeaderProvider>) around it');
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
/** Shares a menu built with useMenu with the blocks inside, for a header an app lays out itself. */
|
|
19
|
+
export function HeaderProvider({ menu, Link = PlainLink, children }) {
|
|
20
|
+
return _jsx(HeaderContext.Provider, { value: { menu, Link }, children: children });
|
|
21
|
+
}
|
|
22
|
+
export function Header({ brand, groups, pathname, navigate, start, end, placeholder, Link = PlainLink, renderItem }) {
|
|
23
|
+
const menu = useMenu({ groups, pathname, navigate });
|
|
24
|
+
return (_jsxs(HeaderProvider, { menu: menu, Link: Link, children: [_jsx("header", { className: menu.scrolled ? 'ak-topbar is-scrolled' : 'ak-topbar', ref: menu.refs.header, children: _jsxs("div", { className: "ak-topbar-inner", children: [_jsx("div", { className: "ak-top-side", children: start }), _jsxs("div", { className: "ak-top-center", children: [_jsx(Launcher, { name: brand.name, mark: brand.mark }), _jsx(MenuPanel, { placeholder: placeholder, renderItem: renderItem })] }), _jsx("div", { className: "ak-top-side ak-end", children: end })] }) }), _jsx(ShortcutsHelp, {})] }));
|
|
25
|
+
}
|
|
26
|
+
/** The brand button that opens the menu. */
|
|
27
|
+
export function Launcher({ name, mark }) {
|
|
28
|
+
const { menu } = useHeader();
|
|
29
|
+
const open = menu.panel === 'menu';
|
|
30
|
+
return (_jsxs("button", { ref: menu.refs.launcher, className: "ak-launcher", type: "button", "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": "ak-menu", onClick: () => (open ? menu.close() : menu.openMenu(false)), children: [mark, _jsx("span", { children: name }), _jsx(Chevron, { open: open })] }));
|
|
31
|
+
}
|
|
32
|
+
/** The menu: search, then each group as tiles or rows. */
|
|
33
|
+
export function MenuPanel({ placeholder = 'Search or jump', renderItem }) {
|
|
34
|
+
const { menu } = useHeader();
|
|
35
|
+
if (menu.panel !== 'menu')
|
|
36
|
+
return null;
|
|
37
|
+
return (_jsxs("div", { ref: menu.refs.dialog, id: "ak-menu", className: "ak-menu", role: "dialog", "aria-modal": "true", "aria-label": "Menu", tabIndex: -1, children: [_jsxs("div", { className: "ak-search", children: [_jsx(SearchIcon, {}), _jsx("input", { ref: menu.refs.search, value: menu.query, onChange: (event) => menu.search(event.target.value), placeholder: placeholder, "aria-label": placeholder, "aria-activedescendant": menu.active >= 0 ? `ak-item-${menu.flat[menu.active]?.id}` : undefined, autoComplete: "off", autoCorrect: "off", spellCheck: false })] }), menu.shown.map((group) => (_jsx(MenuItems, { group: group, renderItem: renderItem }, group.id))), menu.flat.length === 0 && _jsx("p", { className: "ak-empty", children: "Nothing matches." })] }));
|
|
38
|
+
}
|
|
39
|
+
/** One group of the menu. */
|
|
40
|
+
export function MenuItems({ group, renderItem }) {
|
|
41
|
+
const { menu, Link } = useHeader();
|
|
42
|
+
const layout = group.searchOnly ? 'list' : group.layout ?? 'tiles';
|
|
43
|
+
return (_jsxs("div", { className: "ak-group", children: [_jsx("p", { className: "ak-group-label", children: group.label }), _jsx("div", { className: layout === 'tiles' ? 'ak-tiles' : 'ak-list', role: "list", children: group.items.map((item) => {
|
|
44
|
+
const index = menu.flat.indexOf(item);
|
|
45
|
+
const number = menu.numbered.indexOf(item);
|
|
46
|
+
const context = {
|
|
47
|
+
active: index === menu.active,
|
|
48
|
+
current: menu.here(item.href),
|
|
49
|
+
shortcut: number >= 0 ? String(number + 1) : undefined,
|
|
50
|
+
layout,
|
|
51
|
+
};
|
|
52
|
+
const custom = renderItem?.(item, context);
|
|
53
|
+
const inner = custom ?? (_jsxs(_Fragment, { children: [layout === 'tiles' ? item.icon ?? _jsx(DotIcon, {}) : null, layout === 'tiles' ? item.title : _jsxs(_Fragment, { children: [_jsx("b", { children: item.title }), item.detail && _jsx("span", { className: "ak-soft", children: item.detail })] }), context.shortcut && _jsx("kbd", { className: "ak-key-num", "aria-hidden": "true", children: context.shortcut })] }));
|
|
54
|
+
const className = `${layout === 'tiles' ? 'ak-tile' : 'ak-row'}${context.active ? ' is-active' : ''}`;
|
|
55
|
+
const common = {
|
|
56
|
+
id: `ak-item-${item.id}`,
|
|
57
|
+
className,
|
|
58
|
+
onMouseEnter: () => menu.setActive(index),
|
|
59
|
+
};
|
|
60
|
+
return item.href && !item.onSelect ? (_jsx(Link, { ...common, href: item.href, "aria-current": context.current ? 'page' : undefined, "aria-keyshortcuts": context.shortcut, onClick: () => menu.close(), children: inner }, item.id)) : (_jsx("button", { ...common, type: "button", onClick: () => menu.select(item), children: inner }, item.id));
|
|
61
|
+
}) })] }));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A round button in the header with a popover under it: account,
|
|
65
|
+
* notifications, settings, or anything an app needs. `name` keeps one popover
|
|
66
|
+
* open at a time, with the menu.
|
|
67
|
+
*/
|
|
68
|
+
export function HeaderButton({ name, label, icon, badge, variant = 'icon', align = 'start', children, }) {
|
|
69
|
+
const { menu } = useHeader();
|
|
70
|
+
const open = menu.panel === name;
|
|
71
|
+
return (_jsxs("div", { className: "ak-anchor", children: [_jsxs("button", { className: variant === 'profile' ? 'ak-profile-btn' : 'ak-icon-btn', type: "button", "aria-label": badge ? `${badge} ${label}` : label, "aria-expanded": open, onClick: () => menu.toggle(name), children: [icon, !!badge && _jsx("span", { className: "ak-badge", children: badge })] }), open && children && (_jsx("div", { className: align === 'end' ? 'ak-popover ak-end' : 'ak-popover', role: "dialog", "aria-label": label, children: children }))] }));
|
|
72
|
+
}
|
|
73
|
+
/** The `?` overlay listing the shortcuts. */
|
|
74
|
+
export function ShortcutsHelp() {
|
|
75
|
+
const { menu } = useHeader();
|
|
76
|
+
if (!menu.help)
|
|
77
|
+
return null;
|
|
78
|
+
const mod = menu.mod;
|
|
79
|
+
return (_jsx("div", { className: "ak-help-layer", onMouseDown: () => menu.setHelp(false), children: _jsxs("div", { ref: menu.refs.help, className: "ak-help", role: "dialog", "aria-modal": "true", "aria-label": "Keyboard shortcuts", tabIndex: -1, onMouseDown: (event) => event.stopPropagation(), children: [_jsx("h2", { children: "Keyboard shortcuts" }), _jsxs("ul", { className: "ak-help-list", children: [_jsxs("li", { children: [_jsx("span", { children: "Open or close the menu" }), _jsx("span", { className: "ak-help-keys", children: _jsxs("kbd", { children: [mod, "M"] }) })] }), _jsxs("li", { children: [_jsx("span", { children: "Open the menu on search" }), _jsxs("span", { className: "ak-help-keys", children: [_jsx("kbd", { children: "/" }), _jsxs("kbd", { children: [mod, "S"] })] })] }), _jsxs("li", { children: [_jsx("span", { children: "Open a numbered tile" }), _jsx("span", { className: "ak-help-keys", children: _jsx("kbd", { children: "1\u20139" }) })] }), _jsxs("li", { children: [_jsx("span", { children: "Move through the menu" }), _jsxs("span", { className: "ak-help-keys", children: [_jsx("kbd", { children: "\u2191" }), _jsx("kbd", { children: "\u2193" })] })] }), _jsxs("li", { children: [_jsx("span", { children: "Open the highlighted item" }), _jsx("span", { className: "ak-help-keys", children: _jsx("kbd", { children: "Enter" }) })] }), _jsxs("li", { children: [_jsx("span", { children: "Close" }), _jsx("span", { className: "ak-help-keys", children: _jsx("kbd", { children: "Esc" }) })] }), _jsxs("li", { children: [_jsx("span", { children: "Show these shortcuts" }), _jsx("span", { className: "ak-help-keys", children: _jsx("kbd", { children: "?" }) })] })] })] }) }));
|
|
80
|
+
}
|
|
81
|
+
export function Chevron({ open }) {
|
|
82
|
+
return (_jsx("svg", { className: open ? 'ak-chev ak-open' : 'ak-chev', viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: _jsx("path", { d: "M6 9l6 6 6-6" }) }));
|
|
83
|
+
}
|
|
84
|
+
export function SearchIcon() {
|
|
85
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: [_jsx("circle", { cx: "11", cy: "11", r: "6" }), _jsx("path", { d: "M16 16l4 4" })] }));
|
|
86
|
+
}
|
|
87
|
+
export function PersonIcon() {
|
|
88
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: [_jsx("circle", { cx: "12", cy: "8", r: "3" }), _jsx("path", { d: "M5 19c1.4-3 3.8-4.5 7-4.5S17.6 16 19 19" })] }));
|
|
89
|
+
}
|
|
90
|
+
export function BellIcon() {
|
|
91
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: [_jsx("path", { d: "M6 16V10a6 6 0 1 1 12 0v6l1.5 2h-15L6 16Z" }), _jsx("path", { d: "M10 19a2 2 0 0 0 4 0" })] }));
|
|
92
|
+
}
|
|
93
|
+
export function GearIcon() {
|
|
94
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: [_jsx("circle", { cx: "12", cy: "12", r: "3" }), _jsx("path", { d: "M12 3.5v2.2M12 18.3v2.2M3.5 12h2.2M18.3 12h2.2M5.8 5.8l1.6 1.6M16.6 16.6l1.6 1.6M18.2 5.8l-1.6 1.6M7.4 16.6l-1.6 1.6" })] }));
|
|
95
|
+
}
|
|
96
|
+
export function PlusIcon() {
|
|
97
|
+
return (_jsx("svg", { className: "ak-favicon", viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: _jsx("path", { d: "M8 3.5v9M3.5 8h9" }) }));
|
|
98
|
+
}
|
|
99
|
+
function DotIcon() {
|
|
100
|
+
return (_jsx("svg", { className: "ak-favicon", viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", children: _jsx("circle", { cx: "8", cy: "8", r: "3", fill: "currentColor" }) }));
|
|
101
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type ReactNode, type RefObject } from 'react';
|
|
2
|
+
export type MenuItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
/** Where it goes; leave it out and give `onSelect` for an action. */
|
|
6
|
+
href?: string;
|
|
7
|
+
onSelect?: () => void;
|
|
8
|
+
/** A second line, and what search matches besides the title. */
|
|
9
|
+
detail?: string;
|
|
10
|
+
keywords?: string;
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
export type MenuGroup = {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
items: MenuItem[];
|
|
17
|
+
/** Tiles (a grid, numbered 1–9 across groups) or rows. Tiles by default. */
|
|
18
|
+
layout?: 'tiles' | 'list';
|
|
19
|
+
/** Only shown while searching, as matches. */
|
|
20
|
+
searchOnly?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type MenuConfig = {
|
|
23
|
+
groups: MenuGroup[];
|
|
24
|
+
pathname: string;
|
|
25
|
+
navigate: (href: string) => void;
|
|
26
|
+
};
|
|
27
|
+
export type Panel = string | null;
|
|
28
|
+
export declare function matches(item: MenuItem, query: string): boolean;
|
|
29
|
+
export type Menu = ReturnType<typeof useMenu>;
|
|
30
|
+
/**
|
|
31
|
+
* All of the menu's behaviour. `panel` is which popover is open: `'menu'`, or
|
|
32
|
+
* any name an app gives its own (`'account'`, `'notifications'`, …).
|
|
33
|
+
*
|
|
34
|
+
* Keys: ⌘M / Ctrl+M opens and closes the menu; ⌘S, Ctrl+S or `/` opens it on
|
|
35
|
+
* search; typing anywhere starts a search; ↑ ↓ move, Enter opens, 1–9 open a
|
|
36
|
+
* numbered tile, Esc closes, `?` shows the shortcuts.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useMenu({ groups, pathname, navigate }: MenuConfig): {
|
|
39
|
+
panel: Panel;
|
|
40
|
+
setPanel: import("react").Dispatch<import("react").SetStateAction<Panel>>;
|
|
41
|
+
toggle: (name: string) => void;
|
|
42
|
+
close: () => void;
|
|
43
|
+
openMenu: (search: boolean) => void;
|
|
44
|
+
query: string;
|
|
45
|
+
search: (value: string) => void;
|
|
46
|
+
active: number;
|
|
47
|
+
setActive: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
48
|
+
shown: {
|
|
49
|
+
items: MenuItem[];
|
|
50
|
+
id: string;
|
|
51
|
+
label: string;
|
|
52
|
+
/** Tiles (a grid, numbered 1–9 across groups) or rows. Tiles by default. */
|
|
53
|
+
layout?: "tiles" | "list";
|
|
54
|
+
/** Only shown while searching, as matches. */
|
|
55
|
+
searchOnly?: boolean;
|
|
56
|
+
}[];
|
|
57
|
+
flat: MenuItem[];
|
|
58
|
+
numbered: MenuItem[];
|
|
59
|
+
select: (item: MenuItem) => void;
|
|
60
|
+
here: (href?: string) => boolean;
|
|
61
|
+
help: boolean;
|
|
62
|
+
setHelp: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
63
|
+
scrolled: boolean;
|
|
64
|
+
mod: string;
|
|
65
|
+
refs: {
|
|
66
|
+
launcher: RefObject<HTMLButtonElement | null>;
|
|
67
|
+
search: RefObject<HTMLInputElement | null>;
|
|
68
|
+
dialog: RefObject<HTMLDivElement | null>;
|
|
69
|
+
header: RefObject<HTMLElement>;
|
|
70
|
+
help: RefObject<HTMLDivElement | null>;
|
|
71
|
+
};
|
|
72
|
+
};
|