devnonla-ui 0.19.1 → 0.19.2
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/package.json
CHANGED
package/src/lib/markdownScale.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { CSSProperties } from "react";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* One markdown scale. Body reads
|
|
4
|
+
* One markdown scale. Body reads `--nonla-base-text-size` (`text-base`). Leading is 1.6.
|
|
5
5
|
* Tables always use `text-base`.
|
|
6
|
-
*
|
|
6
|
+
* Fenced code reads `--nonla-mono-text-size`, which is `text-sm`.
|
|
7
|
+
* Inline code is `0.875em` of the surrounding text, so the chip stays inside the line.
|
|
7
8
|
* Class fallbacks match these values when the variables are not set.
|
|
8
9
|
*/
|
|
9
10
|
export const markdownScaleStyle = {
|
|
10
|
-
"--md-body-size": "var(--nonla-
|
|
11
|
-
"--md-body-leading": "calc(var(--nonla-
|
|
11
|
+
"--md-body-size": "var(--nonla-base-text-size)",
|
|
12
|
+
"--md-body-leading": "calc(var(--nonla-base-text-size) * 1.6)",
|
|
12
13
|
"--md-h1-size": "32px",
|
|
13
14
|
"--md-h1-leading": "1.25",
|
|
14
15
|
"--md-h1-weight": "800",
|
|
@@ -56,7 +57,7 @@ export const markdownScaleStyle = {
|
|
|
56
57
|
"--md-code-my": "8px",
|
|
57
58
|
"--md-code-size": "var(--nonla-mono-text-size)",
|
|
58
59
|
"--md-code-leading": "calc(var(--nonla-mono-text-size) * 1.6)",
|
|
59
|
-
"--md-inline-size": "
|
|
60
|
+
"--md-inline-size": "0.875em",
|
|
60
61
|
"--md-item-pl": "4px",
|
|
61
62
|
"--md-nest": "1.25rem",
|
|
62
63
|
} as CSSProperties;
|
|
@@ -77,7 +78,15 @@ export function headingClass(level: number): string {
|
|
|
77
78
|
export const pageTitleClass = "text-foreground mt-(--md-h1-mt,0px) mb-(--md-h1-mb,1px) pt-(--md-h1-py,3px) pb-(--md-h1-py,3px) text-(length:--md-h1-size,32px) leading-(--md-h1-leading,1.25) font-(--md-h1-weight,800) tracking-tight";
|
|
78
79
|
|
|
79
80
|
/** Body line. Same size and color as a markdown paragraph. */
|
|
80
|
-
export const markdownBodyClass = "text-(length:--md-body-size,var(--nonla-
|
|
81
|
+
export const markdownBodyClass = "text-(length:--md-body-size,var(--nonla-base-text-size,15px)) leading-(--md-body-leading,calc(var(--nonla-base-text-size,15px)*1.6)) text-foreground";
|
|
81
82
|
|
|
82
83
|
/** Paragraph box. Same rhythm as `MarkdownViewer` `p`. */
|
|
83
|
-
export const markdownParagraphClass = "nonla-typo m-0 my-(--md-p-my,1px) py-(--md-p-py,4px) text-(length:--md-body-size,var(--nonla-
|
|
84
|
+
export const markdownParagraphClass = "nonla-typo m-0 my-(--md-p-my,1px) py-(--md-p-py,4px) text-(length:--md-body-size,var(--nonla-base-text-size,15px)) leading-(--md-p-leading,1.6) text-foreground";
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Inline code. Smaller than the line, normal weight, with a light wash.
|
|
88
|
+
* The wash is ink on whatever sits behind, so it stays visible on the page and on a card.
|
|
89
|
+
* A token stays whole; the line breaks before it.
|
|
90
|
+
*/
|
|
91
|
+
export const markdownInlineCodeClass =
|
|
92
|
+
"nonla-inline-code rounded-[4px] bg-[color-mix(in_oklab,var(--nonla-text-main)_6%,transparent)] px-[0.25em] py-px align-baseline font-mono text-(length:--md-inline-size,0.875em) leading-none whitespace-nowrap";
|
|
@@ -4,7 +4,7 @@ import remarkGfm from "remark-gfm";
|
|
|
4
4
|
import { Checkbox } from "../checkbox/Checkbox";
|
|
5
5
|
import { CodeBlock } from "../codeblock/CodeBlock";
|
|
6
6
|
import { cn } from "../lib/cn";
|
|
7
|
-
import { headingClass, markdownScaleStyle } from "../lib/markdownScale";
|
|
7
|
+
import { headingClass, markdownInlineCodeClass, markdownScaleStyle } from "../lib/markdownScale";
|
|
8
8
|
import { type InlineEdit, type MarkdownBlock, parseMarkdownDoc, readFence, readInlineEdit } from "./blocks";
|
|
9
9
|
import { MarkdownTable } from "./MarkdownTable";
|
|
10
10
|
import { MermaidBlock } from "./MermaidBlock";
|
|
@@ -18,7 +18,7 @@ const taskCheckClass =
|
|
|
18
18
|
"data-[state=checked]:border-foreground! data-[state=checked]:bg-foreground! data-[state=checked]:text-background! data-[state=indeterminate]:border-foreground! data-[state=indeterminate]:bg-foreground! data-[state=indeterminate]:text-background!";
|
|
19
19
|
|
|
20
20
|
const documentClass = cn(
|
|
21
|
-
"min-w-0 wrap-anywhere text-(length:--md-body-size,var(--nonla-
|
|
21
|
+
"min-w-0 wrap-anywhere text-(length:--md-body-size,var(--nonla-base-text-size,15px)) leading-(--md-body-leading,calc(var(--nonla-base-text-size,15px)*1.6)) text-foreground",
|
|
22
22
|
"[&_:is(h1,h2,h3,h4,h5,h6)]:text-foreground",
|
|
23
23
|
"[&_:is(h1,h2)]:mt-(--md-h2-mt,24px) [&_h1]:mb-(--md-h1-mb,12px) [&_h2]:mb-(--md-h2-mb,8px) [&_:is(h1,h2)]:pt-(--md-h2-py,3px) [&_:is(h1,h2)]:pb-(--md-h2-py,3px) [&_:is(h1,h2)]:text-(length:--md-h2-size,26px) [&_:is(h1,h2)]:leading-(--md-h2-leading,32px) [&_:is(h1,h2)]:font-(--md-h2-weight,600) [&_:is(h1,h2)]:tracking-normal",
|
|
24
24
|
"[&_h3]:mt-(--md-h3-mt,22px) [&_h3]:mb-(--md-h3-mb,8px) [&_h3]:text-(length:--md-h3-size,24px) [&_h3]:leading-(--md-h3-leading,32px) [&_h3]:font-(--md-h3-weight,600)",
|
|
@@ -47,7 +47,7 @@ const previewComponents: Components = {
|
|
|
47
47
|
const codeText = String(children).replace(/\n$/, "");
|
|
48
48
|
const isBlock = codeText.includes("\n") || !!match;
|
|
49
49
|
if (!isBlock) {
|
|
50
|
-
return <code className=
|
|
50
|
+
return <code className={markdownInlineCodeClass}>{children}</code>;
|
|
51
51
|
}
|
|
52
52
|
if (lang.toLowerCase() === "mermaid") return <MermaidView code={codeText} />;
|
|
53
53
|
return <CodeBlock code={codeText} language={lang || undefined} className="my-(--md-code-my,8px)" />;
|
|
@@ -65,7 +65,7 @@ const previewComponents: Components = {
|
|
|
65
65
|
input({ type, checked }) {
|
|
66
66
|
if (type !== "checkbox") return <input type={type} checked={checked} readOnly />;
|
|
67
67
|
return (
|
|
68
|
-
<span className="nonla-md-task-check pointer-events-none inline-flex h-(--md-body-leading,calc(var(--nonla-
|
|
68
|
+
<span className="nonla-md-task-check pointer-events-none inline-flex h-(--md-body-leading,calc(var(--nonla-base-text-size,15px)*1.6)) items-center">
|
|
69
69
|
<Checkbox checked={Boolean(checked)} tabIndex={-1} className={taskCheckClass} />
|
|
70
70
|
</span>
|
|
71
71
|
);
|
|
@@ -133,16 +133,16 @@ export function RichText({ source }: { source: string }) {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
* List body
|
|
137
|
-
*
|
|
136
|
+
* List body keeps paragraph leading so wrapped lines stay readable.
|
|
137
|
+
* View and edit share the same rhythm so the block does not jump.
|
|
138
138
|
*/
|
|
139
139
|
const listBodyClass =
|
|
140
|
-
"[&_p]:my-0! [&_p]:
|
|
140
|
+
"[&_p]:my-0! [&_p]:py-0.5! [&_p]:leading-(--md-p-leading,1.6)! [&_textarea]:my-0! [&_textarea]:py-0.5! [&_textarea]:leading-(--md-p-leading,1.6)!";
|
|
141
141
|
|
|
142
142
|
export function ListItem({ view, children }: { view: Extract<InlineEdit, { kind: "list" }>; children: ReactNode }) {
|
|
143
143
|
const level = Math.floor(view.indent.length / 2);
|
|
144
144
|
const ordinal = Number(/^(\d+)/.exec(view.marker)?.[1] ?? "1");
|
|
145
|
-
const marker = "w-6 shrink-0 pt-0.5 text-(length:--md-body-size,var(--nonla-
|
|
145
|
+
const marker = "w-6 shrink-0 pt-0.5 text-(length:--md-body-size,var(--nonla-base-text-size,15px)) leading-(--md-p-leading,1.6)";
|
|
146
146
|
return (
|
|
147
147
|
<div data-md-list="" className="flex items-start gap-1.5 pl-(--md-item-pl,4px)" style={level > 0 ? { marginLeft: `calc(${level} * var(--md-nest, 1.25rem))` } : undefined}>
|
|
148
148
|
{view.task ? (
|
package/src/styles.css
CHANGED
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
|
|
44
44
|
--nonla-font: "Inter Variable", ui-sans-serif, -apple-system, system-ui, "Segoe UI Variable Display", "Segoe UI", Helvetica, "Apple Color Emoji", "Noto Sans Arabic", "Noto Sans Hebrew", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
|
|
45
45
|
--nonla-mono-font: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
|
|
46
|
-
/* Default body size. Tailwind `text-base`
|
|
46
|
+
/* Default body size. Markdown body and Tailwind `text-base` follow this. Leading is 1.6. */
|
|
47
47
|
--nonla-base-text-size: 15px;
|
|
48
|
-
/* `text-md`.
|
|
48
|
+
/* `text-md`. One step above the body. */
|
|
49
49
|
--nonla-md-text-size: 16px;
|
|
50
50
|
/* `text-sm`. Composer, tool lines, and errors use this. User bubbles use `text-base`. */
|
|
51
51
|
--nonla-sm-text-size: 14px;
|
|
52
|
-
/*
|
|
53
|
-
--nonla-mono-text-size:
|
|
52
|
+
/* Fenced code. Same size as `text-sm`. */
|
|
53
|
+
--nonla-mono-text-size: var(--nonla-sm-text-size);
|
|
54
54
|
--nonla-radius: 8px;
|
|
55
55
|
--nonla-height: 32px;
|
|
56
56
|
--nonla-height-sm: 24px;
|
|
@@ -136,12 +136,12 @@
|
|
|
136
136
|
.nonla-ui.light {
|
|
137
137
|
color-scheme: light;
|
|
138
138
|
|
|
139
|
-
/*
|
|
139
|
+
/* Page is white. Text is warm stone, same family as dark. Sidebar and cards stay neutral-50. */
|
|
140
140
|
--nonla-bg: #ffffff; /* white */
|
|
141
|
-
--nonla-text-main: #
|
|
142
|
-
--nonla-text-secondary: #
|
|
143
|
-
--nonla-text-tertiary: #
|
|
144
|
-
--nonla-text-quaternary: #
|
|
141
|
+
--nonla-text-main: #1e1d1b;
|
|
142
|
+
--nonla-text-secondary: #564f48;
|
|
143
|
+
--nonla-text-tertiary: #6f6a63;
|
|
144
|
+
--nonla-text-quaternary: #8a847c;
|
|
145
145
|
--nonla-text-on-solid: #ffffff; /* white */
|
|
146
146
|
--nonla-brand: #f18d00;
|
|
147
147
|
--nonla-danger: #dc3b3b;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AnchorHTMLAttributes, type CSSProperties, createElement, type HTMLAttributes, type ReactNode } from "react";
|
|
2
2
|
import { cn } from "../lib/cn";
|
|
3
|
-
import { headingClass, markdownBodyClass, markdownParagraphClass, markdownScaleStyle, pageTitleClass } from "../lib/markdownScale";
|
|
3
|
+
import { headingClass, markdownBodyClass, markdownInlineCodeClass, markdownParagraphClass, markdownScaleStyle, pageTitleClass } from "../lib/markdownScale";
|
|
4
4
|
|
|
5
5
|
export type TypographyType = "secondary" | "success" | "warning" | "danger";
|
|
6
6
|
|
|
@@ -40,11 +40,9 @@ const TITLE_TAG = {
|
|
|
40
40
|
6: "h6",
|
|
41
41
|
} as const;
|
|
42
42
|
|
|
43
|
-
/** Same scale as MarkdownViewer. Body size is `text-
|
|
43
|
+
/** Same scale as MarkdownViewer. Body size is `text-base`. Inline code uses the viewer chip. */
|
|
44
44
|
const BODY = markdownBodyClass;
|
|
45
45
|
|
|
46
|
-
const INLINE_CODE = "nonla-inline-code rounded-[4px] bg-muted px-[2px] py-px align-baseline font-mono text-(length:--md-inline-size,var(--nonla-mono-text-size)) leading-none whitespace-nowrap [box-decoration-break:clone] [-webkit-box-decoration-break:clone]";
|
|
47
|
-
|
|
48
46
|
const TITLE_SPACE = "nonla-typo";
|
|
49
47
|
|
|
50
48
|
function decorationLine(underline?: boolean, deleted?: boolean) {
|
|
@@ -60,7 +58,7 @@ function wrapDecorations(children: ReactNode, props: Decorations) {
|
|
|
60
58
|
node = <mark className="rounded-sm bg-[color-mix(in_oklab,var(--nonla-warn)_40%,transparent)] px-0.5 text-inherit">{node}</mark>;
|
|
61
59
|
}
|
|
62
60
|
if (props.code) {
|
|
63
|
-
node = <code className={
|
|
61
|
+
node = <code className={markdownInlineCodeClass}>{node}</code>;
|
|
64
62
|
}
|
|
65
63
|
if (props.keyboard) {
|
|
66
64
|
node = <kbd className="inline-block rounded-md border border-b-2 border-border bg-muted px-1.5 font-mono text-[0.85em] leading-5">{node}</kbd>;
|