@weasyprint-tsx/ui 0.1.0 → 0.1.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 +6 -2
- package/src/BlockBox.tsx +6 -3
- package/src/CodeBlock.module.css +4 -0
- package/src/CodeBlock.tsx +20 -2
- package/src/Stack.module.css +9 -0
- package/src/Stack.tsx +24 -0
- package/src/Title.module.css +40 -32
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasyprint-tsx/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./src/index.ts"
|
|
6
6
|
},
|
|
7
|
-
"types": "./src/index.ts"
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"highlight.js": "11.11.1",
|
|
10
|
+
"katex": "^0.16.47"
|
|
11
|
+
}
|
|
8
12
|
}
|
package/src/BlockBox.tsx
CHANGED
|
@@ -16,8 +16,8 @@ interface BlockProps extends ComponentProps<"div"> {
|
|
|
16
16
|
align?: "middle" | "top" | "bottom";
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function Block(
|
|
20
|
-
return
|
|
19
|
+
export function Block({ children }: BlockProps) {
|
|
20
|
+
return children;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function BlockBox({
|
|
@@ -40,7 +40,10 @@ export function BlockBox({
|
|
|
40
40
|
const child = blockList.map(
|
|
41
41
|
({ props: { style, ratio = 1, className, centered, align, ...props } }) => (
|
|
42
42
|
<div
|
|
43
|
-
style={mergeStyle(style, {
|
|
43
|
+
style={mergeStyle(style, {
|
|
44
|
+
"--ratio": ratio,
|
|
45
|
+
"--block-box-align": align,
|
|
46
|
+
})}
|
|
44
47
|
className={joinClasses(
|
|
45
48
|
className,
|
|
46
49
|
styles.block,
|
package/src/CodeBlock.tsx
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import hljs from "highlight.js";
|
|
2
2
|
import "highlight.js/styles/atom-one-dark.css";
|
|
3
3
|
import { ComponentProps } from "preact";
|
|
4
|
+
import styles from "./CodeBlock.module.css";
|
|
5
|
+
import { joinClasses, mergeStyle } from "./utils";
|
|
4
6
|
|
|
5
7
|
interface CodeBlockProps extends Omit<ComponentProps<"code">, "children"> {
|
|
6
8
|
language: string;
|
|
7
9
|
code: string;
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
|
|
8
13
|
}
|
|
9
14
|
|
|
10
|
-
export function CodeBlock({
|
|
15
|
+
export function CodeBlock({
|
|
16
|
+
code,
|
|
17
|
+
language,
|
|
18
|
+
bgColor,
|
|
19
|
+
color,
|
|
20
|
+
style,
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}: CodeBlockProps) {
|
|
11
24
|
const codeBlock = hljs.highlight(code, { language: language });
|
|
25
|
+
const css = mergeStyle(style, {
|
|
26
|
+
"--codeblock-bg": bgColor,
|
|
27
|
+
"--color-color" : color,
|
|
28
|
+
breakInside: "avoid",
|
|
29
|
+
});
|
|
12
30
|
return (
|
|
13
|
-
<pre style={{
|
|
31
|
+
<pre style={css} className={joinClasses(className, styles.pre)}>
|
|
14
32
|
<code {...props} dangerouslySetInnerHTML={{ __html: codeBlock.value }} />
|
|
15
33
|
</pre>
|
|
16
34
|
);
|
package/src/Stack.tsx
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentProps } from "preact";
|
|
2
|
+
import styles from "./Stack.module.css";
|
|
3
|
+
import { joinClasses, mergeStyle } from "./utils";
|
|
4
|
+
|
|
5
|
+
interface StackProps extends ComponentProps<"div"> {
|
|
6
|
+
gap?: number | string;
|
|
7
|
+
align?: "left" | "right";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function Stack({ gap, align, className, style, ...props }: StackProps) {
|
|
11
|
+
const css = mergeStyle(style, {
|
|
12
|
+
"--stack-gap": gap,
|
|
13
|
+
"--stack-ml": align === "left" ? undefined : "auto",
|
|
14
|
+
"--stack-mr": align === "right" ? undefined : "auto",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
style={css}
|
|
20
|
+
className={joinClasses(className, styles.stack)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
package/src/Title.module.css
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
.
|
|
3
|
-
.
|
|
4
|
-
.
|
|
5
|
-
.
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
float: left;
|
|
10
|
-
clear: left;
|
|
11
|
-
}
|
|
12
|
-
&[data-marker]::before {
|
|
13
|
-
content: attr(data-marker);
|
|
14
|
-
}
|
|
1
|
+
.h1::before,
|
|
2
|
+
.h2::before,
|
|
3
|
+
.h3::before,
|
|
4
|
+
.h4::before,
|
|
5
|
+
.h5::before,
|
|
6
|
+
.h6::before {
|
|
7
|
+
float: left;
|
|
8
|
+
clear: left;
|
|
15
9
|
}
|
|
16
10
|
|
|
11
|
+
.h1[data-marker]::before,
|
|
12
|
+
.h2[data-marker]::before,
|
|
13
|
+
.h3[data-marker]::before,
|
|
14
|
+
.h4[data-marker]::before,
|
|
15
|
+
.h5[data-marker]::before,
|
|
16
|
+
.h6[data-marker]::before {
|
|
17
|
+
content: attr(data-marker);
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
.h1 {
|
|
19
21
|
color: var(--h1-color, inherit);
|
|
20
22
|
font-size: var(--h1-fontsize, inherit);
|
|
21
23
|
counter-reset: count-h2 count-h3 count-h4 count-h5 count-h6;
|
|
22
24
|
counter-increment: count-h1;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:where(.h1)::before {
|
|
28
|
+
content: counter(count-h1, upper-roman) ". ";
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
.h2 {
|
|
@@ -30,9 +33,10 @@
|
|
|
30
33
|
font-size: var(--h2-fontsize, inherit);
|
|
31
34
|
counter-reset: count-h3 count-h4 count-h5 count-h6;
|
|
32
35
|
counter-increment: count-h2;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:where(.h2)::before {
|
|
39
|
+
content: counter(count-h2, decimal) ". ";
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
.h3 {
|
|
@@ -40,9 +44,10 @@
|
|
|
40
44
|
font-size: var(--h3-fontsize, inherit);
|
|
41
45
|
counter-reset: count-h4 count-h5 count-h6;
|
|
42
46
|
counter-increment: count-h3;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:where(.h3)::before {
|
|
50
|
+
content: counter(count-h3, upper-alpha) ". ";
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
.h4 {
|
|
@@ -50,9 +55,10 @@
|
|
|
50
55
|
font-size: var(--h4-fontsize, inherit);
|
|
51
56
|
counter-reset: count-h5 count-h6;
|
|
52
57
|
counter-increment: count-h4;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
:where(.h4)::before {
|
|
61
|
+
content: counter(count-h4, decimal) ". ";
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
.h5 {
|
|
@@ -60,16 +66,18 @@
|
|
|
60
66
|
font-size: var(--h5-fontsize, inherit);
|
|
61
67
|
counter-reset: count-h6;
|
|
62
68
|
counter-increment: count-h5;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:where(.h5)::before {
|
|
72
|
+
content: counter(count-h5, lower-alpha) ". ";
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
.h6 {
|
|
69
76
|
color: var(--h6-color, inherit);
|
|
70
77
|
font-size: var(--h6-fontsize, inherit);
|
|
71
78
|
counter-increment: count-h6;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
:where(.h6)::before {
|
|
82
|
+
content: counter(count-h6, lower-roman) ". ";
|
|
75
83
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { DotLine } from "./DotLine";
|
|
|
4
4
|
export { Equation } from "./Equation";
|
|
5
5
|
export { LI, OL, UL } from "./List";
|
|
6
6
|
export { Page, PageBreak } from "./Page";
|
|
7
|
+
export { Stack } from "./Stack";
|
|
7
8
|
export { Entry, Table } from "./Table";
|
|
8
9
|
export { H1, H2, H3, H4, H5, H6, ResetCounter, Title } from "./Titles";
|
|
9
10
|
|