Skip to content

Commit 23a4272

Browse files
committed
feat(links): adds custom links to list & broaden conditions
1 parent 476a42f commit 23a4272

25 files changed

+921
-171
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"eslint-plugin-markdown": "^3.0.1",
9797
"eslint-plugin-prettier": "^5.1.2",
9898
"eslint-plugin-vitest": "^0.4.0",
99-
"eslint-plugin-vue": "^9.19.2",
99+
"eslint-plugin-vue": "^9.29.0",
100100
"eslint-plugin-vuejs-accessibility": "^2.2.0",
101101
"eslint-plugin-yml": "^1.0.0",
102102
"esno": "^4.0.0",

pnpm-lock.yaml

+50-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/common/buttons/TagLink.vue

+32-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import { NIcon, NTag } from 'naive-ui';
3-
import { type PropType, toRefs } from 'vue';
3+
import { computed, type PropType, toRefs } from 'vue';
44
55
import type { TagLink } from '~/models/tag.model';
66
@@ -9,9 +9,20 @@ const props = defineProps({
99
type: Object as PropType<TagLink>,
1010
required: true,
1111
},
12+
short: {
13+
type: Boolean,
14+
required: false,
15+
},
16+
});
17+
18+
const { tag, short } = toRefs(props);
19+
20+
const label = computed(() => {
21+
if (short.value) return tag?.value?.short || tag?.value?.label;
22+
return tag?.value?.label;
1223
});
1324
14-
const { tag } = toRefs(props);
25+
const iconOnly = computed(() => tag?.value?.iconOnly && tag?.value?.icon);
1526
1627
const emit = defineEmits<{
1728
(e: 'onClick', href?: string): void;
@@ -35,13 +46,21 @@ const onClick = (e: MouseEvent) => {
3546
>
3647
<NTag
3748
class="tag"
38-
:class="{ meta: tag?.meta, link: !!tag?.url }"
49+
:class="{
50+
meta: tag?.meta,
51+
link: !!tag?.url,
52+
icon: tag?.icon,
53+
only: iconOnly,
54+
square: !tag?.round,
55+
}"
3956
size="small"
4057
v-bind="tag"
4158
>
42-
<span class="label">{{ tag?.label }}</span>
59+
<span v-if="!iconOnly" class="label">{{ label }}</span>
4360
<template v-if="tag?.icon" #icon>
44-
<NIcon class="icon" :component="tag.icon" v-bind="tag.iconProps" />
61+
<NIcon class="icon" v-bind="tag.iconProps">
62+
<component :is="tag.icon" v-bind="tag.iconImgProps" />
63+
</NIcon>
4564
</template>
4665
</NTag>
4766
</a>
@@ -54,6 +73,14 @@ const onClick = (e: MouseEvent) => {
5473
.tag {
5574
width: fit-content;
5675
border: 1px solid transparent;
76+
77+
&.only {
78+
padding: 0.1rem;
79+
}
80+
81+
&.icon.square {
82+
padding-left: 0.25rem;
83+
}
5784
}
5885
5986
&:focus-visible {

src/components/common/list/ListItemPanel.vue

+20-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import TagLink from '~/components/common/buttons/TagLink.vue';
1919
import ProgressTooltip from '~/components/common/tooltip/ProgressTooltip.vue';
2020
import IconGrid from '~/components/icons/IconGrid.vue';
2121
import IconPlayFilled from '~/components/icons/IconPlayFilled.vue';
22+
import { getCustomLinkIcon } from '~/models/link.model';
2223
import { type ListScrollItem, type ShowProgress } from '~/models/list-scroll.model';
2324
2425
import { ProgressType } from '~/models/progress-type.model';
@@ -98,9 +99,17 @@ const date = computed(() => {
9899
const tags = computed(
99100
() =>
100101
item.value.tags?.map(tag => {
101-
if (!tag.i18n) return tag;
102-
if (typeof tag.i18n === 'boolean') return { ...tag, label: i18n(tag.label) };
103-
return { ...tag, label: i18n(tag.label, ...tag.i18n) };
102+
const _tag = { ...tag };
103+
104+
if (tag.i18n && typeof tag.i18n === 'boolean') _tag.label = i18n(tag.label);
105+
else if (tag.i18n) _tag.label = i18n(tag.label, ...tag.i18n);
106+
107+
if (!tag.icon && tag.iconType) {
108+
const { icon, iconProps } = getCustomLinkIcon(tag.iconType);
109+
_tag.icon = icon;
110+
_tag.iconProps = iconProps;
111+
}
112+
return _tag;
104113
}),
105114
);
106115
@@ -300,6 +309,7 @@ const onTagClick = (url?: string) => {
300309
"
301310
size="medium"
302311
class="tags"
312+
:class="{ 'show-progress': showProgress }"
303313
>
304314
<template v-if="loading && showTagLoader">
305315
<NSkeleton text style="width: 120px; height: 18px; border-radius: 2px" />
@@ -311,7 +321,7 @@ const onTagClick = (url?: string) => {
311321
text
312322
style="width: 120px; height: 18px; border-radius: 2px"
313323
/>
314-
<TagLink :tag="tag" @on-click="onTagClick" />
324+
<TagLink :tag="tag" short @on-click="onTagClick" />
315325
</template>
316326
</template>
317327

@@ -440,7 +450,13 @@ const onTagClick = (url?: string) => {
440450
441451
.tags {
442452
gap: 0.5rem !important;
453+
max-height: 3.325rem;
443454
margin-top: 0.3rem;
455+
overflow: scroll;
456+
457+
&.show-progress {
458+
max-height: 1.5rem;
459+
}
444460
}
445461
446462
.panel-progress {

0 commit comments

Comments
 (0)