@wtfalch/design 0.11.0 → 0.13.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/README.md +30 -0
- package/dist/components/RichText.d.ts +24 -0
- package/dist/components/RichText.js +69 -0
- package/dist/components/RichTextEditor.d.ts +32 -0
- package/dist/components/RichTextEditor.js +163 -0
- package/dist/components/Rows.d.ts +8 -1
- package/dist/components/Rows.js +3 -2
- package/dist/editor.d.ts +16 -0
- package/dist/editor.js +16 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/rich-text/schema.d.ts +219 -0
- package/dist/rich-text/schema.js +88 -0
- package/dist/rich-text/value.d.ts +25 -0
- package/dist/rich-text/value.js +41 -0
- package/dist/rich-text.d.ts +11 -0
- package/dist/rich-text.js +11 -0
- package/dist/styles/index.css +126 -6
- package/dist/tf.css +126 -6
- package/dist/valet.css +126 -6
- package/package.json +44 -4
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* What a rich-text value is, and the only shape `RichTextEditor` produces or
|
|
4
|
+
* `RichText` draws.
|
|
5
|
+
*
|
|
6
|
+
* **A restricted document, on purpose.** The editor is TipTap, which is
|
|
7
|
+
* ProseMirror, which will model tables, colours, fonts and arbitrary nesting
|
|
8
|
+
* given the chance. A system where every writer can reach all of that is one
|
|
9
|
+
* where two pages share nothing but a logo. What is left here is
|
|
10
|
+
* paragraphs, two heading levels, two kinds of list, bold, italic and links
|
|
11
|
+
* — the set a piece of prose actually needs.
|
|
12
|
+
*
|
|
13
|
+
* **The schema is the contract between three things**: what the toolbar can
|
|
14
|
+
* produce, what a consumer should store, and what the view can draw. A
|
|
15
|
+
* consumer validates with this on the way into its database, so a crafted
|
|
16
|
+
* request can no more insert a table than the editor can, and a node the
|
|
17
|
+
* view has no case for cannot arrive.
|
|
18
|
+
*
|
|
19
|
+
* Zod is an OPTIONAL peer dependency, and this file is the only one that
|
|
20
|
+
* reaches it — which is why it ships from `@wtfalch/design/rich-text` rather
|
|
21
|
+
* than the front door. A consumer that renders prose without validating it
|
|
22
|
+
* should not have to install a validator to load the package. The types and
|
|
23
|
+
* the pure helpers live in `./value`, which imports from here with `import
|
|
24
|
+
* type` and so compiles to nothing.
|
|
25
|
+
*/
|
|
26
|
+
/** The marks a run of text may carry. `link` is the only one with a value, and its href is checked. */
|
|
27
|
+
export const richTextMarkSchema = z.discriminatedUnion('type', [
|
|
28
|
+
z.object({ type: z.literal('bold') }),
|
|
29
|
+
z.object({ type: z.literal('italic') }),
|
|
30
|
+
z.object({
|
|
31
|
+
type: z.literal('link'),
|
|
32
|
+
attrs: z.object({
|
|
33
|
+
/**
|
|
34
|
+
* http(s), mailto, or a path. `javascript:` and `data:` are the two
|
|
35
|
+
* that turn a link into script, and they are refused here rather than
|
|
36
|
+
* only in the editor: the editor is a convenience, this is the gate.
|
|
37
|
+
*/
|
|
38
|
+
href: z
|
|
39
|
+
.string()
|
|
40
|
+
.trim()
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(2048)
|
|
43
|
+
.refine((href) => /^(https?:\/\/|mailto:|\/)/i.test(href), 'A link must be http(s), mailto: or a path beginning with /'),
|
|
44
|
+
target: z.string().nullish(),
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
const textNode = z.object({
|
|
49
|
+
type: z.literal('text'),
|
|
50
|
+
text: z.string().max(10_000),
|
|
51
|
+
marks: z.array(richTextMarkSchema).max(8).optional(),
|
|
52
|
+
});
|
|
53
|
+
const inline = z.array(textNode).max(500).optional();
|
|
54
|
+
const paragraph = z.object({ type: z.literal('paragraph'), content: inline });
|
|
55
|
+
const heading = z.object({
|
|
56
|
+
type: z.literal('heading'),
|
|
57
|
+
/**
|
|
58
|
+
* Two levels, and not level 1: the page's own `<h1>` is its title, and a
|
|
59
|
+
* second one in the body is the most common way a document stops being
|
|
60
|
+
* navigable to somebody reading it with a screen reader.
|
|
61
|
+
*/
|
|
62
|
+
attrs: z.object({ level: z.union([z.literal(2), z.literal(3)]) }),
|
|
63
|
+
content: inline,
|
|
64
|
+
});
|
|
65
|
+
const listItem = z.object({
|
|
66
|
+
type: z.literal('listItem'),
|
|
67
|
+
content: z.array(paragraph).max(20),
|
|
68
|
+
});
|
|
69
|
+
const bulletList = z.object({
|
|
70
|
+
type: z.literal('bulletList'),
|
|
71
|
+
content: z.array(listItem).max(200).optional(),
|
|
72
|
+
});
|
|
73
|
+
const orderedList = z.object({
|
|
74
|
+
type: z.literal('orderedList'),
|
|
75
|
+
attrs: z.object({ start: z.number().int().min(1).max(999) }).optional(),
|
|
76
|
+
content: z.array(listItem).max(200).optional(),
|
|
77
|
+
});
|
|
78
|
+
export const blockNodeSchema = z.discriminatedUnion('type', [
|
|
79
|
+
paragraph,
|
|
80
|
+
heading,
|
|
81
|
+
bulletList,
|
|
82
|
+
orderedList,
|
|
83
|
+
]);
|
|
84
|
+
/** A whole value: what TipTap calls the document. */
|
|
85
|
+
export const richTextSchema = z.object({
|
|
86
|
+
type: z.literal('doc'),
|
|
87
|
+
content: z.array(blockNodeSchema).max(400).optional(),
|
|
88
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RichTextValue } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* The parts of a rich-text value that need no validator.
|
|
4
|
+
*
|
|
5
|
+
* Split from `./schema` so the package's front door stays free of zod. The
|
|
6
|
+
* schema is a runtime object and zod is an optional peer dependency, so a
|
|
7
|
+
* consumer that renders prose and never validates it — a site, a preview —
|
|
8
|
+
* would otherwise fail to load the package at all for want of a dependency
|
|
9
|
+
* it has no use for. The type import above is erased at build, so nothing
|
|
10
|
+
* here reaches zod.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A document with nothing in it — and one empty paragraph, not an empty
|
|
14
|
+
* array. ProseMirror's schema says a document is `block+`, so a `doc` with
|
|
15
|
+
* no children is not a document it can put a cursor in: the editor rendered
|
|
16
|
+
* an empty box with no paragraph, which meant no node to mark as empty and
|
|
17
|
+
* so no placeholder. The picture of that is why this reads the way it does.
|
|
18
|
+
* `isEmptyRichText` treats both forms as empty, and the schema accepts both,
|
|
19
|
+
* because a value that arrives from somewhere else may be either.
|
|
20
|
+
*/
|
|
21
|
+
export declare const emptyRichText: RichTextValue;
|
|
22
|
+
/** Whether there is anything to draw, so a caller can skip an empty value rather than leave a gap. */
|
|
23
|
+
export declare function isEmptyRichText(value: RichTextValue): boolean;
|
|
24
|
+
/** The plain words, for a summary, a search index or a document's own `<title>`. */
|
|
25
|
+
export declare function richTextToPlain(value: RichTextValue): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of a rich-text value that need no validator.
|
|
3
|
+
*
|
|
4
|
+
* Split from `./schema` so the package's front door stays free of zod. The
|
|
5
|
+
* schema is a runtime object and zod is an optional peer dependency, so a
|
|
6
|
+
* consumer that renders prose and never validates it — a site, a preview —
|
|
7
|
+
* would otherwise fail to load the package at all for want of a dependency
|
|
8
|
+
* it has no use for. The type import above is erased at build, so nothing
|
|
9
|
+
* here reaches zod.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* A document with nothing in it — and one empty paragraph, not an empty
|
|
13
|
+
* array. ProseMirror's schema says a document is `block+`, so a `doc` with
|
|
14
|
+
* no children is not a document it can put a cursor in: the editor rendered
|
|
15
|
+
* an empty box with no paragraph, which meant no node to mark as empty and
|
|
16
|
+
* so no placeholder. The picture of that is why this reads the way it does.
|
|
17
|
+
* `isEmptyRichText` treats both forms as empty, and the schema accepts both,
|
|
18
|
+
* because a value that arrives from somewhere else may be either.
|
|
19
|
+
*/
|
|
20
|
+
export const emptyRichText = { type: 'doc', content: [{ type: 'paragraph' }] };
|
|
21
|
+
/** Whether there is anything to draw, so a caller can skip an empty value rather than leave a gap. */
|
|
22
|
+
export function isEmptyRichText(value) {
|
|
23
|
+
return (value.content ?? []).every((node) => !('content' in node) || (node.content ?? []).length === 0);
|
|
24
|
+
}
|
|
25
|
+
/** The plain words, for a summary, a search index or a document's own `<title>`. */
|
|
26
|
+
export function richTextToPlain(value) {
|
|
27
|
+
const parts = [];
|
|
28
|
+
const walk = (nodes) => {
|
|
29
|
+
for (const node of nodes) {
|
|
30
|
+
if (!node || typeof node !== 'object')
|
|
31
|
+
continue;
|
|
32
|
+
const record = node;
|
|
33
|
+
if (typeof record.text === 'string')
|
|
34
|
+
parts.push(record.text);
|
|
35
|
+
if (Array.isArray(record.content))
|
|
36
|
+
walk(record.content);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
walk(value.content ?? []);
|
|
40
|
+
return parts.join(' ').replace(/\s+/g, ' ').trim();
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rich-text schema: `@wtfalch/design/rich-text`.
|
|
3
|
+
*
|
|
4
|
+
* What a consumer validates with on the way into its database, so that a
|
|
5
|
+
* crafted request can no more store a table than the toolbar can produce
|
|
6
|
+
* one. Separate from the front door because it is the only part of the
|
|
7
|
+
* package that needs zod, and separate from `./editor` because validating a
|
|
8
|
+
* value is a thing a server does and downloading an editor is not.
|
|
9
|
+
*/
|
|
10
|
+
export { type BlockNode, type RichTextMark, type RichTextValue, blockNodeSchema, richTextMarkSchema, richTextSchema, } from './rich-text/schema.js';
|
|
11
|
+
export { emptyRichText, isEmptyRichText, richTextToPlain } from './rich-text/value.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rich-text schema: `@wtfalch/design/rich-text`.
|
|
3
|
+
*
|
|
4
|
+
* What a consumer validates with on the way into its database, so that a
|
|
5
|
+
* crafted request can no more store a table than the toolbar can produce
|
|
6
|
+
* one. Separate from the front door because it is the only part of the
|
|
7
|
+
* package that needs zod, and separate from `./editor` because validating a
|
|
8
|
+
* value is a thing a server does and downloading an editor is not.
|
|
9
|
+
*/
|
|
10
|
+
export { blockNodeSchema, richTextMarkSchema, richTextSchema, } from './rich-text/schema.js';
|
|
11
|
+
export { emptyRichText, isEmptyRichText, richTextToPlain } from './rich-text/value.js';
|
package/dist/styles/index.css
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
--text-2xs: var(--text-2xs);
|
|
38
38
|
--text-md: var(--text-md);
|
|
39
39
|
--font-weight-strong: var(--weight-strong);
|
|
40
|
+
--radius-DEFAULT: var(--radius);
|
|
40
41
|
--radius-pill: var(--radius-pill);
|
|
41
42
|
--color-text: var(--text);
|
|
42
43
|
--color-muted: var(--muted);
|
|
@@ -173,6 +174,9 @@
|
|
|
173
174
|
.min-h-0 {
|
|
174
175
|
min-height: 0px;
|
|
175
176
|
}
|
|
177
|
+
.min-h-\[calc\(var\(--space-15\)\*2\)\] {
|
|
178
|
+
min-height: calc(var(--space-15) * 2);
|
|
179
|
+
}
|
|
176
180
|
.min-h-screen {
|
|
177
181
|
min-height: 100vh;
|
|
178
182
|
}
|
|
@@ -313,6 +317,9 @@
|
|
|
313
317
|
.rounded {
|
|
314
318
|
border-radius: 0.25rem;
|
|
315
319
|
}
|
|
320
|
+
.rounded-\(--radius\) {
|
|
321
|
+
border-radius: var(--radius);
|
|
322
|
+
}
|
|
316
323
|
.rounded-full {
|
|
317
324
|
border-radius: calc(infinity * 1px);
|
|
318
325
|
}
|
|
@@ -462,6 +469,9 @@
|
|
|
462
469
|
.uppercase {
|
|
463
470
|
text-transform: uppercase;
|
|
464
471
|
}
|
|
472
|
+
.italic {
|
|
473
|
+
font-style: italic;
|
|
474
|
+
}
|
|
465
475
|
.tabular-nums {
|
|
466
476
|
--tw-numeric-spacing: tabular-nums;
|
|
467
477
|
font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);
|
|
@@ -508,9 +518,16 @@
|
|
|
508
518
|
.surface-bg {
|
|
509
519
|
background: var(--bg);
|
|
510
520
|
}
|
|
521
|
+
.surface-control {
|
|
522
|
+
background: var(--control);
|
|
523
|
+
}
|
|
511
524
|
.surface-panel {
|
|
512
525
|
background: var(--panel);
|
|
513
526
|
}
|
|
527
|
+
.focus-within\:shadow-\(--focus-ring\):focus-within {
|
|
528
|
+
--tw-shadow: var(--focus-ring);
|
|
529
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
530
|
+
}
|
|
514
531
|
.disabled\:cursor-default:disabled {
|
|
515
532
|
cursor: default;
|
|
516
533
|
}
|
|
@@ -2540,8 +2557,10 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2540
2557
|
}
|
|
2541
2558
|
|
|
2542
2559
|
/* Only where there is something to pick. A row without `row-hit` is not a
|
|
2543
|
-
choice, and lighting it up on hover promises something that does not happen.
|
|
2544
|
-
|
|
2560
|
+
choice, and lighting it up on hover promises something that does not happen.
|
|
2561
|
+
Nor is a row whose hit is disabled: a waiting row lit up under its own
|
|
2562
|
+
`not-allowed` cursor, and `disabled` would have made that permanent. */
|
|
2563
|
+
.rows-pick > .rows-row:has(.row-hit:enabled):hover {
|
|
2545
2564
|
border-color: var(--accent);
|
|
2546
2565
|
background: var(--panel-2);
|
|
2547
2566
|
}
|
|
@@ -2593,9 +2612,16 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2593
2612
|
/* And nothing else can be chosen while it happens: picking a second model
|
|
2594
2613
|
mid-load queues a second load, which is how a machine ends up swapping two
|
|
2595
2614
|
sets of weights it cannot hold at once. */
|
|
2596
|
-
.rows-pick > .rows-row.is-waiting
|
|
2615
|
+
.rows-pick > .rows-row.is-waiting,
|
|
2616
|
+
.rows-pick > .rows-row.is-disabled { opacity: 0.5; }
|
|
2597
2617
|
|
|
2598
|
-
.rows-pick > .rows-row.is-waiting .row-hit
|
|
2618
|
+
.rows-pick > .rows-row.is-waiting .row-hit,
|
|
2619
|
+
.rows-pick > .rows-row.is-disabled .row-hit { cursor: not-allowed; }
|
|
2620
|
+
|
|
2621
|
+
/* Dimmed once. `.row-hit:disabled` dims the button as well, and under the
|
|
2622
|
+
row's own opacity the hint of a disabled row, the line saying why it cannot
|
|
2623
|
+
be chosen, came out at a quarter strength. */
|
|
2624
|
+
.rows-pick > .rows-row.is-disabled > .row-hit:disabled { opacity: 1; }
|
|
2599
2625
|
|
|
2600
2626
|
@media (prefers-reduced-motion: reduce) {
|
|
2601
2627
|
/* The border still says which one, without the breathing. */
|
|
@@ -2647,7 +2673,7 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2647
2673
|
margin-bottom: calc(var(--space-2) * -1);
|
|
2648
2674
|
}
|
|
2649
2675
|
|
|
2650
|
-
.rows-pick > .rows-row.is-picked:has(.row-hit):hover {
|
|
2676
|
+
.rows-pick > .rows-row.is-picked:has(.row-hit:enabled):hover {
|
|
2651
2677
|
background: color-mix(in srgb, var(--accent) 13%, var(--panel));
|
|
2652
2678
|
}
|
|
2653
2679
|
|
|
@@ -2706,7 +2732,7 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2706
2732
|
border-radius: var(--radius-sm);
|
|
2707
2733
|
}
|
|
2708
2734
|
|
|
2709
|
-
.row-hit:hover .truncate { color: var(--accent); }
|
|
2735
|
+
.row-hit:enabled:hover .truncate { color: var(--accent); }
|
|
2710
2736
|
|
|
2711
2737
|
.row-hit:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
|
2712
2738
|
}
|
|
@@ -4692,3 +4718,97 @@ body.splitting * { cursor: inherit !important; }
|
|
|
4692
4718
|
.ident-remove:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
|
4693
4719
|
}
|
|
4694
4720
|
|
|
4721
|
+
/* Prose and the surface it is written on, added in 0.8.0. Last, because
|
|
4722
|
+
`.prose` styles the elements the reset in `base.css` flattened and has to
|
|
4723
|
+
win over it, and because the editor's box sits over nothing. */
|
|
4724
|
+
/* ---- ./richtext.css ---- */
|
|
4725
|
+
@layer components {
|
|
4726
|
+
/* Prose: one class, and the elements it styles are ones nobody wrote.
|
|
4727
|
+
*
|
|
4728
|
+
* That is the whole reason a class exists here rather than utilities. Inside
|
|
4729
|
+
* the editor the paragraphs, headings and lists are ProseMirror's, built
|
|
4730
|
+
* from the document — there is no JSX to hang a utility on, so the choice is
|
|
4731
|
+
* descendant rules behind one class or an arbitrary variant per element,
|
|
4732
|
+
* which is the same selector spelled worse. `Markdown` has the same problem
|
|
4733
|
+
* for the same reason and answers it the same way, as `.md` in `base.css`.
|
|
4734
|
+
*
|
|
4735
|
+
* The editor and the view share the class on purpose. They have to look
|
|
4736
|
+
* identical and one set of rules is what guarantees it; two sets maintained
|
|
4737
|
+
* separately is precisely how a what-you-see-is-what-you-get editor stops
|
|
4738
|
+
* being one. Everything the components *do* render — the box, the toolbar,
|
|
4739
|
+
* the writing surface's own padding and focus ring — is utilities in the
|
|
4740
|
+
* component, where it belongs.
|
|
4741
|
+
*
|
|
4742
|
+
* `.rich-text` and not `.prose`: this package's classes ship unprefixed into
|
|
4743
|
+
* other people's stylesheets, and `.prose` is the one name in CSS most
|
|
4744
|
+
* likely to already be taken — Tailwind's typography plugin defines exactly
|
|
4745
|
+
* it. A consumer with that plugin and this package would have had two sets
|
|
4746
|
+
* of margins fighting, and it would have read as a theming bug.
|
|
4747
|
+
*
|
|
4748
|
+
* Every value here is a token. The vertical rhythm is `--space-*`, four
|
|
4749
|
+
* pixels a step and scaling with `--density`; the type steps are `--text-*`,
|
|
4750
|
+
* scaling with `--font-size`. A heading two sizes apart from its body at one
|
|
4751
|
+
* density is two sizes apart at every density.
|
|
4752
|
+
*/
|
|
4753
|
+
|
|
4754
|
+
.rich-text > * {
|
|
4755
|
+
margin: 0;
|
|
4756
|
+
}
|
|
4757
|
+
|
|
4758
|
+
.rich-text > * + * {
|
|
4759
|
+
margin-top: var(--space-3);
|
|
4760
|
+
}
|
|
4761
|
+
|
|
4762
|
+
.rich-text h2 {
|
|
4763
|
+
font-size: var(--text-lg);
|
|
4764
|
+
font-weight: var(--weight-strong);
|
|
4765
|
+
letter-spacing: -0.01em;
|
|
4766
|
+
}
|
|
4767
|
+
|
|
4768
|
+
.rich-text h3 {
|
|
4769
|
+
font-size: var(--text-md);
|
|
4770
|
+
font-weight: var(--weight-strong);
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
/* A heading after prose needs more room above it than below: the space
|
|
4774
|
+
belongs to the section it opens, not to the paragraph it follows. */
|
|
4775
|
+
.rich-text > * + :is(h2, h3) {
|
|
4776
|
+
margin-top: var(--space-6);
|
|
4777
|
+
}
|
|
4778
|
+
|
|
4779
|
+
.rich-text :is(ul, ol) {
|
|
4780
|
+
padding-left: var(--space-5);
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4783
|
+
.rich-text li + li {
|
|
4784
|
+
margin-top: var(--space-1);
|
|
4785
|
+
}
|
|
4786
|
+
|
|
4787
|
+
.rich-text a {
|
|
4788
|
+
color: var(--accent);
|
|
4789
|
+
text-decoration: underline;
|
|
4790
|
+
text-underline-offset: 2px;
|
|
4791
|
+
}
|
|
4792
|
+
|
|
4793
|
+
.rich-text strong {
|
|
4794
|
+
font-weight: var(--weight-strong);
|
|
4795
|
+
}
|
|
4796
|
+
|
|
4797
|
+
/* An empty editor says what goes in it. The placeholder extension puts the
|
|
4798
|
+
words on the empty node as `data-placeholder` and marks it, so `attr()` is
|
|
4799
|
+
reading an attribute of the element it is drawn on — which is the part a
|
|
4800
|
+
hand-rolled rule got wrong twice: a rule on the paragraph cannot reach an
|
|
4801
|
+
attribute on the box, and ProseMirror's empty paragraph holds a trailing
|
|
4802
|
+
`<br>` so `:empty` never matches it either. `pointer-events: none` so a
|
|
4803
|
+
click on the words still lands in the text.
|
|
4804
|
+
|
|
4805
|
+
Harmless on the view, which never produces the class. */
|
|
4806
|
+
.rich-text p.is-editor-empty:first-child::before {
|
|
4807
|
+
content: attr(data-placeholder);
|
|
4808
|
+
float: left;
|
|
4809
|
+
height: 0;
|
|
4810
|
+
color: var(--muted);
|
|
4811
|
+
pointer-events: none;
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
|
package/dist/tf.css
CHANGED
|
@@ -307,6 +307,7 @@
|
|
|
307
307
|
--text-2xs: var(--text-2xs);
|
|
308
308
|
--text-md: var(--text-md);
|
|
309
309
|
--font-weight-strong: var(--weight-strong);
|
|
310
|
+
--radius-DEFAULT: var(--radius);
|
|
310
311
|
--radius-pill: var(--radius-pill);
|
|
311
312
|
--color-text: var(--text);
|
|
312
313
|
--color-muted: var(--muted);
|
|
@@ -443,6 +444,9 @@
|
|
|
443
444
|
.min-h-0 {
|
|
444
445
|
min-height: 0px;
|
|
445
446
|
}
|
|
447
|
+
.min-h-\[calc\(var\(--space-15\)\*2\)\] {
|
|
448
|
+
min-height: calc(var(--space-15) * 2);
|
|
449
|
+
}
|
|
446
450
|
.min-h-screen {
|
|
447
451
|
min-height: 100vh;
|
|
448
452
|
}
|
|
@@ -583,6 +587,9 @@
|
|
|
583
587
|
.rounded {
|
|
584
588
|
border-radius: 0.25rem;
|
|
585
589
|
}
|
|
590
|
+
.rounded-\(--radius\) {
|
|
591
|
+
border-radius: var(--radius);
|
|
592
|
+
}
|
|
586
593
|
.rounded-full {
|
|
587
594
|
border-radius: calc(infinity * 1px);
|
|
588
595
|
}
|
|
@@ -732,6 +739,9 @@
|
|
|
732
739
|
.uppercase {
|
|
733
740
|
text-transform: uppercase;
|
|
734
741
|
}
|
|
742
|
+
.italic {
|
|
743
|
+
font-style: italic;
|
|
744
|
+
}
|
|
735
745
|
.tabular-nums {
|
|
736
746
|
--tw-numeric-spacing: tabular-nums;
|
|
737
747
|
font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);
|
|
@@ -778,9 +788,16 @@
|
|
|
778
788
|
.surface-bg {
|
|
779
789
|
background: var(--bg);
|
|
780
790
|
}
|
|
791
|
+
.surface-control {
|
|
792
|
+
background: var(--control);
|
|
793
|
+
}
|
|
781
794
|
.surface-panel {
|
|
782
795
|
background: var(--panel);
|
|
783
796
|
}
|
|
797
|
+
.focus-within\:shadow-\(--focus-ring\):focus-within {
|
|
798
|
+
--tw-shadow: var(--focus-ring);
|
|
799
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
800
|
+
}
|
|
784
801
|
.disabled\:cursor-default:disabled {
|
|
785
802
|
cursor: default;
|
|
786
803
|
}
|
|
@@ -2810,8 +2827,10 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2810
2827
|
}
|
|
2811
2828
|
|
|
2812
2829
|
/* Only where there is something to pick. A row without `row-hit` is not a
|
|
2813
|
-
choice, and lighting it up on hover promises something that does not happen.
|
|
2814
|
-
|
|
2830
|
+
choice, and lighting it up on hover promises something that does not happen.
|
|
2831
|
+
Nor is a row whose hit is disabled: a waiting row lit up under its own
|
|
2832
|
+
`not-allowed` cursor, and `disabled` would have made that permanent. */
|
|
2833
|
+
.rows-pick > .rows-row:has(.row-hit:enabled):hover {
|
|
2815
2834
|
border-color: var(--accent);
|
|
2816
2835
|
background: var(--panel-2);
|
|
2817
2836
|
}
|
|
@@ -2863,9 +2882,16 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2863
2882
|
/* And nothing else can be chosen while it happens: picking a second model
|
|
2864
2883
|
mid-load queues a second load, which is how a machine ends up swapping two
|
|
2865
2884
|
sets of weights it cannot hold at once. */
|
|
2866
|
-
.rows-pick > .rows-row.is-waiting
|
|
2885
|
+
.rows-pick > .rows-row.is-waiting,
|
|
2886
|
+
.rows-pick > .rows-row.is-disabled { opacity: 0.5; }
|
|
2867
2887
|
|
|
2868
|
-
.rows-pick > .rows-row.is-waiting .row-hit
|
|
2888
|
+
.rows-pick > .rows-row.is-waiting .row-hit,
|
|
2889
|
+
.rows-pick > .rows-row.is-disabled .row-hit { cursor: not-allowed; }
|
|
2890
|
+
|
|
2891
|
+
/* Dimmed once. `.row-hit:disabled` dims the button as well, and under the
|
|
2892
|
+
row's own opacity the hint of a disabled row, the line saying why it cannot
|
|
2893
|
+
be chosen, came out at a quarter strength. */
|
|
2894
|
+
.rows-pick > .rows-row.is-disabled > .row-hit:disabled { opacity: 1; }
|
|
2869
2895
|
|
|
2870
2896
|
@media (prefers-reduced-motion: reduce) {
|
|
2871
2897
|
/* The border still says which one, without the breathing. */
|
|
@@ -2917,7 +2943,7 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2917
2943
|
margin-bottom: calc(var(--space-2) * -1);
|
|
2918
2944
|
}
|
|
2919
2945
|
|
|
2920
|
-
.rows-pick > .rows-row.is-picked:has(.row-hit):hover {
|
|
2946
|
+
.rows-pick > .rows-row.is-picked:has(.row-hit:enabled):hover {
|
|
2921
2947
|
background: color-mix(in srgb, var(--accent) 13%, var(--panel));
|
|
2922
2948
|
}
|
|
2923
2949
|
|
|
@@ -2976,7 +3002,7 @@ input[type='radio']:active:not(:disabled) {
|
|
|
2976
3002
|
border-radius: var(--radius-sm);
|
|
2977
3003
|
}
|
|
2978
3004
|
|
|
2979
|
-
.row-hit:hover .truncate { color: var(--accent); }
|
|
3005
|
+
.row-hit:enabled:hover .truncate { color: var(--accent); }
|
|
2980
3006
|
|
|
2981
3007
|
.row-hit:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
|
2982
3008
|
}
|
|
@@ -4961,6 +4987,100 @@ body.splitting * { cursor: inherit !important; }
|
|
|
4961
4987
|
.ident-remove:hover { background: var(--panel); color: var(--text); }
|
|
4962
4988
|
.ident-remove:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
|
4963
4989
|
}
|
|
4990
|
+
|
|
4991
|
+
/* Prose and the surface it is written on, added in 0.8.0. Last, because
|
|
4992
|
+
`.prose` styles the elements the reset in `base.css` flattened and has to
|
|
4993
|
+
win over it, and because the editor's box sits over nothing. */
|
|
4994
|
+
/* ---- ./richtext.css ---- */
|
|
4995
|
+
@layer components {
|
|
4996
|
+
/* Prose: one class, and the elements it styles are ones nobody wrote.
|
|
4997
|
+
*
|
|
4998
|
+
* That is the whole reason a class exists here rather than utilities. Inside
|
|
4999
|
+
* the editor the paragraphs, headings and lists are ProseMirror's, built
|
|
5000
|
+
* from the document — there is no JSX to hang a utility on, so the choice is
|
|
5001
|
+
* descendant rules behind one class or an arbitrary variant per element,
|
|
5002
|
+
* which is the same selector spelled worse. `Markdown` has the same problem
|
|
5003
|
+
* for the same reason and answers it the same way, as `.md` in `base.css`.
|
|
5004
|
+
*
|
|
5005
|
+
* The editor and the view share the class on purpose. They have to look
|
|
5006
|
+
* identical and one set of rules is what guarantees it; two sets maintained
|
|
5007
|
+
* separately is precisely how a what-you-see-is-what-you-get editor stops
|
|
5008
|
+
* being one. Everything the components *do* render — the box, the toolbar,
|
|
5009
|
+
* the writing surface's own padding and focus ring — is utilities in the
|
|
5010
|
+
* component, where it belongs.
|
|
5011
|
+
*
|
|
5012
|
+
* `.rich-text` and not `.prose`: this package's classes ship unprefixed into
|
|
5013
|
+
* other people's stylesheets, and `.prose` is the one name in CSS most
|
|
5014
|
+
* likely to already be taken — Tailwind's typography plugin defines exactly
|
|
5015
|
+
* it. A consumer with that plugin and this package would have had two sets
|
|
5016
|
+
* of margins fighting, and it would have read as a theming bug.
|
|
5017
|
+
*
|
|
5018
|
+
* Every value here is a token. The vertical rhythm is `--space-*`, four
|
|
5019
|
+
* pixels a step and scaling with `--density`; the type steps are `--text-*`,
|
|
5020
|
+
* scaling with `--font-size`. A heading two sizes apart from its body at one
|
|
5021
|
+
* density is two sizes apart at every density.
|
|
5022
|
+
*/
|
|
5023
|
+
|
|
5024
|
+
.rich-text > * {
|
|
5025
|
+
margin: 0;
|
|
5026
|
+
}
|
|
5027
|
+
|
|
5028
|
+
.rich-text > * + * {
|
|
5029
|
+
margin-top: var(--space-3);
|
|
5030
|
+
}
|
|
5031
|
+
|
|
5032
|
+
.rich-text h2 {
|
|
5033
|
+
font-size: var(--text-lg);
|
|
5034
|
+
font-weight: var(--weight-strong);
|
|
5035
|
+
letter-spacing: -0.01em;
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
.rich-text h3 {
|
|
5039
|
+
font-size: var(--text-md);
|
|
5040
|
+
font-weight: var(--weight-strong);
|
|
5041
|
+
}
|
|
5042
|
+
|
|
5043
|
+
/* A heading after prose needs more room above it than below: the space
|
|
5044
|
+
belongs to the section it opens, not to the paragraph it follows. */
|
|
5045
|
+
.rich-text > * + :is(h2, h3) {
|
|
5046
|
+
margin-top: var(--space-6);
|
|
5047
|
+
}
|
|
5048
|
+
|
|
5049
|
+
.rich-text :is(ul, ol) {
|
|
5050
|
+
padding-left: var(--space-5);
|
|
5051
|
+
}
|
|
5052
|
+
|
|
5053
|
+
.rich-text li + li {
|
|
5054
|
+
margin-top: var(--space-1);
|
|
5055
|
+
}
|
|
5056
|
+
|
|
5057
|
+
.rich-text a {
|
|
5058
|
+
color: var(--accent);
|
|
5059
|
+
text-decoration: underline;
|
|
5060
|
+
text-underline-offset: 2px;
|
|
5061
|
+
}
|
|
5062
|
+
|
|
5063
|
+
.rich-text strong {
|
|
5064
|
+
font-weight: var(--weight-strong);
|
|
5065
|
+
}
|
|
5066
|
+
|
|
5067
|
+
/* An empty editor says what goes in it. The placeholder extension puts the
|
|
5068
|
+
words on the empty node as `data-placeholder` and marks it, so `attr()` is
|
|
5069
|
+
reading an attribute of the element it is drawn on — which is the part a
|
|
5070
|
+
hand-rolled rule got wrong twice: a rule on the paragraph cannot reach an
|
|
5071
|
+
attribute on the box, and ProseMirror's empty paragraph holds a trailing
|
|
5072
|
+
`<br>` so `:empty` never matches it either. `pointer-events: none` so a
|
|
5073
|
+
click on the words still lands in the text.
|
|
5074
|
+
|
|
5075
|
+
Harmless on the view, which never produces the class. */
|
|
5076
|
+
.rich-text p.is-editor-empty:first-child::before {
|
|
5077
|
+
content: attr(data-placeholder);
|
|
5078
|
+
float: left;
|
|
5079
|
+
height: 0;
|
|
5080
|
+
color: var(--muted);
|
|
5081
|
+
pointer-events: none;
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
4964
5084
|
/* ---- tf: the themes ---- */
|
|
4965
5085
|
:root[data-theme='night']{--bg:#0f1115;--panel:#161a21;--panel-2:#1c222b;--border:#262d38;--text:#e6e9ef;--muted:#8b94a4;--accent:#5b9dff;--accent-dim:#2a4877;--app-bg:#0f1115;color-scheme:dark}
|
|
4966
5086
|
:root[data-theme='paper']{--bg:#f6f7f9;--panel:#ffffff;--panel-2:#f0f2f5;--border:#e4e8ec;--border-strong:#8792a1;--text:#191d23;--muted:#5d6773;--accent:#0e7872;--accent-dim:#7fbdb8;--on-accent:#ffffff;--good:#1c7a4a;--warn:#8a6216;--bad:#b3312c;--info:#216bc9;--shadow-1:0 4px 14px rgba(16, 24, 40, 0.08);--shadow-2:0 8px 24px rgba(16, 24, 40, 0.10);--shadow-3:0 12px 32px rgba(16, 24, 40, 0.12);--scrim:rgba(16, 24, 40, 0.32);color-scheme:light}
|