Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Convert `VContentLink` story to MDX (#1062)

Sepehr Rezaeicde702e1cc3a
diff --git a/frontend/src/components/VContentLink/meta/VContentLink.stories.js b/frontend/src/components/VContentLink/meta/VContentLink.stories.js
deleted file mode 100644
index 419686a1d..000000000
--- a/frontend/src/components/VContentLink/meta/VContentLink.stories.js
+++ /dev/null
@@ -1,86 +0,0 @@
-import VContentLink from "~/components/VContentLink/VContentLink.vue"
-
-export default {
- title: "Components/VContentLink",
- component: VContentLink,
- argTypes: {
- mediaType: {
- options: ["audio", "image"],
- control: { type: "radio" },
- },
- resultsCount: {
- control: { type: "number" },
- },
- isSelected: {
- control: { type: "boolean" },
- },
- layout: {
- options: ["stacked", "horizontal"],
- control: { type: "radio" },
- },
- },
-}
-
-const VContentLinkStory = (args) => ({
- template: `<VContentLink v-bind="args" />`,
- components: { VContentLink },
- setup() {
- return { args }
- },
-})
-
-const TwoVContentLinkStory = () => ({
- template: `
- <div class="grid grid-cols-2 gap-4">
- <VContentLink
- v-for="(type, key) in types"
- :key="key"
- :media-type="type.mediaType"
- :results-count="type.resultsCount"
- />
- </div>
- `,
- components: { VContentLink },
- data() {
- return {
- types: [
- { mediaType: "image", resultsCount: 4321 },
- { mediaType: "audio", resultsCount: 1234 },
- ],
- selected: "audio",
- }
- },
- methods: {
- onSelected(mediaType) {
- this.selected = mediaType
- },
- },
-})
-
-export const Default = VContentLinkStory.bind({})
-Default.args = {
- mediaType: "image",
- resultsCount: 5708,
- isSelected: false,
-}
-
-const VContentLinkHorizontalStory = (args) => ({
- template: `<div class="max-w-md"><VContentLink v-bind="args" /></div>`,
- components: { VContentLink },
- setup() {
- return { args }
- },
-})
-
-export const Horizontal = VContentLinkHorizontalStory.bind({})
-Horizontal.args = {
- mediaType: "audio",
- resultsCount: 4561,
- isSelected: false,
- layout: "horizontal",
-}
-
-export const Mobile = TwoVContentLinkStory.bind({})
-Mobile.parameters = {
- viewport: { defaultViewport: "xs" },
-}
diff --git a/frontend/src/components/VContentLink/meta/VContentLink.stories.mdx b/frontend/src/components/VContentLink/meta/VContentLink.stories.mdx
new file mode 100644
index 000000000..c3c236d9e
--- /dev/null
+++ b/frontend/src/components/VContentLink/meta/VContentLink.stories.mdx
@@ -0,0 +1,113 @@
+import {
+ ArgsTable,
+ Canvas,
+ Description,
+ Meta,
+ Story,
+} from "@storybook/addon-docs"
+
+import VContentLink from "~/components/VContentLink/VContentLink.vue"
+
+<Meta title="Components/VContentLink" components={VContentLink} argTypes={{}} />
+
+export const contentLinkArgTypes = {
+ mediaType: { options: ["audio", "image"], control: { type: "radio" } },
+ resultsCount: { control: { type: "number" } },
+ isSelected: { control: { type: "boolean" } },
+ layout: { options: ["stacked", "horizontal"], control: { type: "radio" } },
+}
+
+export const VContentLinkStory = (args) => ({
+ template: `<VContentLink v-bind="args" />`,
+ components: { VContentLink },
+ setup() {
+ return { args }
+ },
+})
+
+export const VContentLinkHorizontalStory = (args) => ({
+ template: `<div class="max-w-md"><VContentLink v-bind="args" /></div>`,
+ components: { VContentLink },
+ setup() {
+ return { args }
+ },
+})
+
+export const TwoVContentLinkStory = (agrs) => ({
+ template: `
+ <div class="grid grid-cols-2 gap-4">
+ <VContentLink
+ v-for="(type, key) in types"
+ :key="key"
+ :media-type="type.mediaType"
+ :results-count="type.resultsCount"
+ />
+ </div>
+ `,
+ components: { VContentLink },
+ data() {
+ return {
+ types: [
+ { mediaType: "image", resultsCount: 4321 },
+ { mediaType: "audio", resultsCount: 1234 },
+ ],
+ }
+ },
+ methods: {
+ onSelected(mediaType) {
+ this.selected = mediaType
+ },
+ },
+})
+
+# VContentLink
+
+<Description of={VContentLink} />
+
+<ArgsTable of={VContentLink} />
+
+## Default VContentLink
+
+<Canvas>
+ <Story
+ name="Default"
+ args={{
+ mediaType: "image",
+ resultsCount: 5708,
+ isSelected: false,
+ }}
+ argTypes={contentLinkArgTypes}
+ >
+ {VContentLinkStory.bind({})}
+ </Story>
+</Canvas>
+
+## Horizontal VContentLink
+
+<Canvas>
+ <Story
+ name="Horizontal"
+ args={{
+ mediaType: "audio",
+ resultsCount: 4561,
+ isSelected: false,
+ layout: "horizontal",
+ }}
+ argTypes={contentLinkArgTypes}
+ >
+ {VContentLinkHorizontalStory.bind({})}
+ </Story>
+</Canvas>
+
+## Mobile VContentLink
+
+<Canvas>
+ <Story
+ name="Mobile"
+ parameters={{
+ viewport: { defaultViewport: "xs" },
+ }}
+ >
+ {TwoVContentLinkStory.bind({})}
+ </Story>
+</Canvas>