Skip to content

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

Add `VSnackbar` component (#1621)

Krystle Salazar0b886933f9d7
diff --git a/src/components/VContentLink/meta/VContentLink.stories.js b/src/components/VContentLink/meta/VContentLink.stories.js
index 5889d8ce5..d1ab539a6 100644
--- a/src/components/VContentLink/meta/VContentLink.stories.js
+++ b/src/components/VContentLink/meta/VContentLink.stories.js
@@ -82,5 +82,5 @@ Horizontal.args = {
export const Mobile = TwoVContentLinkStory.bind({})
Mobile.parameters = {
- viewport: { defaultViewport: 'mob' },
+ viewport: { defaultViewport: 'xs' },
}
diff --git a/src/components/VSnackbar.vue b/src/components/VSnackbar.vue
new file mode 100644
index 000000000..86a0d21df
--- /dev/null
+++ b/src/components/VSnackbar.vue
@@ -0,0 +1,35 @@
+<template>
+ <div role="alert" :class="[$style.snackbar, $style[size]]">
+ <!-- @slot Your message or subcomponent goes passed here. -->
+ <slot />
+ </div>
+</template>
+
+<script lang="ts">
+import { defineComponent, PropType } from '@nuxtjs/composition-api'
+
+export default defineComponent({
+ name: 'VSnackbar',
+ props: {
+ size: {
+ type: String as PropType<'small' | 'large'>,
+ default: 'small',
+ },
+ },
+})
+</script>
+
+<style module>
+.snackbar {
+ box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.3);
+ @apply fixed bottom-4 rounded-sm bg-black text-white ltr:left-4 rtl:right-4;
+}
+
+.large {
+ @apply w-max max-w-full flex-row items-center py-4 px-8 text-sm;
+}
+
+.small {
+ @apply w-2/3 flex-col items-start py-3 px-4 text-sr sm:w-2/5;
+}
+</style>
diff --git a/src/components/meta/VSnackbar.stories.mdx b/src/components/meta/VSnackbar.stories.mdx
new file mode 100644
index 000000000..697ab0508
--- /dev/null
+++ b/src/components/meta/VSnackbar.stories.mdx
@@ -0,0 +1,47 @@
+import {
+ ArgsTable,
+ Canvas,
+ Description,
+ Meta,
+ Story,
+} from '@storybook/addon-docs'
+
+import VSnackbar from '~/components/VSnackbar.vue'
+
+<Meta
+ title="Components/VSnackbar"
+ components={VSnackbar}
+ argTypes={{
+ size: {
+ options: ['large', 'small'],
+ control: { type: 'radio' },
+ },
+ }}
+/>
+
+export const Template = (args) => ({
+ components: { VSnackbar },
+ template: `
+ <VSnackbar v-bind="args">
+ <template v-slot>${args.defaultSlot}</template>
+ </Vsnackbar>
+ `,
+ setup() {
+ return { args }
+ },
+})
+
+# VSnackbar
+
+<Description of={VSnackbar} />
+
+<ArgsTable of={VSnackbar} />
+
+<Canvas>
+ <Story
+ name="Default"
+ args={{ defaultSlot: 'Your message goes here.', size: 'small' }}
+ >
+ {Template.bind({})}
+ </Story>
+</Canvas>
diff --git a/tsconfig.json b/tsconfig.json
index 4677796fa..b6ae0c31f 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -63,6 +63,7 @@
"src/components/VMediaInfo/**.vue",
"src/components/VMediaTag/**.vue",
"src/components/VMetaSearch/*.vue",
+ "src/components/VSnackbar.vue",
"src/components/VSkeleton/**.vue",
"src/components/VTabs/**.vue",
"src/components/VAllResultsGrid/VAudioCell.vue",