main
vue 78 lines 1.28 KB
Raw
1 <template>
2 <div class="rules-list flex flex-col">
3 <n-button v-for="rule of rules" :key="rule.id" quaternary size="tiny" @click="emit('click', rule.id)">
4 <div class="btn-wrap flex items-center">
5 <span class="spacer">
6 <Icon :name="ViewIcon" :size="16" />
7 </span>
8 <span class="title grow">
9 {{ rule.title }}
10 </span>
11 <span class="spacer small"></span>
12 </div>
13 </n-button>
14 </div>
15 </template>
16
17 <script setup lang="ts">
18 import { NButton } from "naive-ui"
19 import { toRefs } from "vue"
20 import Icon from "@/components/common/Icon.vue"
21
22 export interface RuleExtended {
23 title: string
24 id: string
25 }
26
27 const props = defineProps<{ rules: RuleExtended[] }>()
28
29 const emit = defineEmits<{
30 (e: "click", value: string): void
31 }>()
32
33 const { rules } = toRefs(props)
34
35 const ViewIcon = "iconoir:eye-solid"
36 </script>
37
38 <style lang="scss" scoped>
39 .rules-list {
40 .n-button {
41 min-width: 100%;
42
43 :deep(.n-button__content) {
44 min-width: 100%;
45 }
46
47 .btn-wrap {
48 max-width: 270px;
49 overflow: hidden;
50
51 .title {
52 overflow: hidden;
53 text-overflow: ellipsis;
54 white-space: nowrap;
55 }
56
57 .spacer {
58 min-width: 24px;
59
60 &.small {
61 min-width: 20px;
62 }
63 }
64 }
65
66 i {
67 opacity: 0;
68 transition: opacity 0.2s;
69 }
70
71 &:hover {
72 i {
73 opacity: 1;
74 }
75 }
76 }
77 }
78 </style>