@zooui/nuxt 0.4.0 → 0.4.1
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/components/CodeBlock.vue +10 -4
- package/components/recipes.ts +17 -2
- package/package.json +1 -1
package/components/CodeBlock.vue
CHANGED
|
@@ -33,6 +33,10 @@ const parts = computed(() => {
|
|
|
33
33
|
: [{ text: chunk, tok: false }]);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
/** A block of one line (a shown-once token, an `export`) keeps the row: the toolbar beside it costs no height, where
|
|
37
|
+
* the corner toolbar would leave an empty band above the code. Only multi-line code gets the corner toolbar. */
|
|
38
|
+
const layout = computed(() => (props.variant === "block" && props.code.includes("\n") ? "block" : "line"));
|
|
39
|
+
|
|
36
40
|
let reset: ReturnType<typeof setTimeout> | undefined;
|
|
37
41
|
async function copy() {
|
|
38
42
|
try {
|
|
@@ -52,11 +56,13 @@ onBeforeUnmount(() => clearTimeout(reset));
|
|
|
52
56
|
<template>
|
|
53
57
|
<code v-if="variant === 'inline'" :class="cx(ident.base, ident.kind.package)">{{ code }}</code>
|
|
54
58
|
|
|
55
|
-
<div v-else :class="codeCls.wrap">
|
|
59
|
+
<div v-else :class="cx(codeCls.wrap, codeCls.layout[layout])">
|
|
56
60
|
<span v-if="variant === 'line' && prompt" :class="codeCls.prompt">{{ prompt }}</span>
|
|
57
|
-
<pre :class="cx(codeCls.pre, wrap ? 'whitespace-pre-wrap
|
|
58
|
-
<
|
|
59
|
-
|
|
61
|
+
<pre :class="cx(codeCls.pre[layout], wrap ? 'whitespace-pre-wrap wrap-anywhere @max-[359px]:whitespace-pre @max-[359px]:wrap-normal' : 'whitespace-pre')"><template v-for="(p, i) in parts" :key="i"><span v-if="p.tok" :class="codeCls.tok">{{ p.text }}</span><template v-else>{{ p.text }}</template></template></pre>
|
|
62
|
+
<div :class="codeCls.bar[layout]">
|
|
63
|
+
<span v-if="lang" :class="codeCls.lang">{{ lang }}</span>
|
|
64
|
+
<button type="button" :class="codeCls.copy" :data-done="result === 'copied'" @click="copy">{{ result === "copied" ? "copied" : result === "failed" ? "copy failed" : "copy" }}</button>
|
|
65
|
+
</div>
|
|
60
66
|
<!-- a changed button label is not announced; this is -->
|
|
61
67
|
<span class="sr-only" role="status">{{ result === "copied" ? "Copied to clipboard" : result === "failed" ? "Couldn't copy — select the text and copy it" : "" }}</span>
|
|
62
68
|
</div>
|
package/components/recipes.ts
CHANGED
|
@@ -105,9 +105,24 @@ export const meter = {
|
|
|
105
105
|
|
|
106
106
|
/** Zoo UI's code surface: near-black in BOTH themes — the one surface that does not follow the page. */
|
|
107
107
|
export const code = {
|
|
108
|
-
wrap: 'relative
|
|
108
|
+
wrap: 'relative py-3 pr-3 pl-4 bg-(--ui-color-neutral-900) dark:bg-(--ui-color-neutral-950) text-(--ui-color-neutral-100) border border-(--ui-color-neutral-700) rounded-md font-mono font-normal text-sm leading-[1.6] [container-type:inline-size]',
|
|
109
|
+
/** line (and a block of one line): prompt, code, lang and copy share one row. block (multi-line code): the code
|
|
110
|
+
* takes the whole width and lang and copy sit over its top-right corner, so a tall block gives up no column. */
|
|
111
|
+
layout: {
|
|
112
|
+
line: 'flex items-start gap-3',
|
|
113
|
+
block: 'block',
|
|
114
|
+
},
|
|
109
115
|
prompt: 'text-(--ui-color-primary-300) select-none flex-none',
|
|
110
|
-
pre:
|
|
116
|
+
pre: {
|
|
117
|
+
line: 'm-0 flex-1 min-w-0 overflow-x-auto [font:inherit]',
|
|
118
|
+
/* pt-6 drops the first line below the toolbar (top-2 + h-6 ends 8px under the wrap's own py-3) */
|
|
119
|
+
block: 'm-0 pt-6 overflow-x-auto [font:inherit]',
|
|
120
|
+
},
|
|
121
|
+
/** lang and copy: flex items of the row (display: contents), or the corner toolbar of multi-line code */
|
|
122
|
+
bar: {
|
|
123
|
+
line: 'contents',
|
|
124
|
+
block: 'absolute top-2 right-2 flex items-center gap-3',
|
|
125
|
+
},
|
|
111
126
|
lang: 'flex-none order-2 self-center font-mono font-medium text-xs leading-[1.2] tracking-[0.08em] uppercase text-(--ui-color-neutral-400)',
|
|
112
127
|
copy: `appearance-none flex-none order-3 h-6 px-2 inline-flex items-center gap-1.5 bg-transparent border border-(--ui-color-neutral-700) rounded-sm text-(--ui-color-neutral-400) font-sans font-medium text-xs leading-[1.2] cursor-pointer hover:text-(--ui-color-neutral-100) hover:border-(--ui-color-neutral-400) data-[done=true]:text-(--ui-color-primary-300) data-[done=true]:border-(--ui-color-primary-300) ${focus}`,
|
|
113
128
|
/** the secret: one click selects all of it, the fallback when the clipboard refuses */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zooui/nuxt",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Zoo UI for Nuxt: a theme-free Nuxt layer with Nuxt UI as it ships, Zoo UI's Z* components and colored-edge surfaces, and the mechanisms every product needs, all on Nuxt UI's tokens so they take the product's own colors. Add a theme layer such as @zooui/theme-forest for a ready-made look.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|