@yunlefun/vue 0.0.2 → 0.0.4
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,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,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/nuxt.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { createResolver, defineNuxtModule } from '@nuxt/kit'
|
|
3
|
+
|
|
4
|
+
export default defineNuxtModule({
|
|
5
|
+
hooks: {
|
|
6
|
+
'components:dirs': (dirs) => {
|
|
7
|
+
const { resolve } = createResolver(import.meta.url)
|
|
8
|
+
// Add ./components dir to the list
|
|
9
|
+
dirs.push({
|
|
10
|
+
path: fileURLToPath(resolve('./components')),
|
|
11
|
+
prefix: '',
|
|
12
|
+
})
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yunlefun/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "Components for YunLeFun",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./components/*": "./components/*",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
"module": "./dist/index.mjs",
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"files": [
|
|
20
|
+
"components",
|
|
20
21
|
"dist",
|
|
21
|
-
"
|
|
22
|
+
"nuxt.js"
|
|
22
23
|
],
|
|
23
24
|
"scripts": {
|
|
24
25
|
"build": "unbuild",
|