Skip to content

Commit 394664c

Browse files
committed
doc: broken callout
Fixes #430
1 parent 3ddde8a commit 394664c

File tree

3 files changed

+89
-8
lines changed

3 files changed

+89
-8
lines changed

docs/app/app.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const { data: files } = await useAsyncData('search', () => queryCollectionSearch
2525
},
2626
})
2727
28+
useHead({
29+
templateParams: {
30+
separator: '·',
31+
},
32+
})
33+
2834
provide('navigation', computed(() => {
2935
return navigation.value || []
3036
}))
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<div :class="[ui.wrapper, to && ui.to]" v-bind="attrs" :style="{ '--color-light': colorLight, '--color-dark': colorDark }">
3+
<NuxtLink v-if="to" :to="to" :target="target" class="focus:outline-none" tabindex="-1">
4+
<span class="absolute inset-0" aria-hidden="true" />
5+
</NuxtLink>
6+
7+
<UIcon v-if="icon" :name="icon" :class="ui.icon.base" />
8+
9+
<UIcon v-if="!!to && target === '_blank'" :name="ui.externalIcon.name" :class="ui.externalIcon.base" />
10+
11+
<slot mdc-unwrap="p" />
12+
</div>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import type { PropType } from 'vue'
17+
import colors from '#tailwind-config/theme/colors'
18+
import type uiColors from '#ui-colors'
19+
20+
const appConfig = useAppConfig()
21+
22+
const config = computed(() => ({
23+
wrapper: 'block pl-4 pr-6 py-3 rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm/6 my-5 last:mb-0 font-normal group relative prose-code:bg-white dark:prose-code:bg-gray-900',
24+
to: 'hover:border-[--color-light] dark:hover:border-[--color-dark] hover:text-[--color-light] dark:hover:text-[--color-dark] border-dashed hover:border-solid hover:text-gray-800 dark:hover:text-gray-200',
25+
icon: {
26+
base: 'w-4 h-4 mr-2 inline-flex items-center align-sub text-[--color-light] dark:text-[--color-dark]',
27+
},
28+
externalIcon: {
29+
name: appConfig.ui.icons.external,
30+
base: 'w-4 h-4 absolute right-2 top-2 text-gray-400 dark:text-gray-500 group-hover:text-[--color-light] dark:group-hover:text-[--color-dark]',
31+
},
32+
}))
33+
34+
defineOptions({
35+
inheritAttrs: false,
36+
})
37+
38+
const props = defineProps({
39+
icon: {
40+
type: String,
41+
default: undefined,
42+
},
43+
color: {
44+
type: String as PropType<typeof uiColors[number]>,
45+
default: 'primary',
46+
},
47+
to: {
48+
type: String,
49+
default: undefined,
50+
},
51+
target: {
52+
type: String,
53+
default: undefined,
54+
},
55+
class: {
56+
type: [String, Object, Array] as PropType<any>,
57+
default: undefined,
58+
},
59+
ui: {
60+
type: Object as PropType<Partial<typeof config.value>>,
61+
default: () => ({}),
62+
},
63+
})
64+
65+
const { ui, attrs } = useUI('content.callout', toRef(props, 'ui'), config, toRef(props, 'class'), true)
66+
67+
const colorLight = computed(() => {
68+
if (props.color === 'primary') {
69+
return 'rgb(var(--color-primary-DEFAULT))'
70+
}
71+
// @ts-expect-error untyped
72+
return colors[props.color]?.['500'] || (colors[props.color] as string) || props.color
73+
})
74+
const colorDark = computed(() => {
75+
if (props.color === 'primary') {
76+
return 'rgb(var(--color-primary-DEFAULT))'
77+
}
78+
// @ts-expect-error untyped
79+
return colors[props.color]?.['400'] || (colors[props.color] as string) || props.color
80+
})
81+
82+
const target = computed(() => props.target || (props.to && props.to.startsWith('http') ? '_blank' : undefined))
83+
</script>

docs/nuxt.config.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ export default defineNuxtConfig({
5050
enabled: true,
5151
},
5252

53-
app: {
54-
head: {
55-
templateParams: {
56-
separator: '·',
57-
},
58-
},
59-
},
60-
6153
site: {
6254
name: 'Nuxt Scripts',
6355
url: 'scripts.nuxt.com',

0 commit comments

Comments
 (0)