components-svelte 0.1.0
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/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/components/Search.svelte +320 -0
- package/dist/components/Search.svelte.d.ts +31 -0
- package/dist/components/SearchButton.svelte +82 -0
- package/dist/components/SearchButton.svelte.d.ts +13 -0
- package/dist/components/SearchProvider.svelte +87 -0
- package/dist/components/SearchProvider.svelte.d.ts +17 -0
- package/dist/components/accordion/Accordion.svelte +150 -0
- package/dist/components/accordion/Accordion.svelte.d.ts +25 -0
- package/dist/components/accordion/AccordionCover.svelte +68 -0
- package/dist/components/accordion/AccordionCover.svelte.d.ts +13 -0
- package/dist/components/accordion/AccordionGroup.svelte +23 -0
- package/dist/components/accordion/AccordionGroup.svelte.d.ts +8 -0
- package/dist/components/accordion/accordion-url-utils.d.ts +4 -0
- package/dist/components/accordion/accordion-url-utils.js +48 -0
- package/dist/components/accordion/index.d.ts +29 -0
- package/dist/components/accordion/index.js +6 -0
- package/dist/components/badge/Badge.svelte +152 -0
- package/dist/components/badge/Badge.svelte.d.ts +23 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +2 -0
- package/dist/components/callout/Callout.svelte +317 -0
- package/dist/components/callout/Callout.svelte.d.ts +17 -0
- package/dist/components/callout/Check.svelte +9 -0
- package/dist/components/callout/Check.svelte.d.ts +4 -0
- package/dist/components/callout/Danger.svelte +9 -0
- package/dist/components/callout/Danger.svelte.d.ts +4 -0
- package/dist/components/callout/Info.svelte +9 -0
- package/dist/components/callout/Info.svelte.d.ts +4 -0
- package/dist/components/callout/Note.svelte +9 -0
- package/dist/components/callout/Note.svelte.d.ts +4 -0
- package/dist/components/callout/Tip.svelte +9 -0
- package/dist/components/callout/Tip.svelte.d.ts +4 -0
- package/dist/components/callout/Warning.svelte +9 -0
- package/dist/components/callout/Warning.svelte.d.ts +4 -0
- package/dist/components/callout/index.d.ts +8 -0
- package/dist/components/callout/index.js +8 -0
- package/dist/components/card/Card.svelte +172 -0
- package/dist/components/card/Card.svelte.d.ts +21 -0
- package/dist/components/card/index.d.ts +3 -0
- package/dist/components/card/index.js +2 -0
- package/dist/components/code-block/BaseCodeBlock.svelte +249 -0
- package/dist/components/code-block/BaseCodeBlock.svelte.d.ts +10 -0
- package/dist/components/code-block/CodeBlock.svelte +185 -0
- package/dist/components/code-block/CodeBlock.svelte.d.ts +5 -0
- package/dist/components/code-block/CodeFooter.svelte +34 -0
- package/dist/components/code-block/CodeFooter.svelte.d.ts +8 -0
- package/dist/components/code-block/CodeHeader.svelte +52 -0
- package/dist/components/code-block/CodeHeader.svelte.d.ts +11 -0
- package/dist/components/code-block/CopyToClipboardButton.svelte +124 -0
- package/dist/components/code-block/CopyToClipboardButton.svelte.d.ts +4 -0
- package/dist/components/code-block/index.d.ts +10 -0
- package/dist/components/code-block/index.js +5 -0
- package/dist/components/code-block/types.d.ts +85 -0
- package/dist/components/code-block/types.js +1 -0
- package/dist/components/code-group/CodeGroup.svelte +327 -0
- package/dist/components/code-group/CodeGroup.svelte.d.ts +24 -0
- package/dist/components/code-group/CodeGroupSelect.svelte +170 -0
- package/dist/components/code-group/CodeGroupSelect.svelte.d.ts +25 -0
- package/dist/components/code-group/CodeSelectDropdown.svelte +74 -0
- package/dist/components/code-group/CodeSelectDropdown.svelte.d.ts +9 -0
- package/dist/components/code-group/LanguageDropdown.svelte +134 -0
- package/dist/components/code-group/LanguageDropdown.svelte.d.ts +11 -0
- package/dist/components/code-group/LanguageIcon.svelte +24 -0
- package/dist/components/code-group/LanguageIcon.svelte.d.ts +8 -0
- package/dist/components/code-group/context.d.ts +14 -0
- package/dist/components/code-group/context.js +2 -0
- package/dist/components/code-group/index.d.ts +8 -0
- package/dist/components/code-group/index.js +4 -0
- package/dist/components/color/Color.svelte +34 -0
- package/dist/components/color/Color.svelte.d.ts +10 -0
- package/dist/components/color/ColorItem.svelte +140 -0
- package/dist/components/color/ColorItem.svelte.d.ts +10 -0
- package/dist/components/color/ColorRow.svelte +27 -0
- package/dist/components/color/ColorRow.svelte.d.ts +8 -0
- package/dist/components/color/index.d.ts +1 -0
- package/dist/components/color/index.js +8 -0
- package/dist/components/columns/Box.svelte +15 -0
- package/dist/components/columns/Box.svelte.d.ts +7 -0
- package/dist/components/columns/Columns.svelte +31 -0
- package/dist/components/columns/Columns.svelte.d.ts +10 -0
- package/dist/components/columns/constants.d.ts +5 -0
- package/dist/components/columns/constants.js +3 -0
- package/dist/components/columns/index.d.ts +5 -0
- package/dist/components/columns/index.js +3 -0
- package/dist/components/expandable/Expandable.svelte +182 -0
- package/dist/components/expandable/Expandable.svelte.d.ts +22 -0
- package/dist/components/expandable/index.d.ts +3 -0
- package/dist/components/expandable/index.js +2 -0
- package/dist/components/frame/Frame.svelte +118 -0
- package/dist/components/frame/Frame.svelte.d.ts +15 -0
- package/dist/components/frame/index.d.ts +3 -0
- package/dist/components/frame/index.js +2 -0
- package/dist/components/icon/Icon.svelte +129 -0
- package/dist/components/icon/Icon.svelte.d.ts +18 -0
- package/dist/components/icon/index.d.ts +2 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +22 -0
- package/dist/components/mermaid/Mermaid.svelte +181 -0
- package/dist/components/mermaid/Mermaid.svelte.d.ts +11 -0
- package/dist/components/mermaid/ZoomControls.svelte +74 -0
- package/dist/components/mermaid/ZoomControls.svelte.d.ts +12 -0
- package/dist/components/mermaid/index.d.ts +7 -0
- package/dist/components/mermaid/index.js +4 -0
- package/dist/components/mermaid/use-pan-zoom.svelte.d.ts +11 -0
- package/dist/components/mermaid/use-pan-zoom.svelte.js +41 -0
- package/dist/components/panel/Panel.svelte +27 -0
- package/dist/components/panel/Panel.svelte.d.ts +9 -0
- package/dist/components/panel/index.d.ts +3 -0
- package/dist/components/panel/index.js +2 -0
- package/dist/components/property/DeprecatedPill.svelte +16 -0
- package/dist/components/property/DeprecatedPill.svelte.d.ts +6 -0
- package/dist/components/property/InfoPill.svelte +32 -0
- package/dist/components/property/InfoPill.svelte.d.ts +10 -0
- package/dist/components/property/ParamHead.svelte +188 -0
- package/dist/components/property/ParamHead.svelte.d.ts +22 -0
- package/dist/components/property/Property.svelte +123 -0
- package/dist/components/property/Property.svelte.d.ts +24 -0
- package/dist/components/property/RequiredPill.svelte +16 -0
- package/dist/components/property/RequiredPill.svelte.d.ts +6 -0
- package/dist/components/property/index.d.ts +11 -0
- package/dist/components/property/index.js +6 -0
- package/dist/components/search/index.d.ts +7 -0
- package/dist/components/search/index.js +4 -0
- package/dist/components/search/use-search.d.ts +9 -0
- package/dist/components/search/use-search.js +6 -0
- package/dist/components/steps/Step.svelte +314 -0
- package/dist/components/steps/Step.svelte.d.ts +26 -0
- package/dist/components/steps/Steps.svelte +51 -0
- package/dist/components/steps/Steps.svelte.d.ts +11 -0
- package/dist/components/steps/constants.d.ts +4 -0
- package/dist/components/steps/constants.js +2 -0
- package/dist/components/steps/context.d.ts +10 -0
- package/dist/components/steps/context.js +2 -0
- package/dist/components/steps/index.d.ts +32 -0
- package/dist/components/steps/index.js +6 -0
- package/dist/components/tabs/Tabs.svelte +254 -0
- package/dist/components/tabs/Tabs.svelte.d.ts +16 -0
- package/dist/components/tabs/TabsItem.svelte +56 -0
- package/dist/components/tabs/TabsItem.svelte.d.ts +15 -0
- package/dist/components/tabs/context.d.ts +20 -0
- package/dist/components/tabs/context.js +2 -0
- package/dist/components/tabs/index.d.ts +27 -0
- package/dist/components/tabs/index.js +5 -0
- package/dist/components/tile/Tile.svelte +124 -0
- package/dist/components/tile/Tile.svelte.d.ts +12 -0
- package/dist/components/tile/index.d.ts +2 -0
- package/dist/components/tile/index.js +1 -0
- package/dist/components/tooltip/Tooltip.svelte +170 -0
- package/dist/components/tooltip/Tooltip.svelte.d.ts +23 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tree/Tree.svelte +226 -0
- package/dist/components/tree/Tree.svelte.d.ts +9 -0
- package/dist/components/tree/TreeFile.svelte +44 -0
- package/dist/components/tree/TreeFile.svelte.d.ts +6 -0
- package/dist/components/tree/TreeFolder.svelte +107 -0
- package/dist/components/tree/TreeFolder.svelte.d.ts +10 -0
- package/dist/components/tree/context.d.ts +3 -0
- package/dist/components/tree/context.js +7 -0
- package/dist/components/tree/index.d.ts +10 -0
- package/dist/components/tree/index.js +9 -0
- package/dist/components/tree/tree-level-context.d.ts +8 -0
- package/dist/components/tree/tree-level-context.js +7 -0
- package/dist/components/tree/use-tree-level.d.ts +3 -0
- package/dist/components/tree/use-tree-level.js +5 -0
- package/dist/components/tree/utils.d.ts +9 -0
- package/dist/components/tree/utils.js +86 -0
- package/dist/components/update/Update.svelte +210 -0
- package/dist/components/update/Update.svelte.d.ts +34 -0
- package/dist/components/update/index.d.ts +4 -0
- package/dist/components/update/index.js +3 -0
- package/dist/components/view/View.svelte +52 -0
- package/dist/components/view/View.svelte.d.ts +14 -0
- package/dist/components/view/index.d.ts +3 -0
- package/dist/components/view/index.js +2 -0
- package/dist/constants/brands.d.ts +2 -0
- package/dist/constants/brands.js +4 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/selectors.d.ts +125 -0
- package/dist/constants/selectors.js +125 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/use-expandable-memory.svelte.d.ts +6 -0
- package/dist/hooks/use-expandable-memory.svelte.js +89 -0
- package/dist/hooks/use-expandable.svelte.d.ts +15 -0
- package/dist/hooks/use-expandable.svelte.js +53 -0
- package/dist/hooks/use-get-shiki-highlighted-html.svelte.d.ts +8 -0
- package/dist/hooks/use-get-shiki-highlighted-html.svelte.js +36 -0
- package/dist/hooks/use-has-hover.d.ts +2 -0
- package/dist/hooks/use-has-hover.js +10 -0
- package/dist/hooks/use-is-dark-theme.svelte.d.ts +3 -0
- package/dist/hooks/use-is-dark-theme.svelte.js +25 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.css +2 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +7 -0
- package/dist/utils/copy-to-clipboard.d.ts +4 -0
- package/dist/utils/copy-to-clipboard.js +50 -0
- package/dist/utils/dedent.d.ts +1 -0
- package/dist/utils/dedent.js +125 -0
- package/dist/utils/enhance-video-props.d.ts +4 -0
- package/dist/utils/enhance-video-props.js +25 -0
- package/dist/utils/get-node-text.d.ts +2 -0
- package/dist/utils/get-node-text.js +26 -0
- package/dist/utils/icon-utils.d.ts +18 -0
- package/dist/utils/icon-utils.js +30 -0
- package/dist/utils/is-absolute-url.d.ts +4 -0
- package/dist/utils/is-absolute-url.js +11 -0
- package/dist/utils/is-remote-url.d.ts +2 -0
- package/dist/utils/is-remote-url.js +12 -0
- package/dist/utils/make-marker-ids-unique.d.ts +2 -0
- package/dist/utils/make-marker-ids-unique.js +36 -0
- package/dist/utils/shiki/code-styling.d.ts +13 -0
- package/dist/utils/shiki/code-styling.js +1 -0
- package/dist/utils/shiki/constants.d.ts +21 -0
- package/dist/utils/shiki/constants.js +116 -0
- package/dist/utils/shiki/get-code-styling.d.ts +9 -0
- package/dist/utils/shiki/get-code-styling.js +38 -0
- package/dist/utils/shiki/get-shiki-background-colors.d.ts +20 -0
- package/dist/utils/shiki/get-shiki-background-colors.js +56 -0
- package/dist/utils/shiki/index.d.ts +30 -0
- package/dist/utils/shiki/index.js +209 -0
- package/dist/utils/shiki/lib.d.ts +4 -0
- package/dist/utils/shiki/lib.js +49 -0
- package/dist/utils/shiki/shiki-themes.d.ts +2 -0
- package/dist/utils/shiki/shiki-themes.js +64 -0
- package/dist/utils/shiki/snippet-presets.d.ts +27 -0
- package/dist/utils/shiki/snippet-presets.js +44 -0
- package/dist/utils/shiki/worker-client.d.ts +9 -0
- package/dist/utils/shiki/worker-client.js +22 -0
- package/dist/utils/shiki/worker.d.ts +1 -0
- package/dist/utils/shiki/worker.js +134 -0
- package/dist/utils/slugify.d.ts +2 -0
- package/dist/utils/slugify.js +9 -0
- package/package.json +100 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Check, ChevronDown } from "@lucide/svelte";
|
|
3
|
+
import { DropdownMenu } from "bits-ui";
|
|
4
|
+
import { cn } from "../../utils/cn";
|
|
5
|
+
|
|
6
|
+
type CodeSelectDropdownProps = {
|
|
7
|
+
selectedOption?: string;
|
|
8
|
+
setSelectedOption: (option: string) => void;
|
|
9
|
+
options: string[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
selectedOption,
|
|
14
|
+
setSelectedOption,
|
|
15
|
+
options,
|
|
16
|
+
}: CodeSelectDropdownProps = $props();
|
|
17
|
+
|
|
18
|
+
let isOpen = $state(false);
|
|
19
|
+
let hasOptions = $derived(options.length > 1);
|
|
20
|
+
|
|
21
|
+
function selectOption(option: string) {
|
|
22
|
+
isOpen = false;
|
|
23
|
+
setSelectedOption(option);
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<DropdownMenu.Root bind:open={isOpen}>
|
|
28
|
+
<DropdownMenu.Trigger
|
|
29
|
+
class="group group min-w-16 select-none overflow-hidden rounded-lg bg-transparent px-2 py-[5px] font-medium text-primary text-xs disabled:pointer-events-none dark:bg-transparent dark:text-primary-light [&>span]:line-clamp-1"
|
|
30
|
+
disabled={!hasOptions}
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
class="flex min-w-16 items-center gap-1.5 rounded-lg px-2 py-1 group-hover:bg-primary/10 dark:group-hover:bg-primary-light/10"
|
|
34
|
+
>
|
|
35
|
+
<p class="truncate">{selectedOption}</p>
|
|
36
|
+
{#if hasOptions}<ChevronDown class="min-w-3" size={12} />{/if}
|
|
37
|
+
</div>
|
|
38
|
+
</DropdownMenu.Trigger>
|
|
39
|
+
|
|
40
|
+
<DropdownMenu.Portal>
|
|
41
|
+
<DropdownMenu.Content
|
|
42
|
+
class="relative max-h-96 min-w-(--anchor-width) overflow-y-auto rounded-2xl border-standard bg-stone-50 p-1 text-stone-950/70 shadow-stone-500/5 shadow-xl dark:border-stone-800/50 dark:bg-[#0F1117] dark:text-white/70 dark:shadow-none dark:shadow-stone-500/5"
|
|
43
|
+
style="text-rendering: geometricPrecision"
|
|
44
|
+
>
|
|
45
|
+
{#each options as option}
|
|
46
|
+
{@const isSelected = option === selectedOption}
|
|
47
|
+
<DropdownMenu.Item
|
|
48
|
+
class={cn(
|
|
49
|
+
"group relative flex w-full cursor-pointer select-none items-center justify-between gap-2 rounded-md px-2 py-1 text-sm outline-0 hover:bg-stone-950/3 focus:bg-stone-950/5 data-[highlighted]:bg-stone-950/5 data-[highlighted]:text-stone-950/75 data-disabled:pointer-events-none data-disabled:cursor-default data-disabled:opacity-50 dark:focus:bg-white/5 dark:hover:bg-white/3 dark:data-[highlighted]:bg-white/5 dark:data-[highlighted]:text-white/75",
|
|
50
|
+
"rounded-xl py-1.5 text-xs",
|
|
51
|
+
"hover:bg-primary/10 hover:text-primary dark:hover:bg-primary-light/10 dark:hover:text-primary-light",
|
|
52
|
+
isSelected && "font-medium text-primary dark:text-primary-light",
|
|
53
|
+
!isSelected && "text-stone-500 dark:text-white/50"
|
|
54
|
+
)}
|
|
55
|
+
onSelect={() => selectOption(option)}
|
|
56
|
+
textValue={option}
|
|
57
|
+
>
|
|
58
|
+
{option}
|
|
59
|
+
<Check
|
|
60
|
+
class={cn(
|
|
61
|
+
"size-3.5 shrink-0 text-primary dark:text-primary-light",
|
|
62
|
+
!isSelected && "opacity-0"
|
|
63
|
+
)}
|
|
64
|
+
strokeWidth={2.5}
|
|
65
|
+
/>
|
|
66
|
+
</DropdownMenu.Item>
|
|
67
|
+
{/each}
|
|
68
|
+
</DropdownMenu.Content>
|
|
69
|
+
</DropdownMenu.Portal>
|
|
70
|
+
</DropdownMenu.Root>
|
|
71
|
+
|
|
72
|
+
<script lang="ts" module>
|
|
73
|
+
export type { CodeSelectDropdownProps };
|
|
74
|
+
</script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { CodeSelectDropdownProps };
|
|
2
|
+
type CodeSelectDropdownProps = {
|
|
3
|
+
selectedOption?: string;
|
|
4
|
+
setSelectedOption: (option: string) => void;
|
|
5
|
+
options: string[];
|
|
6
|
+
};
|
|
7
|
+
declare const CodeSelectDropdown: import("svelte").Component<CodeSelectDropdownProps, {}, "">;
|
|
8
|
+
type CodeSelectDropdown = ReturnType<typeof CodeSelectDropdown>;
|
|
9
|
+
export default CodeSelectDropdown;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ChevronsUpDown, Check } from "@lucide/svelte";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
import { getDisplayName } from "../../utils/shiki/snippet-presets";
|
|
5
|
+
import type { CodeBlockTheme } from "../../utils/shiki/code-styling";
|
|
6
|
+
import LanguageIcon from "./LanguageIcon.svelte";
|
|
7
|
+
|
|
8
|
+
type LanguageDropdownProps = {
|
|
9
|
+
selectedLanguage: string;
|
|
10
|
+
setSelectedLanguage: (language: string, index: number) => void;
|
|
11
|
+
languages: string[];
|
|
12
|
+
codeBlockTheme?: CodeBlockTheme;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
selectedLanguage,
|
|
17
|
+
setSelectedLanguage,
|
|
18
|
+
languages,
|
|
19
|
+
codeBlockTheme = "system",
|
|
20
|
+
}: LanguageDropdownProps = $props();
|
|
21
|
+
|
|
22
|
+
let isOpen = $state(false);
|
|
23
|
+
let rootRef = $state<HTMLDivElement>();
|
|
24
|
+
let hasOptions = $derived(languages.length > 1);
|
|
25
|
+
|
|
26
|
+
function selectLanguage(language: string, index: number) {
|
|
27
|
+
isOpen = false;
|
|
28
|
+
setSelectedLanguage(language, index);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
32
|
+
if (event.key === "Escape") {
|
|
33
|
+
isOpen = false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function handleWindowClick(event: MouseEvent) {
|
|
38
|
+
if (isOpen && rootRef && !rootRef.contains(event.target as Node)) {
|
|
39
|
+
isOpen = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<svelte:window onkeydown={handleKeydown} onclick={handleWindowClick} />
|
|
45
|
+
|
|
46
|
+
<div class="relative" bind:this={rootRef}>
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
class="group cursor-default select-none bg-transparent pb-1 font-medium text-xs dark:bg-transparent"
|
|
50
|
+
disabled={!hasOptions}
|
|
51
|
+
aria-haspopup="menu"
|
|
52
|
+
aria-expanded={isOpen}
|
|
53
|
+
onclick={() => (isOpen = !isOpen)}
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
class={cn(
|
|
57
|
+
"flex items-center gap-1 rounded-[10px] border py-[5px] pr-1.5 pl-2.5 text-stone-500 dark:text-stone-400",
|
|
58
|
+
hasOptions ? "cursor-pointer" : "cursor-default",
|
|
59
|
+
hasOptions &&
|
|
60
|
+
codeBlockTheme === "system" &&
|
|
61
|
+
"hover:bg-stone-200/50 hover:text-primary dark:hover:bg-stone-700/70 dark:hover:text-primary-light",
|
|
62
|
+
hasOptions &&
|
|
63
|
+
codeBlockTheme === "dark" &&
|
|
64
|
+
"hover:bg-stone-700/70 hover:text-primary-light",
|
|
65
|
+
isOpen &&
|
|
66
|
+
"border-stone-600/50 ring-1 dark:border-stone-400/50 dark:ring-stone-800/50",
|
|
67
|
+
isOpen && codeBlockTheme === "system" && "ring-stone-200/70",
|
|
68
|
+
isOpen && codeBlockTheme === "dark" && "ring-stone-800/50",
|
|
69
|
+
!isOpen && "border-transparent"
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
<LanguageIcon language={selectedLanguage} />
|
|
73
|
+
<p class="truncate font-medium">{getDisplayName(selectedLanguage)}</p>
|
|
74
|
+
{#if hasOptions}<ChevronsUpDown class="size-3.5 shrink-0" />{/if}
|
|
75
|
+
</div>
|
|
76
|
+
</button>
|
|
77
|
+
|
|
78
|
+
{#if isOpen && hasOptions}
|
|
79
|
+
<div
|
|
80
|
+
class={cn(
|
|
81
|
+
"absolute top-full right-0 z-50 min-w-[170px] overflow-y-auto rounded-2xl border-standard bg-white p-1 text-stone-950/70 shadow-stone-500/5 shadow-xl dark:bg-stone-950 dark:text-white/70 dark:shadow-none dark:shadow-stone-500/5",
|
|
82
|
+
"min-w-[170px] overflow-y-auto border p-1",
|
|
83
|
+
codeBlockTheme === "system" &&
|
|
84
|
+
"border-stone-200/70 bg-white dark:border-white/10 dark:bg-[#0F1117]",
|
|
85
|
+
codeBlockTheme === "dark" && "border-white/10 bg-[#0F1117]"
|
|
86
|
+
)}
|
|
87
|
+
role="menu"
|
|
88
|
+
style="text-rendering: geometricPrecision"
|
|
89
|
+
>
|
|
90
|
+
{#each languages as language, i}
|
|
91
|
+
{@const isSelected = language === selectedLanguage}
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
class={cn(
|
|
95
|
+
"group relative flex w-full cursor-pointer select-none items-center justify-between gap-2 rounded-md px-2 py-1 text-sm outline-0",
|
|
96
|
+
"flex items-center gap-1.5 py-1.5 text-xs",
|
|
97
|
+
codeBlockTheme === "system" &&
|
|
98
|
+
"hover:bg-primary/10 hover:text-primary focus:bg-primary/10 focus:text-primary dark:hover:bg-primary-light/10 dark:hover:text-primary-light",
|
|
99
|
+
codeBlockTheme === "dark" &&
|
|
100
|
+
"text-primary-light hover:bg-primary-light/10 hover:text-primary-light dark:text-primary-light",
|
|
101
|
+
isSelected &&
|
|
102
|
+
codeBlockTheme === "system" &&
|
|
103
|
+
"font-medium text-primary dark:text-primary-light",
|
|
104
|
+
isSelected &&
|
|
105
|
+
codeBlockTheme === "dark" &&
|
|
106
|
+
"font-medium text-primary-light dark:text-primary-light",
|
|
107
|
+
!isSelected &&
|
|
108
|
+
codeBlockTheme === "system" &&
|
|
109
|
+
"text-stone-500 dark:text-white/50",
|
|
110
|
+
!isSelected && codeBlockTheme === "dark" && "text-white/50"
|
|
111
|
+
)}
|
|
112
|
+
role="menuitem"
|
|
113
|
+
onclick={() => selectLanguage(language, i)}
|
|
114
|
+
>
|
|
115
|
+
<LanguageIcon language={language} />
|
|
116
|
+
<div class="flex min-w-0 flex-1 items-center font-medium">
|
|
117
|
+
{getDisplayName(language)}
|
|
118
|
+
</div>
|
|
119
|
+
<Check
|
|
120
|
+
class={cn(
|
|
121
|
+
"size-3.5 shrink-0 text-primary dark:text-primary-light",
|
|
122
|
+
!isSelected && "opacity-0"
|
|
123
|
+
)}
|
|
124
|
+
strokeWidth={2.5}
|
|
125
|
+
/>
|
|
126
|
+
</button>
|
|
127
|
+
{/each}
|
|
128
|
+
</div>
|
|
129
|
+
{/if}
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<script lang="ts" module>
|
|
133
|
+
export type { LanguageDropdownProps };
|
|
134
|
+
</script>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { LanguageDropdownProps };
|
|
2
|
+
import type { CodeBlockTheme } from "../../utils/shiki/code-styling";
|
|
3
|
+
type LanguageDropdownProps = {
|
|
4
|
+
selectedLanguage: string;
|
|
5
|
+
setSelectedLanguage: (language: string, index: number) => void;
|
|
6
|
+
languages: string[];
|
|
7
|
+
codeBlockTheme?: CodeBlockTheme;
|
|
8
|
+
};
|
|
9
|
+
declare const LanguageDropdown: import("svelte").Component<LanguageDropdownProps, {}, "">;
|
|
10
|
+
type LanguageDropdown = ReturnType<typeof LanguageDropdown>;
|
|
11
|
+
export default LanguageDropdown;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
import { getLanguageIconUrl } from "../../utils/icon-utils";
|
|
4
|
+
|
|
5
|
+
type LanguageIconProps = {
|
|
6
|
+
language: string;
|
|
7
|
+
class?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
let { language, class: className }: LanguageIconProps = $props();
|
|
11
|
+
let url = $derived(getLanguageIconUrl(language));
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
{#if url}
|
|
15
|
+
<svg
|
|
16
|
+
class={cn("size-3.5 shrink-0", className)}
|
|
17
|
+
style={`-webkit-mask-image: url(${url}); -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; mask-image: url(${url}); mask-repeat: no-repeat; mask-position: center; mask-size: 100%; background-color: currentColor;`}
|
|
18
|
+
aria-hidden="true"
|
|
19
|
+
></svg>
|
|
20
|
+
{/if}
|
|
21
|
+
|
|
22
|
+
<script lang="ts" module>
|
|
23
|
+
export type { LanguageIconProps };
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { LanguageIconProps };
|
|
2
|
+
type LanguageIconProps = {
|
|
3
|
+
language: string;
|
|
4
|
+
class?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const LanguageIcon: import("svelte").Component<LanguageIconProps, {}, "">;
|
|
7
|
+
type LanguageIcon = ReturnType<typeof LanguageIcon>;
|
|
8
|
+
export default LanguageIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { CodeBlockProps } from "../code-block/types";
|
|
3
|
+
type CodeGroupChild = Omit<CodeBlockProps, "children"> & {
|
|
4
|
+
id: symbol;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
codeString: string;
|
|
7
|
+
};
|
|
8
|
+
type CodeGroupContext = {
|
|
9
|
+
register: (child: CodeGroupChild) => void;
|
|
10
|
+
unregister: (id: symbol) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const CODE_GROUP_CONTEXT: unique symbol;
|
|
13
|
+
export type { CodeGroupChild, CodeGroupContext };
|
|
14
|
+
export { CODE_GROUP_CONTEXT };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { CodeGroupProps } from "./CodeGroup.svelte";
|
|
2
|
+
export { default as CodeGroup } from "./CodeGroup.svelte";
|
|
3
|
+
export type { CodeGroupSelectProps, ExampleCodeSnippet } from "./CodeGroupSelect.svelte";
|
|
4
|
+
export { default as CodeGroupSelect } from "./CodeGroupSelect.svelte";
|
|
5
|
+
export type { LanguageDropdownProps } from "./LanguageDropdown.svelte";
|
|
6
|
+
export { default as LanguageDropdown } from "./LanguageDropdown.svelte";
|
|
7
|
+
export type { LanguageIconProps } from "./LanguageIcon.svelte";
|
|
8
|
+
export { default as LanguageIcon } from "./LanguageIcon.svelte";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
import { Classes } from "../../constants/selectors";
|
|
4
|
+
import { setContext } from "svelte";
|
|
5
|
+
import type { Snippet } from "svelte";
|
|
6
|
+
|
|
7
|
+
type ColorVariant = "compact" | "table";
|
|
8
|
+
|
|
9
|
+
type ColorProps = {
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
variant: ColorVariant;
|
|
12
|
+
class?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let { children, variant, class: className }: ColorProps = $props();
|
|
16
|
+
|
|
17
|
+
// svelte-ignore state_referenced_locally
|
|
18
|
+
setContext("color-context", variant);
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
class={cn(
|
|
23
|
+
Classes.Color,
|
|
24
|
+
"group flex py-6",
|
|
25
|
+
variant === "table" && "flex-col gap-6",
|
|
26
|
+
variant === "compact" && "flex-row flex-wrap gap-x-2 gap-y-4",
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
data-variant={variant}
|
|
30
|
+
>
|
|
31
|
+
{#if children}
|
|
32
|
+
{@render children()}
|
|
33
|
+
{/if}
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
type ColorVariant = "compact" | "table";
|
|
3
|
+
type ColorProps = {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
variant: ColorVariant;
|
|
6
|
+
class?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const Color: import("svelte").Component<ColorProps, {}, "">;
|
|
9
|
+
type Color = ReturnType<typeof Color>;
|
|
10
|
+
export default Color;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
import { Classes } from "../../constants/selectors";
|
|
4
|
+
import { copyToClipboard } from "../../utils/copy-to-clipboard";
|
|
5
|
+
import { getContext } from "svelte";
|
|
6
|
+
import type { Snippet } from "svelte";
|
|
7
|
+
|
|
8
|
+
type ColorItemProps = {
|
|
9
|
+
value: string | { light: string; dark: string };
|
|
10
|
+
name?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { value, name }: ColorItemProps = $props();
|
|
14
|
+
|
|
15
|
+
let copyState: "idle" | "copied" = $state("idle");
|
|
16
|
+
let timeoutRef: ReturnType<typeof setTimeout> | null = null;
|
|
17
|
+
|
|
18
|
+
let darkMode = $state(false);
|
|
19
|
+
|
|
20
|
+
function getIsDarkTheme() {
|
|
21
|
+
if (typeof document === "undefined") return false;
|
|
22
|
+
return document.documentElement.classList.contains("dark");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
$effect(() => {
|
|
26
|
+
darkMode = getIsDarkTheme();
|
|
27
|
+
const observer = new MutationObserver(() => {
|
|
28
|
+
darkMode = getIsDarkTheme();
|
|
29
|
+
});
|
|
30
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
|
31
|
+
return () => observer.disconnect();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
type ColorVariantLocal = "compact" | "table";
|
|
35
|
+
let variant = getContext<string>("color-context") as string;
|
|
36
|
+
|
|
37
|
+
let currentColor = $derived.by(() => {
|
|
38
|
+
if (typeof value === "string") return value;
|
|
39
|
+
const theme = darkMode ? "dark" : "light";
|
|
40
|
+
return (value as any)[theme];
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
async function handleCopy() {
|
|
44
|
+
const result = await copyToClipboard(currentColor);
|
|
45
|
+
if (result === "error") return;
|
|
46
|
+
copyState = "copied";
|
|
47
|
+
if (timeoutRef) clearTimeout(timeoutRef);
|
|
48
|
+
timeoutRef = setTimeout(() => (copyState = "idle"), 2000);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
$effect(() => {
|
|
52
|
+
return () => {
|
|
53
|
+
if (timeoutRef) clearTimeout(timeoutRef);
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
class={cn(
|
|
60
|
+
Classes.ColorItem,
|
|
61
|
+
(variant as string) === "compact" && "flex shrink-0 flex-col gap-2",
|
|
62
|
+
(variant as string) === "table" && "w-full max-w-[50px] md:max-w-[60px]"
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
{#if (variant as string) === "table"}
|
|
66
|
+
<div title={currentColor} class="contents">
|
|
67
|
+
<button
|
|
68
|
+
aria-label={name || `Color ${currentColor}`}
|
|
69
|
+
aria-pressed={copyState === "copied"}
|
|
70
|
+
aria-roledescription={copyState === "copied" ? "Copied" : "Copy"}
|
|
71
|
+
class={cn(
|
|
72
|
+
"relative flex cursor-copy items-center justify-center rounded-lg border border-stone-200 dark:border-stone-800",
|
|
73
|
+
(variant as string) === "compact" && "aspect-square max-h-[104px]",
|
|
74
|
+
(variant as string) === "table" && "aspect-square w-full md:h-10"
|
|
75
|
+
)}
|
|
76
|
+
data-component-part="color-item-button"
|
|
77
|
+
onclick={handleCopy}
|
|
78
|
+
style={`background-color: ${currentColor}`}
|
|
79
|
+
type="button"
|
|
80
|
+
>
|
|
81
|
+
<svg
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
class={cn(
|
|
84
|
+
"pointer-events-none absolute inset-0 m-auto opacity-0 transition-opacity duration-100",
|
|
85
|
+
"filter-[drop-shadow(0_0_2px_rgb(0_0_0/0.1))_drop-shadow(0_0_4px_rgb(0_0_0/0.1))] text-white dark:text-white",
|
|
86
|
+
copyState === "copied" && "opacity-100"
|
|
87
|
+
)}
|
|
88
|
+
fill="currentColor"
|
|
89
|
+
viewBox="0 0 448 512"
|
|
90
|
+
width="14"
|
|
91
|
+
height="14"
|
|
92
|
+
>
|
|
93
|
+
<path d="M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z" />
|
|
94
|
+
</svg>
|
|
95
|
+
</button>
|
|
96
|
+
</div>
|
|
97
|
+
{:else}
|
|
98
|
+
<button
|
|
99
|
+
aria-label={name || `Color ${currentColor}`}
|
|
100
|
+
aria-pressed={copyState === "copied"}
|
|
101
|
+
aria-roledescription={copyState === "copied" ? "Copied" : "Copy"}
|
|
102
|
+
class={cn(
|
|
103
|
+
"relative flex cursor-copy items-center justify-center rounded-lg border border-stone-200 dark:border-stone-800",
|
|
104
|
+
(variant as string) === "compact" && "aspect-square max-h-[104px]",
|
|
105
|
+
(variant as string) === "table" && "aspect-square w-full md:h-10"
|
|
106
|
+
)}
|
|
107
|
+
data-component-part="color-item-button"
|
|
108
|
+
onclick={handleCopy}
|
|
109
|
+
style={`background-color: ${currentColor}`}
|
|
110
|
+
type="button"
|
|
111
|
+
>
|
|
112
|
+
<svg
|
|
113
|
+
aria-hidden="true"
|
|
114
|
+
class={cn(
|
|
115
|
+
"pointer-events-none absolute inset-0 m-auto opacity-0 transition-opacity duration-100",
|
|
116
|
+
"filter-[drop-shadow(0_0_2px_rgb(0_0_0/0.1))_drop-shadow(0_0_4px_rgb(0_0_0/0.1))] text-white dark:text-white",
|
|
117
|
+
copyState === "copied" && "opacity-100"
|
|
118
|
+
)}
|
|
119
|
+
fill="currentColor"
|
|
120
|
+
viewBox="0 0 448 512"
|
|
121
|
+
width="14"
|
|
122
|
+
height="14"
|
|
123
|
+
>
|
|
124
|
+
<path d="M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z" />
|
|
125
|
+
</svg>
|
|
126
|
+
</button>
|
|
127
|
+
{/if}
|
|
128
|
+
{#if (variant as string) === "compact"}
|
|
129
|
+
<div class="flex w-[104px] min-w-0 flex-col gap-0.5">
|
|
130
|
+
{#if name}
|
|
131
|
+
<p class="m-0 truncate text-center font-medium text-sm text-stone-900 dark:text-stone-200" data-component-part="color-item-name" title={name}>
|
|
132
|
+
{name}
|
|
133
|
+
</p>
|
|
134
|
+
{/if}
|
|
135
|
+
<p class="m-0 truncate text-center font-mono text-stone-600 text-xs dark:text-stone-400" data-component-part="color-item-value" title={currentColor}>
|
|
136
|
+
{currentColor}
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
139
|
+
{/if}
|
|
140
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
import { Classes } from "../../constants/selectors";
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
|
|
6
|
+
type ColorRowProps = {
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
title?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let { children, title }: ColorRowProps = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div class={cn(Classes.ColorRow, "flex flex-col gap-2 md:flex-row md:items-center")}>
|
|
15
|
+
{#if title}
|
|
16
|
+
<div class="w-full shrink-0 md:w-[120px]" data-component-part="color-row-title-container">
|
|
17
|
+
<p class="m-0 truncate font-medium text-sm text-stone-900 tracking-[-0.1px] dark:text-stone-200" data-component-part="color-row-title" title={title}>
|
|
18
|
+
{title}
|
|
19
|
+
</p>
|
|
20
|
+
</div>
|
|
21
|
+
{/if}
|
|
22
|
+
<div class="flex w-full gap-1 md:gap-2" data-component-part="color-row-items-container">
|
|
23
|
+
{#if children}
|
|
24
|
+
{@render children()}
|
|
25
|
+
{/if}
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Color: any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ColorBase from "./Color.svelte";
|
|
2
|
+
import ColorRow from "./ColorRow.svelte";
|
|
3
|
+
import ColorItem from "./ColorItem.svelte";
|
|
4
|
+
// @ts-ignore - Svelte component assignment
|
|
5
|
+
export const Color = Object.assign(ColorBase, {
|
|
6
|
+
Row: ColorRow,
|
|
7
|
+
Item: ColorItem,
|
|
8
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
|
|
4
|
+
type BoxProps = {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
let { children }: BoxProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class="flex h-24 items-center justify-center rounded-lg bg-stone-200 text-sm text-stone-500 dark:bg-stone-800">
|
|
12
|
+
{#if children}
|
|
13
|
+
{@render children()}
|
|
14
|
+
{/if}
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { Classes } from "../../constants/selectors";
|
|
4
|
+
import { cn } from "../../utils/cn";
|
|
5
|
+
import { DEFAULT_COLS, type ColCount } from "./constants";
|
|
6
|
+
|
|
7
|
+
type ColumnsProps = {
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
cols?: ColCount | `${ColCount}`;
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { children, cols = DEFAULT_COLS, class: className }: ColumnsProps = $props();
|
|
14
|
+
|
|
15
|
+
let numCols = $derived(Number(cols) || DEFAULT_COLS);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
class={cn(
|
|
20
|
+
Classes.Columns,
|
|
21
|
+
"prose dark:prose-invert grid max-w-none gap-4",
|
|
22
|
+
"sm:grid-cols-[repeat(var(--cols),minmax(0,1fr))]",
|
|
23
|
+
"@2xl/columns-container:grid-cols-[repeat(var(--cols),minmax(0,1fr))] @[0px]/columns-container:grid-cols-1",
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
style={`--cols: ${numCols}`}
|
|
27
|
+
>
|
|
28
|
+
{#if children}
|
|
29
|
+
{@render children()}
|
|
30
|
+
{/if}
|
|
31
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import { type ColCount } from "./constants";
|
|
3
|
+
type ColumnsProps = {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
cols?: ColCount | `${ColCount}`;
|
|
6
|
+
class?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const Columns: import("svelte").Component<ColumnsProps, {}, "">;
|
|
9
|
+
type Columns = ReturnType<typeof Columns>;
|
|
10
|
+
export default Columns;
|