@nuxt/ui 0.0.0-alpha.1 → 0.0.0-alpha.5

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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Nuxt UI
2
2
 
3
+ UI kit for Nuxt 3's examples and internal tooling UI.
4
+
5
+ > Note: This is library heavily working in progress and does not serve as a generic UI library (for now).
6
+
3
7
  ## Install
4
8
 
5
9
  ```sh
@@ -10,18 +14,61 @@ npm install @nuxt/ui@npm:@nuxt/ui-edge
10
14
  yarn install @nuxt/ui@npm:@nuxt/ui-edge
11
15
  ```
12
16
 
17
+ ```ts
18
+ // nuxt.config.js
19
+ import { defineNuxtConfig } from 'nuxt3'
20
+
21
+ export default defineNuxtConfig({
22
+ buildModules: [
23
+ '@nuxt/ui'
24
+ ]
25
+ })
26
+ ```
27
+
13
28
  ## Usage
14
29
 
30
+ Nuxt UI is an unbundled component library powered by [UnoCSS](https://github.com/antfu/unocss) and [VueUse](https://vueuse.org/).
31
+
32
+ In Nuxt UI, we introduced the `n` attribute for every component to customize the styles and variations. For example, to make a red button:
33
+
34
+ ```html
35
+ <NButton n="red" />
36
+ ```
37
+
38
+ to make it larger, add the size specifier (`sm`, `md`, `lg` or `xl`) the `n` attribute:
39
+
40
+ ```html
41
+ <NButton n="red xl" />
42
+ ```
43
+
44
+ You can apply the same specifiers to any other component, for example:
45
+
46
+ ```html
47
+ <NCheckbox n="red xl" />
48
+ ```
49
+
50
+ Apply it to parent components could make a local theme scope
51
+
52
+ ```html
53
+ <NCard n="green-500">
54
+ <!-- both of them are themed green -->
55
+ <NCheckbox>i accept the terms & conditions</NCheckbox>
56
+ <NButton>Submit</NButton>
57
+ </NCard>
58
+ ```
59
+
15
60
  ## Components
16
61
 
17
62
  ### Base
18
63
 
19
- - [ ] `<NCard>`
20
- - [ ] `<NInput>`
21
- - [ ] `<NCheckbox>`
22
- - [ ] `<NRadio>`
23
- - [ ] `<NIcon>`
24
- - [ ] `<NButton>`
64
+ - [x] `<NCard>`
65
+ - [x] `<NTextInput>`
66
+ - [x] `<NCheckbox>`
67
+ - [x] `<NRadio>`
68
+ - [x] `<NIcon>`
69
+ - [x] `<NLink>`
70
+ - [x] `<NButton>`
71
+ - [x] `<NTip>`
25
72
  - [ ] `<NButtonGroup>`
26
73
  - [ ] `<NSpinner>`
27
74
  - [ ] `<NAlert>`
@@ -29,6 +76,7 @@ yarn install @nuxt/ui@npm:@nuxt/ui-edge
29
76
 
30
77
  ### Interactive
31
78
 
79
+ - [x] `<NDialog>`
32
80
  - [ ] `<NTabs>`
33
81
  - [ ] `<NDropdown>`
34
82
  - [ ] `<NPopup>`
@@ -0,0 +1,18 @@
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>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <Component
3
+ :is="(href || target) ? 'a' : 'nuxt-link'"
4
+ v-bind="$props"
5
+ class="n-link n-link-base n-transition"
6
+ >
7
+ <slot />
8
+ </Component>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ defineProps<{
13
+ to?: string
14
+ href?: string
15
+ target?: string
16
+ }>()
17
+ </script>
@@ -0,0 +1,53 @@
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ name?: string
4
+ showTips?: boolean
5
+ class?: string
6
+ openPath?: string
7
+ }>()
8
+
9
+ const openInEditor = () => {
10
+ fetch(`/__open-in-editor?file=${encodeURIComponent(props.openPath || 'app.vue')}`)
11
+ }
12
+ </script>
13
+
14
+ <template>
15
+ <div class="relative font-sans" n="green6">
16
+ <div class="container max-w-200 mx-auto py-10 px-4">
17
+ <div class="flex flex-col gap-2 items-center mb-4">
18
+ <img src="../assets/logo-nuxt3.svg" h="12">
19
+ <div class="text-xl flex">
20
+ <div class="op-50">
21
+ examples/
22
+ </div>
23
+ <slot name="name">
24
+ <NLink :href="`https://github.com/nuxt/framework/tree/main/examples/${name}`" target="_blank">
25
+ {{ name }}
26
+ </NLink>
27
+ </slot>
28
+ </div>
29
+ <slot name="subtitle" />
30
+ </div>
31
+
32
+ <slot name="nav" />
33
+
34
+ <NCard class="p-6 flex flex-col gap-2 text-center" :class="$props.class">
35
+ <slot />
36
+ </NCard>
37
+
38
+ <div
39
+ v-if="$slots.tips"
40
+ :class="showTips ? 'opacity-100' : 'opacity-0'"
41
+ class="transition py-5 flex items-center gap-2 text-gray-400"
42
+ >
43
+ <NIcon icon="carbon-idea" class="text-xl flex-none" />
44
+ <slot name="tips" />
45
+ <NButton icon="carbon-edit" class="flex-none" @click="openInEditor">
46
+ Open in Editor
47
+ </NButton>
48
+ </div>
49
+
50
+ <slot name="footer" />
51
+ </div>
52
+ </div>
53
+ </template>
package/dist/nuxt.mjs CHANGED
@@ -6,7 +6,7 @@ import UnocssModule from '@unocss/nuxt';
6
6
  import VueUseModule from '@vueuse/nuxt';
7
7
  import { mergeDeep } from '@unocss/core';
8
8
  import presetUno, { theme } from '@unocss/preset-uno';
9
- import { parseColorUtil, fontSizes } from '@unocss/preset-mini/rules';
9
+ import { parseColorUtil, fonts } from '@unocss/preset-mini/rules';
10
10
  import presetIcons from '@unocss/preset-icons';
11
11
  import presetAttributify from '@unocss/preset-attributify';
12
12
 
@@ -29,7 +29,7 @@ const NuxtUIPreset = {
29
29
  };
30
30
  }
31
31
  }],
32
- [/^n-(.*)$/, fontSizes[0][1]],
32
+ [/^n-(.*)$/, fonts[1][1]],
33
33
  ["n-dashed", { "border-style": "dashed" }],
34
34
  ["n-solid", {
35
35
  "background-color": "rgba(var(--nui-c-context), 1) !important",
@@ -70,8 +70,9 @@ const NuxtUIPreset = {
70
70
  "n-transition": "transition-all duration-200",
71
71
  "n-focus-base": "ring-2 ring-context/50",
72
72
  "n-active-base": "ring-3 ring-context/10",
73
+ "n-link-base": "hover:decoration-dotted hover:underline-offset-2 hover:text-context hover:underline",
73
74
  "n-card-base": "border n-border-200 rounded n-bg-base shadow-sm",
74
- "n-header-upper": "text-sm case-upper mb-2 leading-1.2em tracking-wide op50",
75
+ "n-header-upper": "text-sm uppercase mb-2 leading-1.2em tracking-wide op50",
75
76
  "n-button-base": "border n-border-base rounded shadow-sm px-1em py-0.25em inline-flex items-center gap-1 op80 !outline-none",
76
77
  "n-button-hover": "op100 !border-context text-context",
77
78
  "n-button-active": "n-active-base bg-context/5",
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@nuxt/ui",
3
- "version": "0.0.0-alpha.1",
3
+ "version": "0.0.0-alpha.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {
7
7
  "build": "unbuild && cp -R src/components dist/",
8
8
  "lint": "eslint . --ext .vue,.ts",
9
9
  "dev": "yarn nuxi dev playground",
10
- "release": "bumpp --commit --tag --push --preid alpha && npm publish"
10
+ "prepublishOnly": "npm run build",
11
+ "release": "bumpp --commit --tag --push --preid alpha && yarn publish --non-interactive"
11
12
  },
12
13
  "main": "./dist/nuxt.mjs",
13
14
  "exports": {
@@ -26,25 +27,25 @@
26
27
  ],
27
28
  "dependencies": {
28
29
  "@nuxt/kit": "npm:@nuxt/kit-edge@latest",
29
- "@unocss/core": "^0.15.6",
30
- "@unocss/nuxt": "^0.15.6",
31
- "@unocss/preset-attributify": "^0.15.6",
32
- "@unocss/preset-icons": "^0.15.6",
33
- "@unocss/preset-mini": "^0.15.6",
34
- "@unocss/preset-uno": "^0.15.6",
35
- "@unocss/reset": "^0.15.6",
36
- "@vueuse/integrations": "^7.2.2",
37
- "@vueuse/nuxt": "^7.2.2",
30
+ "@unocss/core": "^0.16.4",
31
+ "@unocss/nuxt": "^0.16.4",
32
+ "@unocss/preset-attributify": "^0.16.4",
33
+ "@unocss/preset-icons": "^0.16.4",
34
+ "@unocss/preset-mini": "^0.16.4",
35
+ "@unocss/preset-uno": "^0.16.4",
36
+ "@unocss/reset": "^0.16.4",
37
+ "@vueuse/integrations": "^7.3.0",
38
+ "@vueuse/nuxt": "^7.3.0",
38
39
  "focus-trap": "^6.7.1"
39
40
  },
40
41
  "devDependencies": {
41
- "@antfu/eslint-config": "^0.12.2",
42
+ "@antfu/eslint-config": "^0.13.1",
42
43
  "@iconify-json/carbon": "^1.0.12",
43
44
  "bumpp": "^7.1.1",
44
45
  "eslint": "^8.4.1",
45
46
  "nuxt3": "latest",
46
- "typescript": "^4.5.2",
47
- "unbuild": "^0.6.3"
47
+ "typescript": "^4.5.4",
48
+ "unbuild": "^0.6.7"
48
49
  },
49
50
  "eslintConfig": {
50
51
  "extends": "@antfu"
package/dist/nuxt.cjs DELETED
@@ -1,145 +0,0 @@
1
- 'use strict';
2
-
3
- const url = require('url');
4
- const path = require('path');
5
- const fs = require('fs');
6
- const kit = require('@nuxt/kit');
7
- const UnocssModule = require('@unocss/nuxt');
8
- const VueUseModule = require('@vueuse/nuxt');
9
- const core = require('@unocss/core');
10
- const presetUno = require('@unocss/preset-uno');
11
- const rules = require('@unocss/preset-mini/rules');
12
- const presetIcons = require('@unocss/preset-icons');
13
- const presetAttributify = require('@unocss/preset-attributify');
14
-
15
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
16
-
17
- const UnocssModule__default = /*#__PURE__*/_interopDefaultLegacy(UnocssModule);
18
- const VueUseModule__default = /*#__PURE__*/_interopDefaultLegacy(VueUseModule);
19
- const presetUno__default = /*#__PURE__*/_interopDefaultLegacy(presetUno);
20
- const presetIcons__default = /*#__PURE__*/_interopDefaultLegacy(presetIcons);
21
- const presetAttributify__default = /*#__PURE__*/_interopDefaultLegacy(presetAttributify);
22
-
23
- const NuxtUIPreset = {
24
- name: "nuxt-ui",
25
- theme: core.mergeDeep(presetUno.theme, {
26
- colors: {
27
- context: "rgba(var(--nui-c-context),%alpha)"
28
- },
29
- fontFamily: {
30
- sans: "Avenir, Helvetica, Arial, sans-serif"
31
- }
32
- }),
33
- rules: [
34
- [/^n-(.*)$/, ([, body], { theme }) => {
35
- const { rgba } = rules.parseColorUtil(body, theme) || {};
36
- if (rgba) {
37
- return {
38
- "--nui-c-context": `${rgba.join(",")}`
39
- };
40
- }
41
- }],
42
- [/^n-(.*)$/, rules.fontSizes[0][1]],
43
- ["n-dashed", { "border-style": "dashed" }],
44
- ["n-solid", {
45
- "background-color": "rgba(var(--nui-c-context), 1) !important",
46
- "border-color": "rgba(var(--nui-c-context), 1)",
47
- "color": "white !important"
48
- }],
49
- ["n-disabled", {
50
- "opacity": 0.4,
51
- "pointer-events": "none",
52
- "filter": "saturate(0)"
53
- }]
54
- ],
55
- variants: [
56
- (input) => {
57
- const prefix = "n-disabled:";
58
- if (input.startsWith(prefix)) {
59
- return {
60
- matcher: input.slice(prefix.length),
61
- selector: (input2) => `[disabled] ${input2}, ${input2}[disabled]`
62
- };
63
- }
64
- },
65
- (input) => {
66
- const prefix = "n-checked:";
67
- if (input.startsWith(prefix)) {
68
- return {
69
- matcher: input.slice(prefix.length),
70
- selector: (input2) => `[checked] ${input2}, ${input2}[checked]`
71
- };
72
- }
73
- }
74
- ],
75
- shortcuts: {
76
- "n-bg-base": "bg-white dark:bg-[#222]",
77
- "n-border-base": "border-gray-400/50",
78
- "n-border-300": "border-gray-400/40",
79
- "n-border-200": "border-gray-400/25",
80
- "n-transition": "transition-all duration-200",
81
- "n-focus-base": "ring-2 ring-context/50",
82
- "n-active-base": "ring-3 ring-context/10",
83
- "n-card-base": "border n-border-200 rounded n-bg-base shadow-sm",
84
- "n-header-upper": "text-sm case-upper mb-2 leading-1.2em tracking-wide op50",
85
- "n-button-base": "border n-border-base rounded shadow-sm px-1em py-0.25em inline-flex items-center gap-1 op80 !outline-none",
86
- "n-button-hover": "op100 !border-context text-context",
87
- "n-button-active": "n-active-base bg-context/5",
88
- "n-button-icon": "-ml-0.2em mr-0.2em text-1.1em",
89
- "n-checkbox-box": "border n-border-base w-1.1em h-1.1em mr-1 text-white flex flex-none items-center rounded-sm overflow-visible",
90
- "n-checkbox-box-checked": "bg-context border-context",
91
- "n-checkbox-icon": "carbon-checkmark",
92
- "n-radio-box": "border n-border-base w-1.2em h-1.2em mr-1 text-white flex flex-none rounded-full overflow-visible",
93
- "n-radio-box-checked": "border-context",
94
- "n-radio-inner": "bg-context rounded-1/2 w-0 h-0 m-auto",
95
- "n-radio-inner-checked": "w-0.8em h-0.8em",
96
- "n-switch-base": "inline-flex items-center select-none",
97
- "n-switch-slider": "mr-1 rounded-full border n-border-base relative p-2px",
98
- "n-switch-slider-checked": "border-context/20 bg-context/10",
99
- "n-switch-thumb": "h-1em w-1em rounded-1/2 border n-border-base ml-0 mr-0.8em",
100
- "n-switch-thumb-checked": "bg-context border-context ml-0.8em mr-0",
101
- "n-tip-base": "bg-context/8 text-context px-1em py-0.4em rounded flex items-center dark:bg-context/12",
102
- "n-tip-icon": "-ml-0.2em mr-0.4em text-1.1em"
103
- }
104
- };
105
- function extendUnocssOptions(user = {}) {
106
- return {
107
- ...user,
108
- preflight: true,
109
- presets: [
110
- presetUno__default(),
111
- presetAttributify__default(),
112
- presetIcons__default({
113
- prefix: "",
114
- scale: 1.2,
115
- extraProperties: {
116
- "display": "inline-block",
117
- "vertical-align": "middle"
118
- }
119
- }),
120
- NuxtUIPreset,
121
- ...user.presets || []
122
- ]
123
- };
124
- }
125
-
126
- const rPath = (p) => url.fileURLToPath(new URL(p, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('nuxt.cjs', document.baseURI).href))).toString());
127
- const nuxt = kit.defineNuxtModule({
128
- name: "nui",
129
- defaults: {
130
- preset: rPath("./preset"),
131
- dev: false
132
- },
133
- async setup(options, nuxt) {
134
- kit.addComponentsDir({ path: rPath("./components") });
135
- const presetStyles = path.resolve(options.preset, "styles.css");
136
- if (fs.existsSync(presetStyles))
137
- nuxt.options.css.push(presetStyles);
138
- if (!options.dev)
139
- nuxt.options.unocss = extendUnocssOptions(nuxt.options.unocss);
140
- await kit.installModule(nuxt, UnocssModule__default);
141
- await kit.installModule(nuxt, VueUseModule__default);
142
- }
143
- });
144
-
145
- module.exports = nuxt;