@nuxt/ui 0.0.0-alpha.5 → 0.2.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 +1 -1
- package/README.md +28 -43
- package/dist/assets/styles.css +14 -0
- package/dist/components/NCheckbox.vue +2 -2
- package/dist/components/NDarkToggle.vue +28 -0
- package/dist/components/NDialog.vue +6 -9
- package/dist/components/NDropdown.vue +31 -0
- package/dist/components/NLink.vue +1 -1
- package/dist/components/NRadio.vue +2 -2
- package/dist/components/NSwitch.vue +2 -2
- package/dist/components/NTextInput.vue +4 -2
- package/dist/components/NuxtContentLogo.vue +7 -0
- package/dist/components/NuxtExampleLayout.vue +39 -10
- package/dist/components/NuxtLogo.vue +20 -0
- package/dist/components/nuxt/NDarkToggle.vue +28 -0
- package/dist/nuxt.d.ts +4 -1
- package/dist/nuxt.mjs +35 -25
- package/nuxt.cjs +1 -1
- package/package.json +31 -31
- package/dist/assets/logo-nuxt3.svg +0 -18
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
# Nuxt UI
|
|
1
|
+
# Nuxt UI Components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<a href="https://www.npmjs.com/package/@nuxt/ui-edge"><img src="https://flat.badgen.net/npm/v/@nuxt/ui-edge"></a>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
UI kit for Nuxt 3's examples and internal tooling UI.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> Note: This library is heavily working in progress and does not serve as a generic UI library (for now). It is not recommended to use it in production.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
# npm
|
|
11
|
-
npm install @nuxt/ui@npm:@nuxt/ui-edge
|
|
9
|
+
🏀 [Online Playground](https://components.ui.nuxtjs.org)
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
yarn install @nuxt/ui@npm:@nuxt/ui-edge
|
|
15
|
-
```
|
|
11
|
+
## Install
|
|
16
12
|
|
|
17
13
|
```ts
|
|
18
14
|
// nuxt.config.js
|
|
19
|
-
import { defineNuxtConfig } from '
|
|
15
|
+
import { defineNuxtConfig } from 'nuxt'
|
|
20
16
|
|
|
21
17
|
export default defineNuxtConfig({
|
|
22
|
-
|
|
18
|
+
modules: [
|
|
23
19
|
'@nuxt/ui'
|
|
24
20
|
]
|
|
25
21
|
})
|
|
@@ -57,39 +53,28 @@ Apply it to parent components could make a local theme scope
|
|
|
57
53
|
</NCard>
|
|
58
54
|
```
|
|
59
55
|
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
### Base
|
|
63
|
-
|
|
64
|
-
- [x] `<NCard>`
|
|
65
|
-
- [x] `<NTextInput>`
|
|
66
|
-
- [x] `<NCheckbox>`
|
|
67
|
-
- [x] `<NRadio>`
|
|
68
|
-
- [x] `<NIcon>`
|
|
69
|
-
- [x] `<NLink>`
|
|
70
|
-
- [x] `<NButton>`
|
|
71
|
-
- [x] `<NTip>`
|
|
72
|
-
- [ ] `<NButtonGroup>`
|
|
73
|
-
- [ ] `<NSpinner>`
|
|
74
|
-
- [ ] `<NAlert>`
|
|
75
|
-
- [ ] `<NBadge>`
|
|
56
|
+
## Theming
|
|
76
57
|
|
|
77
|
-
|
|
58
|
+
Powered by [UnoCSS](https://github.com/antfu/unocss), you can use Tailwind/Windi CSS utilities to quickly customize the look and feel of components.
|
|
78
59
|
|
|
79
|
-
|
|
80
|
-
- [ ] `<NTabs>`
|
|
81
|
-
- [ ] `<NDropdown>`
|
|
82
|
-
- [ ] `<NPopup>`
|
|
83
|
-
- [ ] `<NNotification>`
|
|
84
|
-
- [ ] `<NModal>`
|
|
60
|
+
It's also possible to override the default theme globally, for example:
|
|
85
61
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
- [ ] `<NDrawer>`
|
|
90
|
-
- [ ] `<NNavbar>`
|
|
91
|
-
- [ ] `<NPagination>`
|
|
62
|
+
```ts
|
|
63
|
+
// nuxt.config.js
|
|
64
|
+
import { defineNuxtConfig } from 'nuxt'
|
|
92
65
|
|
|
93
|
-
|
|
66
|
+
export default defineNuxtConfig({
|
|
67
|
+
modules: [
|
|
68
|
+
'@nuxt/ui'
|
|
69
|
+
],
|
|
70
|
+
unocss: {
|
|
71
|
+
shortcuts: {
|
|
72
|
+
'n-button-base': 'border n-border-base rounded shadow-sm op80 !outline-none',
|
|
73
|
+
'n-button-hover': 'op100 !border-context text-context',
|
|
74
|
+
'n-button-active': 'n-active-base bg-context/5',
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
```
|
|
94
79
|
|
|
95
|
-
|
|
80
|
+
You can find all the default values and available entries in [src/unocss/index.ts](./src/unocss/index.ts).
|
|
@@ -27,8 +27,8 @@ const props = withDefaults(
|
|
|
27
27
|
disabled?: boolean }>(),
|
|
28
28
|
{
|
|
29
29
|
modelValue: false,
|
|
30
|
-
disabled: false
|
|
31
|
-
}
|
|
30
|
+
disabled: false
|
|
31
|
+
}
|
|
32
32
|
)
|
|
33
33
|
const emit = defineEmits<{(...args: any): void}>()
|
|
34
34
|
const checked = useVModel(props, 'modelValue', emit, { passive: true })
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/* eslint-disable vue/no-multiple-template-root */
|
|
3
|
+
import { useColorMode, useToggle } from '@vueuse/core'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
|
|
6
|
+
const mode = useColorMode()
|
|
7
|
+
|
|
8
|
+
const isDark = computed<boolean>({
|
|
9
|
+
get () {
|
|
10
|
+
return mode.value === 'dark'
|
|
11
|
+
},
|
|
12
|
+
set (v) {
|
|
13
|
+
mode.value = v ? 'dark' : 'light'
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const toggle = useToggle(isDark)
|
|
18
|
+
|
|
19
|
+
const context = {
|
|
20
|
+
mode,
|
|
21
|
+
isDark,
|
|
22
|
+
toggle
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<slot v-bind="context" />
|
|
28
|
+
</template>
|
|
@@ -30,10 +30,10 @@ const props = withDefaults(
|
|
|
30
30
|
}>(),
|
|
31
31
|
{
|
|
32
32
|
modelValue: false,
|
|
33
|
-
dim: true
|
|
34
|
-
}
|
|
33
|
+
dim: true
|
|
34
|
+
}
|
|
35
35
|
)
|
|
36
|
-
const emit = defineEmits<{
|
|
36
|
+
const emit = defineEmits<{(...args: any): void }>()
|
|
37
37
|
|
|
38
38
|
const show = useVModel(props, 'modelValue', emit, { passive: true })
|
|
39
39
|
const card = ref(null)
|
|
@@ -42,14 +42,11 @@ const { activate, deactivate } = useFocusTrap(card, { immediate: false })
|
|
|
42
42
|
|
|
43
43
|
onMounted(() => {
|
|
44
44
|
watch(show, (v) => {
|
|
45
|
-
if (v)
|
|
46
|
-
activate()
|
|
47
|
-
else
|
|
48
|
-
deactivate()
|
|
45
|
+
if (v) { activate() } else { deactivate() }
|
|
49
46
|
}, { immediate: true })
|
|
50
47
|
})
|
|
51
48
|
|
|
52
|
-
function close() {
|
|
49
|
+
function close () {
|
|
53
50
|
show.value = false
|
|
54
51
|
emit('close')
|
|
55
52
|
}
|
|
@@ -57,6 +54,6 @@ function close() {
|
|
|
57
54
|
|
|
58
55
|
<script lang="ts">
|
|
59
56
|
export default {
|
|
60
|
-
inheritAttrs: false
|
|
57
|
+
inheritAttrs: false
|
|
61
58
|
}
|
|
62
59
|
</script>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { onClickOutside, useVModel } from '@vueuse/core'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{ modelValue?: boolean }>()
|
|
6
|
+
const emit = defineEmits<{(...args: any): void }>()
|
|
7
|
+
|
|
8
|
+
const enabled = useVModel(props, 'modelValue', emit, { passive: true })
|
|
9
|
+
const el = ref<HTMLDivElement>()
|
|
10
|
+
|
|
11
|
+
onClickOutside(el, () => {
|
|
12
|
+
enabled.value = false
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div ref="el" class="relative">
|
|
18
|
+
<slot name="trigger" :enabled="enabled" @click="enabled = !enabled">
|
|
19
|
+
<NButton @click="enabled = !enabled">
|
|
20
|
+
Dropdown
|
|
21
|
+
</NButton>
|
|
22
|
+
</slot>
|
|
23
|
+
|
|
24
|
+
<div
|
|
25
|
+
class="absolute z-10 n-transition n-bg-base border n-border-base rounded shadow"
|
|
26
|
+
:class="[enabled ? 'op-100' : 'op0 pointer-events-none -translate-y-1']"
|
|
27
|
+
>
|
|
28
|
+
<slot />
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
@@ -29,8 +29,8 @@ const props = withDefaults(
|
|
|
29
29
|
disabled?: boolean }>(),
|
|
30
30
|
{
|
|
31
31
|
modelValue: false,
|
|
32
|
-
disabled: false
|
|
33
|
-
}
|
|
32
|
+
disabled: false
|
|
33
|
+
}
|
|
34
34
|
)
|
|
35
35
|
const emit = defineEmits<{(...args: any): void}>()
|
|
36
36
|
const checked = useVModel(props, 'modelValue', emit, { passive: true })
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<input
|
|
7
7
|
v-model="input"
|
|
8
8
|
class="!outline-none flex-auto n-bg-base"
|
|
9
|
-
type="
|
|
9
|
+
:type="type"
|
|
10
10
|
:placeholder="placeholder"
|
|
11
11
|
>
|
|
12
12
|
</div>
|
|
@@ -21,11 +21,13 @@ const props = withDefaults(
|
|
|
21
21
|
placeholder?: string
|
|
22
22
|
icon?: string
|
|
23
23
|
disabled?: boolean
|
|
24
|
+
type?: string
|
|
24
25
|
}>(),
|
|
25
26
|
{
|
|
26
27
|
modelValue: '',
|
|
27
28
|
disabled: false,
|
|
28
|
-
|
|
29
|
+
type: 'text'
|
|
30
|
+
}
|
|
29
31
|
)
|
|
30
32
|
const emit = defineEmits<{(...args: any): void}>()
|
|
31
33
|
const input = useVModel(props, 'modelValue', emit, { passive: true })
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg viewBox="0 0 236 65" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M29.3445 12.5176c-1.8181-3.10288-6.3636-3.10288-8.1819 0L1.34708 46.334c-1.8182 3.1029.45453 6.9814 4.09096 6.9814H20.9071c-1.5538-1.3478-2.1292-3.6793-.9532-5.68l15.0073-25.5327-5.6167-9.5851Z" fill="#80EEC0" />
|
|
4
|
+
<path d="M41.9001 19.9353c1.5048-2.5387 5.2665-2.5387 6.7712 0l16.3991 27.6679c1.5048 2.5387-.3762 5.7122-3.3855 5.7122H28.8867c-3.0093 0-4.8904-3.1735-3.3857-5.7122l16.3991-27.6679Z" fill="#00DC82" />
|
|
5
|
+
<path d="M93.247 53.206c7.271 0 12.682-4.1739 13.273-10.2874h-5.579c-.508 3.2042-3.6358 5.4388-7.694 5.4388-5.1572 0-9.0462-3.5415-9.0462-10.2451 0-6.7037 3.889-10.2875 9.0462-10.2875 3.9735 0 7.102 2.2345 7.524 5.4811h5.834c-.803-6.1135-6.214-10.2875-13.358-10.2875-7.7358 0-14.6684 5.0593-14.6684 15.0939 0 10.0344 6.8059 15.0937 14.6684 15.0937Zm26.866 0c6.468 0 11.118-4.6378 11.118-10.962 0-6.3242-4.65-10.962-11.118-10.962-6.51 0-11.159 4.6378-11.159 10.962 0 6.3242 4.649 10.962 11.159 10.962Zm0-4.4692c-3.55 0-5.918-2.6562-5.918-6.4928 0-3.8368 2.368-6.4927 5.918-6.4927 3.509 0 5.877 2.6559 5.877 6.4927 0 3.8366-2.368 6.4928-5.877 6.4928Zm19.826 4.1319V41.2743c0-3.12 2.029-5.3967 4.946-5.3967 2.663 0 4.439 2.0239 4.439 4.933v12.0581h5.199V39.7143c0-4.975-3.128-8.4323-7.947-8.4323-3.044 0-5.453 1.3071-6.637 3.6259v-3.2886h-5.199v21.2494h5.199Zm21.158-21.2494h-4.185v4.3427h4.185v9.4864c0 4.722 3.044 7.4203 7.694 7.4203h3.424v-4.3849h-2.833c-1.943 0-3.085-1.0961-3.085-3.2464V35.962h5.918v-4.3427h-5.918v-6.4085h-5.2v6.4085Zm28.684 14.1662c-.55 2.0237-2.283 3.12-4.946 3.12-3.297 0-5.495-2.1924-5.876-5.6074h15.725c.043-.4217.085-1.0541.085-1.7709 0-5.0593-3.211-10.2452-10.357-10.2452-6.974 0-10.441 5.2703-10.441 10.8776 0 5.5654 3.89 11.0464 10.864 11.0464 5.243 0 9.215-2.9092 10.018-7.4205h-5.072Zm-5.369-10.6245c3.086 0 4.947 2.0237 5.158 4.722h-10.483c.549-3.2044 2.408-4.722 5.325-4.722Zm19.141 17.7077V41.2743c0-3.12 2.029-5.3967 4.947-5.3967 2.663 0 4.439 2.0239 4.439 4.933v12.0581h5.199V39.7143c0-4.975-3.128-8.4323-7.947-8.4323-3.044 0-5.453 1.3071-6.638 3.6259v-3.2886h-5.199v21.2494h5.199Zm21.159-21.2494h-4.185v4.3427h4.185v9.4864c0 4.722 3.043 7.4203 7.693 7.4203h3.425v-4.3849h-2.833c-1.945 0-3.086-1.0961-3.086-3.2464V35.962h5.919v-4.3427h-5.919v-6.4085h-5.199v6.4085Z" fill="currentColor" />
|
|
6
|
+
</svg>
|
|
7
|
+
</template>
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import NIcon from './NIcon.vue'
|
|
3
|
+
import NuxtLogo from './NuxtLogo.vue'
|
|
4
|
+
import NuxtContentLogo from './NuxtContentLogo.vue'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
example?: string
|
|
4
8
|
showTips?: boolean
|
|
5
|
-
class?: string
|
|
6
|
-
openPath?: string
|
|
7
|
-
|
|
9
|
+
class?: string // eslint-disable-line vue/no-reserved-props
|
|
10
|
+
openPath?: string,
|
|
11
|
+
repo?: string
|
|
12
|
+
}
|
|
13
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
14
|
+
repo: 'nuxt/framework'
|
|
15
|
+
})
|
|
8
16
|
|
|
9
17
|
const openInEditor = () => {
|
|
10
18
|
fetch(`/__open-in-editor?file=${encodeURIComponent(props.openPath || 'app.vue')}`)
|
|
@@ -14,21 +22,42 @@ const openInEditor = () => {
|
|
|
14
22
|
<template>
|
|
15
23
|
<div class="relative font-sans" n="green6">
|
|
16
24
|
<div class="container max-w-200 mx-auto py-10 px-4">
|
|
17
|
-
<div class="flex
|
|
18
|
-
<
|
|
25
|
+
<div class="flex items-end gap-3 mb-4 relative">
|
|
26
|
+
<slot name="logo">
|
|
27
|
+
<NuxtContentLogo v-if="repo === 'nuxt/content'" class="h-10" />
|
|
28
|
+
<NuxtLogo v-else class="h-10" />
|
|
29
|
+
</slot>
|
|
19
30
|
<div class="text-xl flex">
|
|
20
31
|
<div class="op-50">
|
|
21
32
|
examples/
|
|
22
33
|
</div>
|
|
23
34
|
<slot name="name">
|
|
24
|
-
<NLink :href="`https://github.com/
|
|
25
|
-
{{
|
|
35
|
+
<NLink :href="`https://github.com/${repo}/tree/main/examples/${example}`" target="_blank">
|
|
36
|
+
{{ example }}
|
|
26
37
|
</NLink>
|
|
27
38
|
</slot>
|
|
28
39
|
</div>
|
|
29
|
-
<
|
|
40
|
+
<div flex-auto />
|
|
41
|
+
<div class="op20 hover:op-100 n-transition -mb-2 -mr-1">
|
|
42
|
+
<NButton
|
|
43
|
+
n="borderless lg"
|
|
44
|
+
class="p-2 op50"
|
|
45
|
+
:to="`https://github.com/${repo}/tree/main/examples/${example}`"
|
|
46
|
+
target="_blank"
|
|
47
|
+
>
|
|
48
|
+
<NIcon icon="carbon-code" />
|
|
49
|
+
</NButton>
|
|
50
|
+
<NDarkToggle>
|
|
51
|
+
<template #default="{ toggle }">
|
|
52
|
+
<NButton n="borderless lg" p-2 op50 @click="toggle">
|
|
53
|
+
<NIcon icon="dark:carbon-moon carbon-sun" />
|
|
54
|
+
</NButton>
|
|
55
|
+
</template>
|
|
56
|
+
</NDarkToggle>
|
|
57
|
+
</div>
|
|
30
58
|
</div>
|
|
31
59
|
|
|
60
|
+
<slot name="subtitle" />
|
|
32
61
|
<slot name="nav" />
|
|
33
62
|
|
|
34
63
|
<NCard class="p-6 flex flex-col gap-2 text-center" :class="$props.class">
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg viewBox="0 0 221 65" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<g clip-path="url(#a)">
|
|
4
|
+
<path
|
|
5
|
+
fill="currentColor"
|
|
6
|
+
d="M82.562 18.57h7.302l15.474 24.742V18.571h6.741v35.057h-7.252l-15.525-24.69v24.69h-6.74V18.57Zm59.645 35.058h-6.282v-3.916c-1.429 2.756-4.339 4.308-8.015 4.308-5.822 0-9.603-4.107-9.603-10.018V28.385h6.282V42.71c0 3.456 2.146 5.859 5.362 5.859 3.524 0 5.974-2.704 5.974-6.41V28.385h6.282v25.243Zm21.857-.4-6.026-8.413-6.027 8.414h-6.69l9.296-13.172-8.58-12.071h6.843l5.158 7.264 5.106-7.264h6.895l-8.632 12.07 9.295 13.173h-6.638Zm19.405-32.455v7.611h7.149v5.16h-7.149v12.53c0 .421.17.825.473 1.123.303.298.715.465 1.144.466h5.532v5.955h-4.137c-5.617 0-9.293-3.206-9.293-8.811V33.548h-5.056v-5.164h3.172c1.479 0 2.34-.864 2.34-2.293v-5.318h5.825Z"
|
|
7
|
+
/>
|
|
8
|
+
<path
|
|
9
|
+
fill-rule="evenodd"
|
|
10
|
+
clip-rule="evenodd"
|
|
11
|
+
d="M30.119 11.546c-1.886-3.242-6.6-3.242-8.484 0L1.087 46.875c-1.885 3.241.472 7.293 4.242 7.293h16.04c-1.61-1.408-2.207-3.844-.988-5.934L35.942 21.56l-5.824-10.013Z"
|
|
12
|
+
fill="#80EEC0"
|
|
13
|
+
/>
|
|
14
|
+
<path
|
|
15
|
+
d="M43.137 19.295c1.56-2.652 5.461-2.652 7.022 0l17.004 28.906c1.56 2.652-.39 5.968-3.51 5.968h-34.01c-3.12 0-5.07-3.316-3.51-5.968l17.004-28.906ZM209.174 53.8h-10.691c0-1.85.067-3.452 0-6.02h10.641c1.868 0 3.353.1 4.354-.935 1-1.034 1.501-2.335 1.501-3.903 0-1.834-.667-3.219-2.002-4.153-1.301-.967-2.985-1.451-5.054-1.451h-2.601v-5.254h2.652c1.701 0 3.119-.4 4.253-1.2 1.134-.801 1.701-1.986 1.701-3.553 0-1.301-.434-2.336-1.301-3.103-.834-.8-2.001-1.2-3.503-1.2-1.634 0-2.918.483-3.853 1.45-.9.968-1.401 2.152-1.501 3.553h-6.254c.133-3.236 1.251-5.788 3.352-7.656 2.135-1.868 4.887-2.802 8.256-2.802 2.402 0 4.42.434 6.055 1.301 1.668.834 2.919 1.952 3.753 3.353.867 1.4 1.301 2.952 1.301 4.653 0 1.968-.551 3.636-1.651 5.004-1.068 1.334-2.402 2.235-4.004 2.702 1.969.4 3.57 1.368 4.804 2.902 1.234 1.501 1.852 3.403 1.852 5.705 0 1.934-.468 3.702-1.402 5.304-.934 1.6-2.301 2.885-4.103 3.852-1.768.968-3.953 1.452-6.555 1.452Z"
|
|
16
|
+
fill="#00DC82"
|
|
17
|
+
/>
|
|
18
|
+
</g>
|
|
19
|
+
</svg>
|
|
20
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/* eslint-disable vue/no-multiple-template-root */
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { useToggle } from '@vueuse/core'
|
|
5
|
+
import { useColorMode } from '#imports'
|
|
6
|
+
|
|
7
|
+
const mode = useColorMode() // Auto imported from @nuxtjs/color-mode
|
|
8
|
+
const isDark = computed<boolean>({
|
|
9
|
+
get () {
|
|
10
|
+
return mode.value === 'dark'
|
|
11
|
+
},
|
|
12
|
+
set () {
|
|
13
|
+
mode.preference = isDark.value ? 'light' : 'dark'
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
const toggle = useToggle(isDark)
|
|
17
|
+
const context = {
|
|
18
|
+
mode,
|
|
19
|
+
isDark,
|
|
20
|
+
toggle
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<ColorScheme tag="span">
|
|
26
|
+
<slot v-bind="context" />
|
|
27
|
+
</ColorScheme>
|
|
28
|
+
</template>
|
package/dist/nuxt.d.ts
CHANGED
package/dist/nuxt.mjs
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { mergeDeep } from '
|
|
8
|
-
import presetUno, { theme } from '@unocss/preset-uno';
|
|
9
|
-
import { parseColorUtil, fonts } from '@unocss/preset-mini/rules';
|
|
10
|
-
import presetIcons from '@unocss/preset-icons';
|
|
11
|
-
import presetAttributify from '@unocss/preset-attributify';
|
|
2
|
+
import { defineNuxtModule, addComponentsDir, createResolver, installModule } from '@nuxt/kit';
|
|
3
|
+
import defu from 'defu';
|
|
4
|
+
import { parseColor } from '@unocss/preset-mini/utils';
|
|
5
|
+
import { theme } from '@unocss/preset-mini';
|
|
6
|
+
import { fonts } from '@unocss/preset-mini/rules';
|
|
7
|
+
import { mergeDeep, presetUno, presetAttributify, presetTypography, presetIcons, transformerDirectives, transformerVariantGroup } from 'unocss';
|
|
12
8
|
|
|
13
9
|
const NuxtUIPreset = {
|
|
14
10
|
name: "nuxt-ui",
|
|
@@ -22,10 +18,10 @@ const NuxtUIPreset = {
|
|
|
22
18
|
}),
|
|
23
19
|
rules: [
|
|
24
20
|
[/^n-(.*)$/, ([, body], { theme }) => {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
21
|
+
const color = parseColor(body, theme);
|
|
22
|
+
if (color?.cssColor?.type === "rgb" && color.cssColor.components) {
|
|
27
23
|
return {
|
|
28
|
-
"--nui-c-context": `${
|
|
24
|
+
"--nui-c-context": `${color.cssColor.components.join(",")}`
|
|
29
25
|
};
|
|
30
26
|
}
|
|
31
27
|
}],
|
|
@@ -34,12 +30,12 @@ const NuxtUIPreset = {
|
|
|
34
30
|
["n-solid", {
|
|
35
31
|
"background-color": "rgba(var(--nui-c-context), 1) !important",
|
|
36
32
|
"border-color": "rgba(var(--nui-c-context), 1)",
|
|
37
|
-
|
|
33
|
+
color: "white !important"
|
|
38
34
|
}],
|
|
39
35
|
["n-disabled", {
|
|
40
|
-
|
|
36
|
+
opacity: 0.4,
|
|
41
37
|
"pointer-events": "none",
|
|
42
|
-
|
|
38
|
+
filter: "saturate(0)"
|
|
43
39
|
}]
|
|
44
40
|
],
|
|
45
41
|
variants: [
|
|
@@ -70,7 +66,9 @@ const NuxtUIPreset = {
|
|
|
70
66
|
"n-transition": "transition-all duration-200",
|
|
71
67
|
"n-focus-base": "ring-2 ring-context/50",
|
|
72
68
|
"n-active-base": "ring-3 ring-context/10",
|
|
73
|
-
"n-
|
|
69
|
+
"n-borderless": "!border-none !shadow-none",
|
|
70
|
+
"n-link-base": "underline underline-offset-2 underline-black/20 dark:underline-white/40",
|
|
71
|
+
"n-link-hover": "decoration-dotted text-context underline-context",
|
|
74
72
|
"n-card-base": "border n-border-200 rounded n-bg-base shadow-sm",
|
|
75
73
|
"n-header-upper": "text-sm uppercase mb-2 leading-1.2em tracking-wide op50",
|
|
76
74
|
"n-button-base": "border n-border-base rounded shadow-sm px-1em py-0.25em inline-flex items-center gap-1 op80 !outline-none",
|
|
@@ -100,36 +98,48 @@ function extendUnocssOptions(user = {}) {
|
|
|
100
98
|
presets: [
|
|
101
99
|
presetUno(),
|
|
102
100
|
presetAttributify(),
|
|
101
|
+
presetTypography(),
|
|
103
102
|
presetIcons({
|
|
104
103
|
prefix: "",
|
|
105
104
|
scale: 1.2,
|
|
106
105
|
extraProperties: {
|
|
107
|
-
|
|
106
|
+
display: "inline-block",
|
|
108
107
|
"vertical-align": "middle"
|
|
109
108
|
}
|
|
110
109
|
}),
|
|
111
110
|
NuxtUIPreset,
|
|
112
111
|
...user.presets || []
|
|
112
|
+
],
|
|
113
|
+
transformers: [
|
|
114
|
+
transformerDirectives(),
|
|
115
|
+
transformerVariantGroup()
|
|
113
116
|
]
|
|
114
117
|
};
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
const rPath = (p) => fileURLToPath(new URL(p, import.meta.url).toString());
|
|
118
121
|
const nuxt = defineNuxtModule({
|
|
119
|
-
|
|
122
|
+
meta: {
|
|
123
|
+
name: "nui",
|
|
124
|
+
configKey: "nui"
|
|
125
|
+
},
|
|
120
126
|
defaults: {
|
|
121
127
|
preset: rPath("./preset"),
|
|
122
128
|
dev: false
|
|
123
129
|
},
|
|
124
130
|
async setup(options, nuxt) {
|
|
131
|
+
addComponentsDir({ path: rPath("./components/nuxt") });
|
|
125
132
|
addComponentsDir({ path: rPath("./components") });
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
nuxt.options.css.push(presetStyles);
|
|
129
|
-
if (!options.dev)
|
|
133
|
+
nuxt.options.css.unshift(rPath("assets/styles.css"));
|
|
134
|
+
if (!options.dev) {
|
|
130
135
|
nuxt.options.unocss = extendUnocssOptions(nuxt.options.unocss);
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
}
|
|
137
|
+
nuxt.options.vueuse = nuxt.options.vueuse || {};
|
|
138
|
+
nuxt.options.colorMode = defu(nuxt.options.colorMode, { classSuffix: "" });
|
|
139
|
+
const resolver = createResolver(import.meta.url);
|
|
140
|
+
await installModule(await resolver.resolvePath("@unocss/nuxt"));
|
|
141
|
+
await installModule(await resolver.resolvePath("@vueuse/nuxt"));
|
|
142
|
+
await installModule(await resolver.resolvePath("@nuxtjs/color-mode"));
|
|
133
143
|
}
|
|
134
144
|
});
|
|
135
145
|
|
package/nuxt.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.2.0",
|
|
5
4
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
"build": "unbuild && cp -R src/components dist/",
|
|
8
|
-
"lint": "eslint . --ext .vue,.ts",
|
|
9
|
-
"dev": "yarn nuxi dev playground",
|
|
10
|
-
"prepublishOnly": "npm run build",
|
|
11
|
-
"release": "bumpp --commit --tag --push --preid alpha && yarn publish --non-interactive"
|
|
12
|
-
},
|
|
13
|
-
"main": "./dist/nuxt.mjs",
|
|
5
|
+
"type": "module",
|
|
14
6
|
"exports": {
|
|
15
7
|
".": {
|
|
16
8
|
"import": "./dist/nuxt.mjs",
|
|
@@ -21,33 +13,41 @@
|
|
|
21
13
|
"require": "./nuxt.cjs"
|
|
22
14
|
}
|
|
23
15
|
},
|
|
16
|
+
"main": "./dist/nuxt.mjs",
|
|
24
17
|
"files": [
|
|
25
18
|
"dist",
|
|
26
19
|
"*.cjs"
|
|
27
20
|
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "unbuild",
|
|
23
|
+
"dev": "nuxi dev playground",
|
|
24
|
+
"lint": "eslint . --ext .vue,.ts",
|
|
25
|
+
"prepack": "npm run build",
|
|
26
|
+
"playground:build": "nuxi build playground"
|
|
27
|
+
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@unocss/
|
|
33
|
-
"@unocss/
|
|
34
|
-
"@unocss/preset-
|
|
35
|
-
"@unocss/preset-
|
|
36
|
-
"@unocss/
|
|
37
|
-
"@
|
|
38
|
-
"@vueuse/
|
|
39
|
-
"
|
|
29
|
+
"@iconify-json/carbon": "^1.1.6",
|
|
30
|
+
"@nuxt/kit": "^3.0.0-rc.4",
|
|
31
|
+
"@nuxtjs/color-mode": "^3.1.4",
|
|
32
|
+
"@unocss/core": "^0.44.1",
|
|
33
|
+
"@unocss/nuxt": "^0.44.1",
|
|
34
|
+
"@unocss/preset-attributify": "^0.44.1",
|
|
35
|
+
"@unocss/preset-icons": "^0.44.1",
|
|
36
|
+
"@unocss/preset-mini": "^0.44.1",
|
|
37
|
+
"@unocss/reset": "^0.44.1",
|
|
38
|
+
"@vueuse/core": "^8.9.2",
|
|
39
|
+
"@vueuse/integrations": "^8.9.2",
|
|
40
|
+
"@vueuse/nuxt": "^8.9.2",
|
|
41
|
+
"defu": "^6.0.0",
|
|
42
|
+
"focus-trap": "^6.9.4",
|
|
43
|
+
"unocss": "^0.44.1"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"typescript": "^4.5.4",
|
|
48
|
-
"unbuild": "^0.6.7"
|
|
46
|
+
"nuxt": "3.0.0-rc.4",
|
|
47
|
+
"unbuild": "^0.7.4"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
49
51
|
},
|
|
50
|
-
"
|
|
51
|
-
"extends": "@antfu"
|
|
52
|
-
}
|
|
52
|
+
"gitHead": "1d10fbfe28e7256c18c04404f4e1f0805a4e454a"
|
|
53
53
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<svg viewBox="0 0 221 65" fill="none" xmlns="http://www.w3.org/2000/svg" class="h-8">
|
|
2
|
-
<g clip-path="url(#a)">
|
|
3
|
-
<path fill="currentColor"
|
|
4
|
-
d="M82.5623 18.5705h7.3017l15.474 24.7415V18.5705h6.741v35.0576h-7.252L89.3025 28.938v24.6901h-6.7402V18.5705ZM142.207 53.628h-6.282v-3.916c-1.429 2.7559-4.339 4.3076-8.015 4.3076-5.822 0-9.603-4.1069-9.603-10.0175V28.3847h6.282v14.3251c0 3.4558 2.146 5.8592 5.362 5.8592 3.524 0 5.974-2.7044 5.974-6.4099V28.3847h6.282V53.628ZM164.064 53.2289l-6.026-8.4144-6.027 8.4144h-6.69l9.296-13.1723-8.58-12.0709h6.843l5.158 7.2641 5.106-7.2641h6.895l-8.632 12.0709 9.295 13.1723h-6.638ZM183.469 20.7726v7.6116h7.149v5.1593h-7.149v12.5311c0 .4208.17.8245.473 1.1223.303.2978.715.4654 1.144.4661h5.532v5.9547h-4.137c-5.617 0-9.293-3.2062-9.293-8.8109V33.5484h-5.056v-5.1642h3.172c1.479 0 2.34-.8639 2.34-2.2932v-5.3184h5.825Z">
|
|
5
|
-
</path>
|
|
6
|
-
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
7
|
-
d="M30.1185 11.5456c-1.8853-3.24168-6.5987-3.24169-8.484 0L1.08737 46.8747c-1.885324 3.2417.47133 7.2938 4.24199 7.2938H21.3695c-1.6112-1.4081-2.2079-3.8441-.9886-5.9341l15.5615-26.675-5.8239-10.0138Z"
|
|
8
|
-
fill="#80EEC0"></path>
|
|
9
|
-
<path
|
|
10
|
-
d="M43.1374 19.2952c1.5603-2.6523 5.461-2.6523 7.0212 0l17.0045 28.9057c1.5603 2.6522-.39 5.9676-3.5106 5.9676h-34.009c-3.1206 0-5.0709-3.3154-3.5106-5.9676l17.0045-28.9057ZM209.174 53.8005H198.483c0-1.8514.067-3.4526 0-6.0213h10.641c1.868 0 3.353.1001 4.354-.934 1-1.0341 1.501-2.3351 1.501-3.9029 0-1.8347-.667-3.2191-2.002-4.1532-1.301-.9674-2.985-1.4511-5.054-1.4511h-2.601v-5.2539h2.652c1.701 0 3.119-.4003 4.253-1.2009 1.134-.8006 1.701-1.9849 1.701-3.5527 0-1.301-.434-2.3351-1.301-3.1023-.834-.8007-2.001-1.201-3.503-1.201-1.634 0-2.918.4837-3.853 1.4511-.9.9674-1.401 2.1517-1.501 3.5527h-6.254c.133-3.2358 1.251-5.7877 3.352-7.6558 2.135-1.868 4.887-2.8021 8.256-2.8021 2.402 0 4.42.4337 6.055 1.301 1.668.834 2.919 1.9515 3.753 3.3525.867 1.4011 1.301 2.9523 1.301 4.6536 0 1.9681-.551 3.636-1.651 5.0037-1.068 1.3344-2.402 2.235-4.004 2.7021 1.969.4003 3.57 1.3677 4.804 2.9022 1.234 1.5011 1.852 3.4025 1.852 5.7043 0 1.9347-.468 3.7028-1.402 5.304-.934 1.6012-2.301 2.8855-4.103 3.8529-1.768.9674-3.953 1.4511-6.555 1.4511Z"
|
|
11
|
-
fill="#00DC82"></path>
|
|
12
|
-
</g>
|
|
13
|
-
<defs>
|
|
14
|
-
<clipPath id="a">
|
|
15
|
-
<path fill="#fff" d="M0 0h221v65H0z"></path>
|
|
16
|
-
</clipPath>
|
|
17
|
-
</defs>
|
|
18
|
-
</svg>
|