@tokamaq/ui 0.0.0-stage → 0.1.0-dev.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 +21 -0
- package/README.md +23 -2
- package/lint/index.js +22 -0
- package/lint/oxlint.json +58 -0
- package/lint/plugin.js +411 -0
- package/package.json +82 -4
- package/src/avatar.tsx +34 -0
- package/src/button.tsx +109 -0
- package/src/chip.tsx +52 -0
- package/src/cn.ts +71 -0
- package/src/code-block.tsx +58 -0
- package/src/collapsible.tsx +76 -0
- package/src/command.tsx +101 -0
- package/src/dialog.tsx +93 -0
- package/src/file-name.tsx +41 -0
- package/src/fonts/Geist-Variable.woff2 +0 -0
- package/src/fonts/GeistMono-Variable.woff2 +0 -0
- package/src/fonts/OFL.txt +92 -0
- package/src/fonts.css +15 -0
- package/src/icon.tsx +30 -0
- package/src/icons.ts +23 -0
- package/src/index.ts +24 -0
- package/src/input.tsx +86 -0
- package/src/kbd.tsx +33 -0
- package/src/kit/command.tsx +45 -0
- package/src/kit/contrast.ts +31 -0
- package/src/kit/controls.tsx +233 -0
- package/src/kit/disclosure.tsx +39 -0
- package/src/kit/frame.tsx +34 -0
- package/src/kit/inputs.tsx +53 -0
- package/src/kit/kit.tsx +76 -0
- package/src/kit/overlays.tsx +79 -0
- package/src/kit/rows.tsx +160 -0
- package/src/kit/tokens.tsx +189 -0
- package/src/menu.tsx +99 -0
- package/src/resizable.tsx +40 -0
- package/src/row-list.tsx +65 -0
- package/src/row.tsx +147 -0
- package/src/scroll-area.tsx +64 -0
- package/src/select.tsx +67 -0
- package/src/status-icon.tsx +49 -0
- package/src/switch.tsx +73 -0
- package/src/tabs.tsx +44 -0
- package/src/textarea.tsx +30 -0
- package/src/theme.css +397 -0
- package/src/tooltip.tsx +40 -0
- package/tests/setup.ts +29 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Copyright (c) 2023 Vercel, in collaboration with basement.studio
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font creation
|
|
14
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
15
|
+
open framework in which fonts may be shared and improved in partnership
|
|
16
|
+
with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply
|
|
25
|
+
to any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software components as
|
|
36
|
+
distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
39
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
40
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
41
|
+
new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION AND CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
49
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
50
|
+
Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components,
|
|
53
|
+
in Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
64
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
65
|
+
presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created
|
|
77
|
+
using the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
package/src/fonts.css
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* Geist and Geist Mono 1.9.2 by Vercel, SIL Open Font License 1.1 (fonts/OFL.txt). */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: "Geist";
|
|
4
|
+
src: url("./fonts/Geist-Variable.woff2") format("woff2");
|
|
5
|
+
font-weight: 100 900;
|
|
6
|
+
font-style: normal;
|
|
7
|
+
font-display: swap;
|
|
8
|
+
}
|
|
9
|
+
@font-face {
|
|
10
|
+
font-family: "Geist Mono";
|
|
11
|
+
src: url("./fonts/GeistMono-Variable.woff2") format("woff2");
|
|
12
|
+
font-weight: 100 900;
|
|
13
|
+
font-style: normal;
|
|
14
|
+
font-display: swap;
|
|
15
|
+
}
|
package/src/icon.tsx
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<Icon path={icons.search} />
|
|
3
|
+
<Icon path={icons.check} size={12} label="Saved" />
|
|
4
|
+
|
|
5
|
+
One single-colour path in a 24 × 24 box, painted in currentColor. Without
|
|
6
|
+
a label it is hidden from assistive technology.
|
|
7
|
+
*/
|
|
8
|
+
import type { JSX } from "@solidjs/web";
|
|
9
|
+
import { cn } from "./cn.ts";
|
|
10
|
+
|
|
11
|
+
export type IconProps = { path: string; size?: 12 | 14 | 16; label?: string; class?: string };
|
|
12
|
+
|
|
13
|
+
export function Icon(props: IconProps): JSX.Element {
|
|
14
|
+
return (
|
|
15
|
+
<svg
|
|
16
|
+
data-slot="icon"
|
|
17
|
+
viewBox="0 0 24 24"
|
|
18
|
+
class={cn(
|
|
19
|
+
"block shrink-0",
|
|
20
|
+
props.size === 12 ? "size-3" : props.size === 14 ? "size-mark" : "size-4",
|
|
21
|
+
props.class,
|
|
22
|
+
)}
|
|
23
|
+
role={props.label ? "img" : undefined}
|
|
24
|
+
aria-label={props.label}
|
|
25
|
+
aria-hidden={props.label ? undefined : "true"}
|
|
26
|
+
>
|
|
27
|
+
<path d={props.path} fill="currentColor" />
|
|
28
|
+
</svg>
|
|
29
|
+
);
|
|
30
|
+
}
|
package/src/icons.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Remix Icon 4.9.1 paths (Apache-2.0), 24 × 24 viewBox. Pass any other Remix
|
|
2
|
+
// path to <Icon path> the same way.
|
|
3
|
+
export const icons = {
|
|
4
|
+
running:
|
|
5
|
+
"M18.364 5.63604L16.9497 7.05025C15.683 5.7835 13.933 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19C15.866 19 19 15.866 19 12H21C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C14.4853 3 16.7353 4.00736 18.364 5.63604Z",
|
|
6
|
+
done: "M4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12ZM12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM17.4571 9.45711L16.0429 8.04289L11 13.0858L8.20711 10.2929L6.79289 11.7071L11 15.9142L17.4571 9.45711Z",
|
|
7
|
+
failed:
|
|
8
|
+
"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 10.5858L14.8284 7.75736L16.2426 9.17157L13.4142 12L16.2426 14.8284L14.8284 16.2426L12 13.4142L9.17157 16.2426L7.75736 14.8284L10.5858 12L7.75736 9.17157L9.17157 7.75736L12 10.5858Z",
|
|
9
|
+
needsYou:
|
|
10
|
+
"M19 10H20C20.5523 10 21 10.4477 21 11V21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21V11C3 10.4477 3.44772 10 4 10H5V9C5 5.13401 8.13401 2 12 2C15.866 2 19 5.13401 19 9V10ZM5 12V20H19V12H5ZM11 14H13V18H11V14ZM17 10V9C17 6.23858 14.7614 4 12 4C9.23858 4 7 6.23858 7 9V10H17Z",
|
|
11
|
+
check:
|
|
12
|
+
"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z",
|
|
13
|
+
close:
|
|
14
|
+
"M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z",
|
|
15
|
+
chevronDown:
|
|
16
|
+
"M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z",
|
|
17
|
+
add: "M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z",
|
|
18
|
+
more: "M4.5 10.5C3.675 10.5 3 11.175 3 12C3 12.825 3.675 13.5 4.5 13.5C5.325 13.5 6 12.825 6 12C6 11.175 5.325 10.5 4.5 10.5ZM19.5 10.5C18.675 10.5 18 11.175 18 12C18 12.825 18.675 13.5 19.5 13.5C20.325 13.5 21 12.825 21 12C21 11.175 20.325 10.5 19.5 10.5ZM12 10.5C11.175 10.5 10.5 11.175 10.5 12C10.5 12.825 11.175 13.5 12 13.5C12.825 13.5 13.5 12.825 13.5 12C13.5 11.175 12.825 10.5 12 10.5Z",
|
|
19
|
+
arrowUp:
|
|
20
|
+
"M13.0001 7.82843V20H11.0001V7.82843L5.63614 13.1924L4.22192 11.7782L12.0001 4L19.7783 11.7782L18.3641 13.1924L13.0001 7.82843Z",
|
|
21
|
+
search:
|
|
22
|
+
"M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6146 17.2475 15.8748 16.0247L16.0247 15.8748Z",
|
|
23
|
+
} as const;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { cn, tv } from "./cn.ts";
|
|
2
|
+
export { icons } from "./icons.ts";
|
|
3
|
+
export { Avatar, type AvatarProps } from "./avatar.tsx";
|
|
4
|
+
export { Button, buttonVariants, type ButtonProps, type ButtonVariant, type ButtonSize } from "./button.tsx";
|
|
5
|
+
export { Chip, chipVariants, type ChipProps } from "./chip.tsx";
|
|
6
|
+
export { CodeBlock } from "./code-block.tsx";
|
|
7
|
+
export { FileName } from "./file-name.tsx";
|
|
8
|
+
export { Icon, type IconProps } from "./icon.tsx";
|
|
9
|
+
export { Kbd, formatKeys } from "./kbd.tsx";
|
|
10
|
+
export { ScrollArea, type ScrollAreaProps } from "./scroll-area.tsx";
|
|
11
|
+
export { Row, rowVariants, type RowProps, type RowKind } from "./row.tsx";
|
|
12
|
+
export { StatusIcon, type Status } from "./status-icon.tsx";
|
|
13
|
+
export { Textarea, type TextareaProps } from "./textarea.tsx";
|
|
14
|
+
export { Input, inputVariants, type InputProps } from "./input.tsx";
|
|
15
|
+
export { Switch, type SwitchProps } from "./switch.tsx";
|
|
16
|
+
export * as Command from "./command.tsx";
|
|
17
|
+
export * as Collapsible from "./collapsible.tsx";
|
|
18
|
+
export * as Dialog from "./dialog.tsx";
|
|
19
|
+
export * as Menu from "./menu.tsx";
|
|
20
|
+
export * as Resizable from "./resizable.tsx";
|
|
21
|
+
export * as RowList from "./row-list.tsx";
|
|
22
|
+
export * as Select from "./select.tsx";
|
|
23
|
+
export * as Tabs from "./tabs.tsx";
|
|
24
|
+
export * as Tooltip from "./tooltip.tsx";
|
package/src/input.tsx
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<Input aria-label="Label" placeholder="Personal" size="lg" />
|
|
3
|
+
<Input aria-label="Callback link" mono placeholder="http://localhost:1455/callback?code=…" />
|
|
4
|
+
<Input aria-label="Search" icon={icons.search} trail={<Button variant="ghost" icon={icons.close} label="Clear" />} />
|
|
5
|
+
|
|
6
|
+
One line of text in the Textarea's translucent well and edge, radius 12
|
|
7
|
+
(Paper "Flow · Profiles", the add-subscription dialog). md is 40 tall with
|
|
8
|
+
12 px sides, as the pasted-link field; lg is 48 with 16, as the label
|
|
9
|
+
field, for roomy forms. mono sets the text in data mono for links and codes.
|
|
10
|
+
icon puts a 16 px tertiary mark before the text; trail holds one action,
|
|
11
|
+
such as a ghost icon button, at the end. invalid edges it in red; say why in
|
|
12
|
+
words beside it, never by colour alone, and point aria-describedby at those words.
|
|
13
|
+
*/
|
|
14
|
+
import { Input as Base, InputGroup } from "@ui-sdk/solid/input";
|
|
15
|
+
import { omit } from "solid-js";
|
|
16
|
+
import type { ComponentProps, JSX } from "@solidjs/web";
|
|
17
|
+
import { tv } from "./cn.ts";
|
|
18
|
+
import { Icon } from "./icon.tsx";
|
|
19
|
+
|
|
20
|
+
export const inputVariants = tv({
|
|
21
|
+
slots: {
|
|
22
|
+
root: [
|
|
23
|
+
"flex min-w-0 cursor-text items-center gap-2 rounded-md bg-edge/50 text-ink inset-ring inset-ring-edge",
|
|
24
|
+
// The ring sits on the well, not the <input>, so it wraps the icon and the action too.
|
|
25
|
+
// focus-ring also draws it for the kit's data-preview="focus".
|
|
26
|
+
"focus-ring has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-brand-text",
|
|
27
|
+
"has-aria-invalid:inset-ring-removed",
|
|
28
|
+
"data-disabled:cursor-default data-disabled:opacity-50",
|
|
29
|
+
],
|
|
30
|
+
control: [
|
|
31
|
+
"h-full min-w-0 flex-1 truncate bg-transparent outline-hidden placeholder:text-ink-3",
|
|
32
|
+
"disabled:cursor-default",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
variants: {
|
|
36
|
+
size: {
|
|
37
|
+
md: { root: "h-10 px-3" },
|
|
38
|
+
lg: { root: "h-12 px-4" },
|
|
39
|
+
},
|
|
40
|
+
mono: { true: { control: "text-data" }, false: { control: "text-row" } },
|
|
41
|
+
// An action fills the end: 4 px in on md keeps a 32 px button concentric with the
|
|
42
|
+
// 12 px corner (12 − 4 = its 8); lg centres it in the 48 px row.
|
|
43
|
+
trail: { true: {} },
|
|
44
|
+
},
|
|
45
|
+
compoundVariants: [
|
|
46
|
+
{ trail: true, size: "md", class: { root: "pe-1" } },
|
|
47
|
+
{ trail: true, size: "lg", class: { root: "pe-2" } },
|
|
48
|
+
],
|
|
49
|
+
defaultVariants: { size: "md", mono: false },
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export type InputProps = Omit<ComponentProps<typeof Base>, "class" | "size"> & {
|
|
53
|
+
size?: "md" | "lg";
|
|
54
|
+
/** Data mono (12 / 16) for links, codes and anything a person would copy. */
|
|
55
|
+
mono?: boolean;
|
|
56
|
+
/** A 16 px icon path before the text. */
|
|
57
|
+
icon?: string;
|
|
58
|
+
/** One action at the end, such as a ghost icon button. */
|
|
59
|
+
trail?: JSX.Element;
|
|
60
|
+
/** Marks the value wrong: aria-invalid on the field and a red edge. */
|
|
61
|
+
invalid?: boolean;
|
|
62
|
+
/** Layout classes for the well (width, margin, flex placement). */
|
|
63
|
+
class?: string;
|
|
64
|
+
/** Pins a state on the well for the kit page (focus); see theme.css. */
|
|
65
|
+
"data-preview"?: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export function Input(props: InputProps): JSX.Element {
|
|
69
|
+
const rest = omit(props, "class", "size", "mono", "icon", "trail", "invalid", "data-preview");
|
|
70
|
+
// `trail={value() && <Clear />}` passes false or "" when there is nothing to show; only a
|
|
71
|
+
// real action may take the end padding.
|
|
72
|
+
const hasTrail = () =>
|
|
73
|
+
props.trail !== undefined && props.trail !== null && props.trail !== false && props.trail !== "";
|
|
74
|
+
const styles = () => inputVariants({ size: props.size, mono: props.mono, trail: hasTrail() });
|
|
75
|
+
return (
|
|
76
|
+
<InputGroup data-preview={props["data-preview"]} class={styles().root({ class: props.class })}>
|
|
77
|
+
{props.icon && <Icon path={props.icon} class="text-ink-3" />}
|
|
78
|
+
<Base
|
|
79
|
+
{...rest}
|
|
80
|
+
aria-invalid={props.invalid ? "true" : props["aria-invalid"]}
|
|
81
|
+
class={styles().control()}
|
|
82
|
+
/>
|
|
83
|
+
{props.trail}
|
|
84
|
+
</InputGroup>
|
|
85
|
+
);
|
|
86
|
+
}
|
package/src/kbd.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<Kbd keys="mod+n" /> → ⌘N on macOS, Ctrl+N elsewhere
|
|
3
|
+
|
|
4
|
+
A keyboard shortcut in data mono, tertiary, with no box.
|
|
5
|
+
*/
|
|
6
|
+
import type { JSX } from "@solidjs/web";
|
|
7
|
+
import { cn } from "./cn.ts";
|
|
8
|
+
|
|
9
|
+
const apple = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
10
|
+
const glyphs: Record<string, [string, string]> = {
|
|
11
|
+
mod: ["⌘", "Ctrl"],
|
|
12
|
+
shift: ["⇧", "Shift"],
|
|
13
|
+
alt: ["⌥", "Alt"],
|
|
14
|
+
ctrl: ["⌃", "Ctrl"],
|
|
15
|
+
enter: ["↩", "Enter"],
|
|
16
|
+
esc: ["esc", "Esc"],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function formatKeys(keys: string, mac = apple): string {
|
|
20
|
+
const parts = keys.split("+").map((key) => {
|
|
21
|
+
const glyph = glyphs[key.toLowerCase()];
|
|
22
|
+
return glyph ? glyph[mac ? 0 : 1] : key.length === 1 ? key.toUpperCase() : key;
|
|
23
|
+
});
|
|
24
|
+
return parts.join(mac ? "" : "+");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function Kbd(props: { keys: string; class?: string }): JSX.Element {
|
|
28
|
+
return (
|
|
29
|
+
<kbd data-slot="kbd" class={cn("text-data whitespace-nowrap text-ink-3", props.class)}>
|
|
30
|
+
{formatKeys(props.keys)}
|
|
31
|
+
</kbd>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import { Command, Kbd, Menu } from "@tokamaq/ui";
|
|
3
|
+
import { Caption, Section } from "./frame.tsx";
|
|
4
|
+
|
|
5
|
+
export function CommandList(props: { theme: string }): JSX.Element {
|
|
6
|
+
return (
|
|
7
|
+
<Section label="Primitive · Command, Menu.RadioItem" title="Search and choices">
|
|
8
|
+
<Caption>A search row over 32 rows; in the app it sits in a dialog opened with ⌘K.</Caption>
|
|
9
|
+
<div class="flex items-start gap-8">
|
|
10
|
+
<div class="w-full max-w-dialog rounded-md surface-card p-1 inset-ring inset-ring-edge">
|
|
11
|
+
<Command.Root>
|
|
12
|
+
<Command.Search label={`Search, ${props.theme}`} placeholder="Search views and commands" />
|
|
13
|
+
<Command.Empty>Nothing matches.</Command.Empty>
|
|
14
|
+
<Command.List>
|
|
15
|
+
<Command.Group>
|
|
16
|
+
<Command.GroupLabel>Views</Command.GroupLabel>
|
|
17
|
+
<Command.Item value="chat">Chat</Command.Item>
|
|
18
|
+
<Command.Item value="notes">Notes</Command.Item>
|
|
19
|
+
</Command.Group>
|
|
20
|
+
<Command.Separator />
|
|
21
|
+
<Command.Group>
|
|
22
|
+
<Command.GroupLabel>Window</Command.GroupLabel>
|
|
23
|
+
<Command.Item value="sidebar">
|
|
24
|
+
Hide sidebar
|
|
25
|
+
<Kbd keys="mod+b" />
|
|
26
|
+
</Command.Item>
|
|
27
|
+
</Command.Group>
|
|
28
|
+
</Command.List>
|
|
29
|
+
</Command.Root>
|
|
30
|
+
</div>
|
|
31
|
+
<Menu.Root defaultOpen={false}>
|
|
32
|
+
<Menu.Trigger>Theme, {props.theme}</Menu.Trigger>
|
|
33
|
+
<Menu.Content>
|
|
34
|
+
<Menu.RadioGroup defaultValue="system">
|
|
35
|
+
<Menu.GroupLabel>Theme</Menu.GroupLabel>
|
|
36
|
+
<Menu.RadioItem value="system">System</Menu.RadioItem>
|
|
37
|
+
<Menu.RadioItem value="dark">Dark</Menu.RadioItem>
|
|
38
|
+
<Menu.RadioItem value="light">Light</Menu.RadioItem>
|
|
39
|
+
</Menu.RadioGroup>
|
|
40
|
+
</Menu.Content>
|
|
41
|
+
</Menu.Root>
|
|
42
|
+
</div>
|
|
43
|
+
</Section>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function luminance([r, g, b]: number[]): number {
|
|
2
|
+
const lin = (v: number) => (v / 255 <= 0.03928 ? v / 255 / 12.92 : ((v / 255 + 0.055) / 1.055) ** 2.4);
|
|
3
|
+
return 0.2126 * lin(r!) + 0.7152 * lin(g!) + 0.0722 * lin(b!);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function ratio(a: number[], b: number[]): number {
|
|
7
|
+
const [x, y] = [luminance(a), luminance(b)].sort((p, q) => q - p);
|
|
8
|
+
return (x! + 0.05) / (y! + 0.05);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const canvas = typeof document === "undefined" ? undefined : document.createElement("canvas");
|
|
12
|
+
const paint = canvas?.getContext("2d", { willReadFrequently: true });
|
|
13
|
+
|
|
14
|
+
// Paints `under`, then `over` on top, and reads back the pixel the browser drew.
|
|
15
|
+
function painted(element: Element, under: string, over?: string): number[] {
|
|
16
|
+
const read = (name: string) => getComputedStyle(element).getPropertyValue(`--color-${name}`).trim();
|
|
17
|
+
if (!paint) return [0, 0, 0];
|
|
18
|
+
paint.clearRect(0, 0, 1, 1);
|
|
19
|
+
paint.fillStyle = read(under);
|
|
20
|
+
paint.fillRect(0, 0, 1, 1);
|
|
21
|
+
if (over) {
|
|
22
|
+
paint.fillStyle = read(over);
|
|
23
|
+
paint.fillRect(0, 0, 1, 1);
|
|
24
|
+
}
|
|
25
|
+
return [...paint.getImageData(0, 0, 1, 1).data.slice(0, 3)];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Contrast of token `top` drawn over token `under`, as painted in this element.
|
|
29
|
+
export function tokenContrast(element: Element, top: string, under: string): number {
|
|
30
|
+
return ratio(painted(element, under, top), painted(element, under));
|
|
31
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { For, createSignal } from "solid-js";
|
|
2
|
+
import {
|
|
3
|
+
Avatar,
|
|
4
|
+
Button,
|
|
5
|
+
Chip,
|
|
6
|
+
Icon,
|
|
7
|
+
Kbd,
|
|
8
|
+
StatusIcon,
|
|
9
|
+
Tabs,
|
|
10
|
+
Textarea,
|
|
11
|
+
icons,
|
|
12
|
+
type ButtonVariant,
|
|
13
|
+
type Status,
|
|
14
|
+
} from "@tokamaq/ui";
|
|
15
|
+
import type { JSX } from "@solidjs/web";
|
|
16
|
+
import { Caption, Section } from "./frame.tsx";
|
|
17
|
+
import { tokenContrast } from "./contrast.ts";
|
|
18
|
+
|
|
19
|
+
const variants: ButtonVariant[] = ["brand", "primary", "outline", "destructive", "ghost"];
|
|
20
|
+
const states = ["rest", "hover", "focus", "pressed", "disabled"] as const;
|
|
21
|
+
const preview = { rest: undefined, hover: "hover", focus: "focus", pressed: "pressed", disabled: undefined };
|
|
22
|
+
|
|
23
|
+
export function Buttons(): JSX.Element {
|
|
24
|
+
return (
|
|
25
|
+
<Section label="Primitives · Button" title="Keys: brand or primary once per region">
|
|
26
|
+
<div class="grid grid-cols-6 items-center gap-3">
|
|
27
|
+
<span />
|
|
28
|
+
<For each={states}>{(state) => <Caption>{state}</Caption>}</For>
|
|
29
|
+
<For each={variants}>
|
|
30
|
+
{(variant) => (
|
|
31
|
+
<>
|
|
32
|
+
<Caption>{variant}</Caption>
|
|
33
|
+
<For each={states}>
|
|
34
|
+
{(state) => (
|
|
35
|
+
<Button
|
|
36
|
+
variant={variant}
|
|
37
|
+
data-preview={preview[state]}
|
|
38
|
+
disabled={state === "disabled"}
|
|
39
|
+
tabindex={state === "rest" ? 0 : -1}
|
|
40
|
+
>
|
|
41
|
+
{variant === "destructive" ? "Delete" : "Merge"}
|
|
42
|
+
</Button>
|
|
43
|
+
)}
|
|
44
|
+
</For>
|
|
45
|
+
</>
|
|
46
|
+
)}
|
|
47
|
+
</For>
|
|
48
|
+
<Caption>icon only</Caption>
|
|
49
|
+
<For each={states}>
|
|
50
|
+
{(state) => (
|
|
51
|
+
<Button
|
|
52
|
+
variant="ghost"
|
|
53
|
+
icon={icons.more}
|
|
54
|
+
label="Thread actions"
|
|
55
|
+
data-preview={preview[state]}
|
|
56
|
+
disabled={state === "disabled"}
|
|
57
|
+
tabindex={-1}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
</For>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="flex items-center gap-3">
|
|
63
|
+
<Button variant="primary" size="lg">
|
|
64
|
+
Large · 48
|
|
65
|
+
</Button>
|
|
66
|
+
<Button size="lg" icon={icons.add}>
|
|
67
|
+
New thread
|
|
68
|
+
</Button>
|
|
69
|
+
<Button variant="outline" icon={icons.add} label="Add" size="lg" />
|
|
70
|
+
<Caption>lg (48) matches a roomy row; use it only there.</Caption>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="flex items-center gap-3">
|
|
73
|
+
<Button variant="ghost" size="sm">
|
|
74
|
+
Sign in
|
|
75
|
+
</Button>
|
|
76
|
+
<Button size="sm" icon={icons.add}>
|
|
77
|
+
Add
|
|
78
|
+
</Button>
|
|
79
|
+
<Button variant="ghost" icon={icons.more} label="More" size="sm" />
|
|
80
|
+
<Caption>sm (24) for quiet actions in dense rows and dialogs.</Caption>
|
|
81
|
+
</div>
|
|
82
|
+
</Section>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function Facts(): JSX.Element {
|
|
87
|
+
const statuses: Status[] = ["running", "needs-you", "done", "failed"];
|
|
88
|
+
return (
|
|
89
|
+
<Section label="Primitives · Chip, Kbd, Avatar, StatusIcon, Icon" title="Small facts">
|
|
90
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
91
|
+
<Chip mono>
|
|
92
|
+
invoices.ts <span class="text-added">+42</span> <span class="text-removed">−3</span>
|
|
93
|
+
</Chip>
|
|
94
|
+
<Chip>feat/csv-export</Chip>
|
|
95
|
+
<Chip tone="added" label="3 checks passed">
|
|
96
|
+
✓ 3
|
|
97
|
+
</Chip>
|
|
98
|
+
<Chip tone="warn" label="2 need you">
|
|
99
|
+
! 2
|
|
100
|
+
</Chip>
|
|
101
|
+
<Chip tone="info" size="sm">
|
|
102
|
+
i 1
|
|
103
|
+
</Chip>
|
|
104
|
+
<Chip tone="removed" size="sm" label="1 failed">
|
|
105
|
+
× 1
|
|
106
|
+
</Chip>
|
|
107
|
+
</div>
|
|
108
|
+
<div class="flex items-center gap-6">
|
|
109
|
+
<span class="flex items-center gap-2 text-row text-ink-2">
|
|
110
|
+
New chat <Kbd keys="mod+n" />
|
|
111
|
+
</span>
|
|
112
|
+
<span class="flex items-center gap-2 text-row text-ink-2">
|
|
113
|
+
Stop <Kbd keys="esc" />
|
|
114
|
+
</span>
|
|
115
|
+
<Avatar name="Sam" />
|
|
116
|
+
<Avatar name="Ana" size={16} />
|
|
117
|
+
</div>
|
|
118
|
+
<div class="flex items-center gap-6">
|
|
119
|
+
<For each={statuses}>
|
|
120
|
+
{(status) => (
|
|
121
|
+
<span class="flex items-center gap-2 text-ink-3">
|
|
122
|
+
<StatusIcon status={status} />
|
|
123
|
+
<span class="text-label">{status}</span>
|
|
124
|
+
</span>
|
|
125
|
+
)}
|
|
126
|
+
</For>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="flex items-center gap-4 text-ink-3">
|
|
129
|
+
<For each={[icons.search, icons.add, icons.more, icons.check, icons.close, icons.arrowUp]}>
|
|
130
|
+
{(path) => <Icon path={path} />}
|
|
131
|
+
</For>
|
|
132
|
+
<span class="text-ink">
|
|
133
|
+
<Icon path={icons.search} />
|
|
134
|
+
</span>
|
|
135
|
+
<Caption>16 in a 32 target. Idle tertiary, current ink.</Caption>
|
|
136
|
+
</div>
|
|
137
|
+
</Section>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function Fields(props: { theme: string }): JSX.Element {
|
|
142
|
+
return (
|
|
143
|
+
<Section label="Primitives · Textarea, Tabs" title="Text and panels">
|
|
144
|
+
<div class="grid grid-cols-2 items-start gap-4">
|
|
145
|
+
<Textarea aria-label={`Empty note, ${props.theme}`} placeholder="Ask Mira" />
|
|
146
|
+
<Textarea
|
|
147
|
+
aria-label={`Filled note, ${props.theme}`}
|
|
148
|
+
value={
|
|
149
|
+
"Move the dentist to next week,\nadd groceries to my todos,\nand draft a note to the landlord."
|
|
150
|
+
}
|
|
151
|
+
/>
|
|
152
|
+
<Textarea aria-label={`Focused note, ${props.theme}`} data-preview="focus" placeholder="Focused" />
|
|
153
|
+
<Textarea aria-label={`Disabled note, ${props.theme}`} disabled placeholder="Disabled" />
|
|
154
|
+
</div>
|
|
155
|
+
<Tabs.Root defaultValue="changes">
|
|
156
|
+
<Tabs.List aria-label={`Review panel, ${props.theme}`}>
|
|
157
|
+
<Tabs.Tab value="files">Files</Tabs.Tab>
|
|
158
|
+
<Tabs.Tab value="changes">
|
|
159
|
+
Changes <span class="text-data text-ink-3">4</span>
|
|
160
|
+
</Tabs.Tab>
|
|
161
|
+
<Tabs.Tab value="checks" data-preview="hover">
|
|
162
|
+
Checks <span class="text-data text-ink-3">3</span>
|
|
163
|
+
</Tabs.Tab>
|
|
164
|
+
<Tabs.Tab value="review" disabled>
|
|
165
|
+
Review
|
|
166
|
+
</Tabs.Tab>
|
|
167
|
+
</Tabs.List>
|
|
168
|
+
<Tabs.Panel value="files">
|
|
169
|
+
<p class="pt-3 text-row text-ink-2">Four files changed.</p>
|
|
170
|
+
</Tabs.Panel>
|
|
171
|
+
<Tabs.Panel value="changes">
|
|
172
|
+
<p class="pt-3 text-row text-ink-2">+86 −21 across four files.</p>
|
|
173
|
+
</Tabs.Panel>
|
|
174
|
+
<Tabs.Panel value="checks">
|
|
175
|
+
<p class="pt-3 text-row text-ink-2">Three checks passed.</p>
|
|
176
|
+
</Tabs.Panel>
|
|
177
|
+
<Tabs.Panel value="review">
|
|
178
|
+
<p class="pt-3 text-row text-ink-2">No review yet.</p>
|
|
179
|
+
</Tabs.Panel>
|
|
180
|
+
</Tabs.Root>
|
|
181
|
+
<Caption>Tabs: selected, rest, hover (Checks), disabled (Review).</Caption>
|
|
182
|
+
</Section>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const tones = ["window", "stage", "tray", "card", "band"] as const;
|
|
187
|
+
const surfaceClass = {
|
|
188
|
+
window: "surface-window",
|
|
189
|
+
stage: "surface-stage",
|
|
190
|
+
tray: "surface-tray",
|
|
191
|
+
card: "surface-card",
|
|
192
|
+
band: "surface-band",
|
|
193
|
+
} as const;
|
|
194
|
+
|
|
195
|
+
function EdgeRatio(props: { tone: (typeof tones)[number] }): JSX.Element {
|
|
196
|
+
const [ratio, setRatio] = createSignal(0);
|
|
197
|
+
return (
|
|
198
|
+
<span
|
|
199
|
+
class="text-data text-ink-3"
|
|
200
|
+
ref={(element) =>
|
|
201
|
+
requestAnimationFrame(() => setRatio(tokenContrast(element, "edge-strong", props.tone)))
|
|
202
|
+
}
|
|
203
|
+
>
|
|
204
|
+
edge {ratio().toFixed(2)}
|
|
205
|
+
</span>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function OnSurfaces(): JSX.Element {
|
|
210
|
+
return (
|
|
211
|
+
<Section label="Primitives · Button on every surface" title="Translucent edges adapt">
|
|
212
|
+
<div class="flex flex-col">
|
|
213
|
+
<For each={tones}>
|
|
214
|
+
{(tone) => (
|
|
215
|
+
<div class={`flex items-center gap-2 px-3 py-2 ${surfaceClass[tone]}`}>
|
|
216
|
+
<span class="w-12 text-data text-ink-3">{tone}</span>
|
|
217
|
+
<For each={variants}>
|
|
218
|
+
{(variant) => (
|
|
219
|
+
<Button variant={variant} tabindex={-1}>
|
|
220
|
+
{variant === "destructive" ? "Delete" : "Save"}
|
|
221
|
+
</Button>
|
|
222
|
+
)}
|
|
223
|
+
</For>
|
|
224
|
+
<Button variant="outline" icon={icons.add} label={`Add on ${tone}`} tabindex={-1} />
|
|
225
|
+
<EdgeRatio tone={tone} />
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
228
|
+
</For>
|
|
229
|
+
</div>
|
|
230
|
+
<Caption>edge = the outline's ring (edge-strong) measured over each surface; it needs 3.</Caption>
|
|
231
|
+
</Section>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import { CodeBlock, Collapsible, StatusIcon } from "@tokamaq/ui";
|
|
3
|
+
import { Caption, Section } from "./frame.tsx";
|
|
4
|
+
|
|
5
|
+
const sample = `export function total(rows: Row[]) {
|
|
6
|
+
return rows.reduce((sum, row) => sum + row.cents, 0);
|
|
7
|
+
}`;
|
|
8
|
+
|
|
9
|
+
export function Disclosure(props: { theme: string }): JSX.Element {
|
|
10
|
+
return (
|
|
11
|
+
<Section label="Primitives · Collapsible, CodeBlock" title="Folded work and code">
|
|
12
|
+
<div class="flex flex-col items-start gap-2 surface-stage p-4">
|
|
13
|
+
<Collapsible.Root>
|
|
14
|
+
<Collapsible.Trigger
|
|
15
|
+
aria-label={`Worked, 4 actions, ${props.theme}`}
|
|
16
|
+
lead={<StatusIcon status="done" />}
|
|
17
|
+
trail="12s"
|
|
18
|
+
class="min-w-menu"
|
|
19
|
+
>
|
|
20
|
+
Worked <span class="text-label text-ink-3">4 actions</span>
|
|
21
|
+
</Collapsible.Trigger>
|
|
22
|
+
<Collapsible.Panel>
|
|
23
|
+
<p class="px-2 py-2 text-row text-ink-2">Read session.ts · Ran the auth tests</p>
|
|
24
|
+
</Collapsible.Panel>
|
|
25
|
+
</Collapsible.Root>
|
|
26
|
+
<Collapsible.Root>
|
|
27
|
+
<Collapsible.Trigger variant="quiet" lead={<StatusIcon status="running" />} trail="0:04">
|
|
28
|
+
<span class="font-medium text-ink">Checking your calendar</span>
|
|
29
|
+
</Collapsible.Trigger>
|
|
30
|
+
<Collapsible.Panel>
|
|
31
|
+
<p class="px-2 py-2 text-row text-ink-2">Opened the calendar</p>
|
|
32
|
+
</Collapsible.Panel>
|
|
33
|
+
</Collapsible.Root>
|
|
34
|
+
<CodeBlock code={sample} language="ts" class="w-full" />
|
|
35
|
+
</div>
|
|
36
|
+
<Caption>Collapsible: filled and quiet triggers. CodeBlock: language and a copy key.</Caption>
|
|
37
|
+
</Section>
|
|
38
|
+
);
|
|
39
|
+
}
|