Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create VTag component #3137

Merged
merged 7 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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">{{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add v-else to VMediaTag here, it will be hidden when additionalSearchViews is true, so there'll be no duplication of tags.

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 }
},
})

# tag
obulat marked this conversation as resolved.
Show resolved Hide resolved

<Description of={VTag} />

<ArgsTable of={VTag} />

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