@yunlefun/vue 0.0.2 → 0.0.3

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.
@@ -0,0 +1,17 @@
1
+ import { defineBuildConfig } from 'unbuild'
2
+
3
+ export default defineBuildConfig({
4
+ entries: [
5
+ './src/index',
6
+ ],
7
+
8
+ declaration: true,
9
+ clean: true,
10
+ rollup: {
11
+ emitCJS: true,
12
+ },
13
+ externals: [
14
+ 'unplugin-vue-components',
15
+ '@nuxt/kit',
16
+ ],
17
+ })
@@ -0,0 +1,7 @@
1
+ <template>
2
+ <div class="bg-gray-100">
3
+ <nav class="flex justify-between mx-auto">
4
+ <slot />
5
+ </nav>
6
+ </div>
7
+ </template>
@@ -0,0 +1,52 @@
1
+ <script lang="ts" setup>
2
+ import type { BottomMenuItem } from '@yunlefun/vue-components'
3
+
4
+ defineProps<{
5
+ active: boolean
6
+ item: BottomMenuItem
7
+ }>()
8
+
9
+ const emit = defineEmits(['click'])
10
+ </script>
11
+
12
+ <template>
13
+ <button
14
+ :class="{
15
+ active,
16
+ }"
17
+ class="ylf-bottom-menu-item hover:text-gray-900 cursor-pointer transition"
18
+ flex="~ 1"
19
+ justify="center" items="center"
20
+ text-gray-800 dark="text-white"
21
+ hover="text-blue-500"
22
+ p="2"
23
+ :to="item.to"
24
+ @click="emit('click', item)"
25
+ >
26
+ <div flex="~ col" justify="center" items="center">
27
+ <slot>
28
+ <div text-xl :class="(active && item.activeIcon) || item.icon" />
29
+ <span text-xs mt="1">
30
+ {{ item.title }}
31
+ </span>
32
+ </slot>
33
+ </div>
34
+ </button>
35
+ </template>
36
+
37
+ <style lang="scss">
38
+ .ylf-bottom-menu-item {
39
+ color: var(--ylf-c-text, black);
40
+ background-color: var(--ylf-bottom-menu-c-bg, #fff);
41
+
42
+ &.active {
43
+ color: var(--ylf-c-primary, dodgerblue);
44
+ }
45
+ }
46
+
47
+ .dark {
48
+ .ylf-bottom-menu-item {
49
+ --ylf-bottom-menu-c-bg: #222;
50
+ }
51
+ }
52
+ </style>
@@ -0,0 +1,42 @@
1
+ <script lang="ts" setup>
2
+ import type { BottomMenuItem } from '@yunlefun/vue-components'
3
+ import { ref } from 'vue'
4
+
5
+ const items: BottomMenuItem[] = [
6
+ {
7
+ icon: 'i-ri-home-line',
8
+ activeIcon: 'i-ri-home-fill',
9
+ title: '首页',
10
+ to: '/',
11
+ },
12
+ {
13
+ icon: 'i-ri-compass-2-line',
14
+ activeIcon: 'i-ri-compass-2-fill',
15
+ title: '发现',
16
+ to: '/discover',
17
+ },
18
+ {
19
+ icon: 'i-ri-user-line',
20
+ activeIcon: 'i-ri-user-fill',
21
+ title: '我的',
22
+ to: '/user',
23
+ },
24
+ ]
25
+
26
+ const active = ref('/')
27
+ function onClick(item: BottomMenuItem) {
28
+ active.value = item.to || ''
29
+ }
30
+ </script>
31
+
32
+ <template>
33
+ <YlfBottomMenu shadow>
34
+ <YlfBottomMenuItem
35
+ v-for="item in items"
36
+ :key="item.to"
37
+ :item="item"
38
+ :active="active === item.to"
39
+ @click="onClick"
40
+ />
41
+ </YlfBottomMenu>
42
+ </template>
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Bottom Menu
3
+ title_zh: 底部菜单
4
+ ---
@@ -0,0 +1,20 @@
1
+ export interface BottomMenuItem {
2
+ title: string
3
+ /**
4
+ * @description icon class
5
+ */
6
+ icon: string
7
+ /**
8
+ * @description active icon class
9
+ */
10
+ activeIcon?: string
11
+ /**
12
+ * @description RouterLink to
13
+ */
14
+ to?: string
15
+ /**
16
+ * onClick
17
+ * @returns
18
+ */
19
+ onClick?: () => void
20
+ }
package/index.md ADDED
@@ -0,0 +1,35 @@
1
+ # Components
2
+
3
+ ## Usage
4
+
5
+ ```bash
6
+ pnpm add -D @yunlefun/vue-components
7
+ ```
8
+
9
+ ### Add auto import resolver for vue components
10
+
11
+ ```ts
12
+ // vite.config.ts
13
+ import { defineConfig } from 'vite'
14
+ import { YlfResolver } from '@yunlefun/vue-components/auto-import-resolver'
15
+ import Components from 'unplugin-vue-components/vite'
16
+
17
+ export default defineConfig({
18
+ plugins: [
19
+ // https://github.com/antfu/unplugin-vue-components
20
+ Components({
21
+ // allow auto load markdown components under `./src/components/`
22
+ extensions: ['vue', 'md'],
23
+ // allow auto import and register components used in markdown
24
+ include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
25
+ dts: 'src/components.d.ts',
26
+ resolvers: [
27
+ // add @yunlefun/vue-components auto import resolver
28
+ YlfResolver(),
29
+ ],
30
+ }),
31
+ ]
32
+ })
33
+ ```
34
+
35
+ You can use `<YlfXxx />` components in your vue files directly.
package/nuxt.js ADDED
@@ -0,0 +1,14 @@
1
+ import { createResolver, defineNuxtModule } from '@nuxt/kit'
2
+
3
+ export default defineNuxtModule({
4
+ hooks: {
5
+ 'components:dirs': (dirs) => {
6
+ const { resolve } = createResolver(import.meta.url)
7
+ // Add ./components dir to the list
8
+ dirs.push({
9
+ path: fileURLToPath(resolve('./components')),
10
+ prefix: '',
11
+ })
12
+ },
13
+ },
14
+ })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yunlefun/vue",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "description": "Components for YunLeFun",
6
6
  "exports": {
7
7
  "./components/*": "./components/*",
@@ -16,10 +16,6 @@
16
16
  "main": "./dist/index.cjs",
17
17
  "module": "./dist/index.mjs",
18
18
  "types": "./dist/index.d.ts",
19
- "files": [
20
- "dist",
21
- "auto-import-resolver.d.ts"
22
- ],
23
19
  "scripts": {
24
20
  "build": "unbuild",
25
21
  "prepublishOnly": "npm run build",
package/src/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @yunlefun/vue
2
+
3
+ - `components`: Source Vue Components.
@@ -0,0 +1 @@
1
+ export default {}
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { dirname, resolve } from 'node:path'
2
+
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ // other exports
6
+ export * from './types'
7
+
8
+ // shim
9
+ export const _dirname = typeof __dirname !== 'undefined'
10
+ ? __dirname
11
+ : dirname(fileURLToPath(import.meta.url))
12
+
13
+ export const componentsDir = resolve(_dirname, '../components')
package/src/module.ts ADDED
@@ -0,0 +1 @@
1
+ type DeepPartial<T> = Partial<{ [P in keyof T]: DeepPartial<T[P]> | { [key: string]: string } }>
package/src/types.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '../components/bottom-menu'
package/tsconfig.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "."
5
+ }
6
+ }