Skip to content

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

Add VContentSettingsButton (#1818)

Olga Bulat35c7c17cb9c0
diff --git a/src/assets/icons/source.svg b/src/assets/icons/source.svg
new file mode 100644
index 000000000..c86690f70
--- /dev/null
+++ b/src/assets/icons/source.svg
@@ -0,0 +1,2 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path id="icon" fill-rule="evenodd" clip-rule="evenodd" d="M7.114 8.5H4V7h3.114a2.501 2.501 0 0 1 4.772 0H20v1.5h-8.114a2.501 2.501 0 0 1-4.772 0ZM4 17h8.114a2.501 2.501 0 0 0 4.771 0H20v-1.5h-3.114a2.501 2.501 0 0 0-4.771 0H4V17Z" fill="currentColor"/></svg>
+
diff --git a/src/components/VButton.vue b/src/components/VButton.vue
index 93011597d..fc85a732a 100644
--- a/src/components/VButton.vue
+++ b/src/components/VButton.vue
@@ -48,6 +48,7 @@ export const buttonVariants = [
'primary',
'secondary',
'tertiary',
+ 'menu',
'action-menu',
'action-menu-secondary',
'action-menu-muted',
@@ -312,6 +313,12 @@ a.button {
.tertiary-pressed {
@apply border-tx bg-dark-charcoal text-white;
}
+.menu {
+ @apply border border-tx bg-white text-dark-charcoal ring-offset-0;
+}
+.menu-pressed {
+ @apply border border-tx bg-dark-charcoal text-white;
+}
.action-menu {
@apply border border-tx bg-tx text-dark-charcoal hover:border-dark-charcoal-20;
diff --git a/src/components/VHeader/VContentSettingsButton.vue b/src/components/VHeader/VContentSettingsButton.vue
new file mode 100644
index 000000000..1382f0d52
--- /dev/null
+++ b/src/components/VHeader/VContentSettingsButton.vue
@@ -0,0 +1,54 @@
+<template>
+ <span class="relative inline-block h-8 w-8">
+ <VIconButton
+ size="new-small"
+ :icon-props="{ iconPath: sourceIcon }"
+ :button-props="{ variant: 'menu', pressed: isPressed }"
+ :has-dot="areFiltersSelected"
+ :aria-label="
+ areFiltersSelected
+ ? $t('header.aria.menu-notification')
+ : $t('header.aria.menu')
+ "
+ :aria-haspopup="true"
+ :aria-pressed="isPressed"
+ aria-controls="content-settings-modal"
+ @click="$emit('click')"
+ />
+ <span
+ v-if="areFiltersSelected"
+ class="absolute top-[-2px] right-[-2px] h-[8px] w-[8px] rounded bg-pink"
+ />
+ </span>
+</template>
+
+<script lang="ts">
+import { defineEvent } from '~/types/emits'
+
+import VIconButton from '~/components/VIconButton/VIconButton.vue'
+
+import sourceIcon from '~/assets/icons/source.svg'
+
+export default {
+ name: 'VContentSettingsButton',
+ components: { VIconButton },
+ props: {
+ isPressed: {
+ type: Boolean,
+ default: false,
+ },
+ areFiltersSelected: {
+ type: Boolean,
+ default: false,
+ },
+ },
+ emits: {
+ click: defineEvent(),
+ },
+ setup() {
+ return {
+ sourceIcon,
+ }
+ },
+}
+</script>
diff --git a/src/components/VHeader/meta/VContentSettingsButton.stories.mdx b/src/components/VHeader/meta/VContentSettingsButton.stories.mdx
new file mode 100644
index 000000000..9e9da723f
--- /dev/null
+++ b/src/components/VHeader/meta/VContentSettingsButton.stories.mdx
@@ -0,0 +1,45 @@
+import {
+ ArgsTable,
+ Canvas,
+ Description,
+ Meta,
+ Story,
+} from '@storybook/addon-docs'
+import VContentSettingsButton from '~/components/VHeader/VContentSettingsButton.vue'
+
+<Meta
+ title="Components/VHeader/VContentSettingsButton"
+ component={VContentSettingsButton}
+ decorators={[
+ () => ({
+ template: '<div class="bg-dark-charcoal-20 p-10"><story /></div>',
+ }),
+ ]}
+ argTypes={{
+ click: {
+ action: 'click',
+ },
+ }}
+/>
+
+export const Template = (args, { argTypes }) => ({
+ template: `<VContentSettingsButton v-bind="args" v-on="args" />`,
+ components: { VContentSettingsButton },
+ props: Object.keys(argTypes),
+ setup() {
+ return { args }
+ },
+})
+
+# Content Settings button
+
+<Description of={VContentSettingsButton} />
+
+<ArgsTable of={VContentSettingsButton} />
+
+The button that opens the content settings modal on screens up to `lg` breakpoint.
+If any filters are selected, it shows a pink dot in the top right corner.
+
+<Canvas>
+ <Story name="Default">{Template.bind({})}</Story>
+</Canvas>
diff --git a/src/components/VIconButton/VIconButton.vue b/src/components/VIconButton/VIconButton.vue
index d51b21caf..d2e371f58 100644
--- a/src/components/VIconButton/VIconButton.vue
+++ b/src/components/VIconButton/VIconButton.vue
@@ -27,6 +27,8 @@ import type { ButtonType } from '~/components/VButton.vue'
const SIZE_MAP = Object.freeze({
tiny: { icon: ['w-6', 'h-6'], button: ['w-6', 'h-6'] },
small: { icon: ['w-6', 'h-6'], button: ['w-10', 'h-10'] },
+ // TODO: audit the sizes after new header is done.
+ 'new-small': { icon: 'w-4 h-4', button: 'w-8 h-8' },
'search-small': {
icon: ['w-6', 'h-6'],
button: ['w-10', 'md:w-12', 'h-10', 'md:h-12'],
diff --git a/src/locales/en.json b/src/locales/en.json
index 2c48cba75..e5f9fe58e 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -41,6 +41,7 @@
"aria": {
"primary": "primary",
"menu": "menu",
+ "menu-notification": "Some filters are applied",
"search": "search",
"sr-search": "search button"
},