@sigx/lynx-daisyui 0.4.7 → 0.4.8
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 +22 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/markdown/editorTheme.d.ts +34 -0
- package/dist/markdown/editorTheme.js +73 -0
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -267,6 +267,28 @@ basis: 0` triple, so `flex={1}` actually fills available space instead
|
|
|
267
267
|
of collapsing to content size — the standard Lynx `flex: 1` shorthand
|
|
268
268
|
expands to `flex: 1 1 auto` which doesn't do what most people expect.
|
|
269
269
|
|
|
270
|
+
## Markdown integration
|
|
271
|
+
|
|
272
|
+
Two bridges into [`@sigx/lynx-markdown`](../lynx-markdown):
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { markdownComponents, useMarkdownEditorTheme } from '@sigx/lynx-daisyui';
|
|
276
|
+
|
|
277
|
+
// Themed rendering: daisyUI typography/colors for every markdown node.
|
|
278
|
+
<MarkdownView value={md} components={markdownComponents} />;
|
|
279
|
+
|
|
280
|
+
// Themed editing: the native <sigx-richtext> element can't read CSS
|
|
281
|
+
// variables (and the built-in theme tokens are oklch, which Lynx can't
|
|
282
|
+
// parse), so this hook reactively resolves the ACTIVE theme's palette to
|
|
283
|
+
// concrete hex color props — a theme switch recolors the editor live.
|
|
284
|
+
const editorTheme = useMarkdownEditorTheme();
|
|
285
|
+
<MarkdownEditor
|
|
286
|
+
textColor={editorTheme.textColor} // base-content
|
|
287
|
+
accentColor={editorTheme.accentColor} // primary (caret, links)
|
|
288
|
+
placeholderColor={editorTheme.placeholderColor} // base-content @ 40%
|
|
289
|
+
/>;
|
|
290
|
+
```
|
|
291
|
+
|
|
270
292
|
## Status
|
|
271
293
|
|
|
272
294
|
Initial release — APIs may shift as the Lynx styling story evolves.
|
package/dist/index.d.ts
CHANGED
|
@@ -67,3 +67,5 @@ export type { TextProps, TextSize, TextWeight, TextColor } from './typography/Te
|
|
|
67
67
|
export { Heading } from './typography/Heading.js';
|
|
68
68
|
export type { HeadingProps, HeadingLevel } from './typography/Heading.js';
|
|
69
69
|
export { markdownComponents } from './markdown/components.js';
|
|
70
|
+
export { useMarkdownEditorTheme } from './markdown/editorTheme.js';
|
|
71
|
+
export type { MarkdownEditorThemeColors } from './markdown/editorTheme.js';
|
package/dist/index.js
CHANGED
|
@@ -46,5 +46,7 @@ export { Avatar } from './data/Avatar.js';
|
|
|
46
46
|
// Typography
|
|
47
47
|
export { Text } from './typography/Text.js';
|
|
48
48
|
export { Heading } from './typography/Heading.js';
|
|
49
|
-
// Markdown — daisyUI rendering for `@sigx/lynx-markdown`
|
|
49
|
+
// Markdown — daisyUI rendering + editor theming for `@sigx/lynx-markdown`
|
|
50
|
+
// (optional peer).
|
|
50
51
|
export { markdownComponents } from './markdown/components.js';
|
|
52
|
+
export { useMarkdownEditorTheme } from './markdown/editorTheme.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* daisyUI theming for `@sigx/lynx-markdown`'s `MarkdownEditor`.
|
|
3
|
+
*
|
|
4
|
+
* The native `<sigx-richtext>` element can't read CSS custom properties — its
|
|
5
|
+
* color props need concrete hex values (and the built-in theme tokens are
|
|
6
|
+
* oklch, which Lynx's CSS engine can't parse anyway). This hook resolves the
|
|
7
|
+
* **active theme's palette** to the editor's color props, reactively: read the
|
|
8
|
+
* returned getters inside render and a theme switch recolors the editor.
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const editorTheme = useMarkdownEditorTheme();
|
|
12
|
+
*
|
|
13
|
+
* <MarkdownEditor
|
|
14
|
+
* textColor={editorTheme.textColor}
|
|
15
|
+
* accentColor={editorTheme.accentColor}
|
|
16
|
+
* placeholderColor={editorTheme.placeholderColor}
|
|
17
|
+
* …
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export interface MarkdownEditorThemeColors {
|
|
22
|
+
/** `base-content` — the theme's text color. */
|
|
23
|
+
readonly textColor: string;
|
|
24
|
+
/** `primary` — caret tint + links. */
|
|
25
|
+
readonly accentColor: string;
|
|
26
|
+
/** `base-content` at 40% alpha. */
|
|
27
|
+
readonly placeholderColor: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the active daisyUI theme into `MarkdownEditor` color props.
|
|
31
|
+
* Getters are reactive via the theme controller's `name` — read them in
|
|
32
|
+
* render (e.g. spread onto the editor's props) to track theme switches.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useMarkdownEditorTheme(): MarkdownEditorThemeColors;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* daisyUI theming for `@sigx/lynx-markdown`'s `MarkdownEditor`.
|
|
3
|
+
*
|
|
4
|
+
* The native `<sigx-richtext>` element can't read CSS custom properties — its
|
|
5
|
+
* color props need concrete hex values (and the built-in theme tokens are
|
|
6
|
+
* oklch, which Lynx's CSS engine can't parse anyway). This hook resolves the
|
|
7
|
+
* **active theme's palette** to the editor's color props, reactively: read the
|
|
8
|
+
* returned getters inside render and a theme switch recolors the editor.
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const editorTheme = useMarkdownEditorTheme();
|
|
12
|
+
*
|
|
13
|
+
* <MarkdownEditor
|
|
14
|
+
* textColor={editorTheme.textColor}
|
|
15
|
+
* accentColor={editorTheme.accentColor}
|
|
16
|
+
* placeholderColor={editorTheme.placeholderColor}
|
|
17
|
+
* …
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { useTheme } from '../theme/ThemeProvider.js';
|
|
22
|
+
import { colorsOf } from '../theme/registry.js';
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the active daisyUI theme into `MarkdownEditor` color props.
|
|
25
|
+
* Getters are reactive via the theme controller's `name` — read them in
|
|
26
|
+
* render (e.g. spread onto the editor's props) to track theme switches.
|
|
27
|
+
*/
|
|
28
|
+
export function useMarkdownEditorTheme() {
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const palette = () => colorsOf(theme.name) ?? colorsOf('daisy-light');
|
|
31
|
+
return {
|
|
32
|
+
get textColor() {
|
|
33
|
+
return toHex(palette()['base-content']);
|
|
34
|
+
},
|
|
35
|
+
get accentColor() {
|
|
36
|
+
return toHex(palette()['primary']);
|
|
37
|
+
},
|
|
38
|
+
get placeholderColor() {
|
|
39
|
+
return withAlpha(toHex(palette()['base-content']), '66'); // ~40%
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize a palette color to hex — the registry allows `rgb()`/`rgba()`
|
|
45
|
+
* entries, but the native `<sigx-richtext>` color parsers are hex-only.
|
|
46
|
+
*/
|
|
47
|
+
function toHex(color) {
|
|
48
|
+
const c = color.trim();
|
|
49
|
+
if (c.startsWith('#'))
|
|
50
|
+
return c;
|
|
51
|
+
const m = /^rgba?\(\s*(\d+)\s*[, ]\s*(\d+)\s*[, ]\s*(\d+)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i.exec(c);
|
|
52
|
+
if (!m)
|
|
53
|
+
return c; // unknown notation — pass through unchanged
|
|
54
|
+
const byte = (v) => Math.max(0, Math.min(255, Math.round(Number(v)))).toString(16).padStart(2, '0');
|
|
55
|
+
let hex = `#${byte(m[1])}${byte(m[2])}${byte(m[3])}`;
|
|
56
|
+
if (m[4] !== undefined) {
|
|
57
|
+
const a = m[4].endsWith('%') ? Number(m[4].slice(0, -1)) / 100 : Number(m[4]);
|
|
58
|
+
hex += byte(String(Math.max(0, Math.min(1, a)) * 255));
|
|
59
|
+
}
|
|
60
|
+
return hex;
|
|
61
|
+
}
|
|
62
|
+
/** Append an alpha byte to a hex color (`#RGB`/`#RRGGBB` → `#RRGGBBAA`). */
|
|
63
|
+
function withAlpha(hex, alpha) {
|
|
64
|
+
let h = hex.trim();
|
|
65
|
+
if (!h.startsWith('#'))
|
|
66
|
+
return h;
|
|
67
|
+
h = h.slice(1);
|
|
68
|
+
if (h.length === 3)
|
|
69
|
+
h = h.split('').map((c) => c + c).join('');
|
|
70
|
+
if (h.length === 8)
|
|
71
|
+
h = h.slice(0, 6);
|
|
72
|
+
return `#${h}${alpha}`;
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/lynx-daisyui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "DaisyUI integration for sigx-lynx",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"LICENSE"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@sigx/lynx": "^0.4.
|
|
41
|
-
"@sigx/lynx-gestures": "^0.4.
|
|
42
|
-
"@sigx/lynx-appearance": "^0.4.
|
|
43
|
-
"@sigx/lynx-icons": "^0.4.
|
|
44
|
-
"@sigx/lynx-motion": "^0.4.
|
|
40
|
+
"@sigx/lynx": "^0.4.8",
|
|
41
|
+
"@sigx/lynx-gestures": "^0.4.8",
|
|
42
|
+
"@sigx/lynx-appearance": "^0.4.8",
|
|
43
|
+
"@sigx/lynx-icons": "^0.4.8",
|
|
44
|
+
"@sigx/lynx-motion": "^0.4.8"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"tailwindcss": "^3.0.0 || ^4.0.0",
|
|
48
|
-
"@sigx/lynx-markdown": "^0.4.
|
|
49
|
-
"@sigx/lynx-navigation": "^0.4.
|
|
48
|
+
"@sigx/lynx-markdown": "^0.4.8",
|
|
49
|
+
"@sigx/lynx-navigation": "^0.4.8"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@sigx/lynx-markdown": {
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@typescript/native-preview": "7.0.0-dev.20260521.1",
|
|
61
61
|
"tailwindcss": "^4.0.0",
|
|
62
62
|
"typescript": "^6.0.3",
|
|
63
|
-
"@sigx/lynx-
|
|
64
|
-
"@sigx/lynx-
|
|
63
|
+
"@sigx/lynx-navigation": "^0.4.8",
|
|
64
|
+
"@sigx/lynx-markdown": "^0.4.8"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|