@elmethis/qwik 0.0.2 → 0.0.4
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/.prettierignore +6 -0
- package/.storybook/main.ts +23 -0
- package/.storybook/preview-head.html +4 -0
- package/.storybook/preview.tsx +51 -0
- package/.storybook/sb.scss +13 -0
- package/.storybook/tsconfig.json +24 -0
- package/eslint.config.js +79 -0
- package/package.json +5 -8
- package/src/assets/bg1.webp +0 -0
- package/src/assets/bg2.webp +0 -0
- package/src/assets/images/2.svg +4 -0
- package/src/assets/images/lamdscape.svg +4 -0
- package/src/assets/images/portrait.svg +4 -0
- package/src/assets/images/square.svg +4 -0
- package/src/assets/vite.svg +1 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/code/elm-code-block.module.scss +67 -0
- package/src/components/code/elm-code-block.stories.tsx +44 -0
- package/src/components/code/elm-code-block.tsx +95 -0
- package/src/components/code/elm-katex.stories.tsx +28 -0
- package/src/components/code/elm-katex.tsx +34 -0
- package/src/components/code/elm-shiki-highlighter.global.scss +18 -0
- package/src/components/code/elm-shiki-highlighter.stories.tsx +21 -0
- package/src/components/code/elm-shiki-highlighter.tsx +44 -0
- package/src/components/code/seed/main.rs +24 -0
- package/{lib/qwik31.js → src/components/code/shikiInstance.ts} +8 -11
- package/src/components/containments/elm-toggle.module.scss +132 -0
- package/src/components/containments/elm-toggle.stories.tsx +34 -0
- package/src/components/containments/elm-toggle.tsx +106 -0
- package/src/components/fallback/elm-block-fallback.module.scss +8 -0
- package/src/components/fallback/elm-block-fallback.stories.tsx +14 -0
- package/src/components/fallback/elm-block-fallback.tsx +20 -0
- package/src/components/fallback/elm-rectangle-wave.module.scss +42 -0
- package/src/components/fallback/elm-rectangle-wave.stories.tsx +28 -0
- package/src/components/fallback/elm-rectangle-wave.tsx +11 -0
- package/src/components/icon/elm-dot-loading-icon.module.scss +53 -0
- package/src/components/icon/elm-dot-loading-icon.stories.tsx +15 -0
- package/src/components/icon/elm-dot-loading-icon.tsx +35 -0
- package/src/components/icon/elm-inline-icon.module.scss +21 -0
- package/src/components/icon/elm-inline-icon.stories.tsx +16 -0
- package/src/components/icon/elm-inline-icon.tsx +25 -0
- package/src/components/icon/elm-language-icon.stories.tsx +22 -0
- package/src/components/icon/elm-language-icon.tsx +167 -0
- package/src/components/icon/elm-mdi-icon.module.scss +8 -0
- package/src/components/icon/elm-mdi-icon.stories.tsx +25 -0
- package/src/components/icon/elm-mdi-icon.tsx +34 -0
- package/src/components/icon/languages/bash.module.scss +6 -0
- package/src/components/icon/languages/bash.tsx +27 -0
- package/src/components/icon/languages/c-plus-plus.tsx +33 -0
- package/src/components/icon/languages/c-sharp.tsx +29 -0
- package/src/components/icon/languages/c.tsx +27 -0
- package/src/components/icon/languages/css.tsx +21 -0
- package/src/components/icon/languages/go.tsx +22 -0
- package/src/components/icon/languages/html.tsx +30 -0
- package/src/components/icon/languages/java.tsx +37 -0
- package/src/components/icon/languages/javascript.tsx +22 -0
- package/src/components/icon/languages/json.tsx +53 -0
- package/src/components/icon/languages/kotlin.tsx +36 -0
- package/src/components/icon/languages/language-interface.ts +4 -0
- package/src/components/icon/languages/lua.tsx +29 -0
- package/src/components/icon/languages/npm.tsx +25 -0
- package/src/components/icon/languages/python.tsx +67 -0
- package/src/components/icon/languages/rust.tsx +19 -0
- package/src/components/icon/languages/sql.tsx +21 -0
- package/src/components/icon/languages/terraform.tsx +31 -0
- package/src/components/icon/languages/typescript.tsx +22 -0
- package/src/components/media/elm-block-image.module.scss +68 -0
- package/src/components/media/elm-block-image.stories.tsx +79 -0
- package/src/components/media/elm-block-image.tsx +110 -0
- package/src/components/media/elm-file.module.scss +43 -0
- package/src/components/media/elm-file.stories.tsx +27 -0
- package/src/components/media/elm-file.tsx +75 -0
- package/src/components/navigation/elm-bookmark.module.scss +100 -0
- package/src/components/navigation/elm-bookmark.stories.tsx +87 -0
- package/src/components/navigation/elm-bookmark.tsx +72 -0
- package/src/components/others/elm-jarkup.module.scss +26 -0
- package/src/components/others/elm-jarkup.stories.tsx +18 -0
- package/src/components/others/elm-jarkup.tsx +267 -0
- package/src/components/table/elm-table-body.tsx +14 -0
- package/src/components/table/elm-table-cell.module.scss +41 -0
- package/src/components/table/elm-table-cell.tsx +33 -0
- package/src/components/table/elm-table-header.module.scss +8 -0
- package/src/components/table/elm-table-header.tsx +21 -0
- package/src/components/table/elm-table-row.module.scss +28 -0
- package/src/components/table/elm-table-row.tsx +15 -0
- package/src/components/table/elm-table.module.scss +29 -0
- package/src/components/table/elm-table.stories.tsx +67 -0
- package/src/components/table/elm-table.tsx +63 -0
- package/src/components/typography/elm-block-quote.module.scss +29 -0
- package/src/components/typography/elm-block-quote.stories.tsx +22 -0
- package/src/components/typography/elm-block-quote.tsx +34 -0
- package/src/components/typography/elm-callout.module.scss +36 -0
- package/src/components/typography/elm-callout.stories.tsx +47 -0
- package/src/components/typography/elm-callout.tsx +52 -0
- package/src/components/typography/elm-divider.module.scss +6 -0
- package/src/components/typography/elm-divider.stories.tsx +14 -0
- package/src/components/typography/elm-divider.tsx +14 -0
- package/src/components/typography/elm-fragment-identifier.module.scss +28 -0
- package/src/components/typography/elm-fragment-identifier.stories.tsx +14 -0
- package/src/components/typography/elm-fragment-identifier.tsx +31 -0
- package/src/components/typography/elm-heading.module.scss +120 -0
- package/src/components/typography/elm-heading.stories.tsx +42 -0
- package/src/components/typography/elm-heading.tsx +40 -0
- package/src/components/typography/elm-inline-text.module.scss +114 -0
- package/src/components/typography/elm-inline-text.stories.tsx +70 -0
- package/src/components/typography/elm-inline-text.tsx +147 -0
- package/src/components/typography/elm-list.global.scss +66 -0
- package/src/components/typography/elm-list.stories.tsx +61 -0
- package/src/components/typography/elm-list.tsx +39 -0
- package/src/components/typography/elm-paragraph.module.scss +21 -0
- package/src/components/typography/elm-paragraph.stories.tsx +47 -0
- package/src/components/typography/elm-paragraph.tsx +31 -0
- package/src/entry.dev.tsx +17 -0
- package/{lib-types/entry.ssr.d.ts → src/entry.ssr.tsx} +9 -2
- package/src/global.d.ts +13 -0
- package/src/hooks/useDelayedSignal.ts +27 -0
- package/src/hooks/useInView.tsx +23 -0
- package/src/index.ts +113 -0
- package/src/root.tsx +13 -0
- package/src/styles/text.module.scss +17 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +21 -0
- package/vite.config.ts +36 -0
- package/lib/assets/6FDiDjPb-qwik.css +0 -955
- package/lib/qwik.js +0 -56
- package/lib/qwik10.js +0 -108
- package/lib/qwik11.js +0 -25
- package/lib/qwik12.js +0 -87
- package/lib/qwik13.js +0 -62
- package/lib/qwik14.js +0 -62
- package/lib/qwik15.js +0 -44
- package/lib/qwik16.js +0 -58
- package/lib/qwik17.js +0 -14
- package/lib/qwik18.js +0 -24
- package/lib/qwik19.js +0 -41
- package/lib/qwik2.js +0 -68
- package/lib/qwik20.js +0 -89
- package/lib/qwik21.js +0 -28
- package/lib/qwik22.js +0 -24
- package/lib/qwik23.js +0 -57
- package/lib/qwik24.js +0 -15
- package/lib/qwik25.js +0 -12
- package/lib/qwik26.js +0 -17
- package/lib/qwik27.js +0 -27
- package/lib/qwik28.js +0 -193
- package/lib/qwik29.js +0 -17
- package/lib/qwik3.js +0 -17
- package/lib/qwik30.js +0 -8
- package/lib/qwik33.js +0 -32
- package/lib/qwik34.js +0 -6
- package/lib/qwik35.js +0 -6
- package/lib/qwik36.js +0 -11
- package/lib/qwik37.js +0 -8
- package/lib/qwik38.js +0 -18
- package/lib/qwik39.js +0 -24
- package/lib/qwik4.js +0 -33
- package/lib/qwik40.js +0 -24
- package/lib/qwik41.js +0 -29
- package/lib/qwik42.js +0 -31
- package/lib/qwik43.js +0 -32
- package/lib/qwik44.js +0 -18
- package/lib/qwik45.js +0 -24
- package/lib/qwik46.js +0 -36
- package/lib/qwik47.js +0 -45
- package/lib/qwik48.js +0 -27
- package/lib/qwik49.js +0 -89
- package/lib/qwik5.js +0 -123
- package/lib/qwik50.js +0 -18
- package/lib/qwik51.js +0 -64
- package/lib/qwik52.js +0 -28
- package/lib/qwik53.js +0 -28
- package/lib/qwik54.js +0 -32
- package/lib/qwik55.js +0 -28
- package/lib/qwik56.js +0 -8
- package/lib/qwik57.js +0 -15
- package/lib/qwik58.js +0 -10
- package/lib/qwik59.js +0 -26
- package/lib/qwik6.js +0 -20
- package/lib/qwik60.js +0 -14
- package/lib/qwik61.js +0 -14
- package/lib/qwik62.js +0 -8
- package/lib/qwik63.js +0 -8
- package/lib/qwik64.js +0 -24
- package/lib/qwik65.js +0 -17
- package/lib/qwik67.js +0 -8
- package/lib/qwik68.js +0 -23
- package/lib/qwik69.js +0 -15
- package/lib/qwik7.js +0 -12
- package/lib/qwik70.js +0 -8
- package/lib/qwik71.js +0 -9
- package/lib/qwik72.js +0 -14
- package/lib/qwik73.js +0 -10
- package/lib/qwik74.js +0 -8
- package/lib/qwik8.js +0 -29
- package/lib/qwik9.js +0 -16
- package/lib-types/components/code/elm-code-block.d.ts +0 -21
- package/lib-types/components/code/elm-code-block.stories.d.ts +0 -9
- package/lib-types/components/code/elm-katex.d.ts +0 -15
- package/lib-types/components/code/elm-katex.stories.d.ts +0 -8
- package/lib-types/components/code/elm-shiki-highlighter.d.ts +0 -12
- package/lib-types/components/code/elm-shiki-highlighter.stories.d.ts +0 -6
- package/lib-types/components/code/shikiInstance.d.ts +0 -2
- package/lib-types/components/containments/elm-toggle.d.ts +0 -7
- package/lib-types/components/containments/elm-toggle.stories.d.ts +0 -6
- package/lib-types/components/fallback/elm-block-fallback.d.ts +0 -5
- package/lib-types/components/fallback/elm-block-fallback.stories.d.ts +0 -6
- package/lib-types/components/fallback/elm-rectangle-wave.d.ts +0 -4
- package/lib-types/components/fallback/elm-rectangle-wave.stories.d.ts +0 -6
- package/lib-types/components/icon/elm-dot-loading-icon.d.ts +0 -14
- package/lib-types/components/icon/elm-dot-loading-icon.stories.d.ts +0 -6
- package/lib-types/components/icon/elm-inline-icon.d.ts +0 -11
- package/lib-types/components/icon/elm-inline-icon.stories.d.ts +0 -6
- package/lib-types/components/icon/elm-language-icon.d.ts +0 -14
- package/lib-types/components/icon/elm-language-icon.stories.d.ts +0 -6
- package/lib-types/components/icon/elm-mdi-icon.d.ts +0 -8
- package/lib-types/components/icon/elm-mdi-icon.stories.d.ts +0 -6
- package/lib-types/components/icon/languages/bash.d.ts +0 -2
- package/lib-types/components/icon/languages/c-plus-plus.d.ts +0 -2
- package/lib-types/components/icon/languages/c-sharp.d.ts +0 -2
- package/lib-types/components/icon/languages/c.d.ts +0 -2
- package/lib-types/components/icon/languages/css.d.ts +0 -2
- package/lib-types/components/icon/languages/go.d.ts +0 -2
- package/lib-types/components/icon/languages/html.d.ts +0 -2
- package/lib-types/components/icon/languages/java.d.ts +0 -2
- package/lib-types/components/icon/languages/javascript.d.ts +0 -2
- package/lib-types/components/icon/languages/json.d.ts +0 -2
- package/lib-types/components/icon/languages/kotlin.d.ts +0 -2
- package/lib-types/components/icon/languages/language-interface.d.ts +0 -4
- package/lib-types/components/icon/languages/lua.d.ts +0 -2
- package/lib-types/components/icon/languages/npm.d.ts +0 -2
- package/lib-types/components/icon/languages/python.d.ts +0 -2
- package/lib-types/components/icon/languages/rust.d.ts +0 -2
- package/lib-types/components/icon/languages/sql.d.ts +0 -2
- package/lib-types/components/icon/languages/terraform.d.ts +0 -2
- package/lib-types/components/icon/languages/typescript.d.ts +0 -2
- package/lib-types/components/media/elm-block-image.d.ts +0 -16
- package/lib-types/components/media/elm-block-image.stories.d.ts +0 -12
- package/lib-types/components/media/elm-file.d.ts +0 -15
- package/lib-types/components/media/elm-file.stories.d.ts +0 -7
- package/lib-types/components/navigation/elm-bookmark.d.ts +0 -24
- package/lib-types/components/navigation/elm-bookmark.stories.d.ts +0 -12
- package/lib-types/components/others/elm-jarkup.d.ts +0 -5
- package/lib-types/components/others/elm-jarkup.stories.d.ts +0 -6
- package/lib-types/components/table/elm-table-body.d.ts +0 -2
- package/lib-types/components/table/elm-table-cell.d.ts +0 -12
- package/lib-types/components/table/elm-table-header.d.ts +0 -3
- package/lib-types/components/table/elm-table-row.d.ts +0 -2
- package/lib-types/components/table/elm-table.d.ts +0 -13
- package/lib-types/components/table/elm-table.stories.d.ts +0 -6
- package/lib-types/components/typography/elm-block-quote.d.ts +0 -4
- package/lib-types/components/typography/elm-block-quote.stories.d.ts +0 -6
- package/lib-types/components/typography/elm-callout.d.ts +0 -8
- package/lib-types/components/typography/elm-callout.stories.d.ts +0 -10
- package/lib-types/components/typography/elm-divider.d.ts +0 -8
- package/lib-types/components/typography/elm-divider.stories.d.ts +0 -6
- package/lib-types/components/typography/elm-fragment-identifier.d.ts +0 -7
- package/lib-types/components/typography/elm-fragment-identifier.stories.d.ts +0 -6
- package/lib-types/components/typography/elm-heading.d.ts +0 -6
- package/lib-types/components/typography/elm-heading.stories.d.ts +0 -7
- package/lib-types/components/typography/elm-inline-text.d.ts +0 -54
- package/lib-types/components/typography/elm-inline-text.stories.d.ts +0 -13
- package/lib-types/components/typography/elm-list.d.ts +0 -5
- package/lib-types/components/typography/elm-list.stories.d.ts +0 -8
- package/lib-types/components/typography/elm-paragraph.d.ts +0 -5
- package/lib-types/components/typography/elm-paragraph.stories.d.ts +0 -9
- package/lib-types/entry.dev.d.ts +0 -2
- package/lib-types/hooks/useDelayedSignal.d.ts +0 -6
- package/lib-types/hooks/useInView.d.ts +0 -6
- package/lib-types/index.d.ts +0 -27
- package/lib-types/root.d.ts +0 -2
- /package/{lib-types/components/table/index.d.ts → src/components/table/index.ts} +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { component$, type JSXOutput } from "@builder.io/qwik";
|
|
2
|
+
import type { Component, InlineComponent } from "jarkup-ts";
|
|
3
|
+
import { kebabCase } from "lodash-es";
|
|
4
|
+
|
|
5
|
+
import styles from "./elm-jarkup.module.scss";
|
|
6
|
+
|
|
7
|
+
import { ElmInlineText } from "../typography/elm-inline-text";
|
|
8
|
+
import { ElmKatex } from "../code/elm-katex";
|
|
9
|
+
import { ElmInlineIcon } from "../icon/elm-inline-icon";
|
|
10
|
+
import { ElmHeading } from "../typography/elm-heading";
|
|
11
|
+
import { ElmParagraph } from "../typography/elm-paragraph";
|
|
12
|
+
import { ElmList } from "../typography/elm-list";
|
|
13
|
+
import { ElmBlockQuote } from "../typography/elm-block-quote";
|
|
14
|
+
import { ElmCallout } from "../typography/elm-callout";
|
|
15
|
+
import { ElmDivider } from "../typography/elm-divider";
|
|
16
|
+
import { ElmToggle } from "../containments/elm-toggle";
|
|
17
|
+
import { ElmBookmark } from "../navigation/elm-bookmark";
|
|
18
|
+
import { ElmFile } from "../media/elm-file";
|
|
19
|
+
import { ElmBlockImage } from "../media/elm-block-image";
|
|
20
|
+
import { ElmCodeBlock } from "../code/elm-code-block";
|
|
21
|
+
import {
|
|
22
|
+
ElmTable,
|
|
23
|
+
ElmTableHeader,
|
|
24
|
+
ElmTableBody,
|
|
25
|
+
ElmTableRow,
|
|
26
|
+
ElmTableCell,
|
|
27
|
+
} from "../table";
|
|
28
|
+
|
|
29
|
+
export interface ElmJarkupProps {
|
|
30
|
+
jsonComponents: Component[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const convertInlineComponentsToPlainText = (
|
|
34
|
+
inlineComponents: InlineComponent[],
|
|
35
|
+
): string => {
|
|
36
|
+
return inlineComponents
|
|
37
|
+
.map((component) => {
|
|
38
|
+
if (component.type === "Text") {
|
|
39
|
+
return component.props.text;
|
|
40
|
+
} else {
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
.join("");
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const ElmJarkup = component$<ElmJarkupProps>((props) => {
|
|
48
|
+
const render = (jsonComponents: Component[]): JSXOutput[] => {
|
|
49
|
+
return jsonComponents.map((component, index) => {
|
|
50
|
+
const key = component.id || index;
|
|
51
|
+
|
|
52
|
+
switch (component.type) {
|
|
53
|
+
case "Text": {
|
|
54
|
+
const { props: p } = component;
|
|
55
|
+
if (p.katex) {
|
|
56
|
+
return <ElmKatex key={key} expression={p.text} block={false} />;
|
|
57
|
+
}
|
|
58
|
+
return (
|
|
59
|
+
<ElmInlineText
|
|
60
|
+
key={key}
|
|
61
|
+
text={p.text}
|
|
62
|
+
color={p.color}
|
|
63
|
+
backgroundColor={p.backgroundColor}
|
|
64
|
+
bold={p.bold}
|
|
65
|
+
italic={p.italic}
|
|
66
|
+
underline={p.underline}
|
|
67
|
+
strikethrough={p.strikethrough}
|
|
68
|
+
code={p.code}
|
|
69
|
+
ruby={p.ruby}
|
|
70
|
+
href={p.href}
|
|
71
|
+
favicon={p.favicon}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
case "Icon":
|
|
77
|
+
return (
|
|
78
|
+
<ElmInlineIcon
|
|
79
|
+
key={key}
|
|
80
|
+
src={component.props.src}
|
|
81
|
+
alt={component.props.alt}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
case "Heading":
|
|
86
|
+
return (
|
|
87
|
+
<ElmHeading
|
|
88
|
+
key={key}
|
|
89
|
+
level={component.props.level}
|
|
90
|
+
id={kebabCase(
|
|
91
|
+
convertInlineComponentsToPlainText(component.slots.default),
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
{render(component.slots.default)}
|
|
95
|
+
</ElmHeading>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
case "Paragraph":
|
|
99
|
+
return (
|
|
100
|
+
<ElmParagraph
|
|
101
|
+
key={key}
|
|
102
|
+
color={component.props?.color}
|
|
103
|
+
backgroundColor={component.props?.backgroundColor}
|
|
104
|
+
>
|
|
105
|
+
{render(component.slots.default)}
|
|
106
|
+
</ElmParagraph>
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
case "ListItem":
|
|
110
|
+
return <li key={key}>{render(component.slots.default)}</li>;
|
|
111
|
+
|
|
112
|
+
case "List":
|
|
113
|
+
return (
|
|
114
|
+
<ElmList
|
|
115
|
+
key={key}
|
|
116
|
+
listStyle={
|
|
117
|
+
component.props?.listStyle === "unordered"
|
|
118
|
+
? "unordered"
|
|
119
|
+
: "ordered"
|
|
120
|
+
}
|
|
121
|
+
>
|
|
122
|
+
{render(component.slots.default)}
|
|
123
|
+
</ElmList>
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
case "BlockQuote":
|
|
127
|
+
return (
|
|
128
|
+
<ElmBlockQuote key={key} cite={component.props?.cite}>
|
|
129
|
+
{render(component.slots.default)}
|
|
130
|
+
</ElmBlockQuote>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
case "Callout":
|
|
134
|
+
return (
|
|
135
|
+
<ElmCallout key={key} type={component.props?.type}>
|
|
136
|
+
{render(component.slots.default)}
|
|
137
|
+
</ElmCallout>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
case "Divider":
|
|
141
|
+
return <ElmDivider key={key} />;
|
|
142
|
+
|
|
143
|
+
case "Toggle":
|
|
144
|
+
return (
|
|
145
|
+
<ElmToggle key={key}>
|
|
146
|
+
<div q:slot="summary">{render(component.slots.summary)}</div>
|
|
147
|
+
{render(component.slots.default)}
|
|
148
|
+
</ElmToggle>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
case "Bookmark":
|
|
152
|
+
return (
|
|
153
|
+
<ElmBookmark
|
|
154
|
+
key={key}
|
|
155
|
+
url={component.props.url}
|
|
156
|
+
title={component.props.title}
|
|
157
|
+
description={component.props.description}
|
|
158
|
+
image={component.props.image}
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
case "File":
|
|
163
|
+
return (
|
|
164
|
+
<ElmFile
|
|
165
|
+
key={key}
|
|
166
|
+
src={component.props.src}
|
|
167
|
+
name={component.props.name}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
case "Image":
|
|
172
|
+
return (
|
|
173
|
+
<ElmBlockImage
|
|
174
|
+
key={key}
|
|
175
|
+
src={component.props.src}
|
|
176
|
+
alt={component.props.alt}
|
|
177
|
+
enableModal={true}
|
|
178
|
+
/>
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
case "CodeBlock":
|
|
182
|
+
return (
|
|
183
|
+
<ElmCodeBlock
|
|
184
|
+
key={key}
|
|
185
|
+
code={component.props.code}
|
|
186
|
+
language={component.props.language}
|
|
187
|
+
>
|
|
188
|
+
{component.slots?.default && render(component.slots.default)}
|
|
189
|
+
</ElmCodeBlock>
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
case "Katex":
|
|
193
|
+
return (
|
|
194
|
+
<ElmKatex
|
|
195
|
+
key={key}
|
|
196
|
+
expression={component.props.expression}
|
|
197
|
+
block={true}
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
case "Table":
|
|
202
|
+
return (
|
|
203
|
+
<ElmTable
|
|
204
|
+
key={key}
|
|
205
|
+
caption={component.props?.caption}
|
|
206
|
+
hasRowHeader={component.props?.hasRowHeader}
|
|
207
|
+
>
|
|
208
|
+
{component.slots.header && (
|
|
209
|
+
<ElmTableHeader>
|
|
210
|
+
{render(component.slots.header)}
|
|
211
|
+
</ElmTableHeader>
|
|
212
|
+
)}
|
|
213
|
+
<ElmTableBody>{render(component.slots.body)}</ElmTableBody>
|
|
214
|
+
</ElmTable>
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
case "TableRow":
|
|
218
|
+
return (
|
|
219
|
+
<ElmTableRow key={key}>
|
|
220
|
+
{render(component.slots.default)}
|
|
221
|
+
</ElmTableRow>
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
case "TableCell":
|
|
225
|
+
return (
|
|
226
|
+
<ElmTableCell key={key}>
|
|
227
|
+
{render(component.slots.default)}
|
|
228
|
+
</ElmTableCell>
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
case "ColumnList":
|
|
232
|
+
return (
|
|
233
|
+
<div key={key} class={styles["column-list"]}>
|
|
234
|
+
{render(component.slots.default)}
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
case "Column":
|
|
239
|
+
return (
|
|
240
|
+
<div
|
|
241
|
+
key={key}
|
|
242
|
+
class={styles.column}
|
|
243
|
+
style={{
|
|
244
|
+
"--width-ratio": component.props?.widthRatio || 1,
|
|
245
|
+
width: component.props?.widthRatio
|
|
246
|
+
? `${component.props.widthRatio * 100}%`
|
|
247
|
+
: undefined,
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
{render(component.slots.default)}
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
default:
|
|
255
|
+
return (
|
|
256
|
+
<div key={key} style={{ color: "red", border: "1px solid red" }}>
|
|
257
|
+
Unsupported component type: {component.type}
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<div class={styles["jarkup-body"]}>{render(props.jsonComponents)}</div>
|
|
266
|
+
);
|
|
267
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { component$, Slot, useContextProvider } from "@builder.io/qwik";
|
|
2
|
+
import { HasHeaderContext } from "./elm-table-header";
|
|
3
|
+
|
|
4
|
+
export type ElmTableBodyProps = object;
|
|
5
|
+
|
|
6
|
+
export const ElmTableBody = component$<ElmTableBodyProps>(() => {
|
|
7
|
+
useContextProvider(HasHeaderContext, false);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<tbody>
|
|
11
|
+
<Slot />
|
|
12
|
+
</tbody>
|
|
13
|
+
);
|
|
14
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.common {
|
|
2
|
+
padding: 0.75rem 1rem;
|
|
3
|
+
|
|
4
|
+
color: rgba(black, 0.7);
|
|
5
|
+
|
|
6
|
+
border-right: 1px dotted rgba(black, 0.15);
|
|
7
|
+
|
|
8
|
+
&::selection {
|
|
9
|
+
color: rgba(white, 0.7);
|
|
10
|
+
background-color: rgba(black, 0.7);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[data-theme="dark"] & {
|
|
14
|
+
color: rgba(white, 0.7);
|
|
15
|
+
|
|
16
|
+
&::selection {
|
|
17
|
+
color: rgba(black, 0.7);
|
|
18
|
+
background-color: rgba(white, 0.7);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[data-theme="dark"] & {
|
|
23
|
+
border-right: 1px dotted rgba(white, 0.15);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:last-child {
|
|
27
|
+
border-right: none;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.td {
|
|
32
|
+
border-top: 1px solid rgba(black, 0.15);
|
|
33
|
+
|
|
34
|
+
[data-theme="dark"] & {
|
|
35
|
+
border-top-color: rgba(white, 0.15);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.th {
|
|
40
|
+
background-color: rgba(gray, 0.15);
|
|
41
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { component$, Slot, useContext } from "@builder.io/qwik";
|
|
2
|
+
import styles from "./elm-table-cell.module.scss";
|
|
3
|
+
import { HasHeaderContext } from "./elm-table-header";
|
|
4
|
+
|
|
5
|
+
export interface ElmTableCellProps {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the cell is a header cell.
|
|
8
|
+
*/
|
|
9
|
+
hasHeader?: boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The text content of the cell.
|
|
13
|
+
* If not provided, the cell will render its children as content.
|
|
14
|
+
*/
|
|
15
|
+
text?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const ElmTableCell = component$<ElmTableCellProps>((props) => {
|
|
19
|
+
const { hasHeader = false, text } = props;
|
|
20
|
+
const hasHeaderInjected = useContext(HasHeaderContext, false);
|
|
21
|
+
|
|
22
|
+
const isHeader = hasHeader || (hasHeaderInjected as boolean | undefined);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
{isHeader ? (
|
|
27
|
+
<th class={[styles.common, styles.th]}>{text ? text : <Slot />}</th>
|
|
28
|
+
) : (
|
|
29
|
+
<td class={[styles.common, styles.td]}>{text ? text : <Slot />}</td>
|
|
30
|
+
)}
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
component$,
|
|
3
|
+
Slot,
|
|
4
|
+
createContextId,
|
|
5
|
+
useContextProvider,
|
|
6
|
+
} from "@builder.io/qwik";
|
|
7
|
+
import styles from "./elm-table-header.module.scss";
|
|
8
|
+
|
|
9
|
+
export const HasHeaderContext = createContextId<boolean>("HasHeaderContext");
|
|
10
|
+
|
|
11
|
+
export type ElmTableHeaderProps = object;
|
|
12
|
+
|
|
13
|
+
export const ElmTableHeader = component$<ElmTableHeaderProps>(() => {
|
|
14
|
+
useContextProvider(HasHeaderContext, true);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<thead class={styles.thead}>
|
|
18
|
+
<Slot />
|
|
19
|
+
</thead>
|
|
20
|
+
);
|
|
21
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.tr {
|
|
2
|
+
transition: background-color 200ms;
|
|
3
|
+
|
|
4
|
+
&:nth-child(odd) {
|
|
5
|
+
background-color: transparent;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&:nth-child(even) {
|
|
9
|
+
background-color: rgba(black, 0.015);
|
|
10
|
+
[data-theme="dark"] & {
|
|
11
|
+
background-color: rgba(white, 0.015);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
background-color: rgba(#6987b8, 0.15);
|
|
17
|
+
[data-theme="dark"] & {
|
|
18
|
+
background-color: rgba(#6987b8, 0.15);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.has-row-header {
|
|
24
|
+
td:first-child,
|
|
25
|
+
tr:first-child {
|
|
26
|
+
background-color: rgba(gray, 0.15);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { component$, Slot, useContext } from "@builder.io/qwik";
|
|
2
|
+
import styles from "./elm-table-row.module.scss";
|
|
3
|
+
import { HasRowHeaderContext } from "./elm-table";
|
|
4
|
+
|
|
5
|
+
export type ElmTableRowProps = object;
|
|
6
|
+
|
|
7
|
+
export const ElmTableRow = component$<ElmTableRowProps>(() => {
|
|
8
|
+
const hasRowHeader = useContext(HasRowHeaderContext);
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<tr class={[styles.tr, hasRowHeader.value && styles["has-row-header"]]}>
|
|
12
|
+
<Slot />
|
|
13
|
+
</tr>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.table {
|
|
2
|
+
margin-block: var(--margin-block);
|
|
3
|
+
border-collapse: collapse;
|
|
4
|
+
border-spacing: 0;
|
|
5
|
+
box-shadow: 0 0 0.125rem rgba(black, 0.2);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.caption {
|
|
9
|
+
position: relative;
|
|
10
|
+
width: 100%;
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 1rem;
|
|
15
|
+
margin-block-end: 1rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.caption-inner {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 0.25rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.spacing {
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
height: 1px;
|
|
28
|
+
background-color: rgba(gray, 0.2);
|
|
29
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "storybook-framework-qwik";
|
|
2
|
+
import { ElmTable } from "./elm-table";
|
|
3
|
+
import { ElmTableHeader } from "./elm-table-header";
|
|
4
|
+
import { ElmTableBody } from "./elm-table-body";
|
|
5
|
+
import { ElmTableRow } from "./elm-table-row";
|
|
6
|
+
import { ElmTableCell } from "./elm-table-cell";
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof ElmTable> = {
|
|
9
|
+
title: "Components/Table/elm-table",
|
|
10
|
+
component: ElmTable,
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
args: {
|
|
13
|
+
caption: "Example Table",
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Primary: Story = {
|
|
21
|
+
render() {
|
|
22
|
+
return (
|
|
23
|
+
<ElmTable {...this.args}>
|
|
24
|
+
<ElmTableHeader>
|
|
25
|
+
<ElmTableRow>
|
|
26
|
+
<ElmTableCell hasHeader text="Header 1" />
|
|
27
|
+
<ElmTableCell hasHeader text="Header 2" />
|
|
28
|
+
<ElmTableCell hasHeader text="Header 3" />
|
|
29
|
+
<ElmTableCell hasHeader text="Header 4" />
|
|
30
|
+
<ElmTableCell hasHeader text="Header 5" />
|
|
31
|
+
</ElmTableRow>
|
|
32
|
+
</ElmTableHeader>
|
|
33
|
+
|
|
34
|
+
<ElmTableBody>
|
|
35
|
+
<ElmTableRow>
|
|
36
|
+
<ElmTableCell text="Row 1, Cell 1" />
|
|
37
|
+
<ElmTableCell text="Row 1, Cell 2" />
|
|
38
|
+
<ElmTableCell text="Row 1, Cell 3" />
|
|
39
|
+
<ElmTableCell text="Row 1, Cell 4" />
|
|
40
|
+
<ElmTableCell text="Row 1, Cell 5" />
|
|
41
|
+
</ElmTableRow>
|
|
42
|
+
<ElmTableRow>
|
|
43
|
+
<ElmTableCell text="Row 2, Cell 1" />
|
|
44
|
+
<ElmTableCell text="Row 2, Cell 2" />
|
|
45
|
+
<ElmTableCell text="Row 2, Cell 3" />
|
|
46
|
+
<ElmTableCell text="Row 2, Cell 4" />
|
|
47
|
+
<ElmTableCell text="Row 2, Cell 5" />
|
|
48
|
+
</ElmTableRow>
|
|
49
|
+
<ElmTableRow>
|
|
50
|
+
<ElmTableCell text="Row 3, Cell 1" />
|
|
51
|
+
<ElmTableCell text="Row 3, Cell 2" />
|
|
52
|
+
<ElmTableCell text="Row 3, Cell 3" />
|
|
53
|
+
<ElmTableCell text="Row 3, Cell 4" />
|
|
54
|
+
<ElmTableCell text="Row 3, Cell 5" />
|
|
55
|
+
</ElmTableRow>
|
|
56
|
+
<ElmTableRow>
|
|
57
|
+
<ElmTableCell text="Row 4, Cell 1" />
|
|
58
|
+
<ElmTableCell text="Row 4, Cell 2" />
|
|
59
|
+
<ElmTableCell text="Row 4, Cell 3" />
|
|
60
|
+
<ElmTableCell text="Row 4, Cell 4" />
|
|
61
|
+
<ElmTableCell text="Row 4, Cell 5" />
|
|
62
|
+
</ElmTableRow>
|
|
63
|
+
</ElmTableBody>
|
|
64
|
+
</ElmTable>
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
component$,
|
|
3
|
+
Slot,
|
|
4
|
+
createContextId,
|
|
5
|
+
useContextProvider,
|
|
6
|
+
useComputed$,
|
|
7
|
+
} from "@builder.io/qwik";
|
|
8
|
+
import type { CSSProperties } from "@builder.io/qwik";
|
|
9
|
+
import styles from "./elm-table.module.scss";
|
|
10
|
+
import textStyles from "../../styles/text.module.scss";
|
|
11
|
+
import { ElmInlineText } from "../typography/elm-inline-text";
|
|
12
|
+
|
|
13
|
+
export const HasRowHeaderContext = createContextId<
|
|
14
|
+
Readonly<{ value: boolean }>
|
|
15
|
+
>("HasRowHeaderContext");
|
|
16
|
+
|
|
17
|
+
export interface ElmTableProps {
|
|
18
|
+
/**
|
|
19
|
+
* The margin of the table.
|
|
20
|
+
*/
|
|
21
|
+
margin?: CSSProperties["marginBlock"];
|
|
22
|
+
|
|
23
|
+
caption?: string;
|
|
24
|
+
|
|
25
|
+
hasRowHeader?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const ElmTable = component$<ElmTableProps>((props) => {
|
|
29
|
+
const { margin, caption, hasRowHeader = false } = props;
|
|
30
|
+
|
|
31
|
+
const hasRowHeaderComputed = useComputed$(() => hasRowHeader);
|
|
32
|
+
useContextProvider(HasRowHeaderContext, hasRowHeaderComputed);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<table
|
|
36
|
+
class={[styles.table, textStyles.text]}
|
|
37
|
+
style={{
|
|
38
|
+
"--margin-block": margin,
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{caption && (
|
|
42
|
+
<caption>
|
|
43
|
+
<span class={styles["caption"]}>
|
|
44
|
+
<span class={styles.spacing}></span>
|
|
45
|
+
|
|
46
|
+
<span class={styles["caption-inner"]}>
|
|
47
|
+
<svg viewBox="0 0 24 24" width="1rem" height="1rem">
|
|
48
|
+
<path
|
|
49
|
+
d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4M12,6A6,6 0 0,0 6,12A6,6 0 0,0 12,18A6,6 0 0,0 18,12A6,6 0 0,0 12,6M12,8A4,4 0 0,1 16,12A4,4 0 0,1 12,16A4,4 0 0,1 8,12A4,4 0 0,1 12,8Z"
|
|
50
|
+
fill="#6987b8"
|
|
51
|
+
/>
|
|
52
|
+
</svg>
|
|
53
|
+
<ElmInlineText text={caption} />
|
|
54
|
+
</span>
|
|
55
|
+
|
|
56
|
+
<span class={styles.spacing}></span>
|
|
57
|
+
</span>
|
|
58
|
+
</caption>
|
|
59
|
+
)}
|
|
60
|
+
<Slot />
|
|
61
|
+
</table>
|
|
62
|
+
);
|
|
63
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.blockquote {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
width: 100%;
|
|
4
|
+
margin: 0;
|
|
5
|
+
background-color: rgba(#868e9c, 0.1);
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
&::after {
|
|
9
|
+
position: absolute;
|
|
10
|
+
content: "";
|
|
11
|
+
top: 0;
|
|
12
|
+
left: 0;
|
|
13
|
+
width: 4px;
|
|
14
|
+
height: 100%;
|
|
15
|
+
background-color: #868e9c;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.body {
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
padding: 2rem 1.5rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.icon {
|
|
25
|
+
position: absolute;
|
|
26
|
+
content: "";
|
|
27
|
+
inset: var(--inset);
|
|
28
|
+
opacity: 0.5;
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "storybook-framework-qwik";
|
|
2
|
+
import { ElmBlockQuote } from "./elm-block-quote";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ElmBlockQuote> = {
|
|
5
|
+
title: "Components/Typography/elm-block-quote",
|
|
6
|
+
component: ElmBlockQuote,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
args: {},
|
|
9
|
+
render() {
|
|
10
|
+
return (
|
|
11
|
+
<ElmBlockQuote>
|
|
12
|
+
Only a fool learns from his own mistakes. The wise man learns from the
|
|
13
|
+
mistakes of others.
|
|
14
|
+
</ElmBlockQuote>
|
|
15
|
+
);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
|
|
22
|
+
export const Primary: Story = {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { component$, Slot } from "@builder.io/qwik";
|
|
2
|
+
|
|
3
|
+
import styles from "./elm-block-quote.module.scss";
|
|
4
|
+
import textStyles from "../../styles/text.module.scss";
|
|
5
|
+
import { ElmMdiIcon } from "../icon/elm-mdi-icon";
|
|
6
|
+
import { mdiFormatQuoteClose, mdiFormatQuoteOpen } from "@mdi/js";
|
|
7
|
+
|
|
8
|
+
export interface ElmBlockQuoteProps {
|
|
9
|
+
cite?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ElmBlockQuote = component$<ElmBlockQuoteProps>(({ cite }) => {
|
|
13
|
+
return (
|
|
14
|
+
<blockquote class={[styles.blockquote, textStyles.text]} cite={cite}>
|
|
15
|
+
<div
|
|
16
|
+
class={styles.icon}
|
|
17
|
+
style={{ "--inset": "0.25rem auto auto 0.5rem" }}
|
|
18
|
+
>
|
|
19
|
+
<ElmMdiIcon d={mdiFormatQuoteOpen} />
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div class={[styles.body]}>
|
|
23
|
+
<Slot />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div
|
|
27
|
+
class={styles.icon}
|
|
28
|
+
style={{ "--inset": "auto 0.25rem 0.25rem auto" }}
|
|
29
|
+
>
|
|
30
|
+
<ElmMdiIcon d={mdiFormatQuoteClose} />
|
|
31
|
+
</div>
|
|
32
|
+
</blockquote>
|
|
33
|
+
);
|
|
34
|
+
});
|