Skip to content

Commit

Permalink
Create VTag component (#3137)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Olga Bulat <[email protected]>
  • Loading branch information
3 people authored Oct 13, 2023
1 parent ad4c814 commit 2e4cc83
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 3 deletions.
26 changes: 23 additions & 3 deletions frontend/src/components/VMediaInfo/VMediaTags.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
<template>
<ul v-if="tags.length" class="flex flex-wrap gap-2">
<ul v-if="tags.length && additionalSearchViews" class="flex flex-wrap gap-2">
<VTag
v-for="(tag, index) in tags"
:key="index"
href="/"
:title="tag.name"
/>
</ul>
<ul v-else>
<VMediaTag v-for="(tag, index) in tags" :key="index" tag="li">{{
tag.name
}}</VMediaTag>
</ul>
</template>
<script lang="ts">
import { defineComponent, PropType } from "vue"
import { computed, defineComponent, PropType } from "vue"
import type { Tag } from "~/types/media"
import { useFeatureFlagStore } from "~/stores/feature-flag"
import VMediaTag from "~/components/VMediaTag/VMediaTag.vue"
import VTag from "~/components/VTag/VTag.vue"
export default defineComponent({
name: "VMediaTags",
components: { VMediaTag },
components: { VMediaTag, VTag },
props: {
tags: {
type: Array as PropType<Tag[]>,
required: true,
},
},
setup() {
const featureFlagStore = useFeatureFlagStore()
const additionalSearchViews = computed(() =>
featureFlagStore.isOn("additional_search_views")
)
return { additionalSearchViews }
},
})
</script>
31 changes: 31 additions & 0 deletions frontend/src/components/VTag/VTag.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<VButton
as="VLink"
size="small"
variant="filled-gray"
class="label-bold"
:href="href"
>{{ title }}</VButton
>
</template>

<script lang="ts">
import { defineComponent } from "vue"
import VButton from "~/components/VButton.vue"
export default defineComponent({
name: "VTag",
components: { VButton },
props: {
title: {
type: String,
required: true,
},
href: {
type: String,
required: true,
},
},
})
</script>
48 changes: 48 additions & 0 deletions frontend/src/components/VTag/meta/VTag.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
ArgsTable,
Canvas,
Description,
Meta,
Story,
} from "@storybook/addon-docs"

import VTag from "~/components/VTag/VTag.vue"

<Meta
title="Components/VTag"
component={VTag}
argTypes={{
title: {
type: "text",
},
href: {
type: "text",
},
}}
/>

export const Template = (args) => ({
template: `<VTag v-bind="args"/>`,
components: { VTag },
setup() {
return { args }
},
})

# VTag

<Description of={VTag} />

<ArgsTable of={VTag} />

<Canvas>
<Story
name="default"
args={{
title: "cat",
href: "#",
}}
>
{Template.bind({})}
</Story>
</Canvas>

0 comments on commit 2e4cc83

Please sign in to comment.