@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,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$,
|
|
3
|
+
component$,
|
|
4
|
+
CSSProperties,
|
|
5
|
+
Slot,
|
|
6
|
+
useSignal,
|
|
7
|
+
} from "@builder.io/qwik";
|
|
8
|
+
|
|
9
|
+
import styles from "./elm-code-block.module.scss";
|
|
10
|
+
|
|
11
|
+
import { ElmLanguageIcon } from "../icon/elm-language-icon";
|
|
12
|
+
import { ElmInlineText } from "../typography/elm-inline-text";
|
|
13
|
+
import { ElmShikiHighlighter } from "./elm-shiki-highlighter";
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
mdiClipboardMultipleOutline,
|
|
17
|
+
mdiClipboardCheckMultipleOutline,
|
|
18
|
+
} from "@mdi/js";
|
|
19
|
+
import { ElmMdiIcon } from "../icon/elm-mdi-icon";
|
|
20
|
+
|
|
21
|
+
export interface ElmCodeBlockProps {
|
|
22
|
+
/**
|
|
23
|
+
* The code to display.
|
|
24
|
+
*/
|
|
25
|
+
code: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The language of the code.
|
|
29
|
+
*/
|
|
30
|
+
language?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The caption of the code block.
|
|
34
|
+
* If not provided, the language will be used.
|
|
35
|
+
*/
|
|
36
|
+
caption?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The margin of the code block.
|
|
40
|
+
*/
|
|
41
|
+
margin?: CSSProperties["margin"];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const ElmCodeBlock = component$<ElmCodeBlockProps>(
|
|
45
|
+
({ code, language = "txt", caption, margin }) => {
|
|
46
|
+
const timerId = useSignal<number | null>(null);
|
|
47
|
+
|
|
48
|
+
const copyToClipboard = $(async () => {
|
|
49
|
+
if (timerId.value !== null) {
|
|
50
|
+
window.clearTimeout(timerId.value);
|
|
51
|
+
timerId.value = null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
await navigator.clipboard.writeText(code);
|
|
56
|
+
timerId.value = window.setTimeout(() => (timerId.value = null), 1500);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error("Failed to copy: ", err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<figure class={styles["code-block"]} style={{ margin }}>
|
|
64
|
+
<span class={styles["language-icon"]}>
|
|
65
|
+
<ElmLanguageIcon language={language} />
|
|
66
|
+
</span>
|
|
67
|
+
|
|
68
|
+
<span class={styles["caption"]}>
|
|
69
|
+
<ElmInlineText>
|
|
70
|
+
{caption || language}
|
|
71
|
+
<Slot />
|
|
72
|
+
</ElmInlineText>
|
|
73
|
+
</span>
|
|
74
|
+
|
|
75
|
+
<div class={styles["copy-icon"]} onClick$={copyToClipboard}>
|
|
76
|
+
<ElmMdiIcon
|
|
77
|
+
size="1.25rem"
|
|
78
|
+
d={
|
|
79
|
+
timerId.value !== null
|
|
80
|
+
? mdiClipboardCheckMultipleOutline
|
|
81
|
+
: mdiClipboardMultipleOutline
|
|
82
|
+
}
|
|
83
|
+
color={timerId.value !== null ? "#59b57c" : undefined}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<hr class={styles["divider"]} />
|
|
88
|
+
|
|
89
|
+
<div class={styles["code"]}>
|
|
90
|
+
<ElmShikiHighlighter code={code} language={language} />
|
|
91
|
+
</div>
|
|
92
|
+
</figure>
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "storybook-framework-qwik";
|
|
2
|
+
import { ElmKatex } from "./elm-katex";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ElmKatex> = {
|
|
5
|
+
title: "Components/Code/elm-katex",
|
|
6
|
+
component: ElmKatex,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
args: {},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
export const Inline: Story = {
|
|
15
|
+
args: { expression: "c = pmsqrt{a^2 + b^2}" },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const Block: Story = {
|
|
19
|
+
args: { expression: "c = pmsqrt{a^2 + b^2}", block: true },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Complex: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
expression:
|
|
25
|
+
"i\\hbar \\frac{\\partial}{\\partial t} \\Psi(\\mathbf{r}, t) = \\left( -\\frac{\\hbar^2}{2m} \\nabla^2 + V(\\mathbf{r}, t) \\right) \\Psi(\\mathbf{r}, t)",
|
|
26
|
+
block: true,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { component$, useComputed$ } from "@builder.io/qwik";
|
|
2
|
+
|
|
3
|
+
import textStyle from "../../styles/text.module.scss";
|
|
4
|
+
|
|
5
|
+
import { renderToString } from "katex";
|
|
6
|
+
|
|
7
|
+
export interface ElmKatexProps {
|
|
8
|
+
/**
|
|
9
|
+
* The KaTex expression.
|
|
10
|
+
*/
|
|
11
|
+
expression: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whether to render the equation in block mode.
|
|
15
|
+
* - If `true`, the equation will be rendered in block mode.
|
|
16
|
+
* - If `false`, the equation will be rendered in inline mode.
|
|
17
|
+
*
|
|
18
|
+
* Default is `false`.
|
|
19
|
+
*/
|
|
20
|
+
block?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ElmKatex = component$<ElmKatexProps>(
|
|
24
|
+
({ expression, block = false }) => {
|
|
25
|
+
const html = useComputed$(() =>
|
|
26
|
+
renderToString(expression, {
|
|
27
|
+
displayMode: block,
|
|
28
|
+
output: "mathml",
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return <div class={textStyle.text} dangerouslySetInnerHTML={html.value} />;
|
|
33
|
+
},
|
|
34
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.shiki,
|
|
2
|
+
.shiki span {
|
|
3
|
+
font-family:
|
|
4
|
+
"Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace !important;
|
|
5
|
+
|
|
6
|
+
*::selection {
|
|
7
|
+
background-color: rgba(black, 0.1);
|
|
8
|
+
|
|
9
|
+
[data-theme="dark"] & {
|
|
10
|
+
background-color: rgba(white, 0.15);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[data-theme="dark"] & {
|
|
15
|
+
color: var(--shiki-dark) !important;
|
|
16
|
+
background-color: var(--shiki-dark-bg) !important;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "storybook-framework-qwik";
|
|
2
|
+
import { ElmShikiHighlighter } from "./elm-shiki-highlighter";
|
|
3
|
+
|
|
4
|
+
import code from "./seed/main.rs?raw";
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof ElmShikiHighlighter> = {
|
|
7
|
+
title: "Components/Code/elm-shiki-highlighter",
|
|
8
|
+
component: ElmShikiHighlighter,
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
args: {},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Primary: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
code: code,
|
|
19
|
+
language: "rust",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { component$, useSignal, useTask$ } from "@builder.io/qwik";
|
|
2
|
+
|
|
3
|
+
import "./elm-shiki-highlighter.global.scss";
|
|
4
|
+
|
|
5
|
+
export interface ElmShikiHighlighterProps {
|
|
6
|
+
/**
|
|
7
|
+
* The code to display.
|
|
8
|
+
*/
|
|
9
|
+
code: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The language of the code.
|
|
13
|
+
*/
|
|
14
|
+
language?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ElmShikiHighlighter = component$<ElmShikiHighlighterProps>(
|
|
18
|
+
({ code, language = "txt" }) => {
|
|
19
|
+
const rawHtml = useSignal("");
|
|
20
|
+
|
|
21
|
+
useTask$(async ({ track }) => {
|
|
22
|
+
const currentCode = track(() => code);
|
|
23
|
+
const currentLang = track(() => language);
|
|
24
|
+
|
|
25
|
+
const { getHighlighterSingleton } = await import("./shikiInstance");
|
|
26
|
+
const highlighter = await getHighlighterSingleton();
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
rawHtml.value = highlighter.codeToHtml(currentCode, {
|
|
30
|
+
lang: currentLang,
|
|
31
|
+
themes: { dark: "vitesse-dark", light: "vitesse-light" },
|
|
32
|
+
colorReplacements: {
|
|
33
|
+
"#ffffff": "transparent",
|
|
34
|
+
"#121212": "transparent",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
} catch {
|
|
38
|
+
rawHtml.value = `<pre>${currentCode.replace(/</g, "<")}</pre>`;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return <pre dangerouslySetInnerHTML={rawHtml.value} />;
|
|
43
|
+
},
|
|
44
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
use reqwest::Error;
|
|
2
|
+
use serde::{Deserialize, Serialize};
|
|
3
|
+
|
|
4
|
+
#[derive(Serialize, Deserialize, Debug)]
|
|
5
|
+
struct Post {
|
|
6
|
+
#[serde(rename = "userId")]
|
|
7
|
+
user_id: u32,
|
|
8
|
+
id: u32,
|
|
9
|
+
title: String,
|
|
10
|
+
body: String,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#[tokio::main]
|
|
14
|
+
async fn main() -> Result<(), Error> {
|
|
15
|
+
let url = "https://jsonplaceholder.typicode.com/posts";
|
|
16
|
+
let response = reqwest::get(url).await?;
|
|
17
|
+
let posts: Vec<Post> = response.json().await?;
|
|
18
|
+
|
|
19
|
+
for post in posts.iter().take(5) {
|
|
20
|
+
println!("ID: {}, Title: {}", post.id, post.title);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Ok(())
|
|
24
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// shikiInstance.ts
|
|
2
|
+
import { createHighlighter, Highlighter } from "shiki";
|
|
3
|
+
|
|
4
|
+
let highlighterPromise: Promise<Highlighter> | null = null;
|
|
5
|
+
|
|
6
|
+
export function getHighlighterSingleton() {
|
|
4
7
|
if (!highlighterPromise) {
|
|
5
8
|
highlighterPromise = createHighlighter({
|
|
6
9
|
langs: [
|
|
@@ -64,16 +67,10 @@ function getHighlighterSingleton() {
|
|
|
64
67
|
"typescript",
|
|
65
68
|
"wasm",
|
|
66
69
|
"xml",
|
|
67
|
-
"yaml"
|
|
70
|
+
"yaml",
|
|
68
71
|
],
|
|
69
|
-
themes: [
|
|
70
|
-
"vitesse-light",
|
|
71
|
-
"vitesse-dark"
|
|
72
|
-
]
|
|
72
|
+
themes: ["vitesse-light", "vitesse-dark"],
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
return highlighterPromise;
|
|
76
76
|
}
|
|
77
|
-
export {
|
|
78
|
-
getHighlighterSingleton
|
|
79
|
-
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
.toggle {
|
|
2
|
+
margin: 0;
|
|
3
|
+
display: grid;
|
|
4
|
+
transition: grid 200ms;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
&.toggle-closed {
|
|
8
|
+
grid-template-rows: 3.5rem 0fr 0rem;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&.toggle-open {
|
|
12
|
+
grid-template-rows: 3.5rem 1fr 3rem;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.summary {
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
padding-inline: 1rem;
|
|
19
|
+
|
|
20
|
+
display: grid;
|
|
21
|
+
grid-template-columns: min-content 1fr min-content;
|
|
22
|
+
gap: 1rem;
|
|
23
|
+
align-items: center;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
|
|
26
|
+
border: 1px solid rgba(black, 0.125);
|
|
27
|
+
background-color: rgba(#3e434b, 0.05);
|
|
28
|
+
|
|
29
|
+
[data-theme="dark"] & {
|
|
30
|
+
border: 1px solid rgba(white, 0.125);
|
|
31
|
+
background-color: rgba(#bec2ca, 0.1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.summary-open {
|
|
35
|
+
border-radius: 0.25rem 0.25rem 0 0;
|
|
36
|
+
border-bottom-color: transparent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.summary-closed {
|
|
40
|
+
border-radius: 0.25rem;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.chevron-icon {
|
|
45
|
+
transition: transform 200ms;
|
|
46
|
+
|
|
47
|
+
&.chevron-icon-open {
|
|
48
|
+
transform: rotate(90deg);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.chevron-icon-closed {
|
|
52
|
+
transform: rotate(0deg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.plus-icon {
|
|
57
|
+
height: 1rem;
|
|
58
|
+
width: 1rem;
|
|
59
|
+
transform-origin: center;
|
|
60
|
+
transition: transform 200ms;
|
|
61
|
+
|
|
62
|
+
&.plus-icon-open {
|
|
63
|
+
transform: rotate(135deg);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.plus-icon-closed {
|
|
67
|
+
transform: rotate(0deg);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.content {
|
|
72
|
+
box-sizing: border-box;
|
|
73
|
+
padding: 1rem;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
transition: opacity 200ms;
|
|
76
|
+
|
|
77
|
+
border: 1px solid rgba(black, 0.125);
|
|
78
|
+
border-radius: 0 0 0.25rem 0.25rem;
|
|
79
|
+
background-color: rgba(#3e434b, 0.0125);
|
|
80
|
+
|
|
81
|
+
[data-theme="dark"] & {
|
|
82
|
+
border-color: rgba(white, 0.125);
|
|
83
|
+
background-color: rgba(#bec2ca, 0.025);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&.content-open {
|
|
87
|
+
opacity: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&.content-closed {
|
|
91
|
+
opacity: 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.footer {
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
margin: 0.25rem 0rem;
|
|
98
|
+
padding: 0.5rem;
|
|
99
|
+
color: #c56565;
|
|
100
|
+
font-family: monospace;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
gap: 0.5rem;
|
|
105
|
+
user-select: none;
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
border-radius: 0.25rem;
|
|
108
|
+
transition:
|
|
109
|
+
opacity 200ms,
|
|
110
|
+
background-color 200ms;
|
|
111
|
+
|
|
112
|
+
&:hover {
|
|
113
|
+
opacity: 0.5;
|
|
114
|
+
background-color: rgba(#606875, 0.1);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&.footer-line {
|
|
118
|
+
box-sizing: border-box;
|
|
119
|
+
margin: 0 0.25rem;
|
|
120
|
+
flex-grow: 1;
|
|
121
|
+
border: none;
|
|
122
|
+
border-bottom: solid 1px rgba(gray, 0.3);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&.footer-cross-icon {
|
|
126
|
+
transform: rotate(45deg);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&.footer-chevron-icon {
|
|
130
|
+
transform: rotate(-90deg);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "storybook-framework-qwik";
|
|
2
|
+
import { ElmToggle } from "./elm-toggle";
|
|
3
|
+
import { ElmHeading } from "../typography/elm-heading";
|
|
4
|
+
import { ElmParagraph } from "../typography/elm-paragraph";
|
|
5
|
+
import { ElmInlineText } from "../typography/elm-inline-text";
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ElmToggle> = {
|
|
8
|
+
title: "Components/Containments/elm-toggle",
|
|
9
|
+
component: ElmToggle,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
args: {},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
type Story = StoryObj<typeof meta>;
|
|
16
|
+
|
|
17
|
+
export const Primary: Story = {
|
|
18
|
+
render() {
|
|
19
|
+
return (
|
|
20
|
+
<ElmToggle {...this.args}>
|
|
21
|
+
<div q:slot="summary">
|
|
22
|
+
<ElmInlineText>Click me to toggle</ElmInlineText>
|
|
23
|
+
</div>
|
|
24
|
+
<div>
|
|
25
|
+
<ElmHeading level={2}>Body</ElmHeading>
|
|
26
|
+
<ElmParagraph>
|
|
27
|
+
This is the body of the toggle. You can put any content here, and it
|
|
28
|
+
will be shown or hidden when you click the summary.
|
|
29
|
+
</ElmParagraph>
|
|
30
|
+
</div>
|
|
31
|
+
</ElmToggle>
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { $, component$, Slot, useSignal } from "@builder.io/qwik";
|
|
2
|
+
|
|
3
|
+
import styles from "./elm-toggle.module.scss";
|
|
4
|
+
import { ElmMdiIcon } from "../icon/elm-mdi-icon";
|
|
5
|
+
import { mdiChevronRight, mdiPlus } from "@mdi/js";
|
|
6
|
+
import { ElmInlineText } from "../typography/elm-inline-text";
|
|
7
|
+
|
|
8
|
+
export interface ElmToggleProps {
|
|
9
|
+
/**
|
|
10
|
+
* The summary of the toggle.
|
|
11
|
+
*/
|
|
12
|
+
summary?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const ElmToggle = component$<ElmToggleProps>(({ summary }) => {
|
|
16
|
+
const isOpen = useSignal(false);
|
|
17
|
+
|
|
18
|
+
const toggle = $(() => {
|
|
19
|
+
isOpen.value = !isOpen.value;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
class={[
|
|
25
|
+
styles["toggle"],
|
|
26
|
+
{
|
|
27
|
+
[styles["toggle-open"]]: isOpen.value,
|
|
28
|
+
[styles["toggle-closed"]]: !isOpen.value,
|
|
29
|
+
},
|
|
30
|
+
]}
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
class={[
|
|
34
|
+
styles["summary"],
|
|
35
|
+
{
|
|
36
|
+
[styles["summary-open"]]: isOpen.value,
|
|
37
|
+
[styles["summary-closed"]]: !isOpen.value,
|
|
38
|
+
},
|
|
39
|
+
]}
|
|
40
|
+
onClick$={toggle}
|
|
41
|
+
>
|
|
42
|
+
<span
|
|
43
|
+
class={[
|
|
44
|
+
styles["chevron-icon"],
|
|
45
|
+
{
|
|
46
|
+
[styles["chevron-icon-open"]]: isOpen.value,
|
|
47
|
+
[styles["chevron-icon-closed"]]: !isOpen.value,
|
|
48
|
+
},
|
|
49
|
+
]}
|
|
50
|
+
>
|
|
51
|
+
<ElmMdiIcon d={mdiChevronRight} />
|
|
52
|
+
</span>
|
|
53
|
+
|
|
54
|
+
<span class={styles["summary-text"]}>
|
|
55
|
+
{summary ? summary : <Slot name="summary" />}
|
|
56
|
+
</span>
|
|
57
|
+
|
|
58
|
+
<span
|
|
59
|
+
class={[
|
|
60
|
+
styles["plus-icon"],
|
|
61
|
+
{
|
|
62
|
+
[styles["plus-icon-open"]]: isOpen.value,
|
|
63
|
+
[styles["plus-icon-closed"]]: !isOpen.value,
|
|
64
|
+
},
|
|
65
|
+
]}
|
|
66
|
+
>
|
|
67
|
+
<ElmMdiIcon
|
|
68
|
+
d={mdiPlus}
|
|
69
|
+
color={isOpen.value ? "#c56565" : "#59b57c"}
|
|
70
|
+
size="1rem"
|
|
71
|
+
/>
|
|
72
|
+
</span>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<div
|
|
76
|
+
class={[
|
|
77
|
+
styles["content"],
|
|
78
|
+
{
|
|
79
|
+
[styles["content-open"]]: isOpen.value,
|
|
80
|
+
[styles["content-closed"]]: !isOpen.value,
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
>
|
|
84
|
+
<Slot />
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div class={styles.footer} onClick$={toggle}>
|
|
88
|
+
<span class={styles["footer-chevron-icon"]}>
|
|
89
|
+
<ElmMdiIcon d={mdiChevronRight} color="gray" />
|
|
90
|
+
</span>
|
|
91
|
+
<hr class={styles["footer-line"]} />
|
|
92
|
+
<span class={styles["footer-cross-icon"]}>
|
|
93
|
+
<ElmMdiIcon d={mdiPlus} color="#c56565" />
|
|
94
|
+
</span>
|
|
95
|
+
<ElmInlineText>CLOSE</ElmInlineText>
|
|
96
|
+
<span class={styles["footer-cross-icon"]}>
|
|
97
|
+
<ElmMdiIcon d={mdiPlus} color="#c56565" />
|
|
98
|
+
</span>
|
|
99
|
+
<hr class={styles["footer-line"]} />
|
|
100
|
+
<span class={styles["footer-chevron-icon"]}>
|
|
101
|
+
<ElmMdiIcon d={mdiChevronRight} color="gray" />
|
|
102
|
+
</span>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "storybook-framework-qwik";
|
|
2
|
+
import { ElmBlockFallback } from "./elm-block-fallback";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ElmBlockFallback> = {
|
|
5
|
+
title: "Components/Fallback/elm-block-fallback",
|
|
6
|
+
component: ElmBlockFallback,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
args: {},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
export const Primary: Story = {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { component$, CSSProperties } from "@builder.io/qwik";
|
|
2
|
+
|
|
3
|
+
import styles from "./elm-block-fallback.module.scss";
|
|
4
|
+
import { ElmDotLoadingIcon } from "../icon/elm-dot-loading-icon";
|
|
5
|
+
import { ElmRectangleWave } from "./elm-rectangle-wave";
|
|
6
|
+
|
|
7
|
+
export interface ElmBlockFallbackProps {
|
|
8
|
+
height?: CSSProperties["height"];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ElmBlockFallback = component$<ElmBlockFallbackProps>(
|
|
12
|
+
({ height = "16rem" }) => {
|
|
13
|
+
return (
|
|
14
|
+
<div class={styles["block-fallback"]} style={{ "--height": height }}>
|
|
15
|
+
<ElmDotLoadingIcon />
|
|
16
|
+
<ElmRectangleWave />
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@keyframes elm-rectangle-wave {
|
|
2
|
+
0% {
|
|
3
|
+
transform: scale(0);
|
|
4
|
+
opacity: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
30% {
|
|
8
|
+
opacity: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
40% {
|
|
12
|
+
opacity: 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
100% {
|
|
16
|
+
transform: scale(1);
|
|
17
|
+
opacity: 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rectangle-wave {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
position: absolute;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
|
|
26
|
+
margin: 0;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
|
|
30
|
+
animation-name: elm-rectangle-wave;
|
|
31
|
+
animation-duration: 1200ms;
|
|
32
|
+
animation-iteration-count: infinite;
|
|
33
|
+
animation-fill-mode: both;
|
|
34
|
+
|
|
35
|
+
border-style: solid;
|
|
36
|
+
border-width: 1px;
|
|
37
|
+
border-color: rgba(0, 0, 0, 0.7);
|
|
38
|
+
|
|
39
|
+
[data-theme="dark"] & {
|
|
40
|
+
border-color: rgba(255, 255, 255, 0.7);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "storybook-framework-qwik";
|
|
2
|
+
import { ElmRectangleWave } from "./elm-rectangle-wave";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ElmRectangleWave> = {
|
|
5
|
+
title: "Components/Fallback/elm-rectangle-wave",
|
|
6
|
+
component: ElmRectangleWave,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
args: {},
|
|
9
|
+
render() {
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
style={{
|
|
13
|
+
width: "100%",
|
|
14
|
+
aspectRatio: "2/1",
|
|
15
|
+
margin: 0,
|
|
16
|
+
position: "relative",
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
<ElmRectangleWave />
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
export const Primary: Story = {};
|