Skip to content

Commit 2e4cc83

Browse files
ngken0995Panisa Busayanontobulat
authored
Create VTag component (#3137)
* create VTag component * revise VTag and VMediaTags * revise test and update VMediaTags * run just lint * revise VTag storybook * revise VTag storybook * Update frontend/src/components/VTag/meta/VTag.stories.mdx --------- Co-authored-by: Panisa Busayanont <Panisa@ecipanisamac.lan> Co-authored-by: Olga Bulat <obulat@gmail.com>
1 parent ad4c814 commit 2e4cc83

File tree

3 files changed

+102
-3
lines changed

3 files changed

+102
-3
lines changed
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
<template>
2-
<ul v-if="tags.length" class="flex flex-wrap gap-2">
2+
<ul v-if="tags.length && additionalSearchViews" class="flex flex-wrap gap-2">
3+
<VTag
4+
v-for="(tag, index) in tags"
5+
:key="index"
6+
href="/"
7+
:title="tag.name"
8+
/>
9+
</ul>
10+
<ul v-else>
311
<VMediaTag v-for="(tag, index) in tags" :key="index" tag="li">{{
412
tag.name
513
}}</VMediaTag>
614
</ul>
715
</template>
816
<script lang="ts">
9-
import { defineComponent, PropType } from "vue"
17+
import { computed, defineComponent, PropType } from "vue"
1018
1119
import type { Tag } from "~/types/media"
20+
import { useFeatureFlagStore } from "~/stores/feature-flag"
1221
1322
import VMediaTag from "~/components/VMediaTag/VMediaTag.vue"
1423
24+
import VTag from "~/components/VTag/VTag.vue"
25+
1526
export default defineComponent({
1627
name: "VMediaTags",
17-
components: { VMediaTag },
28+
components: { VMediaTag, VTag },
1829
props: {
1930
tags: {
2031
type: Array as PropType<Tag[]>,
2132
required: true,
2233
},
2334
},
35+
setup() {
36+
const featureFlagStore = useFeatureFlagStore()
37+
38+
const additionalSearchViews = computed(() =>
39+
featureFlagStore.isOn("additional_search_views")
40+
)
41+
42+
return { additionalSearchViews }
43+
},
2444
})
2545
</script>

frontend/src/components/VTag/VTag.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
<VButton
3+
as="VLink"
4+
size="small"
5+
variant="filled-gray"
6+
class="label-bold"
7+
:href="href"
8+
>{{ title }}</VButton
9+
>
10+
</template>
11+
12+
<script lang="ts">
13+
import { defineComponent } from "vue"
14+
15+
import VButton from "~/components/VButton.vue"
16+
17+
export default defineComponent({
18+
name: "VTag",
19+
components: { VButton },
20+
props: {
21+
title: {
22+
type: String,
23+
required: true,
24+
},
25+
href: {
26+
type: String,
27+
required: true,
28+
},
29+
},
30+
})
31+
</script>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {
2+
ArgsTable,
3+
Canvas,
4+
Description,
5+
Meta,
6+
Story,
7+
} from "@storybook/addon-docs"
8+
9+
import VTag from "~/components/VTag/VTag.vue"
10+
11+
<Meta
12+
title="Components/VTag"
13+
component={VTag}
14+
argTypes={{
15+
title: {
16+
type: "text",
17+
},
18+
href: {
19+
type: "text",
20+
},
21+
}}
22+
/>
23+
24+
export const Template = (args) => ({
25+
template: `<VTag v-bind="args"/>`,
26+
components: { VTag },
27+
setup() {
28+
return { args }
29+
},
30+
})
31+
32+
# VTag
33+
34+
<Description of={VTag} />
35+
36+
<ArgsTable of={VTag} />
37+
38+
<Canvas>
39+
<Story
40+
name="default"
41+
args={{
42+
title: "cat",
43+
href: "#",
44+
}}
45+
>
46+
{Template.bind({})}
47+
</Story>
48+
</Canvas>

0 commit comments

Comments
 (0)