Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Update license explanation tooltip #850

Merged
merged 33 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
871c72a
Add icons for deprecated CC licenses
dhruvkb Feb 10, 2022
eb8ebb8
Replace hardcoded licenses with use of constant
dhruvkb Feb 10, 2022
e8c51b6
Add explanation for sampling
dhruvkb Feb 10, 2022
524fe76
Update strings to match updated UI
dhruvkb Feb 10, 2022
ba944c9
Refactor and update the license elements component
dhruvkb Feb 10, 2022
7a24d2a
Update the usage of the `VLicenseElements` component
dhruvkb Feb 10, 2022
05d3c62
Update the contents of the explanation popover to match the UI
dhruvkb Feb 10, 2022
f5f96ed
Update the filter checklist to use `VPopover` for license explanations
dhruvkb Feb 10, 2022
b94e1ce
Update the license order putting public domain before CC
dhruvkb Feb 10, 2022
09152b2
Replace @ imports with ~
dhruvkb Feb 14, 2022
c302831
Document the difference between licenses and marks
dhruvkb Feb 14, 2022
17c8d26
Remove `atype` param from the link
dhruvkb Feb 14, 2022
0a25092
Use element itself as the key instead of an additional index
dhruvkb Feb 14, 2022
3cb81aa
Use props directly from `this`
dhruvkb Feb 14, 2022
f69df84
Remove class with no effect
dhruvkb Feb 14, 2022
87d2262
Improve the UI for smaller screens
dhruvkb Feb 15, 2022
11f0648
Use dynamic expression in return type
dhruvkb Feb 15, 2022
e8d9cdf
Only render license elements if the license is not `null`-ish
dhruvkb Feb 15, 2022
803143a
Rectify the font size of the heading
dhruvkb Feb 15, 2022
ebf52ff
Fix non-existent max width
dhruvkb Feb 15, 2022
0af7e0d
Add a close button to the license popover
dhruvkb Feb 15, 2022
a98e709
Fix bug with click outside
dhruvkb Feb 15, 2022
03ed3bd
Fix inline popover content taking up space (#870)
sarayourfriend Feb 15, 2022
b13ea0c
Cleanup trigger button
dhruvkb Feb 16, 2022
beafb05
Add focus ring around the close button
dhruvkb Feb 16, 2022
5523171
Explicitly register VButton to prevent test from failing
dhruvkb Feb 16, 2022
df66c76
Fix strange Safari bug with VoiceOver
dhruvkb Feb 17, 2022
3f91c0e
Resolve lapses in accessibility
dhruvkb Feb 17, 2022
99126ee
Merge branch 'main' of https://github.com/WordPress/openverse-fronten…
dhruvkb Feb 17, 2022
0390c7c
Merge branch 'main' into licence_popover
dhruvkb Feb 18, 2022
3df35cd
Only read the element title if there are more than one
dhruvkb Feb 18, 2022
94eeda4
Merge branch 'main' into licence_popover
dhruvkb Feb 22, 2022
c1f5ccb
Merge branch 'main' into licence_popover
dhruvkb Feb 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/assets/licenses/remix.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/licenses/sampling-plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/licenses/sampling.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 0 additions & 55 deletions src/components/LicenseElements.vue

This file was deleted.

74 changes: 37 additions & 37 deletions src/components/VFilters/VFilterChecklist.vue
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -20,40 +20,56 @@
<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'">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pass the label prop here with the value of the license definition. That way the popover label is read out when it is opened and we don't have to mess with moving the focus away from the default of the close button (which I think makes the most sense ergonomically to auto-focus when the popover is opened).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not understand what you mean by license definition. A license can have several elements, each with their own definition (eg. BY-NC-SA with 3 elements & 3 definitions).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right. We might need to find a compromise for screen reader folks to get that information quickly upon opening the popover. Maybe something to explore later on though 🤔 Otherwise the aria-label would be a huge wall of text for multi-element licenses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can separate this into a separate issue to at least move past the post-launch bugs milestone.

<template #trigger="{ a11yProps }">
<VButton
v-bind="a11yProps"
variant="plain"
size="disabled"
:aria-label="$t('browse-page.aria.license-explanation')"
class="text-dark-charcoal-70"
dhruvkb marked this conversation as resolved.
Show resolved Hide resolved
type="button"
>
<VIcon :icon-path="icons.help" />
</VButton>
</template>
<template #default="{ close }">
<div class="relative">
<VIconButton
dhruvkb marked this conversation as resolved.
Show resolved Hide resolved
: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',
components: {
VCheckbox,
VIcon,
VLicense,
VLicenseExplanationTooltip,
VLicenseExplanation,
VPopover,
},
props: {
options: { type: Array, required: false },
Expand All @@ -63,9 +79,7 @@ export default {
},
data() {
return {
licenseExplanationVisible: false,
licenseExplanationCode: null,
helpIcon,
icons: { help: helpIcon, closeSmall: closeSmallIcon },
}
},
computed: {
Expand All @@ -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)
Expand All @@ -120,13 +127,6 @@ export default {
}
return this.disabled
},
shouldRenderLicenseExplanationTooltip(licenseCode) {
return (
!this.isDisabled({ code: licenseCode }) &&
this.licenseExplanationVisible &&
this.licenseExplanationCode === licenseCode
)
},
},
}
</script>
88 changes: 88 additions & 0 deletions src/components/VFilters/VLicenseExplanation.vue
Original file line number Diff line number Diff line change
@@ -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
sarayourfriend marked this conversation as resolved.
Show resolved Hide resolved
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>
Loading