Skip to content

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

Update license explanation tooltip (#850)

Dhruv Bhanushalicb1954ffaef5
diff --git a/src/assets/licenses/remix.svg b/src/assets/licenses/remix.svg
new file mode 100644
index 000000000..21c8d95a6
--- /dev/null
+++ b/src/assets/licenses/remix.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg">
+ <g id="icon" fill="currentColor">
+ <path d="M14.973 0c4.196 0 7.75 1.455 10.66 4.366C28.544 7.26 30 10.804 30 15c0 4.197-1.43 7.714-4.287 10.553C22.696 28.518 19.115 30 14.973 30c-4.054 0-7.571-1.473-10.553-4.42C1.474 22.634 0 19.108 0 15c0-4.088 1.474-7.633 4.42-10.633C7.33 1.455 10.848 0 14.973 0zm.054 2.706c-3.41 0-6.295 1.205-8.652 3.616-2.447 2.483-3.67 5.375-3.67 8.678 0 3.34 1.214 6.214 3.642 8.625 2.429 2.43 5.322 3.643 8.679 3.643 3.339 0 6.25-1.223 8.732-3.67 2.358-2.285 3.536-5.151 3.536-8.598 0-3.428-1.197-6.321-3.589-8.678-2.375-2.412-5.268-3.616-8.678-3.616zm9.776 12.562l.295.134v4.232l-.268.133-3.642 1.554-.161.054-.188-.053-7.848-3.241-.268-.108-3.884 1.608-3.83-1.662v-3.857l3.59-1.5-.027-.027V8.303l4.071-1.794 9.188 3.803v3.723l2.972 1.233zm-4.259 4.928v-2.651h-.026v-.108l-6.884-2.812v2.733l6.884 2.84v-.028l.026.026zM21 16.714l2.411-.99-2.224-.938-2.357.99 2.17.938zm3.16 2.304V16.42l-2.678 1.125v2.625l2.679-1.152z"/>
+ </g>
+</svg>
diff --git a/src/assets/licenses/sampling-plus.svg b/src/assets/licenses/sampling-plus.svg
new file mode 100644
index 000000000..ea3b134b3
--- /dev/null
+++ b/src/assets/licenses/sampling-plus.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg">
+ <g id="icon" fill="currentColor">
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M4.43 4.35C7.31 1.45 10.826 0 14.981 0c4.206 0 7.76 1.45 10.664 4.35C28.548 7.25 30 10.8 30 15s-1.428 7.712-4.28 10.538C22.69 28.513 19.11 30 14.98 30c-4.08 0-7.597-1.474-10.55-4.425C1.476 22.626 0 19.101 0 15c0-4.1 1.477-7.65 4.43-10.65zM23.692 6.3c-2.378-2.4-5.269-3.6-8.673-3.6-3.405 0-6.283 1.2-8.636 3.6-2.453 2.475-3.68 5.375-3.68 8.7 0 3.324 1.214 6.2 3.643 8.625 2.428 2.424 5.318 3.638 8.673 3.638 3.353 0 6.27-1.225 8.748-3.676 2.353-2.274 3.529-5.137 3.529-8.587 0-3.426-1.202-6.325-3.604-8.7zm-2.843 9.27a.701.701 0 01.649-.434h3.523v1.407h-3.054l-1.09 2.625a.702.702 0 01-1.347-.186l-.16-1.35-.414 5.017a.701.701 0 01-1.4-.005l-.296-3.896-.275 3.545a.704.704 0 01-1.402-.01l-.273-4.34-.297 4.867a.702.702 0 01-1.403.003l-.29-4.436-.28 4.26a.702.702 0 01-1.403.005l-.343-4.738-.227 2.635a.704.704 0 01-1.396.041l-.65-4.423a.703.703 0 01-.627.384h-3.1v-1.405H7.95l.795-1.674a.703.703 0 011.33.2l.108.738.468-5.432a.703.703 0 011.402.009l.25 3.445.32-4.85a.702.702 0 011.402.001l.261 4.009.309-5.063a.703.703 0 011.403-.001l.359 5.7.211-2.716a.703.703 0 011.402.002l.315 4.163.257-3.11a.704.704 0 011.4-.027l.667 5.616.24-.576zm-5.397-.118h1.327a.453.453 0 100-.905h-1.327V13.22a.452.452 0 10-.905 0v1.327H13.22a.454.454 0 000 .905h1.327v1.327a.453.453 0 00.905 0v-1.327z"/>
+ </g>
+</svg>
diff --git a/src/assets/licenses/sampling.svg b/src/assets/licenses/sampling.svg
new file mode 100644
index 000000000..bdb78817a
--- /dev/null
+++ b/src/assets/licenses/sampling.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg">
+ <g id="icon" fill="currentColor">
+ <path d="M14.973 0c4.213 0 7.772 1.451 10.674 4.353C28.549 7.254 30 10.803 30 15s-1.43 7.705-4.287 10.526C22.696 28.51 19.115 30 14.973 30c-4.072 0-7.585-1.474-10.54-4.42C1.477 22.633 0 19.107 0 15S1.474 7.34 4.42 4.34C7.313 1.446 10.83 0 14.973 0zm.04 2.706c-3.401 0-6.281 1.196-8.638 3.589C3.93 8.777 2.705 11.679 2.705 15c0 3.321 1.215 6.196 3.643 8.624 2.429 2.429 5.321 3.642 8.679 3.642 3.357 0 6.267-1.222 8.732-3.67 2.357-2.285 3.536-5.151 3.536-8.598 0-3.428-1.197-6.33-3.589-8.705-2.393-2.392-5.291-3.588-8.692-3.588zm.228 3.213a.6.6 0 01.47.148.655.655 0 01.226.442v.107l.402 6.482.295-3.59c0-.178.062-.33.187-.455a.621.621 0 01.455-.188c.178 0 .33.063.456.188a.62.62 0 01.187.456v.106l.347 4.822.349-3.884a.62.62 0 01.202-.401.587.587 0 01.414-.16c.162 0 .304.05.429.147a.553.553 0 01.215.388l.697 5.84.321-.777c.107-.268.312-.402.615-.402h3.51v1.286h-3.081l-1.098 2.678c-.126.321-.358.456-.697.401a.596.596 0 01-.388-.187.686.686 0 01-.174-.402l-.24-1.928-.456 5.598a.625.625 0 01-.617.562.64.64 0 01-.429-.161.601.601 0 01-.214-.401v-.081l-.374-4.634-.322 4.366a.767.767 0 01-.228.402.59.59 0 01-.416.16.638.638 0 01-.428-.16.6.6 0 01-.214-.402v-.08l-.349-5.224-.348 5.733v.08a.667.667 0 01-.187.469.599.599 0 01-.455.201.598.598 0 01-.456-.201.662.662 0 01-.188-.469v-.053l-.348-5.303-.322 5.115v.08a.755.755 0 01-.227.402.59.59 0 01-.415.161.638.638 0 01-.428-.16.6.6 0 01-.215-.402v-.08h-.026v-.08l-.375-5.357-.295 3.428a.598.598 0 01-.214.402.64.64 0 01-.428.16c-.161 0-.3-.048-.416-.147a.684.684 0 01-.228-.388l-.67-4.607-.08.16c-.107.233-.304.349-.59.349H5.275v-1.287h2.706l.83-1.687c.125-.286.343-.406.656-.362.313.045.496.219.55.522l.187 1.232.508-5.92c0-.178.063-.33.188-.454a.622.622 0 01.455-.188.62.62 0 01.455.188.619.619 0 01.187.455v.107l.295 4.179.402-5.598v-.08a.618.618 0 01.616-.562c.16 0 .303.053.428.16.126.107.196.24.214.402v.08l.322 4.875.375-5.92V6.51c0-.16.058-.295.174-.402a.725.725 0 01.418-.188z"/>
+ </g>
+</svg>
diff --git a/src/components/LicenseElements.vue b/src/components/LicenseElements.vue
deleted file mode 100644
index 508dfee3d..000000000
--- a/src/components/LicenseElements.vue
+++ /dev/null
@@ -1,55 +0,0 @@
-<template>
- <div v-if="license">
- <ul>
- <li
- v-for="(li, index) in splitLicenses"
- :key="index"
- class="flex items-start my-2"
- >
- <i
- aria-hidden="true"
- class="icon me-2 text-black text-3xl bg-white"
- :class="`cc-${getLicenseIcon(li)}`"
- :title="`${li.toUpperCase()}`"
- />
- <span class="sr-only">{{ li.toUpperCase() }}</span>
- <p class="text-sm">
- {{ $t(`browse-page.license-description.${li}`) }}
- </p>
- </li>
- </ul>
- </div>
-</template>
-
-<script>
-const APItoIconNameMap = {
- by: 'by',
- nc: 'nc',
- nd: 'nd',
- sa: 'sa',
- cc0: 'zero',
- pdm: 'pd',
-}
-
-const LicenseElements = {
- name: 'license-elements',
- props: {
- license: {
- type: String,
- default: '',
- },
- },
- computed: {
- splitLicenses() {
- return this.$props.license.split('-')
- },
- },
- methods: {
- getLicenseIcon(licenseTerm) {
- return APItoIconNameMap[licenseTerm]
- },
- },
-}
-
-export default LicenseElements
-</script>
diff --git a/src/components/VFilters/VFilterChecklist.vue b/src/components/VFilters/VFilterChecklist.vue
index ec4aed661..f4d1152ca 100644
--- a/src/components/VFilters/VFilterChecklist.vue
+++ b/src/components/VFilters/VFilterChecklist.vue
@@ -1,5 +1,5 @@
<template>
- <fieldset class="mb-8" @click.stop="hideLicenseExplanationVisibility">
+ <fieldset class="mb-8">
<legend v-if="title" class="text-sm font-semibold">
{{ title }}
</legend>
@@ -20,32 +20,47 @@
<VLicense v-if="filterType === 'licenses'" :license="item.code" />
<template v-else>{{ itemLabel(item) }}</template>
</VCheckbox>
- <button
- v-if="filterType === 'licenses'"
- :ref="`${item.code}licenseIcon`"
- :aria-label="$t('browse-page.aria.license-explanation')"
- class="text-dark-charcoal-70 appearance-none"
- type="button"
- @click.stop="toggleLicenseExplanationVisibility(item.code)"
- >
- <VIcon :icon-path="helpIcon" />
- </button>
+
+ <!-- License explanation -->
+ <VPopover v-if="filterType === 'licenses'">
+ <template #trigger="{ a11yProps }">
+ <VButton
+ v-bind="a11yProps"
+ variant="plain"
+ size="disabled"
+ :aria-label="$t('browse-page.aria.license-explanation')"
+ class="text-dark-charcoal-70"
+ type="button"
+ >
+ <VIcon :icon-path="icons.help" />
+ </VButton>
+ </template>
+ <template #default="{ close }">
+ <div class="relative">
+ <VIconButton
+ :aria-label="$t('modal.close')"
+ class="absolute top-2 end-2 border-none"
+ size="small"
+ :icon-props="{ iconPath: icons.closeSmall }"
+ @click="close"
+ />
+ <VLicenseExplanation :license="item.code" />
+ </div>
+ </template>
+ </VPopover>
</div>
- <VLicenseExplanationTooltip
- v-if="licenseExplanationVisible"
- :license="licenseExplanationCode"
- :icon-dom-node="$refs[`${licenseExplanationCode}licenseIcon`][0]"
- />
</fieldset>
</template>
<script>
-import helpIcon from '~/assets/icons/help.svg'
-
-import VLicenseExplanationTooltip from '~/components/VFilters/VLicenseExplanationTooltip.vue'
+import VLicenseExplanation from '~/components/VFilters/VLicenseExplanation.vue'
import VCheckbox from '~/components/VCheckbox/VCheckbox.vue'
import VLicense from '~/components/License/VLicense.vue'
import VIcon from '~/components/VIcon/VIcon.vue'
+import VPopover from '~/components/VPopover/VPopover.vue'
+
+import helpIcon from '~/assets/icons/help.svg'
+import closeSmallIcon from '~/assets/icons/close-small.svg'
export default {
name: 'FilterCheckList',
@@ -53,7 +68,8 @@ export default {
VCheckbox,
VIcon,
VLicense,
- VLicenseExplanationTooltip,
+ VLicenseExplanation,
+ VPopover,
},
props: {
options: { type: Array, required: false },
@@ -63,9 +79,7 @@ export default {
},
data() {
return {
- licenseExplanationVisible: false,
- licenseExplanationCode: null,
- helpIcon,
+ icons: { help: helpIcon, closeSmall: closeSmallIcon },
}
},
computed: {
@@ -87,13 +101,6 @@ export default {
filterType: this.filterType,
})
},
- toggleLicenseExplanationVisibility(licenseCode) {
- this.licenseExplanationVisible = !this.licenseExplanationVisible
- this.licenseExplanationCode = licenseCode
- },
- hideLicenseExplanationVisibility() {
- this.licenseExplanationVisible = false
- },
getFilterTypeValue(filterKey, val) {
return this.$store.state.search.filters[filterKey].filter((item) =>
item.code.includes(val)
@@ -120,13 +127,6 @@ export default {
}
return this.disabled
},
- shouldRenderLicenseExplanationTooltip(licenseCode) {
- return (
- !this.isDisabled({ code: licenseCode }) &&
- this.licenseExplanationVisible &&
- this.licenseExplanationCode === licenseCode
- )
- },
},
}
</script>
diff --git a/src/components/VFilters/VLicenseExplanation.vue b/src/components/VFilters/VLicenseExplanation.vue
new file mode 100644
index 000000000..b5c0a6cb9
--- /dev/null
+++ b/src/components/VFilters/VLicenseExplanation.vue
@@ -0,0 +1,88 @@
+<template>
+ <div class="license-explanation w-full max-w-xs p-6">
+ <h5 class="text-base font-semibold">
+ <template v-if="isTechnicallyLicense">{{
+ $t('filters.license-explanation.license-definition')
+ }}</template>
+ <template v-else>{{
+ $t('filters.license-explanation.mark-definition', {
+ mark: license.toUpperCase(),
+ })
+ }}</template>
+ </h5>
+
+ <VLicenseElements
+ v-if="license"
+ size="small"
+ class="my-4"
+ :license="license"
+ />
+
+ <i18n
+ :path="`filters.license-explanation.more.${
+ isTechnicallyLicense ? 'license' : 'mark'
+ }`"
+ tag="p"
+ class="text-sm"
+ >
+ <template #read-more>
+ <VLink :href="`${getLicenseDeedLink(license)}`">{{
+ $t('filters.license-explanation.more.read-more')
+ }}</VLink>
+ </template>
+ <template #mark>{{ license.toUpperCase() }}</template>
+ </i18n>
+ </div>
+</template>
+
+<script>
+import { isLicense } from '~/utils/license'
+
+import VLicenseElements from '~/components/VLicenseElements.vue'
+
+import { DEPRECATED_LICENSES } from '~/constants/license'
+
+/**
+ * Renders the explanation of the license passed to it by breaking it down to
+ * its constituent clauses.
+ */
+export default {
+ name: 'VLicenseExplanation',
+ components: {
+ VLicenseElements,
+ },
+ props: {
+ /**
+ * the code of the license whose elements need to be explained
+ */
+ license: {
+ type: String,
+ required: true,
+ },
+ },
+ computed: {
+ /**
+ * Public domain marks such as CC0 and PDM are not technically licenses.
+ * @return {boolean} true if the license is not CC0 or PDM, false otherwise
+ */
+ isTechnicallyLicense() {
+ return isLicense(this.license)
+ },
+ },
+ methods: {
+ getLicenseDeedLink(licenseTerm) {
+ let fragment
+ if (licenseTerm === 'cc0') {
+ fragment = 'publicdomain/zero/1.0'
+ } else if (licenseTerm === 'pdm') {
+ fragment = 'publicdomain/mark/1.0'
+ } else if (DEPRECATED_LICENSES.includes(licenseTerm)) {
+ fragment = `licenses/${licenseTerm}/1.0`
+ } else {
+ fragment = `licenses/${licenseTerm}/4.0`
+ }
+ return `https://creativecommons.org/${fragment}/?ref=openverse`
+ },
+ },
+}
+</script>
diff --git a/src/components/VFilters/VLicenseExplanationTooltip.vue b/src/components/VFilters/VLicenseExplanationTooltip.vue
deleted file mode 100644
index 2166f1501..000000000
--- a/src/components/VFilters/VLicenseExplanationTooltip.vue
+++ /dev/null
@@ -1,171 +0,0 @@
-<template>
- <div
- ref="tooltip"
- class="license-explanation-tooltip p-2"
- :style="inlineStyle"
- >
- <h5 v-if="!isLicense" class="b-header mb-4">
- {{ isLicense ? $t('browse-page.license-description.title') : '' }}
- {{ license.toUpperCase() }}
- </h5>
- <LicenseElements :license="license" class="tooltip" />
- <i18n
- v-if="!isLicense"
- path="filters.license-explanation.tool"
- tag="p"
- class="caption float-right m-2"
- >
- <template #link>
- <VLink :href="`${getLicenseDeedLink(license)}`">{{
- $t('filters.license-explanation.link')
- }}</VLink>
- </template>
- </i18n>
- <i18n
- v-else
- path="filters.license-explanation.license"
- tag="p"
- class="caption float-right m-2"
- >
- <template #link>
- <VLink :href="`${getLicenseDeedLink(license)}`">{{
- $t('filters.license-explanation.link')
- }}</VLink>
- </template>
- </i18n>
- </div>
-</template>
-
-<script>
-import { isLicense } from '~/utils/license'
-import VLink from '~/components/VLink.vue'
-import LicenseElements from '~/components/LicenseElements.vue'
-
-export default {
- name: 'VLicenseExplanationTooltip',
- components: { VLink, LicenseElements },
- props: {
- license: {
- type: String,
- required: true,
- },
- iconDomNode: {
- required: true,
- },
- },
- data() {
- return {
- tooltipBeforeBorderWidth: 13,
- tooltipBeforeTop: 10,
- }
- },
- computed: {
- isLicense() {
- return isLicense(this.$props.license)
- },
- inlineStyle() {
- const helpIconBounding = this.iconDomNode.getBoundingClientRect()
- const helpIconLeft = helpIconBounding.x
- const helpIconTop = helpIconBounding.y
- const helpIconWidth = helpIconBounding.width
- const helpIconHeight = helpIconBounding.height
- const helpIconTopRelative = this.iconDomNode.offsetTop
- const helpIconWidthNoPadding = this.iconDomNode.width
-
- return {
- '--desktop-tooltip-top': `${Math.round(
- helpIconTop -
- this.tooltipBeforeTop -
- this.tooltipBeforeBorderWidth / 2
- )}px`,
- '--desktop-tooltip-left': `${
- Math.round(helpIconLeft + helpIconWidth) +
- this.tooltipBeforeBorderWidth
- }px`,
- '--touch-tooltip-top': `${Math.round(
- helpIconTopRelative + helpIconHeight + this.tooltipBeforeTop
- )}px`,
- '--touch-tooltip-right': `calc(1rem - ${Math.round(
- helpIconWidth / 2 - (helpIconWidth - helpIconWidthNoPadding)
- )}px)`,
- '--tooltip-before-top': `${this.tooltipBeforeTop}px`,
- '--tooltip-before-border-width': `${this.tooltipBeforeBorderWidth}px`,
- }
- },
- },
- methods: {
- getLicenseDeedLink(licenseTerm) {
- if (licenseTerm === 'cc0') {
- return 'https://creativecommons.org/publicdomain/zero/1.0/?ref=openverse&atype=rich'
- } else if (licenseTerm === 'pdm') {
- return 'https://creativecommons.org/publicdomain/mark/1.0/?ref=openverse&atype=rich'
- }
- return `https://creativecommons.org/licenses/${licenseTerm}/4.0/?ref=openverse&atype=rich`
- },
- },
-}
-</script>
-
-<style lang="scss" scoped>
-// from http://www.cssarrowplease.com/
-.license-explanation-tooltip {
- position: absolute;
- background: #ffffff;
- border: 2px solid #d8d8d8;
- z-index: 400;
- width: 20rem;
- box-shadow: 10px 10px 10px -10px rgba(0, 0, 0, 0.25);
- @screen lg {
- top: var(--desktop-tooltip-top);
- left: var(--desktop-tooltip-left);
- }
- @include touch {
- top: var(--touch-tooltip-top);
- right: var(--touch-tooltip-right);
- }
-}
-.license-explanation-tooltip:after,
-.license-explanation-tooltip:before {
- @screen lg {
- right: 100%;
- top: var(--tooltip-before-top);
- }
- @include touch {
- bottom: 100%;
- left: 10%;
- }
- border: solid transparent;
- content: ' ';
- height: 0;
- width: 0;
- position: absolute;
- pointer-events: none;
-}
-
-.license-explanation-tooltip:after {
- border-color: rgba(255, 255, 255, 0);
- border-width: 10px;
-
- @screen lg {
- border-right-color: #ffffff;
- margin-top: 3px;
- }
- @include touch {
- border-bottom-color: #ffffff;
- margin-left: 258px;
- }
-}
-.license-explanation-tooltip:before {
- border-color: rgba(120, 120, 120, 0);
- border-width: var(--tooltip-before-border-width);
-
- @screen lg {
- border-right-color: #d8d8d8;
- margin-top: 0px;
- }
- @include touch {
- border-bottom-color: #d8d8d8;
- margin-left: 255px;
- }
-}
-</style>
diff --git a/src/components/VFilters/meta/VLicenseExplanation.stories.mdx b/src/components/VFilters/meta/VLicenseExplanation.stories.mdx
new file mode 100644
index 000000000..991015a22
--- /dev/null
+++ b/src/components/VFilters/meta/VLicenseExplanation.stories.mdx
@@ -0,0 +1,39 @@
+import {
+ ArgsTable,
+ Canvas,
+ Description,
+ Meta,
+ Story,
+} from '@storybook/addon-docs'
+
+import VLicenseExplanation from '~/components/VFilters/VLicenseExplanation.vue'
+
+import { ALL_LICENSES } from '~/constants/license'
+
+<Meta
+ title="Components/VLicenseExplanation"
+ components={VLicenseExplanation}
+ argTypes={{
+ license: {
+ defaultValue: ALL_LICENSES[0],
+ options: ALL_LICENSES,
+ control: 'select',
+ },
+ }}
+/>
+
+export const Template = (args, { argTypes }) => ({
+ template: `<VLicenseExplanation v-bind="$props" v-on="$props"/>`,
+ components: { VLicenseExplanation },
+ props: Object.keys(argTypes),
+})
+
+# VLicenseExplanation
+
+<Description of={VLicenseExplanation} />
+
+<ArgsTable of={VLicenseExplanation} />
+
+<Canvas>
+ <Story name="Default">{Template.bind({})}</Story>
+</Canvas>
diff --git a/src/components/VIconButton/VIconButton.vue b/src/components/VIconButton/VIconButton.vue
index bb6c665c2..99920a3de 100644
--- a/src/components/VIconButton/VIconButton.vue
+++ b/src/components/VIconButton/VIconButton.vue
@@ -1,5 +1,7 @@
<template>
- <button
+ <VButton
+ variant="plain"
+ size="disabled"
class="icon-button flex flex-shrink-0 items-center justify-center border-1.5 focus:border-pink focus:outline-none focus:shadow-ring active:shadow-ring"
:class="[...buttonSizeClasses]"
:type="type"
@@ -10,17 +12,18 @@
:class="[...iconSizeClasses]"
v-bind="iconProps"
/>
- </button>
+ </VButton>
</template>
<script>
import { computed } from '@nuxtjs/composition-api'
import VIcon from '~/components/VIcon/VIcon.vue'
+import VButton from '~/components/VButton.vue'
export default {
name: 'VIconButton',
- components: { VIcon },
+ components: { VIcon, VButton },
props: {
/**
* the size of the button; The size affects both the size of the button
diff --git a/src/components/VLicenseElements.vue b/src/components/VLicenseElements.vue
new file mode 100644
index 000000000..5839cd028
--- /dev/null
+++ b/src/components/VLicenseElements.vue
@@ -0,0 +1,69 @@
+<template>
+ <ul>
+ <li
+ v-for="element in elements"
+ :key="element"
+ class="flex items-center gap-3 mt-2"
+ >
+ <VIcon
+ view-box="0 0 30 30"
+ :size="isSmall ? 5 : 6"
+ :icon-path="icons[element]"
+ />
+ <span v-if="elements.length > 1" class="sr-only">{{
+ element.toUpperCase()
+ }}</span>
+ <p :class="{ 'text-sm': isSmall }">
+ {{ $t(`browse-page.license-description.${element}`) }}
+ </p>
+ </li>
+ </ul>
+</template>
+
+<script>
+import { computed, defineComponent } from '@nuxtjs/composition-api'
+
+import by from '~/assets/licenses/by.svg'
+import cc0 from '~/assets/licenses/cc0.svg'
+import nc from '~/assets/licenses/nc.svg'
+import nd from '~/assets/licenses/nd.svg'
+import pdm from '~/assets/licenses/pdm.svg'
+import sa from '~/assets/licenses/sa.svg'
+import sampling from '~/assets/licenses/sampling.svg'
+import samplingPlus from '~/assets/licenses/sampling-plus.svg'
+
+export default defineComponent({
+ name: 'VLicenseElements',
+ props: {
+ license: {
+ type: String,
+ required: true,
+ },
+ size: {
+ type: String,
+ default: 'big',
+ validator: (val) => ['big', 'small'].includes(val),
+ },
+ },
+ setup(props) {
+ const elements = computed(() => props.license.split('-'))
+
+ const isSmall = computed(() => props.size === 'small')
+
+ return {
+ icons: {
+ by,
+ nc,
+ nd,
+ sa,
+ cc0,
+ pdm,
+ sampling,
+ 'sampling+': samplingPlus,
+ },
+ elements,
+ isSmall,
+ }
+ },
+})
+</script>
diff --git a/src/components/VMediaInfo/VMediaLicense.vue b/src/components/VMediaInfo/VMediaLicense.vue
index 1b80e5cca..c30fbac99 100644
--- a/src/components/VMediaInfo/VMediaLicense.vue
+++ b/src/components/VMediaInfo/VMediaLicense.vue
@@ -15,7 +15,7 @@
</VLink>
</template>
</i18n>
- <LicenseElements :license="license" class="md:py-4" />
+ <VLicenseElements v-if="license" :license="license" class="md:py-4" />
<i18n
v-if="!isLicense"
path="media-details.reuse.license.content"
@@ -33,7 +33,7 @@
</i18n>
</template>
<template v-else>
- <LicenseElements :license="license" class="md:py-4" />
+ <VLicenseElements v-if="license" :license="license" class="md:py-4" />
<i18n
path="media-details.reuse.tool.content"
tag="span"
@@ -53,13 +53,14 @@
</template>
<script>
-import { isLicense } from '~/utils/license'
-import LicenseElements from '~/components/LicenseElements.vue'
+import VLicenseElements from '~/components/VLicenseElements.vue'
import VLink from '~/components/VLink.vue'
+import { isLicense } from '~/utils/license'
+
export default {
name: 'MediaLicense',
- components: { LicenseElements, VLink },
+ components: { VLicenseElements, VLink },
props: {
fullLicenseName: String,
license: String,
@@ -67,7 +68,7 @@ export default {
},
computed: {
isLicense() {
- return isLicense(this.$props.license)
+ return isLicense(this.license)
},
headerText() {
const licenseOrTool = this.isLicense ? 'license' : 'tool'
diff --git a/src/components/VPopover/VPopoverContent.vue b/src/components/VPopover/VPopoverContent.vue
index 0b2ad9daa..2ac3eee7c 100644
--- a/src/components/VPopover/VPopoverContent.vue
+++ b/src/components/VPopover/VPopoverContent.vue
@@ -1,15 +1,20 @@
<template>
<div
- v-if="visible"
- ref="popoverRef"
- :class="[$style.popover, { [`z-[${zIndex}]`]: zIndex !== undefined }]"
+ v-show="visible"
+ class="w-0 h-0"
:aria-hidden="!visible"
- :tabindex="typeof $props.tabindex !== 'undefined' ? $props.tabindex : -1"
v-on="$listeners"
@keydown="onKeyDown"
- @blur="onBlur"
>
- <slot />
+ <div
+ ref="popoverRef"
+ class="bg-white border border-light-gray rounded-sm shadow max-w-max"
+ :class="{ [`z-[${zIndex}]`]: zIndex !== undefined }"
+ :tabindex="-1"
+ @blur="onBlur"
+ >
+ <slot />
+ </div>
</div>
</template>
@@ -56,9 +61,3 @@ export default defineComponent({
},
})
</script>
-
-<style module>
-.popover {
- @apply bg-white border border-light-gray rounded-sm max-w-max shadow;
-}
-</style>
diff --git a/src/constants/license.js b/src/constants/license.js
index 287229a2d..f5cc5591f 100644
--- a/src/constants/license.js
+++ b/src/constants/license.js
@@ -11,6 +11,8 @@ export const NON_CC_LICENSES = ['cc0', 'pdm']
export const DEPRECATED_LICENSES = ['nc-sampling+', 'sampling+']
+export const ACTIVE_LICENSES = [...NON_CC_LICENSES, ...CC_LICENSES]
+
export const ALL_LICENSES = [
...CC_LICENSES,
...NON_CC_LICENSES,
diff --git a/src/locales/en.json b/src/locales/en.json
index d7069de08..42c51c7aa 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -365,9 +365,13 @@
"creator": "Creator"
},
"license-explanation": {
- "tool": "Read more about the tool {link}.",
- "license": "Read more about the license {link}.",
- "link": "here"
+ "license-definition": "License definition",
+ "mark-definition": "{mark} definition",
+ "more": {
+ "license": "{read-more} about this license.",
+ "mark": "{read-more} about {mark}.",
+ "read-more": "Read more"
+ }
},
"aria": {
"remove-filter": "Remove {label} filter"
@@ -408,7 +412,8 @@
"nd": "No derivatives or adaptations permitted.",
"sa": "Share adaptations under the same terms.",
"cc0": "This work has been marked as dedicated to the public domain.",
- "pdm": "This work is marked as being in the public domain."
+ "pdm": "This work is marked as being in the public domain.",
+ "sampling+": "Samples, mash-ups, creative transformations permitted."
},
"aria": {
"close": "close",
diff --git a/src/locales/po-files/openverse.pot b/src/locales/po-files/openverse.pot
index 665b9ade2..eaa749ee4 100644
--- a/src/locales/po-files/openverse.pot
+++ b/src/locales/po-files/openverse.pot
@@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Openverse \n"
"Report-Msgid-Bugs-To: https://github.com/wordpress/openverse/issues \n"
-"POT-Creation-Date: 2022-02-22T15:15:29+00:00\n"
+"POT-Creation-Date: 2022-02-22T20:16:03+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -62,7 +62,7 @@ msgctxt "search-type.see-audio"
msgid "See all audio"
msgstr ""
-#: src/components/VModal/VMobileModalContent.vue:28
+#: src/components/VFilters/VFilterChecklist.vue:41
msgctxt "modal.close"
msgid "Close"
msgstr ""
@@ -236,7 +236,7 @@ msgid "Loading..."
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/VAudioThumbnail/VAudioThumbnail.vue:102
+#: src/components/VAudioThumbnail/VAudioThumbnail.vue:54
msgctxt "audio-thumbnail.alt"
msgid "Cover art for \"###title###\" by ###creator###"
msgstr ""
@@ -730,7 +730,7 @@ msgctxt "browse-page.aria.remove-filter"
msgid "remove filter"
msgstr ""
-#: src/components/VFilters/VFilterChecklist.vue:26
+#: src/components/VFilters/VFilterChecklist.vue:31
msgctxt "browse-page.aria.license-explanation"
msgid "license explanation"
msgstr ""
@@ -749,7 +749,6 @@ msgctxt "browse-page.aria.relevance.no"
msgid "relevant result? answer: no"
msgstr ""
-#: src/components/VFilters/VLicenseExplanationTooltip.vue:8
msgctxt "browse-page.license-description.title"
msgid "License CC"
msgstr ""
@@ -778,6 +777,10 @@ msgctxt "browse-page.license-description.pdm"
msgid "This work is marked as being in the public domain."
msgstr ""
+msgctxt "browse-page.license-description.sampling+"
+msgid "Samples, mash-ups, creative transformations permitted."
+msgstr ""
+
#. Do not translate words between ### ###.
msgctxt "browse-page.search-form.placeholder"
msgid "Search all ###type###"
@@ -867,24 +870,33 @@ msgctxt "filters.aria.remove-filter"
msgid "Remove ###label### filter"
msgstr ""
+#: src/components/VFilters/VLicenseExplanation.vue:5
+msgctxt "filters.license-explanation.license-definition"
+msgid "License definition"
+msgstr ""
+
#. Do not translate words between ### ###.
-#: src/components/VFilters/VLicenseExplanationTooltip.vue:12
-msgctxt "filters.license-explanation.tool"
-msgid "Read more about the tool ###link###."
+#: src/components/VFilters/VLicenseExplanation.vue:8
+msgctxt "filters.license-explanation.mark-definition"
+msgid "###mark### definition"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/VFilters/VLicenseExplanationTooltip.vue:24
-msgctxt "filters.license-explanation.license"
-msgid "Read more about the license ###link###."
+msgctxt "filters.license-explanation.more.license"
+msgid "###read-more### about this license."
msgstr ""
-#: src/components/VFilters/VLicenseExplanationTooltip.vue:20
-msgctxt "filters.license-explanation.link"
-msgid "here"
+#. Do not translate words between ### ###.
+msgctxt "filters.license-explanation.more.mark"
+msgid "###read-more### about ###mark###."
+msgstr ""
+
+#: src/components/VFilters/VLicenseExplanation.vue:30
+msgctxt "filters.license-explanation.more.read-more"
+msgid "Read more"
msgstr ""
-#: src/components/VFilters/VFilterChecklist.vue:74
+#: src/components/VFilters/VFilterChecklist.vue:88
msgctxt "filters.search-by.title"
msgid "Search By"
msgstr ""
diff --git a/src/store/search.js b/src/store/search.js
index 986bdde74..f4e8074f7 100644
--- a/src/store/search.js
+++ b/src/store/search.js
@@ -29,6 +29,7 @@ import {
SET_QUERY,
SET_SEARCH_TYPE,
} from '~/constants/mutation-types'
+import { ACTIVE_LICENSES } from '~/constants/license'
/**
* List of filters available for each search type. The order of the keys
@@ -85,16 +86,7 @@ export const mediaSpecificFilters = {
/** @type {import('./types').Filters} */
export const filterData = deepFreeze({
- licenses: createInitialFilters('licenses', [
- 'cc0',
- 'pdm',
- 'by',
- 'by-sa',
- 'by-nc',
- 'by-nd',
- 'by-nc-sa',
- 'by-nc-nd',
- ]),
+ licenses: createInitialFilters('licenses', ACTIVE_LICENSES),
licenseTypes: createInitialFilters('license-types', [
'commercial',
'modification',
diff --git a/src/utils/license.js b/src/utils/license.js
index 800a8649e..9e3557cc1 100644
--- a/src/utils/license.js
+++ b/src/utils/license.js
@@ -31,9 +31,8 @@ export const getFullLicenseName = (license, license_version) => {
/**
* CC licenses have different legal status from the public domain marks
* such as CC0 and PDM, and need different wording.
- * Returns false if licenseOrMark is CC0 or PDM
* @param {License|LicenseName|''} licenseOrMark
- * @return {boolean}
+ * @return {asserts licenseOrMark is Exclude<'pdm' | 'cc0', License | LicenseName | ''>} false if licenseOrMark is CC0 or PDM, true otherwise
*/
export const isLicense = (licenseOrMark = '') => {
return !['pdm', 'cc0'].includes(licenseOrMark.toLowerCase())
diff --git a/test/unit/specs/components/v-popover.spec.js b/test/unit/specs/components/v-popover.spec.js
index a30ebc325..dd4552f0b 100644
--- a/test/unit/specs/components/v-popover.spec.js
+++ b/test/unit/specs/components/v-popover.spec.js
@@ -58,7 +58,9 @@ const expectOpen = () => {
}
const expectClosed = () => {
- expect(queryPopover()).toBe(null)
+ expect(queryPopover().parentElement.parentElement.style.display).toEqual(
+ 'none'
+ )
}
describe('VPopover', () => {