Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Make Header RTL-compatible (#429)
Dhruv Bhanushali0175d348c7a9
diff --git a/src/assets/icons/external-link.svg b/src/assets/icons/external-link.svgnew file mode 100644index 000000000..9a778d47b--- /dev/null+++ b/src/assets/icons/external-link.svg@@ -0,0 +1,6 @@+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">+ <g id="icon">+ <path d="M10.25 5.00012H7C5.89543 5.00012 5 5.89555 5 7.00012V17.0001C5 18.1047 5.89543 19.0001 7 19.0001H17C18.1046 19.0001 19 18.1047 19 17.0001V13.3612" fill="none" stroke="currentColor" stroke-width="1.5"/>+ <path d="M14.8947 3.78646L20.4423 3.76139M20.4423 3.76139L20.3947 9.28646M20.4423 3.76139C18.0852 6.11842 15.024 9.17966 12.7612 11.4424" fill="none" stroke="currentColor" stroke-width="1.5"/>+ </g>+</svg>diff --git a/src/components/Dropdown.vue b/src/components/Dropdown.vueindex d6e0fc771..072b200a9 100644--- a/src/components/Dropdown.vue+++ b/src/components/Dropdown.vue@@ -25,7 +25,7 @@</div><div- class="navbar-dropdown"+ class="navbar-dropdown start-0":class="{ visible: isHovered || isFocused }"role="menu">diff --git a/src/components/EmbeddedNavSection.vue b/src/components/EmbeddedNavSection.vueindex fbfd41605..2ea564c2d 100644--- a/src/components/EmbeddedNavSection.vue+++ b/src/components/EmbeddedNavSection.vue@@ -1,53 +1,65 @@<template>- <nav :aria-label="$t('header.aria.primary')" class="navbar embedded">- <NuxtLink to="/" style="align-self: center; line-height: 0">- <img- alt="Openverse logo mark"- src="~/assets/logo.svg?data"- style="padding-right: 24px"- width="160"- height="24"- />- </NuxtLink>- <div class="navbar-brand text-white">+ <!-- Refer to the Bulma docs for markup: https://bulma.io/documentation/components/navbar/ -->+ <nav+ role="navigation"+ class="navbar embedded"+ :aria-label="$t('header.aria.primary')"+ >+ <div class="navbar-brand flex-grow md:flex-grow-0">+ <NuxtLink+ to="/"+ class="navbar-item"+ style="align-self: center; line-height: 0"+ >+ <!-- width and height chosen w.r.t. viewBox "0 0 280 42" -->+ <OpenverseLogo+ :style="{ width: '160px', height: '24px' }"+ alt="Openverse logo mark"+ />+ </NuxtLink>++ <!-- Hamburger menu --><arole="button"- :class="{ ['navbar-burger']: true, ['is-active']: isBurgerMenuActive }"+ class="navbar-burger"+ :class="{ 'is-active': isBurgerMenuActive }":aria-label="$t('header.aria.menu')"aria-expanded="false"@click="toggleBurgerActive"@keyup.enter="toggleBurgerActive">- <span aria-hidden="true" />- <span aria-hidden="true" />- <span aria-hidden="true" />+ <span v-for="i in 3" :key="i" aria-hidden="true" /></a></div>- <div :class="{ ['navbar-menu']: true, ['is-active']: isBurgerMenuActive }">- <form- v-if="showNavSearch"- class="hero_search-form"- role="search"- method="post"- @submit.prevent="onSubmit"- >- <input- v-model.lazy="form.searchTerm"- :aria-label="$t('header.aria.search')"- class="input"- type="search"- :placeholder="navSearchPlaceholder"- />- <div class="sr-only">- <button- :aria-label="$t('header.aria.sr-search')"- tabindex="-1"- type="submit"- class="button secondary"- value="Search"++ <div class="navbar-menu" :class="{ 'is-active': isBurgerMenuActive }">+ <div class="navbar-start">+ <form+ v-if="showNavSearch"+ class="navbar-item flex items-center"+ role="search"+ method="post"+ @submit.prevent="onSubmit"+ >+ <input+ v-model.lazy="form.searchTerm"+ :aria-label="$t('header.aria.search')"+ class="input w-64"+ type="search"+ :placeholder="navSearchPlaceholder"/>- </div>- </form>+ <div class="sr-only">+ <button+ :aria-label="$t('header.aria.sr-search')"+ tabindex="-1"+ type="submit"+ class="button secondary"+ value="Search"+ />+ </div>+ </form>+ </div>+<div class="navbar-end"><Dropdown v-slot="{ onFocus }" :text="$t('header.about-tab')"><NuxtLink@@ -74,7 +86,7 @@role="menuitem"@focus="onFocus()">{{ $t('header.licenses-nav-item') }}- <i class="icon external-link" />+ <VIcon class="inline ms-2" :icon-path="externalLinkIcon" rtl-flip /></a></Dropdown>@@ -111,7 +123,7 @@class="navbar-item"@focus="onFocus()">{{ $t('header.api-nav-item') }}- <i class="icon external-link" />+ <VIcon class="inline ms-2" :icon-path="externalLinkIcon" rtl-flip /></a></Dropdown>@@ -124,20 +136,34 @@</template><script>-import { UPDATE_QUERY } from '~/constants/action-types'+import { mapActions } from 'vuex'+import Dropdown from '~/components/Dropdown'+import VIcon from '~/components/VIcon/VIcon.vue'++import { UPDATE_QUERY } from '~/constants/action-types'import { SEARCH } from '~/constants/store-modules'-import { mapActions } from 'vuex'++import OpenverseLogo from '~/assets/logo.svg?inline'+import externalLinkIcon from '~/assets/icons/external-link.svg'export default {name: 'EmbeddedNavSection',- components: { Dropdown },+ components: {+ VIcon,+ Dropdown,+ OpenverseLogo,+ },props: {showNavSearch: {default: false,},},- data: () => ({ form: { searchTerm: '' }, isBurgerMenuActive: false }),+ data: () => ({+ form: { searchTerm: '' },+ isBurgerMenuActive: false,+ externalLinkIcon,+ }),computed: {navSearchPlaceholder() {return this.$t('header.placeholder')@@ -160,29 +186,3 @@ export default {},}</script>--<!-- Add "scoped" attribute to limit CSS to this component only -->-<style lang="scss" scoped>-/* header */-.logo {- color: black;- font-size: 2rem;- font-weight: bold;- &:link,- &:visited,- &:hover,- &:active {- text-decoration: none;- }-}--.hero_search-form {- margin: 0 15px 0 0;- display: flex;- align-items: center;-- input {- width: 16rem;- }-}-</style>diff --git a/src/components/HeaderSection.vue b/src/components/HeaderSection.vueindex 248d608b2..551bf1b55 100644--- a/src/components/HeaderSection.vue+++ b/src/components/HeaderSection.vue@@ -1,5 +1,5 @@<template>- <header :class="isEmbedded ? 'embedded' : ''">+ <header :class="{ embedded: isEmbedded }"><EmbeddedNavSectionv-if="isEmbedded":key="$route.path"diff --git a/src/components/VIcon/VIcon.vue b/src/components/VIcon/VIcon.vueindex 2680a9f1e..3e53b9803 100644--- a/src/components/VIcon/VIcon.vue+++ b/src/components/VIcon/VIcon.vue@@ -1,7 +1,7 @@<template><svgclass="v-icon"- :class="`w-${size} h-${size}`"+ :class="[`w-${size}`, `h-${size}`, { 'rtl-flip': rtlFlip }]"xmlns="http://www.w3.org/2000/svg":viewBox="viewBox"aria-hidden="true"@@ -41,6 +41,18 @@ export default {type: String,default: 'icon',},+ /**+ * whether to flip the icon for RTL languages; This generally makes sense+ * for directional icons such as those involving arrows.+ */+ rtlFlip: {+ type: Boolean,+ default: false,+ },+ /**+ * the size of the icon in terms of the Tailwind height and width scale; The+ * icon, being square, uses this for both dimensions.+ */size: {type: Number,default: 6,@@ -48,3 +60,9 @@ export default {},}</script>++<style scoped>+[dir='rtl'] .v-icon.rtl-flip {+ @apply transform -scale-x-100;+}+</style>diff --git a/src/components/VIcon/meta/VIcon.stories.mdx b/src/components/VIcon/meta/VIcon.stories.mdxindex dc1823353..5b35e88c6 100644--- a/src/components/VIcon/meta/VIcon.stories.mdx+++ b/src/components/VIcon/meta/VIcon.stories.mdx@@ -9,6 +9,7 @@ import {import VIcon from '~/components/VIcon/VIcon.vue'import replayIcon from '~/assets/icons/replay.svg'+import externalLinkIcon from '~/assets/icons/external-link.svg'<Meta title="Components/VIcon" component={VIcon} />@@ -52,3 +53,20 @@ You can then pass this imported value as the `iconPath` prop.Each icon SVG must have a `<g>` element right below the top-level `<svg>`element. This element should have the `id` attribute equal to `"icon"`. If not,pass the attribute value as the `gId` prop.++## RTL++`VIcon` can flip the icon for RTL languages. This is useful for certain icons+that have an intrinsic directional nature such as those involving arrows.++<Canvas>+ <Story+ name="RTL"+ args={{+ rtlFlip: true,+ iconPath: externalLinkIcon,+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>diff --git a/src/styles/components/navbar.sass b/src/styles/components/navbar.sassindex c8c090639..344a0fc21 100644--- a/src/styles/components/navbar.sass+++ b/src/styles/components/navbar.sass@@ -82,11 +82,11 @@ $wp-max-width: 940pxpadding: 0.5rem 0.75remposition: relative.icon- margin-left: $space-small+ margin-inline-start: $space-small.navbar.embedded.navbar-end- margin-left: auto+ margin-inline-start: autojustify-content: space-between+tablet()> div.navbar-item:first-child > a.navbar-link@@ -210,9 +210,9 @@ a.navbar-item,flex-shrink: 0.navbar-endjustify-content: flex-end- +ltr-property("margin", auto, false)+ margin-inline-start: auto& > .navbar-item:not(:first-child)- margin-left: $space-large+ margin-inline-start: $space-large.navbar-dropdownbackground-color: $navbar-dropdown-background-colorborder-bottom-left-radius: $navbar-dropdown-radius@@ -221,7 +221,6 @@ a.navbar-item,box-shadow: 0 8px 8px toRgba($scheme-invert, 0.1)display: nonefont-size: 0.875rem- +ltr-position(0, false)min-width: 100%position: absolutetop: 100%@@ -230,7 +229,7 @@ a.navbar-item,padding: 0.375rem 1remwhite-space: nowrapa.navbar-item- +ltr-property("padding", 3rem)+ padding-inline-end: 3rem&:focus,&:hoverbackground-color: $navbar-dropdown-item-hover-background-colordiff --git a/src/styles/form/input-textarea.sass b/src/styles/form/input-textarea.sassindex c3cef930e..7102dbd81 100644--- a/src/styles/form/input-textarea.sass+++ b/src/styles/form/input-textarea.sass@@ -4,8 +4,6 @@ $textarea-min-height: 8em%input-textarea@extend %input- max-width: 100%- width: 100%&[readonly]box-shadow: none// Sizesdiff --git a/tailwind.config.js b/tailwind.config.jsindex c462fe279..bb45259e8 100644--- a/tailwind.config.js+++ b/tailwind.config.js@@ -73,6 +73,7 @@ module.exports = {20: '5.00rem',24: '6.00rem',30: '7.50rem',+ 64: '16.00rem',70: '17.50rem',80: '20.00rem',},@@ -173,6 +174,11 @@ module.exports = {mono: ['"JetBrains Mono"', 'monospace'],icons: ['"Vocabulary Icons"'],},+ extend: {+ scale: {+ '-100': '-1',+ },+ },},variants: {extend: {