Skip to content

Commit 27488e1

Browse files
committed
docs(copy-css-config): use highlight instead of plain string
1 parent 25a36ce commit 27488e1

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

apps/website/src/components/copy-css-config/copy-css-config.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { extractThemeCSS } from '@qwik-ui/utils';
55
import { LuX } from '@qwikest/icons/lucide';
66
import { useTheme } from 'qwik-themes';
77
import globalCSS from '~/global.css?raw';
8+
import { Highlight } from '../highlight/highlight';
89

910
export default component$(() => {
1011
const showSig = useSignal(false);
@@ -17,34 +18,30 @@ export default component$(() => {
1718
<>
1819
<Button
1920
onClick$={() => {
20-
showSig.value = true;
2121
cssThemeOutput.value = extractThemeCSS(
2222
theme === 'dark' || theme === 'light'
2323
? 'border-radius-0 simple primary-cyan-600 light base-slate'
2424
: theme,
2525
globalCSS,
2626
);
27+
showSig.value = true;
2728
}}
2829
>
2930
Copy code
3031
</Button>
3132
<Modal
3233
bind:show={showSig}
33-
class="my-animation h-full max-w-2xl overflow-x-hidden rounded-base bg-background p-8 text-foreground shadow-md backdrop:backdrop-blur backdrop:backdrop-brightness-50 dark:backdrop:backdrop-brightness-100"
34+
class="my-animation h-[650px] max-w-2xl overflow-x-hidden rounded-base p-8 shadow-md backdrop:backdrop-blur backdrop:backdrop-brightness-50 dark:backdrop:backdrop-brightness-100"
3435
>
3536
<ModalHeader>
36-
<h2 class="text-lg font-bold">Copy config</h2>
37-
<p>
37+
<h2 class="mb-2 text-lg font-bold">Copy config</h2>
38+
<p class="mb-6">
3839
Copy and paste the following code into your global.css file to apply the
3940
styles.
4041
</p>
4142
</ModalHeader>
42-
<ModalContent class="mb-2 pb-4 pt-2">
43-
<div>
44-
<pre>
45-
<code>{cssThemeOutput.value}</code>
46-
</pre>
47-
</div>
43+
<ModalContent>
44+
<Highlight code={cssThemeOutput.value} language="css" />
4845
</ModalContent>
4946
<button
5047
onClick$={() => (showSig.value = false)}

apps/website/src/components/highlight/highlight.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export const Highlight = component$(
3131
}: HighlightProps) => {
3232
const codeSig = useSignal('');
3333

34+
useVisibleTask$(({ track }) => {
35+
track(() => codeSig.value);
36+
console.log('codeSig changed: ', codeSig.value);
37+
});
38+
3439
const addShiki$ = $(async () => {
3540
let modifiedCode: string = code;
3641

@@ -67,15 +72,17 @@ export const Highlight = component$(
6772
codeSig.value = str.toString();
6873
});
6974

70-
useTask$(async function createHighlightedCode() {
75+
useTask$(async ({ track }) => {
76+
track(() => code);
7177
if (!isDev) {
7278
await addShiki$();
7379
}
7480
});
7581

7682
// eslint-disable-next-line qwik/no-use-visible-task
7783
useVisibleTask$(
78-
async () => {
84+
async ({ track }) => {
85+
track(() => code);
7986
if (isDev) {
8087
await addShiki$();
8188
}

0 commit comments

Comments
 (0)