Skip to content

Commit 595591f

Browse files
committed
0.1.4: MyFeaturePanel props
1 parent 0adc226 commit 595591f

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

.eslintrc.cjs

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = {
1717
'@typescript-eslint'
1818
],
1919
rules: {
20+
"func-call-spacing": "off",
21+
"@typescript-eslint/func-call-spacing": "error",
2022
"no-unused-vars": 0,
2123
"@typescript-eslint/no-unused-vars": "error",
2224
"no-undef": 0,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@libreservice/my-widget",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"main": "dist/index.js",
55
"type": "module",
66
"files": [

src/MyFeature.vue

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script setup lang="ts">
2-
import { Component } from 'vue'
2+
import { Component, VNode, defineComponent } from 'vue'
33
import { NIcon, NH3 } from 'naive-ui'
44
55
defineProps<{
66
icon: Component,
77
title: string,
8-
description: string
8+
content?: () => VNode
9+
description?: string
910
}>()
1011
</script>
1112

@@ -17,5 +18,11 @@ defineProps<{
1718
style="margin-right: 8px"
1819
/>{{ title }}
1920
</n-h3>
20-
{{ description }}
21+
<component
22+
:is="defineComponent(() => content!)"
23+
v-if="content"
24+
/>
25+
<template v-else>
26+
{{ description }}
27+
</template>
2128
</template>

src/MyFeaturePanel.vue

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1-
<script setup lang="ts">
2-
import { Component } from 'vue'
1+
<script lang="ts">
2+
import { Component, VNode } from 'vue'
33
import { NCard, NH2, NGrid, NGi } from 'naive-ui'
44
import MyFeature from './MyFeature.vue'
55
6-
defineProps<{
6+
interface Props {
7+
title: string
78
features: {
89
icon: Component,
910
title: string,
10-
description: string
11+
content?: () => VNode
12+
description?: string
1113
}[]
12-
}>()
14+
}
15+
</script>
16+
17+
<script setup lang="ts">
18+
withDefaults(defineProps<Props>(), {
19+
title: 'Features'
20+
})
1321
</script>
1422

1523
<template>
1624
<n-card>
1725
<div style="text-align: center">
18-
<n-h2>Features</n-h2>
26+
<n-h2>{{ title }}</n-h2>
1927
</div>
2028
<n-grid
2129
:x-gap="16"
2230
:y-gap="24"
2331
cols="1 400:2 600:3"
2432
>
25-
<n-gi v-for="{ icon, title, description } of features">
33+
<n-gi v-for="{ icon, title: panelTitle, content, description } of features">
2634
<my-feature
2735
:icon="icon"
28-
:title="title"
36+
:title="panelTitle"
37+
:content="content"
2938
:description="description"
3039
/>
3140
</n-gi>

0 commit comments

Comments
 (0)