@dumiflex/wp-kit 0.3.0 → 0.5.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/CHANGELOG.md +92 -51
- package/LICENSE +674 -674
- package/README.md +73 -76
- package/package.json +78 -77
- package/src/Avatar.vue +83 -83
- package/src/Badge.vue +97 -97
- package/src/Banner.vue +118 -118
- package/src/BookmarkButton.vue +27 -27
- package/src/BundleMeta.vue +51 -51
- package/src/Button.vue +103 -103
- package/src/Card.vue +68 -68
- package/src/Checkbox.vue +109 -107
- package/src/Chip.vue +163 -97
- package/src/ChoiceCards.vue +133 -133
- package/src/CloseButton.vue +69 -69
- package/src/CodeBlock.vue +146 -119
- package/src/ColorField.vue +188 -206
- package/src/ColorPicker.vue +201 -201
- package/src/Combobox.vue +331 -334
- package/src/ConfirmDialog.vue +165 -163
- package/src/ConfirmModal.vue +147 -147
- package/src/ConstraintMatrixPreview.vue +708 -708
- package/src/ContextMenu.vue +386 -379
- package/src/CopyButton.vue +156 -156
- package/src/DataTable.vue +293 -292
- package/src/DatePicker.vue +234 -234
- package/src/DescriptionList.vue +73 -73
- package/src/DiffView.vue +68 -68
- package/src/Disclosure.vue +166 -166
- package/src/DragHandle.vue +49 -49
- package/src/Drawer.vue +131 -131
- package/src/DropZone.vue +196 -196
- package/src/DropdownMenu.vue +72 -72
- package/src/EmptyState.vue +111 -111
- package/src/Field.vue +28 -28
- package/src/HsvPicker.vue +208 -208
- package/src/Icon.vue +39 -39
- package/src/IconPicker.vue +209 -209
- package/src/ImageGrid.vue +127 -125
- package/src/InlineEdit.vue +183 -183
- package/src/Input.vue +99 -99
- package/src/Kbd.vue +56 -56
- package/src/Lightbox.vue +176 -173
- package/src/ListFilter.vue +85 -85
- package/src/ListRow.vue +204 -204
- package/src/LoadingMark.vue +217 -161
- package/src/Logo.vue +60 -60
- package/src/Modal.vue +78 -76
- package/src/ModalShell.vue +109 -107
- package/src/Pagination.vue +106 -106
- package/src/Popover.vue +180 -171
- package/src/PostCard.vue +210 -211
- package/src/ProgressBar.vue +90 -90
- package/src/RadioGroup.vue +177 -177
- package/src/RangeSlider.vue +183 -183
- package/src/RelativeDate.vue +35 -35
- package/src/ResizeHandle.vue +143 -143
- package/src/SearchInput.vue +192 -199
- package/src/Select.vue +644 -641
- package/src/Separator.vue +54 -54
- package/src/Skeleton.vue +98 -82
- package/src/Slider.vue +198 -198
- package/src/SortableList.vue +260 -260
- package/src/SplitPane.vue +68 -68
- package/src/StarButton.vue +40 -40
- package/src/Stepper.vue +141 -141
- package/src/SupportLinks.vue +93 -93
- package/src/TagInput.vue +297 -300
- package/src/Textarea.vue +57 -57
- package/src/Timeline.vue +92 -92
- package/src/ToastCard.vue +119 -119
- package/src/ToastHost.vue +40 -40
- package/src/Toggle.vue +36 -36
- package/src/TokenizedValue.vue +310 -310
- package/src/Toolbar.vue +110 -110
- package/src/VirtualList.vue +87 -87
- package/src/VisuallyHidden.vue +29 -29
- package/src/WpButton.vue +75 -75
- package/src/WpCheck.vue +104 -102
- package/src/WpIconButton.vue +107 -107
- package/src/WpImageZoom.vue +544 -544
- package/src/WpNumber.vue +178 -183
- package/src/WpSegmented.vue +175 -175
- package/src/WpSelect.vue +93 -89
- package/src/WpSwitch.vue +163 -163
- package/src/WpTabs.vue +188 -188
- package/src/_modal-motion.css +33 -33
- package/src/_skeleton.css +50 -50
- package/src/axis-color.ts +42 -42
- package/src/button.css +169 -169
- package/src/calendar.ts +59 -59
- package/src/clipboard.ts +50 -50
- package/src/colour-presets.ts +12 -12
- package/src/diff.ts +51 -51
- package/src/drop-zone.ts +41 -41
- package/src/field.css +50 -0
- package/src/flip.ts +237 -237
- package/src/floating-layer.ts +48 -0
- package/src/floating.ts +99 -99
- package/src/highlight.ts +199 -0
- package/src/hsv.ts +100 -100
- package/src/icon-catalog.ts +52 -52
- package/src/image-zoom.ts +93 -93
- package/src/kind-colour.ts +28 -0
- package/src/loading-mark-motion.ts +249 -0
- package/src/logo-paths.ts +21 -21
- package/src/matrix-axis.ts +91 -91
- package/src/pagination.ts +27 -27
- package/src/platform-keys.ts +29 -29
- package/src/rich-tokenize.ts +357 -357
- package/src/select-types.ts +32 -32
- package/src/slider-math.ts +45 -45
- package/src/sortable.ts +22 -22
- package/src/theme/fonts/OFL-Fraunces.txt +93 -93
- package/src/theme/fonts/OFL-JetBrainsMono.txt +93 -93
- package/src/theme/fonts/OFL-Manrope.txt +93 -93
- package/src/theme/looks.css +428 -428
- package/src/theme/palettes.css +254 -254
- package/src/theme/tokens.css +2896 -2894
- package/src/tokens.ts +56 -56
- package/src/tooltip.css +43 -43
- package/src/tooltip.ts +146 -146
- package/src/useDialogFocus.ts +73 -73
- package/src/useGrowableField.ts +357 -357
- package/src/useModalKeyShield.ts +116 -116
- package/src/useToast.ts +48 -48
- package/src/wp-logo.svg +14 -14
- package/src/ChipToggle.vue +0 -92
- package/src/KindChip.vue +0 -53
- package/src/RatingBadge.vue +0 -42
package/src/CloseButton.vue
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* Close button: the one × that closes a dialog, drawer, panel or banner. A
|
|
4
|
-
* square, quiet icon button on the 24/32/40 height scale, named by `label`
|
|
5
|
-
* for screen readers and shown as its tooltip. Works on the canvas
|
|
6
|
-
* (`size="sm"`) and in the manager (`md`).
|
|
7
|
-
*
|
|
8
|
-
* <CloseButton @click="close" />
|
|
9
|
-
* <CloseButton label="Dismiss" size="sm" @click="hide" />
|
|
10
|
-
*
|
|
11
|
-
* Manager icon actions other than closing use `Button` with an icon and no
|
|
12
|
-
* text.
|
|
13
|
-
*/
|
|
14
|
-
import { vTooltip } from "./tooltip";
|
|
15
|
-
|
|
16
|
-
withDefaults(defineProps<{
|
|
17
|
-
label?: string | undefined;
|
|
18
|
-
size?: "sm" | "md" | "lg" | undefined;
|
|
19
|
-
disabled?: boolean | undefined;
|
|
20
|
-
/** A shortcut for the tooltip, e.g. "Esc". */
|
|
21
|
-
kbd?: string | undefined;
|
|
22
|
-
}>(), { label: "Close", size: "md", kbd: undefined });
|
|
23
|
-
|
|
24
|
-
const emit = defineEmits<{ (e: "click", ev: MouseEvent): void }>();
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<template>
|
|
28
|
-
<button
|
|
29
|
-
v-tooltip="{ text: label, kbd }"
|
|
30
|
-
type="button"
|
|
31
|
-
class="wp-close-btn"
|
|
32
|
-
:data-size="size"
|
|
33
|
-
:aria-label="label"
|
|
34
|
-
:disabled="disabled"
|
|
35
|
-
@click="emit('click', $event)"
|
|
36
|
-
>
|
|
37
|
-
<i class="pi pi-times" aria-hidden="true" />
|
|
38
|
-
</button>
|
|
39
|
-
</template>
|
|
40
|
-
|
|
41
|
-
<style scoped>
|
|
42
|
-
.wp-close-btn {
|
|
43
|
-
display: inline-grid;
|
|
44
|
-
place-items: center;
|
|
45
|
-
flex: none;
|
|
46
|
-
width: var(--wp-control-h-md);
|
|
47
|
-
height: var(--wp-control-h-md);
|
|
48
|
-
margin: 0;
|
|
49
|
-
padding: 0;
|
|
50
|
-
border: 1px solid transparent;
|
|
51
|
-
border-radius: var(--wp-radius);
|
|
52
|
-
background: transparent;
|
|
53
|
-
color: var(--wp-text-muted);
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
transition: background var(--wp-motion-hover), color var(--wp-motion-hover), border-color var(--wp-motion-hover);
|
|
56
|
-
}
|
|
57
|
-
.wp-close-btn[data-size="sm"] { width: var(--wp-control-h-sm); height: var(--wp-control-h-sm); border-radius: var(--wp-radius-sm); }
|
|
58
|
-
.wp-close-btn[data-size="lg"] { width: var(--wp-control-h-lg); height: var(--wp-control-h-lg); }
|
|
59
|
-
.wp-close-btn .pi { font-size: 12px; }
|
|
60
|
-
.wp-close-btn[data-size="sm"] .pi { font-size: 10px; }
|
|
61
|
-
.wp-close-btn[data-size="lg"] .pi { font-size: 14px; }
|
|
62
|
-
.wp-close-btn:hover:not(:disabled) { background: var(--wp-bg-3); color: var(--wp-text); border-color: var(--wp-border); }
|
|
63
|
-
.wp-close-btn:active:not(:disabled) { background: var(--wp-bg-4); }
|
|
64
|
-
.wp-close-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--wp-border-focus); }
|
|
65
|
-
.wp-close-btn:disabled { opacity: 0.45; cursor: not-allowed; }
|
|
66
|
-
@media (prefers-reduced-motion: reduce) {
|
|
67
|
-
.wp-close-btn { transition: none; }
|
|
68
|
-
}
|
|
69
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Close button: the one × that closes a dialog, drawer, panel or banner. A
|
|
4
|
+
* square, quiet icon button on the 24/32/40 height scale, named by `label`
|
|
5
|
+
* for screen readers and shown as its tooltip. Works on the canvas
|
|
6
|
+
* (`size="sm"`) and in the manager (`md`).
|
|
7
|
+
*
|
|
8
|
+
* <CloseButton @click="close" />
|
|
9
|
+
* <CloseButton label="Dismiss" size="sm" @click="hide" />
|
|
10
|
+
*
|
|
11
|
+
* Manager icon actions other than closing use `Button` with an icon and no
|
|
12
|
+
* text.
|
|
13
|
+
*/
|
|
14
|
+
import { vTooltip } from "./tooltip";
|
|
15
|
+
|
|
16
|
+
withDefaults(defineProps<{
|
|
17
|
+
label?: string | undefined;
|
|
18
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
19
|
+
disabled?: boolean | undefined;
|
|
20
|
+
/** A shortcut for the tooltip, e.g. "Esc". */
|
|
21
|
+
kbd?: string | undefined;
|
|
22
|
+
}>(), { label: "Close", size: "md", kbd: undefined });
|
|
23
|
+
|
|
24
|
+
const emit = defineEmits<{ (e: "click", ev: MouseEvent): void }>();
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<button
|
|
29
|
+
v-tooltip="{ text: label, kbd }"
|
|
30
|
+
type="button"
|
|
31
|
+
class="wp-close-btn"
|
|
32
|
+
:data-size="size"
|
|
33
|
+
:aria-label="label"
|
|
34
|
+
:disabled="disabled"
|
|
35
|
+
@click="emit('click', $event)"
|
|
36
|
+
>
|
|
37
|
+
<i class="pi pi-times" aria-hidden="true" />
|
|
38
|
+
</button>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<style scoped>
|
|
42
|
+
.wp-close-btn {
|
|
43
|
+
display: inline-grid;
|
|
44
|
+
place-items: center;
|
|
45
|
+
flex: none;
|
|
46
|
+
width: var(--wp-control-h-md);
|
|
47
|
+
height: var(--wp-control-h-md);
|
|
48
|
+
margin: 0;
|
|
49
|
+
padding: 0;
|
|
50
|
+
border: 1px solid transparent;
|
|
51
|
+
border-radius: var(--wp-radius);
|
|
52
|
+
background: transparent;
|
|
53
|
+
color: var(--wp-text-muted);
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
transition: background var(--wp-motion-hover), color var(--wp-motion-hover), border-color var(--wp-motion-hover);
|
|
56
|
+
}
|
|
57
|
+
.wp-close-btn[data-size="sm"] { width: var(--wp-control-h-sm); height: var(--wp-control-h-sm); border-radius: var(--wp-radius-sm); }
|
|
58
|
+
.wp-close-btn[data-size="lg"] { width: var(--wp-control-h-lg); height: var(--wp-control-h-lg); }
|
|
59
|
+
.wp-close-btn .pi { font-size: 12px; }
|
|
60
|
+
.wp-close-btn[data-size="sm"] .pi { font-size: 10px; }
|
|
61
|
+
.wp-close-btn[data-size="lg"] .pi { font-size: 14px; }
|
|
62
|
+
.wp-close-btn:hover:not(:disabled) { background: var(--wp-bg-3); color: var(--wp-text); border-color: var(--wp-border); }
|
|
63
|
+
.wp-close-btn:active:not(:disabled) { background: var(--wp-bg-4); }
|
|
64
|
+
.wp-close-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--wp-border-focus); }
|
|
65
|
+
.wp-close-btn:disabled { opacity: 0.45; cursor: not-allowed; }
|
|
66
|
+
@media (prefers-reduced-motion: reduce) {
|
|
67
|
+
.wp-close-btn { transition: none; }
|
|
68
|
+
}
|
|
69
|
+
</style>
|
package/src/CodeBlock.vue
CHANGED
|
@@ -1,119 +1,146 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* Code block: text that must stay as written (JSON, a prompt as sent, a log,
|
|
4
|
-
* a snippet), in the mono font, with a copy button and a wrap switch in its
|
|
5
|
-
* head. Long text scrolls inside `max-height`. Works on the canvas and in the
|
|
6
|
-
* manager.
|
|
7
|
-
*
|
|
8
|
-
* <CodeBlock :code="json" language="JSON" max-height="240px" />
|
|
9
|
-
* <CodeBlock :code="log" title="Request" line-numbers v-model:wrap="wrap" />
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
</span>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.wp-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
.wp-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
.wp-
|
|
100
|
-
.wp-
|
|
101
|
-
|
|
102
|
-
.wp-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.wp-
|
|
111
|
-
.wp-
|
|
112
|
-
.wp-
|
|
113
|
-
.wp-
|
|
114
|
-
.wp-
|
|
115
|
-
|
|
116
|
-
color: var(--wp-text
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Code block: text that must stay as written (JSON, a prompt as sent, a log,
|
|
4
|
+
* a snippet), in the mono font, with a copy button and a wrap switch in its
|
|
5
|
+
* head. Long text scrolls inside `max-height`. Works on the canvas and in the
|
|
6
|
+
* manager.
|
|
7
|
+
*
|
|
8
|
+
* <CodeBlock :code="json" language="JSON" max-height="240px" />
|
|
9
|
+
* <CodeBlock :code="log" title="Request" line-numbers v-model:wrap="wrap" />
|
|
10
|
+
*
|
|
11
|
+
* Syntax colours come from `language` (JSON, TS, Vue/HTML, CSS, shell, the
|
|
12
|
+
* prompt template grammar; see highlight.ts), or from `syntax` when the head
|
|
13
|
+
* shows a title instead of a language tag:
|
|
14
|
+
*
|
|
15
|
+
* <CodeBlock :code="template" title="Template" syntax="prompt" />
|
|
16
|
+
*
|
|
17
|
+
* Unknown languages stay plain. The colours are shared tokens, so a block
|
|
18
|
+
* reads right on the canvas, in the manager and in light mode. A block that
|
|
19
|
+
* scrolls can be focused, so the keyboard can scroll it too.
|
|
20
|
+
*/
|
|
21
|
+
import { computed, ref, watch } from "vue";
|
|
22
|
+
import CopyButton from "./CopyButton.vue";
|
|
23
|
+
import { vTooltip } from "./tooltip";
|
|
24
|
+
import { highlight, highlightLanguage, highlightLines } from "./highlight";
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(defineProps<{
|
|
27
|
+
code: string;
|
|
28
|
+
/** A small tag in the head, e.g. "JSON". Also picks the syntax colours. */
|
|
29
|
+
language?: string | undefined;
|
|
30
|
+
/** Syntax colours without a tag in the head ("prompt", "json", "ts" …). */
|
|
31
|
+
syntax?: string | undefined;
|
|
32
|
+
/** A name in the head, e.g. "Prompt as sent". */
|
|
33
|
+
title?: string | undefined;
|
|
34
|
+
/** Wrap long lines. Bind with v-model:wrap, or leave it to the button. */
|
|
35
|
+
wrap?: boolean | undefined;
|
|
36
|
+
/** Where wrap starts when nobody binds `wrap`. */
|
|
37
|
+
defaultWrap?: boolean | undefined;
|
|
38
|
+
/** CSS max height; the block scrolls past it. */
|
|
39
|
+
maxHeight?: string | undefined;
|
|
40
|
+
lineNumbers?: boolean | undefined;
|
|
41
|
+
/** Leave out the head (copy and wrap). */
|
|
42
|
+
bare?: boolean | undefined;
|
|
43
|
+
size?: "sm" | "md" | undefined;
|
|
44
|
+
}>(), { language: undefined, syntax: undefined, title: undefined, wrap: undefined, maxHeight: undefined, size: "md" });
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits<{ (e: "update:wrap", v: boolean): void }>();
|
|
47
|
+
|
|
48
|
+
const own = ref(props.wrap ?? props.defaultWrap ?? false);
|
|
49
|
+
watch(() => props.wrap, (v) => { if (v !== undefined) own.value = v; });
|
|
50
|
+
const wrapped = computed(() => props.wrap ?? own.value);
|
|
51
|
+
function toggleWrap(): void {
|
|
52
|
+
own.value = !wrapped.value;
|
|
53
|
+
emit("update:wrap", own.value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const tokens = computed(() => highlight(props.code, highlightLanguage(props.syntax ?? props.language)));
|
|
57
|
+
const lines = computed(() => highlightLines(highlight(props.code.replace(/\n$/, ""), highlightLanguage(props.syntax ?? props.language))));
|
|
58
|
+
const name = computed(() => props.title ?? props.language ?? "Code");
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<figure class="wp-code" :data-size="size" :data-wrap="wrapped || undefined">
|
|
63
|
+
<figcaption v-if="!bare" class="wp-code__head">
|
|
64
|
+
<span class="wp-code__title">{{ title }}</span>
|
|
65
|
+
<span v-if="language" class="wp-code__lang">{{ language }}</span>
|
|
66
|
+
<span class="wp-code__tools">
|
|
67
|
+
<button
|
|
68
|
+
v-tooltip="wrapped ? 'Don’t wrap lines' : 'Wrap lines'"
|
|
69
|
+
type="button"
|
|
70
|
+
class="wp-code__tool"
|
|
71
|
+
:aria-pressed="wrapped"
|
|
72
|
+
aria-label="Wrap lines"
|
|
73
|
+
@click="toggleWrap"
|
|
74
|
+
><i class="pi pi-align-left" aria-hidden="true" /></button>
|
|
75
|
+
<CopyButton :text="code" :label="`Copy ${name.toLowerCase() === 'code' ? 'code' : name}`" size="sm" />
|
|
76
|
+
</span>
|
|
77
|
+
</figcaption>
|
|
78
|
+
<pre
|
|
79
|
+
class="wp-code__pre"
|
|
80
|
+
tabindex="0"
|
|
81
|
+
:aria-label="name"
|
|
82
|
+
:style="{ maxHeight }"
|
|
83
|
+
><code v-if="!lineNumbers" class="wp-code__code"><template v-for="(t, i) in tokens" :key="i"><span v-if="t.kind !== 'plain'" :class="`wp-code__t--${t.kind}`">{{ t.text }}</span><template v-else>{{ t.text }}</template></template></code><code v-else class="wp-code__code wp-code__code--numbered"><span v-for="(l, i) in lines" :key="i" class="wp-code__line"><span class="wp-code__num" aria-hidden="true">{{ i + 1 }}</span><span class="wp-code__text"><template v-for="(t, j) in l" :key="j"><span v-if="t.kind !== 'plain'" :class="`wp-code__t--${t.kind}`">{{ t.text }}</span><template v-else>{{ t.text }}</template></template><template v-if="!l.length">{{ "\u00a0" }}</template></span></span></code></pre>
|
|
84
|
+
</figure>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<style scoped>
|
|
88
|
+
.wp-code {
|
|
89
|
+
display: flex; flex-direction: column; min-width: 0; margin: 0;
|
|
90
|
+
border: 1px solid var(--wp-border); border-radius: var(--wp-radius);
|
|
91
|
+
background: var(--wp-bg-1); overflow: hidden;
|
|
92
|
+
}
|
|
93
|
+
.wp-code__head {
|
|
94
|
+
display: flex; align-items: center; gap: var(--wp-space-3); min-height: 28px;
|
|
95
|
+
padding: 2px var(--wp-space-2) 2px var(--wp-space-4);
|
|
96
|
+
border-bottom: 1px solid var(--wp-border-soft); background: var(--wp-bg-2);
|
|
97
|
+
color: var(--wp-text-muted); font: 500 var(--wp-text-xs)/1.2 var(--wp-font-sans);
|
|
98
|
+
}
|
|
99
|
+
.wp-code__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--wp-text); }
|
|
100
|
+
.wp-code__lang {
|
|
101
|
+
padding: 1px 6px; border-radius: var(--wp-radius-sm); background: var(--wp-bg-3);
|
|
102
|
+
font: 600 10px/1.4 var(--wp-font-mono); letter-spacing: 0.04em; text-transform: uppercase;
|
|
103
|
+
}
|
|
104
|
+
.wp-code__tools { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
|
|
105
|
+
.wp-code__tool {
|
|
106
|
+
display: inline-grid; place-items: center; width: var(--wp-control-h-sm); height: var(--wp-control-h-sm);
|
|
107
|
+
margin: 0; padding: 0; border: 0; border-radius: var(--wp-radius-sm);
|
|
108
|
+
background: transparent; color: var(--wp-text-muted); cursor: pointer;
|
|
109
|
+
}
|
|
110
|
+
.wp-code__tool .pi { font-size: 11px; }
|
|
111
|
+
.wp-code__tool:hover { background: var(--wp-row-hover); color: var(--wp-text); }
|
|
112
|
+
.wp-code__tool[aria-pressed="true"] { color: var(--wp-accent-text); background: var(--wp-bg-3); }
|
|
113
|
+
.wp-code__tool:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--wp-border-focus); }
|
|
114
|
+
.wp-code__pre {
|
|
115
|
+
margin: 0; padding: var(--wp-space-4); overflow: auto;
|
|
116
|
+
color: var(--wp-text); font: 400 var(--wp-text-sm)/1.55 var(--wp-font-mono);
|
|
117
|
+
white-space: pre; tab-size: 2;
|
|
118
|
+
/* Code shows as written: no `===` or `<!--` ligatures. */
|
|
119
|
+
font-variant-ligatures: none;
|
|
120
|
+
}
|
|
121
|
+
.wp-code[data-size="sm"] .wp-code__pre { padding: var(--wp-space-3); font-size: var(--wp-text-xs); }
|
|
122
|
+
.wp-code[data-wrap] .wp-code__pre { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
123
|
+
.wp-code__pre:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--wp-border-focus); }
|
|
124
|
+
.wp-code__code { font: inherit; background: none; padding: 0; color: inherit; }
|
|
125
|
+
.wp-code__code--numbered { display: table; }
|
|
126
|
+
.wp-code__line { display: table-row; }
|
|
127
|
+
.wp-code__num {
|
|
128
|
+
display: table-cell; padding-right: var(--wp-space-4); text-align: right;
|
|
129
|
+
color: var(--wp-text-dim); user-select: none; font-variant-numeric: tabular-nums;
|
|
130
|
+
}
|
|
131
|
+
.wp-code__text { display: table-cell; }
|
|
132
|
+
|
|
133
|
+
/* Syntax colours: shared tokens only, so they hold on the canvas and in light mode. */
|
|
134
|
+
.wp-code__t--keyword { color: var(--wp-violet); }
|
|
135
|
+
.wp-code__t--string { color: var(--wp-green); }
|
|
136
|
+
.wp-code__t--number { color: var(--wp-amber); }
|
|
137
|
+
.wp-code__t--comment { color: var(--wp-text-dim); font-style: italic; }
|
|
138
|
+
.wp-code__t--punct { color: var(--wp-text-muted); }
|
|
139
|
+
.wp-code__t--key, .wp-code__t--attr { color: var(--wp-teal); }
|
|
140
|
+
.wp-code__t--tag { color: var(--wp-rose); }
|
|
141
|
+
.wp-code__t--fn { color: var(--wp-info); }
|
|
142
|
+
.wp-code__t--var { color: var(--wp-accent-text); }
|
|
143
|
+
.wp-code__t--ref { color: var(--wp-teal); }
|
|
144
|
+
.wp-code__t--brace { color: var(--wp-amber); }
|
|
145
|
+
.wp-code__t--escape { color: var(--wp-text-dim); }
|
|
146
|
+
</style>
|