Skip to content

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

🔄 Synced file(s) with WordPress/openverse (#2039)

Openverse (Bot)ca02c8bd8a6a
diff --git a/.eslintrc.js b/.eslintrc.js
index 19c563aaf..7812c1d3c 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -2,7 +2,7 @@
// https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000771544-ESLint-does-not-work-with-webpack-import-resolver-in-2017-3
process.chdir(__dirname)
-const i18nDestructureRules = ['t', 'tc', 'te', 'td', 'd', 'n'].map(
+const i18nDestructureRules = ["t", "tc", "te", "td", "d", "n"].map(
(methodName) => ({
selector: `VariableDeclarator[id.type="ObjectPattern"]:has(Property[key.name="${methodName}"])[init.callee.name="useI18n"]`,
message: `Do not destructure ${methodName} from the i18n object as its methods internally depend on "this". Instead, use it directly (e.g., "i18n.${methodName}"). If you need an independent reference to the function then bind it or wrap it in a closure.`,
@@ -16,128 +16,128 @@ module.exports = {
node: true,
},
parserOptions: {
- parser: '@typescript-eslint/parser',
+ parser: "@typescript-eslint/parser",
},
extends: [
- 'eslint:recommended',
- 'plugin:@typescript-eslint/recommended',
- 'plugin:vue/recommended',
- 'plugin:prettier/recommended',
- 'plugin:vuejs-accessibility/recommended',
- 'plugin:@intlify/vue-i18n/recommended',
- 'plugin:import/recommended',
- 'plugin:eslint-comments/recommended',
+ "eslint:recommended",
+ "plugin:@typescript-eslint/recommended",
+ "plugin:vue/recommended",
+ "plugin:prettier/recommended",
+ "plugin:vuejs-accessibility/recommended",
+ "plugin:@intlify/vue-i18n/recommended",
+ "plugin:import/recommended",
+ "plugin:eslint-comments/recommended",
],
plugins: [
- '@typescript-eslint',
- 'eslint-plugin-tsdoc',
- 'vue',
- 'vuejs-accessibility',
- 'unicorn',
+ "@typescript-eslint",
+ "eslint-plugin-tsdoc",
+ "vue",
+ "vuejs-accessibility",
+ "unicorn",
],
rules: {
- semi: [2, 'never'],
- 'no-console': 'off',
- 'prettier/prettier': 'off',
- 'vue/max-attributes-per-line': 'off',
- 'vue/require-prop-types': 'off',
- 'vue/require-default-prop': 'off',
- 'vue/html-closing-bracket-newline': 'off',
- 'vue/html-indent': 'off',
- 'vue/singleline-html-element-content-newline': 'off',
- 'vue/block-lang': [
- 'error',
+ semi: [2, "never"],
+ "no-console": "off",
+ "prettier/prettier": "off",
+ "vue/max-attributes-per-line": "off",
+ "vue/require-prop-types": "off",
+ "vue/require-default-prop": "off",
+ "vue/html-closing-bracket-newline": "off",
+ "vue/html-indent": "off",
+ "vue/singleline-html-element-content-newline": "off",
+ "vue/block-lang": [
+ "error",
{
// This confusing naming prevents the use of 'lang' directives
// entirely on Vue SFC style blocks.
style: { allowNoLang: true },
},
],
- 'vue/component-name-in-template-casing': [
- 'error',
- 'PascalCase',
- { registeredComponentsOnly: false, ignores: ['i18n'] },
+ "vue/component-name-in-template-casing": [
+ "error",
+ "PascalCase",
+ { registeredComponentsOnly: false, ignores: ["i18n"] },
],
- 'vue/html-self-closing': [
- 'error',
+ "vue/html-self-closing": [
+ "error",
{
html: {
- void: 'always',
- normal: 'always',
- component: 'always',
+ void: "always",
+ normal: "always",
+ component: "always",
},
- svg: 'always',
- math: 'always',
+ svg: "always",
+ math: "always",
},
],
- 'vuejs-accessibility/aria-role': 'error',
- 'vuejs-accessibility/label-has-for': [
- 'error',
- { required: { some: ['nesting', 'id'] } },
+ "vuejs-accessibility/aria-role": "error",
+ "vuejs-accessibility/label-has-for": [
+ "error",
+ { required: { some: ["nesting", "id"] } },
],
/**
* Custom rule to disallow raw `<a></a>` tag usage.
* Learn more about vue-eslint-parser's AST syntax:
* https://github.com/vuejs/vue-eslint-parser/blob/master/docs/ast.md
*/
- 'vue/no-restricted-syntax': [
- 'error',
+ "vue/no-restricted-syntax": [
+ "error",
{
selector: 'VElement[name="a"]',
- message: 'Use the <VLink> component instead of a raw <a> tag.',
+ message: "Use the <VLink> component instead of a raw <a> tag.",
},
{
selector: 'VElement[name="nuxtlink"]',
- message: 'Use the <VLink> component instead of <NuxtLink>.',
+ message: "Use the <VLink> component instead of <NuxtLink>.",
},
{
selector: 'VElement[name="routerlink"]',
- message: 'Use the <VLink> component instead of <RouterLink>.',
+ message: "Use the <VLink> component instead of <RouterLink>.",
},
],
- 'no-restricted-syntax': ['error', ...i18nDestructureRules],
- 'unicorn/filename-case': ['error', { case: 'kebabCase' }],
- '@typescript-eslint/no-var-requires': ['off'],
- 'import/no-unresolved': [
- 'error',
+ "no-restricted-syntax": ["error", ...i18nDestructureRules],
+ "unicorn/filename-case": ["error", { case: "kebabCase" }],
+ "@typescript-eslint/no-var-requires": ["off"],
+ "import/no-unresolved": [
+ "error",
{
// https://github.com/nuxt-community/svg-module/issues/4
- ignore: ['.svg'],
+ ignore: [".svg"],
},
],
- 'import/newline-after-import': ['error'],
- 'import/order': [
- 'error',
+ "import/newline-after-import": ["error"],
+ "import/order": [
+ "error",
{
- 'newlines-between': 'always-and-inside-groups',
+ "newlines-between": "always-and-inside-groups",
groups: [
- 'builtin',
- 'external',
- 'internal',
- 'parent',
- 'sibling',
- 'index',
- 'object',
- 'type',
+ "builtin",
+ "external",
+ "internal",
+ "parent",
+ "sibling",
+ "index",
+ "object",
+ "type",
],
pathGroups: [
{
// Treat vue and composition-api as "builtin"
- pattern: '(vue|@nuxtjs/composition-api)',
- group: 'builtin',
- position: 'before',
+ pattern: "(vue|@nuxtjs/composition-api)",
+ group: "builtin",
+ position: "before",
},
{
// Move assets to the very end of the imports list
- pattern: '~/assets/**',
- group: 'type',
- position: 'after',
+ pattern: "~/assets/**",
+ group: "type",
+ position: "after",
},
{
// Treat components as their own group and move to the end of the internal imports list
- pattern: '~/components/**',
- group: 'internal',
- position: 'after',
+ pattern: "~/components/**",
+ group: "internal",
+ position: "after",
},
/**
* These next two must come after any more specific matchers
@@ -147,60 +147,60 @@ module.exports = {
*/
{
// Document webpack alias
- pattern: '~/**',
- group: 'internal',
- position: 'before',
+ pattern: "~/**",
+ group: "internal",
+ position: "before",
},
{
// Document webpack alias
- pattern: '~~/**',
- group: 'external',
- position: 'after',
+ pattern: "~~/**",
+ group: "external",
+ position: "after",
},
],
},
],
- 'import/extensions': ['error', 'always', { js: 'never', ts: 'never' }],
- '@intlify/vue-i18n/no-raw-text': [
- 'error',
+ "import/extensions": ["error", "always", { js: "never", ts: "never" }],
+ "@intlify/vue-i18n/no-raw-text": [
+ "error",
{
ignoreText: [
// Brand names that should not be translated
- 'Common Crawl',
- 'Creative Commons',
- 'Europeana',
- 'Flickr',
- 'Openverse',
- 'WordPress',
+ "Common Crawl",
+ "Creative Commons",
+ "Europeana",
+ "Flickr",
+ "Openverse",
+ "WordPress",
],
},
],
},
overrides: [
{
- files: ['*.ts'],
+ files: ["*.ts"],
rules: {
- 'tsdoc/syntax': 'error',
+ "tsdoc/syntax": "error",
},
},
{
- files: ['*.spec.js'],
+ files: ["*.spec.js"],
rules: {
- '@intlify/vue-i18n/no-raw-text': ['off'],
+ "@intlify/vue-i18n/no-raw-text": ["off"],
},
},
],
settings: {
- 'vue-i18n': {
- localeDir: './src/locales/*.{json}',
- messageSyntaxVersion: '^8.24.3',
+ "vue-i18n": {
+ localeDir: "./src/locales/*.{json}",
+ messageSyntaxVersion: "^8.24.3",
},
- 'import/resolver': {
- 'eslint-import-resolver-custom-alias': {
+ "import/resolver": {
+ "eslint-import-resolver-custom-alias": {
alias: {
- '~': './src',
- '~~': '.',
+ "~": "./src",
+ "~~": ".",
},
/**
* SVG imports are excluded for the import/no-unresolved
@@ -208,7 +208,7 @@ module.exports = {
*
* Therefore, there's no need to configure them here
*/
- extensions: ['.js', '.ts', '.vue', '.png'],
+ extensions: [".js", ".ts", ".vue", ".png"],
},
},
},
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index debacdb69..cffdd1d81 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -6,30 +6,35 @@ title: "<Replace this with actual title>"
---
## Description
+
<!-- Concisely describe the bug. Compare your experience with what you expected to happen. -->
<!-- For example: "I clicked the 'submit' button and instead of seeing a thank you message, I saw a blank page." -->
## Reproduction
+
<!-- Provide detailed steps to reproduce the bug. -->
+
1. <!-- Step 1 ... -->
2. <!-- Step 2 ... -->
3. <!-- Step 3 ... -->
4. See error.
## Screenshots
+
<!-- Add screenshots to show the problem; or delete the section entirely. -->
## Environment
+
<!-- Please complete this, unless you are certain the problem is not environment specific. -->
- - Device: <!-- (_eg._ iPhone Xs; laptop) -->
- - OS: <!-- (_eg._ iOS 13.5; Fedora 32) -->
- - Browser: <!-- (_eg._ Safari; Firefox) -->
- - Version: <!-- (_eg._ 13; 73) -->
- - Other info: <!-- (_eg._ display resolution, ease-of-access settings) -->
+
+- Device: <!-- (_eg._ iPhone Xs; laptop) -->
+- OS: <!-- (_eg._ iOS 13.5; Fedora 32) -->
+- Browser: <!-- (_eg._ Safari; Firefox) -->
+- Version: <!-- (_eg._ 13; 73) -->
+- Other info: <!-- (_eg._ display resolution, ease-of-access settings) -->
## Additional context
+
<!-- Add any other context about the problem here; or delete the section entirely. -->
-## Resolution
-<!-- Replace the [ ] with [x] to check the box. -->
-- [ ] 🙋 I would be interested in resolving this bug.
+<!-- If you would like to work on this, please comment below separately. -->
diff --git a/.github/ISSUE_TEMPLATE/discussion.md b/.github/ISSUE_TEMPLATE/discussion.md
index 79344d2c4..ca91bba13 100644
--- a/.github/ISSUE_TEMPLATE/discussion.md
+++ b/.github/ISSUE_TEMPLATE/discussion.md
@@ -6,13 +6,16 @@ title: "<Replace this with actual title>"
---
<!-- Consider how soon we need the discussion resolved vs. giving everyone an opportunity to participate. -->
+
## Due date: yyyy-mm-dd
<!-- Suggest two members of @WordPress/openverse to review the discussion. -->
+
## Assigned reviewers
- [ ] TBD
- [ ] TBD
<!-- Start the conversation. Please @ anyone relevant and try to ask questions to help facilate discussion. -->
+
## Description
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 75c3ee41d..ab7047947 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -6,17 +6,19 @@ title: "<Replace this with actual title>"
---
## Problem
+
<!-- Describe a problem solved by this feature; or delete the section entirely. -->
## Description
+
<!-- Describe the feature and how it solves the problem. -->
## Alternatives
+
<!-- Describe any alternative solutions or features you have considered. How is this feature better? -->
## Additional context
+
<!-- Add any other context about the feature here; or delete the section entirely. -->
-## Implementation
-<!-- Replace the [ ] with [x] to check the box. -->
-- [ ] 🙋 I would be interested in implementing this feature.
+<!-- If you would like to work on this, please comment below separately. -->
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index accf40a74..dc5a5773b 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,28 +1,39 @@
## Fixes
+
<!-- If PR doesn't fully resolve the issue, replace 'Fixes' below with 'Related to'. -->
<!-- If there is no issue being resolved, please consider opening one before creating this pull request. -->
+
Fixes #[issue number] by @[issue author]
## Description
+
<!-- Concisely describe what the pull request does. -->
<!-- Add screenshots, videos, or other media to show the problem and the solution when appropriate. -->
## Testing Instructions
+
<!-- Give steps for the reviewer to verify that this PR fixes the problem; or delete this section entirely. -->
## Checklist
+
<!-- Replace the [ ] with [x] to check the boxes. -->
-- [ ] My pull request has a descriptive title (not a vague title like `Update index.md`).
-- [ ] My pull request targets the *default* branch of the repository (`main`) or a parent feature branch.
+
+- [ ] My pull request has a descriptive title (not a vague title like
+ `Update index.md`).
+- [ ] My pull request targets the _default_ branch of the repository (`main`) or
+ a parent feature branch.
- [ ] My commit messages follow [best practices][best_practices].
- [ ] My code follows the established code style of the repository.
- [ ] I added or updated tests for the changes I made (if applicable).
- [ ] I added or updated documentation (if applicable).
-- [ ] I tried running the project locally and verified that there are no visible errors.
+- [ ] I tried running the project locally and verified that there are no visible
+ errors.
-[best_practices]:https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines
+[best_practices]:
+ https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines
## Developer Certificate of Origin
+
<!-- You must read and understand the following attestation. -->
<details>
diff --git a/.github/workflows/pr_label_check.yml b/.github/workflows/pr_label_check.yml
index 726c02934..d8dd7c16d 100644
--- a/.github/workflows/pr_label_check.yml
+++ b/.github/workflows/pr_label_check.yml
@@ -13,24 +13,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check aspect label
- uses: sugarshin/[email protected]
+ uses: docker://agilepathway/pull-request-label-checker:v1.2.9
with:
- required_oneof: "💻 aspect: code,📄 aspect: text,🤖 aspect: dx,🕹 aspect: interface,♿️ aspect: a11y"
+ one_of: "💻 aspect: code,📄 aspect: text,🤖 aspect: dx,🕹 aspect: interface,♿️ aspect: a11y"
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
check_goal_label:
name: Check goal label
runs-on: ubuntu-latest
steps:
- name: Check goal label
- uses: sugarshin/[email protected]
+ uses: docker://agilepathway/pull-request-label-checker:v1.2.9
with:
- required_oneof: "🌟 goal: addition,🛠 goal: fix,✨ goal: improvement,🧰 goal: internal improvement"
+ one_of: "🌟 goal: addition,🛠 goal: fix,✨ goal: improvement,🧰 goal: internal improvement"
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
check_priority_label:
name: Check priority label
runs-on: ubuntu-latest
steps:
- name: Check priority label
- uses: sugarshin/[email protected]
+ uses: docker://agilepathway/pull-request-label-checker:v1.2.9
with:
- required_oneof: "🟩 priority: low,🟨 priority: medium,🟧 priority: high,🟥 priority: critical"
+ one_of: "🟩 priority: low,🟨 priority: medium,🟧 priority: high,🟥 priority: critical"
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.pnpmfile.cjs b/.pnpmfile.cjs
index 4b574db1a..f7e65fabe 100644
--- a/.pnpmfile.cjs
+++ b/.pnpmfile.cjs
@@ -1,4 +1,4 @@
-const packageJson = require('./package.json')
+const packageJson = require("./package.json")
function readPackage(pkg, context) {
if (pkg.dependencies.typescript) {
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 5fc82d80f..8a10d6f2d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -12,7 +12,9 @@ repos:
name: i18n
# Check if the i18n files have been downloaded by checking if the Arabic translation exists
# Download the i18n files if they do not exist
- entry: bash -c 'if [ ! -f "$(dirname "$dir")"/src/locales/ar.json ]; then pnpm i18n; fi'
+ entry:
+ bash -c 'if [ ! -f "$(dirname "$dir")"/src/locales/ar.json ]; then
+ pnpm i18n; fi'
language: system
pass_filenames: false
@@ -43,7 +45,7 @@ repos:
- id: eslint
files: \.(js|ts|vue)$
exclude: ^nuxt-template-overrides/.*$ # ESLint raises warnings for ignored files.
- 'types': [file] # ESLint only accepts [javascript] by default.
+ "types": [file] # ESLint only accepts [javascript] by default.
args:
- --ignore-path=.gitignore
- --ignore-path=.eslintignore
@@ -51,11 +53,11 @@ repos:
additional_dependencies:
- - '@babel/[email protected]'
- - '@intlify/[email protected]'
- - '@nuxtjs/[email protected]'
- - '@typescript-eslint/[email protected]'
- - '@typescript-eslint/[email protected]'
+ - "@babel/[email protected]"
+ - "@intlify/[email protected]"
+ - "@nuxtjs/[email protected]"
+ - "@typescript-eslint/[email protected]"
+ - "@typescript-eslint/[email protected]"
@@ -70,7 +72,6 @@ repos:
rev: v2.6.0
hooks:
- id: prettier
- exclude: \.md$ # TODO: https://github.com/WordPress/openverse/issues/333
additional_dependencies:
diff --git a/.storybook/.eslintrc.js b/.storybook/.eslintrc.js
index 7343f3a84..9554c6963 100644
--- a/.storybook/.eslintrc.js
+++ b/.storybook/.eslintrc.js
@@ -11,10 +11,10 @@
* directory.
*/
module.exports = {
- extends: '../.eslintrc.js',
+ extends: "../.eslintrc.js",
rules: {
- 'import/extensions': 'off',
- 'import/export': 'off',
- 'import/no-unresolved': 'off',
+ "import/extensions": "off",
+ "import/export": "off",
+ "import/no-unresolved": "off",
},
}
diff --git a/.storybook/decorators/with-rtl.js b/.storybook/decorators/with-rtl.js
index 2ce8ae547..384a001b1 100644
--- a/.storybook/decorators/with-rtl.js
+++ b/.storybook/decorators/with-rtl.js
@@ -1,9 +1,9 @@
-import Vue from 'vue'
+import Vue from "vue"
-import { ref, watch, useContext, onMounted } from '@nuxtjs/composition-api'
-import { useEffect } from '@storybook/client-api'
+import { ref, watch, useContext, onMounted } from "@nuxtjs/composition-api"
+import { useEffect } from "@storybook/client-api"
-const languageDirection = Vue.observable({ value: 'ltr' })
+const languageDirection = Vue.observable({ value: "ltr" })
export const WithRTL = (story, context) => {
useEffect(() => {
@@ -23,8 +23,8 @@ export const WithRTL = (story, context) => {
i18n.localeProperties.dir = direction.value
if (element.value) {
element.value.ownerDocument.documentElement.setAttribute(
- 'dir',
- direction?.value ?? 'ltr'
+ "dir",
+ direction?.value ?? "ltr"
)
}
},
diff --git a/.storybook/decorators/with-ui-store.js b/.storybook/decorators/with-ui-store.js
index 82c48d822..d57f28fa7 100644
--- a/.storybook/decorators/with-ui-store.js
+++ b/.storybook/decorators/with-ui-store.js
@@ -1,6 +1,6 @@
-import { ref, onMounted } from '@nuxtjs/composition-api'
+import { ref, onMounted } from "@nuxtjs/composition-api"
-import { useLayout } from '~/composables/use-layout'
+import { useLayout } from "~/composables/use-layout"
export const WithUiStore = (story) => {
return {
diff --git a/.storybook/main.js b/.storybook/main.js
index 5c9d776e0..94e745799 100644
--- a/.storybook/main.js
+++ b/.storybook/main.js
@@ -1,4 +1,4 @@
-const { nuxifyStorybook } = require('../.nuxt-storybook/storybook/main')
+const { nuxifyStorybook } = require("../.nuxt-storybook/storybook/main")
module.exports = nuxifyStorybook({
webpackFinal(config) {
diff --git a/.storybook/middleware.js b/.storybook/middleware.js
index 4c719daf7..29cf1ee3f 100644
--- a/.storybook/middleware.js
+++ b/.storybook/middleware.js
@@ -1 +1 @@
-module.exports = require('../.nuxt-storybook/storybook/middleware')
+module.exports = require("../.nuxt-storybook/storybook/middleware")
diff --git a/.storybook/preview.js b/.storybook/preview.js
index 68a0ea220..5e6b9d1c1 100644
--- a/.storybook/preview.js
+++ b/.storybook/preview.js
@@ -1,27 +1,27 @@
/* eslint-disable import/order */
-export * from '~~/.nuxt-storybook/storybook/preview'
+export * from "~~/.nuxt-storybook/storybook/preview"
import {
globalTypes as nuxtGlobalTypes,
decorators as nuxtDecorators,
-} from '~~/.nuxt-storybook/storybook/preview'
+} from "~~/.nuxt-storybook/storybook/preview"
-import { WithRTL } from './decorators/with-rtl'
-import { WithUiStore } from './decorators/with-ui-store'
+import { WithRTL } from "./decorators/with-rtl"
+import { WithUiStore } from "./decorators/with-ui-store"
/* eslint-enable import/order */
export const globalTypes = {
...nuxtGlobalTypes,
languageDirection: {
- name: 'RTL',
- description: 'Simulate an RTL language.',
- defaultValue: 'ltr',
+ name: "RTL",
+ description: "Simulate an RTL language.",
+ defaultValue: "ltr",
toolbar: {
- icon: 'globe',
+ icon: "globe",
items: [
- { value: 'ltr', title: 'LTR' },
- { value: 'rtl', title: 'RTL' },
+ { value: "ltr", title: "LTR" },
+ { value: "rtl", title: "RTL" },
],
},
},
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 5a77323cc..d68c1b7de 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -1,11 +1,25 @@
-This project comes under the WordPress [Etiquette](https://wordpress.org/about/etiquette/):
+This project comes under the WordPress
+[Etiquette](https://wordpress.org/about/etiquette/):
-In the WordPress open source project, we realize that our biggest asset is the community that we foster. The project, as a whole, follows these basic philosophical principles from The Cathedral and The Bazaar.
+In the WordPress open source project, we realize that our biggest asset is the
+community that we foster. The project, as a whole, follows these basic
+philosophical principles from The Cathedral and The Bazaar.
-- Contributions to the WordPress open source project are for the benefit of the WordPress community as a whole, not specific businesses or individuals. All actions taken as a contributor should be made with the best interests of the community in mind.
-- Participation in the WordPress open source project is open to all who wish to join, regardless of ability, skill, financial status, or any other criteria.
-- The WordPress open source project is a volunteer-run community. Even in cases where contributors are sponsored by companies, that time is donated for the benefit of the entire open source community.
-- Any member of the community can donate their time and contribute to the project in any form including design, code, documentation, community building, etc. For more information, go to make.wordpress.org.
-- The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included, by keeping communication free of discrimination, incitement to violence, promotion of hate, and unwelcoming behavior.
+- Contributions to the WordPress open source project are for the benefit of the
+ WordPress community as a whole, not specific businesses or individuals. All
+ actions taken as a contributor should be made with the best interests of the
+ community in mind.
+- Participation in the WordPress open source project is open to all who wish to
+ join, regardless of ability, skill, financial status, or any other criteria.
+- The WordPress open source project is a volunteer-run community. Even in cases
+ where contributors are sponsored by companies, that time is donated for the
+ benefit of the entire open source community.
+- Any member of the community can donate their time and contribute to the
+ project in any form including design, code, documentation, community building,
+ etc. For more information, go to make.wordpress.org.
+- The WordPress open source community cares about diversity. We strive to
+ maintain a welcoming environment where everyone can feel included, by keeping
+ communication free of discrimination, incitement to violence, promotion of
+ hate, and unwelcoming behavior.
The team involved will block any user who causes any breach in this.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f19cfb7f9..7d330238c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,10 +1,12 @@
# Contributing to Openverse
-Thank you for your interest in contributing to Openverse! This document is a set of guidelines to help you contribute to this project.
+Thank you for your interest in contributing to Openverse! This document is a set
+of guidelines to help you contribute to this project.
## Code of Conduct
-By participating in this project, you are expected to uphold our [Code of Conduct](./CODE_OF_CONDUCT.md).
+By participating in this project, you are expected to uphold our
+[Code of Conduct](./CODE_OF_CONDUCT.md).
## Project Documentation
@@ -12,58 +14,114 @@ Please consult the [README](./README.md) file at the root of this repository.
## How to Contribute
-Please read the processes in our general [Contributing Code](https://creativecommons.github.io/contributing-code/) guidelines on the Creative Common Open Source website. It contains some general instructions that should be followed when contributing to any of the WP Photos open-source repositories.
+Please read the processes in our general
+[Contributing Code](https://creativecommons.github.io/contributing-code/)
+guidelines on the Creative Common Open Source website. It contains some general
+instructions that should be followed when contributing to any of the WP Photos
+open-source repositories.
### Bugs and testing
-If you find a bug, please open an issue in this repository describing the bug. You can file a bug [here](https://github.com/wordpress/openverse-frontend/issues/new?template=bug_report.md). You will see a bug report template with the required information you should provide.
+If you find a bug, please open an issue in this repository describing the bug.
+You can file a bug
+[here](https://github.com/wordpress/openverse-frontend/issues/new?template=bug_report.md).
+You will see a bug report template with the required information you should
+provide.
-Please see our [testing guidelines](./TESTING_GUIDELINES.md) for general instructions and recommendations for how to test the application.
+Please see our [testing guidelines](./TESTING_GUIDELINES.md) for general
+instructions and recommendations for how to test the application.
### Proposing changes or new features
-If you have an idea of a new feature or change to how the Openverse frontend works, please [file an issue](https://github.com/wordpress/openverse-frontend/issues/new?template=feature_request.md) so we can discuss the possibility of that change or new feature being implemented and released in the future. This lets us come to an agreement about the proposed idea before any work is done.
+If you have an idea of a new feature or change to how the Openverse frontend
+works, please
+[file an issue](https://github.com/wordpress/openverse-frontend/issues/new?template=feature_request.md)
+so we can discuss the possibility of that change or new feature being
+implemented and released in the future. This lets us come to an agreement about
+the proposed idea before any work is done.
-If you'd like to build a new feature but don't have a specific idea, please check out the historic [public roadmap](https://docs.google.com/document/d/19yH2V5K4nzWgEXaZhkzD1egzrRayyDdxlzxZOTCm_pc/). Choose something from the pipeline of ideas and follow the same process as above.
+If you'd like to build a new feature but don't have a specific idea, please
+check out the historic
+[public roadmap](https://docs.google.com/document/d/19yH2V5K4nzWgEXaZhkzD1egzrRayyDdxlzxZOTCm_pc/).
+Choose something from the pipeline of ideas and follow the same process as
+above.
### Pull requests
-Before you start writing code, make sure there is an issue open. Pull requests without a link to an existing issue won't be merged. All pull requests _must_ target the `main` branch of the repository.
+Before you start writing code, make sure there is an issue open. Pull requests
+without a link to an existing issue won't be merged. All pull requests _must_
+target the `main` branch of the repository.
-If you want to get started contributing code to this project but don't know exactly what to work on, we compiled a good list of issues labeled as ['good first issues'](https://github.com/wordpress/openverse-frontend/labels/good%20first%20issue) which are small in scope and not so complex to solve. There are also issues labeled as ['help wanted'](https://github.com/wordpress/openverse-frontend/labels/help%20wanted) which can be a bit more complex but are good examples of things we are currently accepting help from the community.
+If you want to get started contributing code to this project but don't know
+exactly what to work on, we compiled a good list of issues labeled as
+['good first issues'](https://github.com/wordpress/openverse-frontend/labels/good%20first%20issue)
+which are small in scope and not so complex to solve. There are also issues
+labeled as
+['help wanted'](https://github.com/wordpress/openverse-frontend/labels/help%20wanted)
+which can be a bit more complex but are good examples of things we are currently
+accepting help from the community.
-Any code modifications will have to be accompanied by the appropriate unit tests. This will be checked and verified during code review. Once the pull request is opened, our CI server will run the unit test suite and run a code linter to verify that the code follows the coding guidelines.
+Any code modifications will have to be accompanied by the appropriate unit
+tests. This will be checked and verified during code review. Once the pull
+request is opened, our CI server will run the unit test suite and run a code
+linter to verify that the code follows the coding guidelines.
-If you want to run the unit tests and linter on your machine, run the following commands:
+If you want to run the unit tests and linter on your machine, run the following
+commands:
`pnpm test:unit` for unit tests
`pnpm lint` for linter.
-You can also configure your editor of choice with a ESLint plugin so you can get the linter feedback as you write code.
+You can also configure your editor of choice with a ESLint plugin so you can get
+the linter feedback as you write code.
### Types
-We use native TypeScript everywhere we can. Currently there are very few edge cases where it is not possible to use TypeScript, primarily in older components that do not use the composition-api or that rely on Nuxt's auto-component importing.
+We use native TypeScript everywhere we can. Currently there are very few edge
+cases where it is not possible to use TypeScript, primarily in older components
+that do not use the composition-api or that rely on Nuxt's auto-component
+importing.
-TypeScript support for Vue 2 is limited to composition-api based components (i.e., components that use `defineComponent` and declare a `setup` function). If you'd like to use TypeScript for a Vue SFC, add `lang="ts"` to the `script` tag and add the file to the `tsconfig.json` `includes` array.
+TypeScript support for Vue 2 is limited to composition-api based components
+(i.e., components that use `defineComponent` and declare a `setup` function). If
+you'd like to use TypeScript for a Vue SFC, add `lang="ts"` to the `script` tag
+and add the file to the `tsconfig.json` `includes` array.
Elsewhere, simply use (and prefer) the `.ts` extension for all new files.
-See [Vue's official documentation about IDE support for Vue with TypeScript](https://vuejs.org/guide/typescript/overview.html#ide-support) for guides on how to set up your editor.
+See
+[Vue's official documentation about IDE support for Vue with TypeScript](https://vuejs.org/guide/typescript/overview.html#ide-support)
+for guides on how to set up your editor.
#### JSDoc TypeScript
-Some older modules use JSDoc flavored TypeScript. This was primarily used before the project had included support for native TypeScript. Please do not extend the use of JSDoc TypeScript outside of modules that already use it. If you feel so inclined, we always welcome PRs updating such modules to native TypeScript.
+Some older modules use JSDoc flavored TypeScript. This was primarily used before
+the project had included support for native TypeScript. Please do not extend the
+use of JSDoc TypeScript outside of modules that already use it. If you feel so
+inclined, we always welcome PRs updating such modules to native TypeScript.
### Styles/CSS
-We use [Tailwind CSS](https://tailwindcss.com/) for writing styles. There are some legacy components that have been written in "hand-written" CSS. Our aim is to eventually re-write these using Tailwind classes.
+We use [Tailwind CSS](https://tailwindcss.com/) for writing styles. There are
+some legacy components that have been written in "hand-written" CSS. Our aim is
+to eventually re-write these using Tailwind classes.
-Our Tailwind configuration lives at [`./tailwind.config.js`](./tailwind.config.js) and is a useful reference for Openverse specific spacing and color classes. Please refer to the official [Tailwind CSS documentation](https://tailwindcss.com/docs) for a detailed and searchable list of the available classes. At times you'll need to cross reference this documentation with our specific configuration in the `tailwind.config.js` file.
+Our Tailwind configuration lives at
+[`./tailwind.config.js`](./tailwind.config.js) and is a useful reference for
+Openverse specific spacing and color classes. Please refer to the official
+[Tailwind CSS documentation](https://tailwindcss.com/docs) for a detailed and
+searchable list of the available classes. At times you'll need to cross
+reference this documentation with our specific configuration in the
+`tailwind.config.js` file.
-We also use the [Tailwind CSS RTL](https://github.com/20lives/tailwindcss-rtl) plugin to make writing [right-to-left (RTL)](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) styles seamless. Most use cases of the right/left based classes should use the start/end variants introduced by the plugin instead.
+We also use the [Tailwind CSS RTL](https://github.com/20lives/tailwindcss-rtl)
+plugin to make writing
+[right-to-left (RTL)](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
+styles seamless. Most use cases of the right/left based classes should use the
+start/end variants introduced by the plugin instead.
## Questions or Thoughts?
-Feel free to [join us on Slack](https://make.wordpress.org/chat/) and discuss the project with the engineers and community members on #openverse.
+Feel free to [join us on Slack](https://make.wordpress.org/chat/) and discuss
+the project with the engineers and community members on #openverse.
diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md
index eff675b47..2a2ef0faa 100644
--- a/DEPLOYMENT.md
+++ b/DEPLOYMENT.md
@@ -5,85 +5,178 @@
| Staging | [Staging Deployment Log](https://github.com/WordPress/openverse-frontend/actions/workflows/ghcr.yml?query=branch%3Amain+event%3Apush) | <https://search-staging.openverse.engineering> | [Staging version](https://search-staging.openverse.engineering/version.json) |
| Production | [Production Deployment Log](https://github.com/WordPress/openverse-frontend/actions/workflows/ghcr.yml?query=event%3Arelease) | <https://search-production.openverse.engineering>[^production] | [Production version](https://search-production.openverse.engineering/version.json) |
-[^versions]: To determine the currently deployed version for any environment, visit the `/version.json` of the environment. The `release` property will list the relevant image tag for the current deployment.
-[^production]: Note that production is accessed via the iframe at <https://wordpress.org/openverse>, not directly via the `search-production` subdomain.
-
-The Openverse frontend is deployed using AWS's Elastic Container Service. The frontend is encapsulated into a single _ECS service_ per environment. The overall approach of deployments is to generate a new _task definition_ and to associate that task definition with the ECS Service. This causes the service to deploy the new task definition as a newly running _task_. Once the service has determined the new task to be healthy, it will redirect all traffic to the new task away from the old task. This is called _draining_. Once the old task is drained, it is spun down and the only task left running is the new one.
-
-> _**Note:**_ The number of running tasks per active task definition may vary per environment but has no bearings on the deployment process. The size of the service is handle entirely on the infrastructure side. The process above is completely automated and contributors generally do not need to be acutely aware of the "behind the scenes" stuff going on, but it can be helpful for understanding what is happening during a deployment.
+[^versions]:
+ To determine the currently deployed version for any environment, visit the
+ `/version.json` of the environment. The `release` property will list the
+ relevant image tag for the current deployment.
+
+[^production]:
+ Note that production is accessed via the iframe at
+ <https://wordpress.org/openverse>, not directly via the `search-production`
+ subdomain.
+
+The Openverse frontend is deployed using AWS's Elastic Container Service. The
+frontend is encapsulated into a single _ECS service_ per environment. The
+overall approach of deployments is to generate a new _task definition_ and to
+associate that task definition with the ECS Service. This causes the service to
+deploy the new task definition as a newly running _task_. Once the service has
+determined the new task to be healthy, it will redirect all traffic to the new
+task away from the old task. This is called _draining_. Once the old task is
+drained, it is spun down and the only task left running is the new one.
+
+> _**Note:**_ The number of running tasks per active task definition may vary
+> per environment but has no bearings on the deployment process. The size of the
+> service is handle entirely on the infrastructure side. The process above is
+> completely automated and contributors generally do not need to be acutely
+> aware of the "behind the scenes" stuff going on, but it can be helpful for
+> understanding what is happening during a deployment.
## Deployment Workflow
-Deployments for all environments follow the same general workflow. This workflow is completely automated and auditable via GitHub Workflows.
+Deployments for all environments follow the same general workflow. This workflow
+is completely automated and auditable via GitHub Workflows.
-1. Build the ghcr.io/wordpress/openverse-frontend docker image. Tag it appropriately for the deployment.
-2. Download the template task definition from AWS for the environment being deployed. Update the template with the following:
+1. Build the ghcr.io/wordpress/openverse-frontend docker image. Tag it
+ appropriately for the deployment.
+2. Download the template task definition from AWS for the environment being
+ deployed. Update the template with the following:
1. The new image tag
2. The reified task definition family name without the `-template` suffix
3. Register the new task definition to the ECS service.
4. Wait for the ECS service to report that it is stable.
- - During this waiting period, the process described in the opening paragraph is orchestrated by ECS. This part is _not_ transparent in the GitHub Workflows and will simply appear as a waiting step without any further information.
+ - During this waiting period, the process described in the opening paragraph
+ is orchestrated by ECS. This part is _not_ transparent in the GitHub
+ Workflows and will simply appear as a waiting step without any further
+ information.
-This process, from start to finish, generally takes less than 15 minutes. If it takes longer than 15 then something is probably wrong.
+This process, from start to finish, generally takes less than 15 minutes. If it
+takes longer than 15 then something is probably wrong.
### Failures
-Failures are automatically handled and the Openverse maintainers are notified. The GitHub Workflow log is the canonical source of truth of the record of our deployment attempts. See the table at the top of this document for links to these logs per environment.
-
-If any of the steps described above fails, including the new task spin up and switch over, the deployment is deemed a failure. If the failure occurs while trying to start a new healthy task, the ECS service will automatically rollback to the previous task definition revision. Remember that the previous task is not drained and removed until the new task is determined to be healthy, so this rollback has zero downtime.
-
-If the docker build fails then there is nothing to rollback. The failure needs to be investigated and the issue fixed for deployments to be possible again. However, this is unlikely to happen because we require valid Docker image builds as part of our CI. Nonetheless, given certain semantic merge conflicts, it is possible that a PR could pass CI and still cause a build failure when merged, so it is technically possible for a failure to occur during the first step.
+Failures are automatically handled and the Openverse maintainers are notified.
+The GitHub Workflow log is the canonical source of truth of the record of our
+deployment attempts. See the table at the top of this document for links to
+these logs per environment.
+
+If any of the steps described above fails, including the new task spin up and
+switch over, the deployment is deemed a failure. If the failure occurs while
+trying to start a new healthy task, the ECS service will automatically rollback
+to the previous task definition revision. Remember that the previous task is not
+drained and removed until the new task is determined to be healthy, so this
+rollback has zero downtime.
+
+If the docker build fails then there is nothing to rollback. The failure needs
+to be investigated and the issue fixed for deployments to be possible again.
+However, this is unlikely to happen because we require valid Docker image builds
+as part of our CI. Nonetheless, given certain semantic merge conflicts, it is
+possible that a PR could pass CI and still cause a build failure when merged, so
+it is technically possible for a failure to occur during the first step.
## Staging
-Staging is automatically deployed any time code is merged to the `main` branch of this repository. It follows the process above. Staging images are tagged with the commit SHA, following the pattern `sha-<commit>`. They are also tagged with `main`[^staging-tag].
+Staging is automatically deployed any time code is merged to the `main` branch
+of this repository. It follows the process above. Staging images are tagged with
+the commit SHA, following the pattern `sha-<commit>`. They are also tagged with
+`main`[^staging-tag].
-[^staging-tag]: Currently the staging task definition gets rendered with the `main` tag instead of the commit SHA based one. This may change in the future. If it does change, there should be no noticeable difference in the deployment process to contributors.
+[^staging-tag]:
+ Currently the staging task definition gets rendered with the `main` tag
+ instead of the commit SHA based one. This may change in the future. If it
+ does change, there should be no noticeable difference in the deployment
+ process to contributors.
## Production
-Production is automatically deployed any time a new release is created in GitHub. Release images are tagged with the release tag name, for example `v3.4.3`. The task definition is rendered using this tag.
+Production is automatically deployed any time a new release is created in
+GitHub. Release images are tagged with the release tag name, for example
+`v3.4.3`. The task definition is rendered using this tag.
## Rollbacks
-Even if the deployment process described above succeeds, sometimes we may realise that the deployed code is not behaving as we expected. In these cases it may be necessary to force an environment to be deployed to a specific version.
+Even if the deployment process described above succeeds, sometimes we may
+realise that the deployed code is not behaving as we expected. In these cases it
+may be necessary to force an environment to be deployed to a specific version.
-The [Rollback Frontend](https://github.com/WordPress/openverse-frontend/actions/workflows/rollback.yml) workflow makes this possible. It is a dispatchable workflow. Only members of the @WordPress/openverse-maintainers GitHub team are able to dispatch the workflow to completion. Anyone else who tries to dispatch it will have the workflow automatically fail.
+The
+[Rollback Frontend](https://github.com/WordPress/openverse-frontend/actions/workflows/rollback.yml)
+workflow makes this possible. It is a dispatchable workflow. Only members of the
+@WordPress/openverse-maintainers GitHub team are able to dispatch the workflow
+to completion. Anyone else who tries to dispatch it will have the workflow
+automatically fail.
-The workflow requires two inputs: `environment` and `tag`. `environment` must be either `staging` or `production` and the `tag` must be a valid tag that exists on the ghcr.io/wordpress/openverse-frontend image. The `tag` input is validated against the available list of tags and the workflow will fail if the tag is determined not to exist in the image repository.
+The workflow requires two inputs: `environment` and `tag`. `environment` must be
+either `staging` or `production` and the `tag` must be a valid tag that exists
+on the ghcr.io/wordpress/openverse-frontend image. The `tag` input is validated
+against the available list of tags and the workflow will fail if the tag is
+determined not to exist in the image repository.
-After validating the tag and that the dispatcher is authorised, the Rollback workflow follows the deployment process described above, except that it skips the Docker image build and goes straight to step 2. Because of this difference, the rollback workflow generally takes less than 10 minutes.
+After validating the tag and that the dispatcher is authorised, the Rollback
+workflow follows the deployment process described above, except that it skips
+the Docker image build and goes straight to step 2. Because of this difference,
+the rollback workflow generally takes less than 10 minutes.
## Environment Variables
-To add new environment variables for a given service, you must first update the task definition template in Terraform with the new variables and then deploy the code that depends on it. It is generally good practice to have safe defaults for environment variables so that this ordering does not matter.
+To add new environment variables for a given service, you must first update the
+task definition template in Terraform with the new variables and then deploy the
+code that depends on it. It is generally good practice to have safe defaults for
+environment variables so that this ordering does not matter.
-If you're adding a new environment variable, be sure to coordinate with someone on @WordPress/openverse-maintainers who is able to update the task definition template for you, if you're unable to do so yourself.
+If you're adding a new environment variable, be sure to coordinate with someone
+on @WordPress/openverse-maintainers who is able to update the task definition
+template for you, if you're unable to do so yourself.
-After the template is updated, deploy the new code following the usual procedures and the new template will be used.
+After the template is updated, deploy the new code following the usual
+procedures and the new template will be used.
-When updating existing environment variable values or adding new variables that do not have dependent code, update the template for the environment that needs updating and then redeploy the environment using the rollback workflow described above.
+When updating existing environment variable values or adding new variables that
+do not have dependent code, update the template for the environment that needs
+updating and then redeploy the environment using the rollback workflow described
+above.
## Future end-to-end test integration
-In the future we hope to integrate end-to-end tests into this workflow and to tighten the staging to production pipeline. Essentially, we would like the deployment pipeline to go something like this:
+In the future we hope to integrate end-to-end tests into this workflow and to
+tighten the staging to production pipeline. Essentially, we would like the
+deployment pipeline to go something like this:
1. Merge PR to `main`.
2. Wait for staging to deploy.
3. Playwright tests automatically run against the new staging environment.
-4. While Playwright tests are running, the person who merged the PR should manually verify that their change behaves as expected.
-5. After the Playwright tests are confirmed to have passed, unlock a "deploy to production" button somewhere that pushes the image currently deployed to staging into the production task definition.
-
-Following this process would mean that production gets deployed every time code is merged to `main`. It reduces the turn around for new features and bug fixes because they don't have to wait for a new release to be manually created.
-
-We could more or less follow the process as described today just by creating a new release every time we've merged to staging and verified our changes, but there are a couple missing pieces that would need to be implemented to make this process easy to follow, to varying degrees of difficulty:
-
-1. We need a GitHub workflow that runs the Playwright tests against the staging deployment automatically after staging is deployed. This will require some Playwright configuration tweaks and increased test timeouts due to network latency.
-2. We would need to create a queue so that new staging deployments do not occur until the current staging deployment is live on production. This could be implemented by polling the `/version.json` endpoints of both environments and only liberating a new staging deployment for new merges once the endpoints both report the same `release` property.
-3. We would need to update the production deployment workflow to not create a new Docker build and instead just pull the current tag from the staging `/version.json` endpoint.
-
-Note that this workflow does make the process of merging a PR heavier than it is today. This comes with some benefits:
-
-1. PRs will likely be more carefully tested as the consequence of merging them is higher and more immediately consequential.
+4. While Playwright tests are running, the person who merged the PR should
+ manually verify that their change behaves as expected.
+5. After the Playwright tests are confirmed to have passed, unlock a "deploy to
+ production" button somewhere that pushes the image currently deployed to
+ staging into the production task definition.
+
+Following this process would mean that production gets deployed every time code
+is merged to `main`. It reduces the turn around for new features and bug fixes
+because they don't have to wait for a new release to be manually created.
+
+We could more or less follow the process as described today just by creating a
+new release every time we've merged to staging and verified our changes, but
+there are a couple missing pieces that would need to be implemented to make this
+process easy to follow, to varying degrees of difficulty:
+
+1. We need a GitHub workflow that runs the Playwright tests against the staging
+ deployment automatically after staging is deployed. This will require some
+ Playwright configuration tweaks and increased test timeouts due to network
+ latency.
+2. We would need to create a queue so that new staging deployments do not occur
+ until the current staging deployment is live on production. This could be
+ implemented by polling the `/version.json` endpoints of both environments and
+ only liberating a new staging deployment for new merges once the endpoints
+ both report the same `release` property.
+3. We would need to update the production deployment workflow to not create a
+ new Docker build and instead just pull the current tag from the staging
+ `/version.json` endpoint.
+
+Note that this workflow does make the process of merging a PR heavier than it is
+today. This comes with some benefits:
+
+1. PRs will likely be more carefully tested as the consequence of merging them
+ is higher and more immediately consequential.
2. Bugs will be fixed in production more quickly.
-3. Features can be rolled out with more care using feature flags and likewise more quickly.
+3. Features can be rolled out with more care using feature flags and likewise
+ more quickly.
diff --git a/README.md b/README.md
index d6f9bf036..11a942f8f 100644
--- a/README.md
+++ b/README.md
@@ -8,19 +8,31 @@
![openverse-frontend-ci](https://github.com/wordpress/openverse-frontend/workflows/openverse-frontend-ci/badge.svg)
-This repository is the frontend UI for accessing and exploring the openly-licensed content provided by the [Openverse API](https://github.com/wordpress/openverse-api).
+This repository is the frontend UI for accessing and exploring the
+openly-licensed content provided by the
+[Openverse API](https://github.com/wordpress/openverse-api).
-You can view [the application](https://wordpress.org/openverse) live on WordPress.org.
+You can view [the application](https://wordpress.org/openverse) live on
+WordPress.org.
## Technology
-The frontend app is built using [Vue.js](https://vuejs.org/) and [Nuxt.js](https://nuxtjs.org).
+The frontend app is built using [Vue.js](https://vuejs.org/) and
+[Nuxt.js](https://nuxtjs.org).
## Local Development
-**Note for Windows users:** Please use [WSL](https://docs.microsoft.com/en-us/windows/wsl/install) for developing on the Openverse frontend. Several scripts, primarily support scripts, rely on a general \*nix type environment. Maintaining parity for cross platform scripts proved complicated without significant duplication. If you run into issues with running the Openverse frontend in WSL please let us know by opening an issue or [joining us on Slack](https://make.wordpress.org/chat/) in the `#openverse` room and ask for help.
+**Note for Windows users:** Please use
+[WSL](https://docs.microsoft.com/en-us/windows/wsl/install) for developing on
+the Openverse frontend. Several scripts, primarily support scripts, rely on a
+general \*nix type environment. Maintaining parity for cross platform scripts
+proved complicated without significant duplication. If you run into issues with
+running the Openverse frontend in WSL please let us know by opening an issue or
+[joining us on Slack](https://make.wordpress.org/chat/) in the `#openverse` room
+and ask for help.
-We use [Volta](https://volta.sh/) to manage our local environment tools. Please install it using the instructions on their website.
+We use [Volta](https://volta.sh/) to manage our local environment tools. Please
+install it using the instructions on their website.
Before installing pnpm, make sure to switch to node version 16 using Volta:
@@ -28,13 +40,16 @@ Before installing pnpm, make sure to switch to node version 16 using Volta:
volta install node@16
```
-Once you have volta installed, manually install `pnpm` using volta. [Volta does not currently officially support `pnpm`](https://github.com/volta-cli/volta/issues/737) so this is a stop gap solution until that support is implemented:
+Once you have volta installed, manually install `pnpm` using volta.
+[Volta does not currently officially support `pnpm`](https://github.com/volta-cli/volta/issues/737)
+so this is a stop gap solution until that support is implemented:
```bash
volta install pnpm
```
-Run the following commands in order to have the code up and running on your machine:
+Run the following commands in order to have the code up and running on your
+machine:
```bash
# Builds and serves assets with hot-reload
@@ -42,7 +57,9 @@ Run the following commands in order to have the code up and running on your mach
volta run pnpm dev
```
-If you intend to change any text in the app, you will need to edit `src/locales/scripts/en.json5`. To ensure your changes are reflected immediately, run the following command.
+If you intend to change any text in the app, you will need to edit
+`src/locales/scripts/en.json5`. To ensure your changes are reflected
+immediately, run the following command.
```bash
# Watches the en.json5 file and updates the en.json file for every change.
@@ -51,24 +68,34 @@ pnpm i18n:watch-en
### Using HTTPS Locally
-To enable SSL support in local development, use the `pnpm dev:secure` command. This requires you to have a private key and certificate in the root of the repository with the following names:
+To enable SSL support in local development, use the `pnpm dev:secure` command.
+This requires you to have a private key and certificate in the root of the
+repository with the following names:
```shell
localhost+1-key.pem # The private key file
localhost+1.pem # The certificate file
```
-The easiest way to create these files is with a local development tool called [mkcert](https://github.com/FiloSottile/mkcert). First make sure you have [mkcert installed](https://github.com/FiloSottile/mkcert#installation) and activated with `mkcert -install`. Then use `mkcert` to create a certificate for `localhost` and for the external IP address used by Nuxt's development process. That command looks like this:
+The easiest way to create these files is with a local development tool called
+[mkcert](https://github.com/FiloSottile/mkcert). First make sure you have
+[mkcert installed](https://github.com/FiloSottile/mkcert#installation) and
+activated with `mkcert -install`. Then use `mkcert` to create a certificate for
+`localhost` and for the external IP address used by Nuxt's development process.
+That command looks like this:
```shell
mkcert localhost 192.168.50.119
```
-Be sure to replace the IP address in the example with your own. See the next section for how to identify that IP address.
+Be sure to replace the IP address in the example with your own. See the next
+section for how to identify that IP address.
#### Finding your local IP address <a name = "finding-your-local-ip-address"></a>
-You can find the local IP address Nuxt uses by looking at the output of `nuxt dev`. Look in your console for a box of configuration details that looks like this:
+You can find the local IP address Nuxt uses by looking at the output of
+`nuxt dev`. Look in your console for a box of configuration details that looks
+like this:
```bash
# ╭───────────────────────────────────────────╮
@@ -84,11 +111,16 @@ You can find the local IP address Nuxt uses by looking at the output of `nuxt de
# ╰───────────────────────────────────────────╯
```
-You will need to regenerate the certificate if this IP address changes for any reason, like by enabling a VPN or changing networks.
+You will need to regenerate the certificate if this IP address changes for any
+reason, like by enabling a VPN or changing networks.
### Choosing which API to use
-You don't need to have the Openverse API running locally to be able to run the frontend application. It's configured to communicate, by default, with the [production API](https://api.openverse.engineering) that's already publicly available. If you need to test against changes in your local API, set the `API_URL` environment variable when run the development server.
+You don't need to have the Openverse API running locally to be able to run the
+frontend application. It's configured to communicate, by default, with the
+[production API](https://api.openverse.engineering) that's already publicly
+available. If you need to test against changes in your local API, set the
+`API_URL` environment variable when run the development server.
```shell
API_URL=http://localhost:8000 pnpm dev
@@ -96,16 +128,27 @@ API_URL=http://localhost:8000 pnpm dev
### Standalone and embedded modes
-The application can run in two modes. By default, it runs in embedded mode, which is loaded in an iframe on [WordPress.org/openverse](https://make.wordpress.org/openverse). It has a small header without logo and no footer.
-The standalone mode which has a large header with logo and a footer, can be enabled by adding `?embedded=false` query parameter to the URL. For example, when running locally, you can go to [http://localhost:8443?embedded=false](http://localhost:8443?embedded=false) to view the standalone application.
+The application can run in two modes. By default, it runs in embedded mode,
+which is loaded in an iframe on
+[WordPress.org/openverse](https://make.wordpress.org/openverse). It has a small
+header without logo and no footer. The standalone mode which has a large header
+with logo and a footer, can be enabled by adding `?embedded=false` query
+parameter to the URL. For example, when running locally, you can go to
+[http://localhost:8443?embedded=false](http://localhost:8443?embedded=false) to
+view the standalone application.
### Running tests
-Refer to the [`TESTING_GUIDELINES.md` file](./TESTING_GUIDELINES.md) for instructions on how to run tests.
+Refer to the [`TESTING_GUIDELINES.md` file](./TESTING_GUIDELINES.md) for
+instructions on how to run tests.
### localhost tunneling
-If you want to make your local development server accessible to the internet (for testing or showing someone something you're working on), you can use [`ngrok`](https://ngrok.com/). Follow the documentation on the `ngrok` site to install it and set it up. Once you have it installed, get the development server for Openverse running and in a separate window/tab, run:
+If you want to make your local development server accessible to the internet
+(for testing or showing someone something you're working on), you can use
+[`ngrok`](https://ngrok.com/). Follow the documentation on the `ngrok` site to
+install it and set it up. Once you have it installed, get the development server
+for Openverse running and in a separate window/tab, run:
```
# The extra parameters are required to ensure that ngrok redirects to the HTTPS version of the site
@@ -114,7 +157,10 @@ If you want to make your local development server accessible to the internet (fo
ngrok http http://localhost:8443 -host-header="localhost:8443"
```
-If you need to run an HTTP version (for example, if you're testing against third-party websites that do not accept the self-signed certificate generated by the dev server), run the dev server using `pnpm dev` and use the following command to start `ngrok`:
+If you need to run an HTTP version (for example, if you're testing against
+third-party websites that do not accept the self-signed certificate generated by
+the dev server), run the dev server using `pnpm dev` and use the following
+command to start `ngrok`:
```bash
ngrok http 8443 -host-header="localhost:8443"
@@ -122,29 +168,43 @@ ngrok http 8443 -host-header="localhost:8443"
## Frontend Components
-The frontend app is composed of a number of components that are documented in our [Storybook](https://wordpress.github.io/openverse-frontend).
+The frontend app is composed of a number of components that are documented in
+our [Storybook](https://wordpress.github.io/openverse-frontend).
### CSS Framework
-To design our components, we use the [TailwindCSS](https://tailwindcss.com/) utility-first CSS framework. We have compiled a list of TailwindCSS classes that are used in the frontend app. You can view the list [here](https://wordpress.github.io/openverse-frontend/tailwind/).
+To design our components, we use the [TailwindCSS](https://tailwindcss.com/)
+utility-first CSS framework. We have compiled a list of TailwindCSS classes that
+are used in the frontend app. You can view the list
+[here](https://wordpress.github.io/openverse-frontend/tailwind/).
### Development Tips
-If you use VS Code, you can install the [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) extension to get autocomplete for TailwindCSS classes.
+If you use VS Code, you can install the
+[Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)
+extension to get autocomplete for TailwindCSS classes.
## Docker and Openverse frontend
-We do not currently support local development using Docker or `docker-compose`. It was supported in the past, but it was not used by the core contributors. It remained broken for many months without ever being noticed, so the assumption is that it was also not being used active community members. Local `nuxt` development is still easy across platforms, so maintaining a separate Docker development stack for the frontend did not make sense.
+We do not currently support local development using Docker or `docker-compose`.
+It was supported in the past, but it was not used by the core contributors. It
+remained broken for many months without ever being noticed, so the assumption is
+that it was also not being used active community members. Local `nuxt`
+development is still easy across platforms, so maintaining a separate Docker
+development stack for the frontend did not make sense.
-However, we do build and actively deploy the frontend using Docker images. If you wish to build the production image for yourself, run the following:
+However, we do build and actively deploy the frontend using Docker images. If
+you wish to build the production image for yourself, run the following:
```shell
pnpm docker:build
```
-You can also find the latest `openverse-frontend` images on our [GitHub packages page](https://github.com/WordPress/openverse-frontend/pkgs/container/openverse-frontend).
+You can also find the latest `openverse-frontend` images on our
+[GitHub packages page](https://github.com/WordPress/openverse-frontend/pkgs/container/openverse-frontend).
-You can then run using either the locally built image or the `ghcr.io` image from the link above:
+You can then run using either the locally built image or the `ghcr.io` image
+from the link above:
```shell
pnpm docker:run
@@ -152,7 +212,8 @@ pnpm docker:run
The app will be available at <http://localhost:8443>.
-> **Note**: If you are _not_ using HTTPS locally, do not use the URL provided by Nuxt - this will cause certificate errors because it gets rerouted to HTTPS.
+> **Note**: If you are _not_ using HTTPS locally, do not use the URL provided by
+> Nuxt - this will cause certificate errors because it gets rerouted to HTTPS.
> E.g. this link will not work:
>
> ```
@@ -180,13 +241,23 @@ The app will be available at <http://localhost:8443>.
## Formatting and Linting
-The code in this repository is formatted using `prettier`. If you have prettier setup in your code editor it should work out of the box; otherwise you can use the `pnpm lint:fix` script to format and fix lint errors in your code. Checks are run to lint your code and validate the formatting on git precommit using [husky](https://github.com/typicode/husky).
+The code in this repository is formatted using `prettier`. If you have prettier
+setup in your code editor it should work out of the box; otherwise you can use
+the `pnpm lint:fix` script to format and fix lint errors in your code. Checks
+are run to lint your code and validate the formatting on git precommit using
+[husky](https://github.com/typicode/husky).
-You will need to fix any linting issues before committing. We recommend formatting your JavaScript files on save in your text editor. You can learn how to do this in Visual Studio Code [here](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode#format-on-save).
+You will need to fix any linting issues before committing. We recommend
+formatting your JavaScript files on save in your text editor. You can learn how
+to do this in Visual Studio Code
+[here](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode#format-on-save).
### File name conventions
-All files and folders should be written in `kebab-case`, with the exception of Vue single file components. If it ends in `.vue`, please use `PascalCase`. This distinction makes our component files stand out clearly and is [recommended by the Vue community](https://vuejs.org/v2/style-guide/#Single-file-component-filename-casing-strongly-recommended).
+All files and folders should be written in `kebab-case`, with the exception of
+Vue single file components. If it ends in `.vue`, please use `PascalCase`. This
+distinction makes our component files stand out clearly and is
+[recommended by the Vue community](https://vuejs.org/v2/style-guide/#Single-file-component-filename-casing-strongly-recommended).
## Redirects <a name = "redirects"></a>
@@ -196,14 +267,32 @@ All files and folders should be written in `kebab-case`, with the exception of V
## Just
-If [`just`](https://github.com/casey/just) is your preferred command runner, you can also use `just run {script}` to run any pnpm script and `just` on its own to list the available scripts (e.g. `just run docker:build`). Our other projects use `just` as their primary script runner, so this allows parity with both the API and the catalog.
+If [`just`](https://github.com/casey/just) is your preferred command runner, you
+can also use `just run {script}` to run any pnpm script and `just` on its own to
+list the available scripts (e.g. `just run docker:build`). Our other projects
+use `just` as their primary script runner, so this allows parity with both the
+API and the catalog.
## Contributing
-Pull requests are welcome! Feel free to [join us on Slack](https://make.wordpress.org/chat/) and discuss the project with the engineers and community members on #openverse.
+Pull requests are welcome! Feel free to
+[join us on Slack](https://make.wordpress.org/chat/) and discuss the project
+with the engineers and community members on #openverse.
-You are welcome to take any open issue in the tracker labeled [`help wanted`](https://github.com/wordpress/openverse-frontend/labels/help%20wanted) or [`good first issue`](https://github.com/wordpress/openverse-frontend/labels/good%20first%20issue); **there's no need to ask for permission in advance**. Other issues are open for contribution as well, but may be less accessible or well defined in comparison to those that are explicitly labeled.
+You are welcome to take any open issue in the tracker labeled
+[`help wanted`](https://github.com/wordpress/openverse-frontend/labels/help%20wanted)
+or
+[`good first issue`](https://github.com/wordpress/openverse-frontend/labels/good%20first%20issue);
+**there's no need to ask for permission in advance**. Other issues are open for
+contribution as well, but may be less accessible or well defined in comparison
+to those that are explicitly labeled.
## Acknowledgments
-Openverse, previously known as CC Search, was conceived and built at [Creative Commons](https://creativecommons.org). We thank them for their commitment to open source and openly licensed content, with particular thanks to previous team members @ryanmerkley, @janetpkr, @lizadaly, @sebworks, @pa-w, @kgodey, @annatuma, @mathemancer, @aldenstpage, @brenoferreira, and @sclachar, along with their [community of volunteers](https://opensource.creativecommons.org/community/community-team/).
+Openverse, previously known as CC Search, was conceived and built at
+[Creative Commons](https://creativecommons.org). We thank them for their
+commitment to open source and openly licensed content, with particular thanks to
+previous team members @ryanmerkley, @janetpkr, @lizadaly, @sebworks, @pa-w,
+@kgodey, @annatuma, @mathemancer, @aldenstpage, @brenoferreira, and @sclachar,
+along with their
+[community of volunteers](https://opensource.creativecommons.org/community/community-team/).
diff --git a/TESTING_GUIDELINES.md b/TESTING_GUIDELINES.md
index 3b282c2ba..e7bae6d5e 100644
--- a/TESTING_GUIDELINES.md
+++ b/TESTING_GUIDELINES.md
@@ -1,35 +1,63 @@
# Testing Guidelines
-This document describes general guidelines you should follow when testing pull requests in this repository. It is not exhaustive but should be the starting point that you adapt for each PR. You may also use your best judgement and skip things that are unrelated to a specific PR. However, please be careful when doing this as accessibility bugs _especially_ are easy to slip through the cracks when we aren't doing our due diligence and testing changes thoroughly.
+This document describes general guidelines you should follow when testing pull
+requests in this repository. It is not exhaustive but should be the starting
+point that you adapt for each PR. You may also use your best judgement and skip
+things that are unrelated to a specific PR. However, please be careful when
+doing this as accessibility bugs _especially_ are easy to slip through the
+cracks when we aren't doing our due diligence and testing changes thoroughly.
## Running the application
-Please follow the instructions in the README for how to set up and run the application locally. If you want to just generally test the application in its current state (i.e., what exists on `main` as opposed to what has actually been deployed to production) you can find the staging deployment here:
+Please follow the instructions in the README for how to set up and run the
+application locally. If you want to just generally test the application in its
+current state (i.e., what exists on `main` as opposed to what has actually been
+deployed to production) you can find the staging deployment here:
https://search-staging.openverse.engineering
-Staging is redeployed everytime we merge to the `main` branch, so if you're looking to test the latest version of the app without going through the local set up, that's the easiest way to go.
+Staging is redeployed everytime we merge to the `main` branch, so if you're
+looking to test the latest version of the app without going through the local
+set up, that's the easiest way to go.
-Once you have the application running, you can visit it in your browser at http://localhost:8443.
+Once you have the application running, you can visit it in your browser at
+http://localhost:8443.
-You can also access it from other devices in your same network (like a mobile phone) for additional testing. See the [finding your local IP address](./README.md#finding-your-local-ip-address) section of the README for how to identify the local IP adress Nuxt is served on. Once you have identified your local IP address, you can access the website running on your computer by visiting `https://<local IP>:8443` replacing `<local IP>` (including the brackets) with the value you found using the instructions above in your mobile device's browser.
+You can also access it from other devices in your same network (like a mobile
+phone) for additional testing. See the
+[finding your local IP address](./README.md#finding-your-local-ip-address)
+section of the README for how to identify the local IP adress Nuxt is served on.
+Once you have identified your local IP address, you can access the website
+running on your computer by visiting `https://<local IP>:8443` replacing
+`<local IP>` (including the brackets) with the value you found using the
+instructions above in your mobile device's browser.
-Testing from multiple different devices as often as possible is a great way to contribute to Openverse's frontend development.
+Testing from multiple different devices as often as possible is a great way to
+contribute to Openverse's frontend development.
### API Authentication
-By default, the application will run using the production API without authentication. This means your local frontend server may be subject to the unauthenticated rate limiting, depending on your testing behavior. There are two ways to solve this:
+By default, the application will run using the production API without
+authentication. This means your local frontend server may be subject to the
+unauthenticated rate limiting, depending on your testing behavior. There are two
+ways to solve this:
-1. You can change your local Nuxt server to point to a local API server that does not have throttling enabled
-2. You can introduce the environment variables necessary for authenticating with an API
+1. You can change your local Nuxt server to point to a local API server that
+ does not have throttling enabled
+2. You can introduce the environment variables necessary for authenticating with
+ an API
-For the first, [run the Openverse API locally](https://github.com/WordPress/openverse-api). Then create a `.env` file by copying the `.env.template` file and update it with the following:
+For the first,
+[run the Openverse API locally](https://github.com/WordPress/openverse-api).
+Then create a `.env` file by copying the `.env.template` file and update it with
+the following:
```shell
API_URL="http://localhost:8000/"
```
-Be sure to remove the leading `#` to uncomment the variable from the copied template.
+Be sure to remove the leading `#` to uncomment the variable from the copied
+template.
The run the dev server as usual:
@@ -37,16 +65,24 @@ The run the dev server as usual:
pnpm dev
```
-For the second, you'll need to follow [the instructions to set up an OAuth application](https://api.openverse.engineering/v1/#section/Register-and-Authenticate) and then fill in the `API_CLIENT_ID` and `API_CLIENT_SECRET` in the `.env` file copied from `.env.template`. Be sure to remove the leading `#` to uncomment these variables from the copied template.
+For the second, you'll need to follow
+[the instructions to set up an OAuth application](https://api.openverse.engineering/v1/#section/Register-and-Authenticate)
+and then fill in the `API_CLIENT_ID` and `API_CLIENT_SECRET` in the `.env` file
+copied from `.env.template`. Be sure to remove the leading `#` to uncomment
+these variables from the copied template.
```shell
API_CLIENT_ID=""
API_CLIENT_SECRET=""
```
-Then run the API as usual using `pnpm dev`. Nuxt automatically loads `.env` files into the environment. With these variables in the environment, all requests made by your server will be made using an access token retrieved by the `~/plugins/api-token.server.ts` plugin.
+Then run the API as usual using `pnpm dev`. Nuxt automatically loads `.env`
+files into the environment. With these variables in the environment, all
+requests made by your server will be made using an access token retrieved by the
+`~/plugins/api-token.server.ts` plugin.
-Once the `.env` file is set up, you may run the development build the typical way:
+Once the `.env` file is set up, you may run the development build the typical
+way:
```shell
pnpm build && pnpm start
@@ -54,62 +90,124 @@ pnpm build && pnpm start
## Browsers
-In addition to testing on multiple devices, we also strive to test on almost all widely used browsers excluding Internet Explorer. Please be ready to regularly test your work and the work of others in Firefox, Chrome, and Safari on a desktop computer. On mobile devices, Mobile Safari on iOS, Firefox for Android and Mobile Chrome on iOS are all important targets for testing as well. A significant amount of web traffic is mobile these days.
+In addition to testing on multiple devices, we also strive to test on almost all
+widely used browsers excluding Internet Explorer. Please be ready to regularly
+test your work and the work of others in Firefox, Chrome, and Safari on a
+desktop computer. On mobile devices, Mobile Safari on iOS, Firefox for Android
+and Mobile Chrome on iOS are all important targets for testing as well. A
+significant amount of web traffic is mobile these days.
## Accessibility
### Prerequisite reading
-Please review the [WordPress Accessibility Handbook](https://make.wordpress.org/accessibility/handbook/).
+Please review the
+[WordPress Accessibility Handbook](https://make.wordpress.org/accessibility/handbook/).
-The [WAI-ARIA](https://www.w3.org/TR/wai-aria/) spec. This document describes, in detail, all of the documented types of interactions that happen on most websites and the accessibility properties of them. Many of them also include examples.
+The [WAI-ARIA](https://www.w3.org/TR/wai-aria/) spec. This document describes,
+in detail, all of the documented types of interactions that happen on most
+websites and the accessibility properties of them. Many of them also include
+examples.
-Gutenberg also has an excellent [Accessibility Testing Guide](https://github.com/WordPress/gutenberg/blob/086b77ed409a70a6c6a6e74dee704851eff812f2/docs/contributors/accessibility-testing.md) with specific instructions for setting up screen readers for testing with.
+Gutenberg also has an excellent
+[Accessibility Testing Guide](https://github.com/WordPress/gutenberg/blob/086b77ed409a70a6c6a6e74dee704851eff812f2/docs/contributors/accessibility-testing.md)
+with specific instructions for setting up screen readers for testing with.
### General recommendations
-Practice using keyboard navigation when you run the app locally generally. This will reveal to you some of the initial hurdles that the app currently presents to users who rely on assistive technology. Note that keyboard accessibility is part of the bare-minimum in accessibility for a website along with accessible color contrasts.
-
-If you are a regular contributor, at least once a week, attempt to use the site using a screen reader like VoiceOver on macOS, NVDA on Windows, or Orca on Linux. If you do not regularly rely on a screen reader for navigating the web, it can also stretch your comfort level a lot by closing your eyes or turning off your monitor while navigating using the screen reader. Keep in mind that many people who rely on screen readers to navigate the web do not have any of the visual context that a sighted user is using to interpret a website. This especially applies to directionality and the _broad_ context of a page. Screen readers can't "see" what's at the "end" of the page unless the user navigates all the way there. Sighted users have a huge privilege in being able to take in the broader context of a website almost immediately through visual information.
+Practice using keyboard navigation when you run the app locally generally. This
+will reveal to you some of the initial hurdles that the app currently presents
+to users who rely on assistive technology. Note that keyboard accessibility is
+part of the bare-minimum in accessibility for a website along with accessible
+color contrasts.
+
+If you are a regular contributor, at least once a week, attempt to use the site
+using a screen reader like VoiceOver on macOS, NVDA on Windows, or Orca on
+Linux. If you do not regularly rely on a screen reader for navigating the web,
+it can also stretch your comfort level a lot by closing your eyes or turning off
+your monitor while navigating using the screen reader. Keep in mind that many
+people who rely on screen readers to navigate the web do not have any of the
+visual context that a sighted user is using to interpret a website. This
+especially applies to directionality and the _broad_ context of a page. Screen
+readers can't "see" what's at the "end" of the page unless the user navigates
+all the way there. Sighted users have a huge privilege in being able to take in
+the broader context of a website almost immediately through visual information.
## Specific things to test for
### Focus styles
-Buttons, form fields, and other interactive elements should all have visible and high contrast focus styles applied. Please note that hover styles are _not_ the same as focus styles and are often distinct. Note also that hover styles and focus styles may not always be applied at the same time. It is best to test the following scenarios:
+Buttons, form fields, and other interactive elements should all have visible and
+high contrast focus styles applied. Please note that hover styles are _not_ the
+same as focus styles and are often distinct. Note also that hover styles and
+focus styles may not always be applied at the same time. It is best to test the
+following scenarios:
1. Hover over the element, unfocused
2. Focus the element using the keyboard, no mouse hover
3. Focus the element using the keyboard and also hover over it with the mouse
-That will exhaust 95% of the interactions that visible focus styles need to cover.
+That will exhaust 95% of the interactions that visible focus styles need to
+cover.
### Interactiveness
-Buttons should be able to be activated using mouse click, <kbd>Enter</kbd> and <kbd>Space</kbd> keys. Links should be able to be activated using a mouse click and <kbd>Enter</kbd> but not <kbd>Space</kbd>.
+Buttons should be able to be activated using mouse click, <kbd>Enter</kbd> and
+<kbd>Space</kbd> keys. Links should be able to be activated using a mouse click
+and <kbd>Enter</kbd> but not <kbd>Space</kbd>.
-Arrow keys are common methods for navigating distinct UI elements, especially composite groups like field sets, radio groups, menus, and other [composite elements](https://www.w3.org/TR/wai-aria-1.1/#composite). Please test these interactions and compare them against the WAI-ARIA examples for the same UI components.
+Arrow keys are common methods for navigating distinct UI elements, especially
+composite groups like field sets, radio groups, menus, and other
+[composite elements](https://www.w3.org/TR/wai-aria-1.1/#composite). Please test
+these interactions and compare them against the WAI-ARIA examples for the same
+UI components.
### Screen reader intelligibility
-When testing a new piece of UI, please test it thoroughly with a screen reader paying close attention to what the screen reader is saying, in particular how it is describing parts of the page.
+When testing a new piece of UI, please test it thoroughly with a screen reader
+paying close attention to what the screen reader is saying, in particular how it
+is describing parts of the page.
-Buttons, for example, should have appropriate labels. If the visible text of the button relies on some wider visual context to be intelligible, ensure that it has an appropriate `aria-label` that a screen reader can use to give more information about the button.
+Buttons, for example, should have appropriate labels. If the visible text of the
+button relies on some wider visual context to be intelligible, ensure that it
+has an appropriate `aria-label` that a screen reader can use to give more
+information about the button.
### Server vs client side render
-The Openverse frontend is a Nuxt SSR application. This means the initial Vue page rendering when you make a request is processed by a server and then delivered to you to be "hydrated" with the current state of the page. The implication of this is that there are two ways for _every single page_ to be rendered, and we should test with that in mind. Please make sure that you are testing client side navigation as well as SSR. To test SSR for a page, simply reload the page: it will be rendered in SSR and then delivered to your browser. To test client side rendering for a page, navigate to that page from another page without reloading the page in between. For example, to test the search route client side, you can execute a search from the homepage and it will redirect you client-side to the search page.
+The Openverse frontend is a Nuxt SSR application. This means the initial Vue
+page rendering when you make a request is processed by a server and then
+delivered to you to be "hydrated" with the current state of the page. The
+implication of this is that there are two ways for _every single page_ to be
+rendered, and we should test with that in mind. Please make sure that you are
+testing client side navigation as well as SSR. To test SSR for a page, simply
+reload the page: it will be rendered in SSR and then delivered to your browser.
+To test client side rendering for a page, navigate to that page from another
+page without reloading the page in between. For example, to test the search
+route client side, you can execute a search from the homepage and it will
+redirect you client-side to the search page.
## Conclusion
-Please note that these are non-expert and non-exhaustive recommendations. Spend time reading the [WAI-ARIA spec](https://www.w3.org/TR/wai-aria/) and other web accessibility materials. Even just knowing about specific roles and interactions that exist and are meant to be developed in consistent ways is a good first step to learning what to look out for when testing.
+Please note that these are non-expert and non-exhaustive recommendations. Spend
+time reading the [WAI-ARIA spec](https://www.w3.org/TR/wai-aria/) and other web
+accessibility materials. Even just knowing about specific roles and interactions
+that exist and are meant to be developed in consistent ways is a good first step
+to learning what to look out for when testing.
# Automated tests
-Openverse uses [Vue Testing Library](https://testing-library.com/docs/vue-testing-library/intro/) for unit testing with [Jest](https://jestjs.io/docs/), and [Playwright](https://playwright.dev) for end-to-end and visual-regression testing.
+Openverse uses
+[Vue Testing Library](https://testing-library.com/docs/vue-testing-library/intro/)
+for unit testing with [Jest](https://jestjs.io/docs/), and
+[Playwright](https://playwright.dev) for end-to-end and visual-regression
+testing.
-There are also legacy unit tests written in [Vue Test Utils](https://vue-test-utils.vuejs.org/) but those are slated to be re-written using testing library.
+There are also legacy unit tests written in
+[Vue Test Utils](https://vue-test-utils.vuejs.org/) but those are slated to be
+re-written using testing library.
### Playwright tests
-Please see the [Playwright test README.md](./test/playwright/README.md) for instructions on running and maintaining the Playwright test suite.
+Please see the [Playwright test README.md](./test/playwright/README.md) for
+instructions on running and maintaining the Playwright test suite.
diff --git a/jest.config.js b/jest.config.js
index f151e97d6..0ba41b100 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,33 +1,33 @@
module.exports = {
globals: {
- 'vue-jest': {
+ "vue-jest": {
experimentalCSSCompile: false,
},
},
- moduleFileExtensions: ['ts', 'js', 'vue', 'json'],
+ moduleFileExtensions: ["ts", "js", "vue", "json"],
moduleNameMapper: {
- '^@/(.*)$': '<rootDir>/src/$1',
- '^~/(.*.svg)\\?inline$': '<rootDir>/src/$1',
- '^~/(.*)$': '<rootDir>/src/$1',
- '^~~/(.*)$': '<rootDir>/$1',
- '^vue$': 'vue/dist/vue.common.js',
- '(.*svg)(\\?inline)$': '<rootDir>/test/unit/test-utils/svgTransform.js',
+ "^@/(.*)$": "<rootDir>/src/$1",
+ "^~/(.*.svg)\\?inline$": "<rootDir>/src/$1",
+ "^~/(.*)$": "<rootDir>/src/$1",
+ "^~~/(.*)$": "<rootDir>/$1",
+ "^vue$": "vue/dist/vue.common.js",
+ "(.*svg)(\\?inline)$": "<rootDir>/test/unit/test-utils/svgTransform.js",
},
- setupFiles: ['<rootDir>/test/unit/setup.js'],
- setupFilesAfterEnv: ['<rootDir>/test/unit/setup-after-env.js'],
+ setupFiles: ["<rootDir>/test/unit/setup.js"],
+ setupFilesAfterEnv: ["<rootDir>/test/unit/setup-after-env.js"],
transform: {
- '^.+\\.(j|t)s$': 'babel-jest',
- '.*\\.(vue)$': 'vue-jest',
- '.+\\.(css|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
- '^.+\\.svg$': '<rootDir>/test/unit/svg-transform.js',
+ "^.+\\.(j|t)s$": "babel-jest",
+ ".*\\.(vue)$": "vue-jest",
+ ".+\\.(css|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
+ "^.+\\.svg$": "<rootDir>/test/unit/svg-transform.js",
},
- testPathIgnorePatterns: ['/playwright/', '/storybook/'],
+ testPathIgnorePatterns: ["/playwright/", "/storybook/"],
collectCoverage: true,
- coverageDirectory: '<rootDir>/test/unit/coverage',
+ coverageDirectory: "<rootDir>/test/unit/coverage",
collectCoverageFrom: [
- '<rootDir>/src/**/*.vue',
- '<rootDir>/src/**/*.js',
- '<rootDir>/src/**/*.ts',
- '!<rootDir>/src/**/*.stories.js',
+ "<rootDir>/src/**/*.vue",
+ "<rootDir>/src/**/*.js",
+ "<rootDir>/src/**/*.ts",
+ "!<rootDir>/src/**/*.stories.js",
],
}
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 94ef39c0b..98e5716fd 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -1,22 +1,22 @@
-import path from 'path'
-import fs from 'fs'
+import path from "path"
+import fs from "fs"
-import promBundle from 'express-prom-bundle'
+import promBundle from "express-prom-bundle"
-import pkg from './package.json'
-import locales from './src/locales/scripts/valid-locales.json'
+import pkg from "./package.json"
+import locales from "./src/locales/scripts/valid-locales.json"
-import { searchTypes } from './src/constants/media'
-import { VIEWPORTS } from './src/constants/screens'
+import { searchTypes } from "./src/constants/media"
+import { VIEWPORTS } from "./src/constants/screens"
-import { isProd } from './src/utils/node-env'
-import { sentryConfig } from './src/utils/sentry-config'
-import { env } from './src/utils/env'
+import { isProd } from "./src/utils/node-env"
+import { sentryConfig } from "./src/utils/sentry-config"
+import { env } from "./src/utils/env"
-import type { NuxtConfig, ServerMiddleware } from '@nuxt/types'
-import type { LocaleObject } from '@nuxtjs/i18n'
-import type { IncomingMessage, NextFunction } from 'connect'
-import type http from 'http'
+import type { NuxtConfig, ServerMiddleware } from "@nuxt/types"
+import type { LocaleObject } from "@nuxtjs/i18n"
+import type { IncomingMessage, NextFunction } from "connect"
+import type http from "http"
/**
* The default metadata for the site. Can be extended and/or overwritten per page. And even in components!
@@ -24,156 +24,156 @@ import type http from 'http'
* {@link https://nuxtjs.org/guides/features/meta-tags-seo} Nuxt.js Docs
*/
const meta = [
- { charset: 'utf-8' },
+ { charset: "utf-8" },
{
- name: 'viewport',
- content: 'width=device-width,initial-scale=1',
+ name: "viewport",
+ content: "width=device-width,initial-scale=1",
},
// By default, tell all robots not to index pages. Will be overridden in the
// search, content and home pages.
- { hid: 'robots', name: 'robots', content: 'noindex' },
+ { hid: "robots", name: "robots", content: "noindex" },
// Tell Googlebot to crawl Openverse when iframed
// TODO: remove after the iframe is removed
- { hid: 'googlebot', name: 'googlebot', content: 'indexifembedded' },
+ { hid: "googlebot", name: "googlebot", content: "indexifembedded" },
{
- vmid: 'monetization',
- name: 'monetization',
- content: '$ilp.uphold.com/edR8erBDbRyq',
+ vmid: "monetization",
+ name: "monetization",
+ content: "$ilp.uphold.com/edR8erBDbRyq",
},
{
- hid: 'theme-color',
- name: 'theme-color',
- content: '#ffffff',
+ hid: "theme-color",
+ name: "theme-color",
+ content: "#ffffff",
},
{
- name: 'description',
+ name: "description",
content:
- 'Search over 600 million free and openly licensed images, photos, audio, and other media types for reuse and remixing.',
+ "Search over 600 million free and openly licensed images, photos, audio, and other media types for reuse and remixing.",
},
- { hid: 'og:title', name: 'og:title', content: 'Openverse' },
+ { hid: "og:title", name: "og:title", content: "Openverse" },
{
- hid: 'og:image',
- name: 'og:image',
- content: '/openverse-default.jpg',
+ hid: "og:image",
+ name: "og:image",
+ content: "/openverse-default.jpg",
},
{
- hid: 'og:description',
- name: 'og:description',
+ hid: "og:description",
+ name: "og:description",
content:
- 'Search over 600 million free and openly licensed images, photos, audio, and other media types for reuse and remixing.',
+ "Search over 600 million free and openly licensed images, photos, audio, and other media types for reuse and remixing.",
},
- { name: 'twitter:card', content: 'summary_large_image' },
- { name: 'twitter:site', content: '@WPOpenverse' },
+ { name: "twitter:card", content: "summary_large_image" },
+ { name: "twitter:site", content: "@WPOpenverse" },
]
-if (process.env.NODE_ENV === 'production') {
+if (process.env.NODE_ENV === "production") {
meta.push({
// @ts-expect-error: 'http-equiv' isn't allowed here by Nuxt
- 'http-equiv': 'Content-Security-Policy',
- content: 'upgrade-insecure-requests',
+ "http-equiv": "Content-Security-Policy",
+ content: "upgrade-insecure-requests",
})
}
const favicons = [
// SVG favicon
{
- rel: 'icon',
- href: '/openverse-logo.svg',
+ rel: "icon",
+ href: "/openverse-logo.svg",
},
// SVG favicon for Safari
{
- rel: 'mask-icon',
- href: '/opvenverse-logo.svg',
- color: '#30272E',
+ rel: "mask-icon",
+ href: "/opvenverse-logo.svg",
+ color: "#30272E",
},
// Fallback iPhone Icon
{
- rel: 'apple-touch-icon',
- href: '/openverse-logo-180.png',
+ rel: "apple-touch-icon",
+ href: "/openverse-logo-180.png",
},
]
// Default html head
const head = {
- title: 'Openly Licensed Images, Audio and More | Openverse',
+ title: "Openly Licensed Images, Audio and More | Openverse",
meta,
link: [
...favicons,
{
- rel: 'preconnect',
+ rel: "preconnect",
href: env.apiUrl,
- crossorigin: '',
+ crossorigin: "",
},
{
- rel: 'dns-prefetch',
+ rel: "dns-prefetch",
href: env.apiUrl,
},
{
- rel: 'search',
- type: 'application/opensearchdescription+xml',
- title: 'Openverse',
- href: '/opensearch.xml',
+ rel: "search",
+ type: "application/opensearchdescription+xml",
+ title: "Openverse",
+ href: "/opensearch.xml",
},
],
}
-const baseProdName = process.env.CI ? '[name]' : '[contenthash:7]'
+const baseProdName = process.env.CI ? "[name]" : "[contenthash:7]"
-const filenames: NonNullable<NuxtConfig['build']>['filenames'] = {
+const filenames: NonNullable<NuxtConfig["build"]>["filenames"] = {
app: ({ isDev, isModern }) =>
isDev
- ? `[name]${isModern ? '.modern' : ''}.js`
- : `${baseProdName}${isModern ? '.modern' : ''}.js`,
+ ? `[name]${isModern ? ".modern" : ""}.js`
+ : `${baseProdName}${isModern ? ".modern" : ""}.js`,
chunk: ({ isDev, isModern }) =>
isDev
- ? `[name]${isModern ? '.modern' : ''}.js`
- : `${baseProdName}${isModern ? '.modern' : ''}.js`,
- css: ({ isDev }) => (isDev ? '[name].css' : `css/${baseProdName}.css`),
+ ? `[name]${isModern ? ".modern" : ""}.js`
+ : `${baseProdName}${isModern ? ".modern" : ""}.js`,
+ css: ({ isDev }) => (isDev ? "[name].css" : `css/${baseProdName}.css`),
img: ({ isDev }) =>
- isDev ? '[path][name].[ext]' : `img/${baseProdName}.[ext]`,
+ isDev ? "[path][name].[ext]" : `img/${baseProdName}.[ext]`,
font: ({ isDev }) =>
- isDev ? '[path][name].[ext]' : `fonts/${baseProdName}.[ext]`,
+ isDev ? "[path][name].[ext]" : `fonts/${baseProdName}.[ext]`,
video: ({ isDev }) =>
- isDev ? '[path][name].[ext]' : `videos/${baseProdName}.[ext]`,
+ isDev ? "[path][name].[ext]" : `videos/${baseProdName}.[ext]`,
}
const config: NuxtConfig = {
// eslint-disable-next-line no-undef
version: pkg.version, // used to purge cache :)
cache: {
- pages: ['/'],
+ pages: ["/"],
store: {
- type: 'memory', // 'redis' would be nice
+ type: "memory", // 'redis' would be nice
max: 100,
ttl: process.env.MICROCACHE_DURATION || 60,
},
},
- srcDir: 'src/',
- modern: 'client',
+ srcDir: "src/",
+ modern: "client",
server: {
port: process.env.PORT || 8443,
https: process.env.LOCAL_SSL
? {
- key: fs.readFileSync(path.resolve(__dirname, 'localhost+1-key.pem')),
- cert: fs.readFileSync(path.resolve(__dirname, 'localhost+1.pem')),
+ key: fs.readFileSync(path.resolve(__dirname, "localhost+1-key.pem")),
+ cert: fs.readFileSync(path.resolve(__dirname, "localhost+1.pem")),
}
: undefined,
},
router: {
- middleware: 'middleware',
+ middleware: "middleware",
},
components: [
- { path: '~/components', extensions: ['vue'], pathPrefix: false },
+ { path: "~/components", extensions: ["vue"], pathPrefix: false },
],
plugins: [
- '~/plugins/url-change.ts',
- '~/plugins/migration-notice.ts',
- '~/plugins/ua-parse.ts',
- '~/plugins/focus-visible.client.ts',
- '~/plugins/api-token.server.ts',
- '~/plugins/sentry.ts',
+ "~/plugins/url-change.ts",
+ "~/plugins/migration-notice.ts",
+ "~/plugins/ua-parse.ts",
+ "~/plugins/focus-visible.client.ts",
+ "~/plugins/api-token.server.ts",
+ "~/plugins/sentry.ts",
],
- css: ['~/assets/fonts.css', '~/styles/tailwind.css', '~/styles/accent.css'],
+ css: ["~/assets/fonts.css", "~/styles/tailwind.css", "~/styles/accent.css"],
head,
env, // TODO: Replace with `publicRuntimeConfig`
privateRuntimeConfig: {
@@ -182,43 +182,43 @@ const config: NuxtConfig = {
},
dev: !isProd,
buildModules: [
- '@nuxt/typescript-build',
- '@nuxtjs/composition-api/module',
- '@nuxt/postcss8',
- '@nuxtjs/style-resources',
- '@nuxtjs/svg',
- '@nuxtjs/eslint-module',
- '@pinia/nuxt',
+ "@nuxt/typescript-build",
+ "@nuxtjs/composition-api/module",
+ "@nuxt/postcss8",
+ "@nuxtjs/style-resources",
+ "@nuxtjs/svg",
+ "@nuxtjs/eslint-module",
+ "@pinia/nuxt",
],
modules: [
- 'portal-vue/nuxt',
- '@nuxtjs/i18n',
- '@nuxtjs/redirect-module',
- '@nuxtjs/sentry',
- '@nuxtjs/sitemap',
- 'cookie-universal-nuxt',
+ "portal-vue/nuxt",
+ "@nuxtjs/i18n",
+ "@nuxtjs/redirect-module",
+ "@nuxtjs/sentry",
+ "@nuxtjs/sitemap",
+ "cookie-universal-nuxt",
],
serverMiddleware: [
- { path: '/healthcheck', handler: '~/server-middleware/healthcheck.js' },
+ { path: "/healthcheck", handler: "~/server-middleware/healthcheck.js" },
],
i18n: {
locales: [
{
// unique identifier for the locale in Vue i18n
- code: 'en',
- name: 'English',
- nativeName: 'English',
+ code: "en",
+ name: "English",
+ nativeName: "English",
// ISO code used for SEO purposes (html lang attribute)
- iso: 'en',
+ iso: "en",
// wp_locale as found in GlotPress
- wpLocale: 'en_US',
- file: 'en.json',
+ wpLocale: "en_US",
+ file: "en.json",
},
...(locales ?? []),
].filter((l) => Boolean(l.iso)) as LocaleObject[],
lazy: true,
- langDir: 'locales',
- defaultLocale: 'en',
+ langDir: "locales",
+ defaultLocale: "en",
/**
* `detectBrowserLanguage` must be false to prevent nuxt/i18n from automatically
* setting the locale based on headers or the client-side `navigator` object.
@@ -231,7 +231,7 @@ const config: NuxtConfig = {
* - [Browser language detection info](https://i18n.nuxtjs.org/browser-language-detection)
* */
detectBrowserLanguage: false,
- vueI18n: '~/plugins/vue-i18n',
+ vueI18n: "~/plugins/vue-i18n",
},
/**
* Map the old route for /photos/_id page to /image/_id permanently to keep links working.
@@ -240,9 +240,9 @@ const config: NuxtConfig = {
*/
redirect: {
rules: [
- { from: '^/photos/(.*)$', to: '/image/$1', statusCode: 301 },
- { from: '/meta-search', to: '/about', statusCode: 301 },
- { from: '/external-sources', to: '/about', statusCode: 301 },
+ { from: "^/photos/(.*)$", to: "/image/$1", statusCode: 301 },
+ { from: "/meta-search", to: "/about", statusCode: 301 },
+ { from: "/external-sources", to: "/about", statusCode: 301 },
],
// If the URL cannot be decoded, we call next() to show the client-side error page.
onDecodeError: (
@@ -267,20 +267,20 @@ const config: NuxtConfig = {
* need to debug metrics locally, comment out the early return in development.
*/
setupMiddleware: (app) => {
- if (process.env.NODE_ENV === 'development') return
+ if (process.env.NODE_ENV === "development") return
const bypassMetricsPathParts = [
/**
* Exclude static paths. Remove once we've moved static file
* hosting out of the SSR server's responsibilities.
*/
- '_nuxt',
+ "_nuxt",
/**
* Only include these paths in development. They do not exist in production
* so we can happily skip the extra iterations these path parts introduce.
*/
- ...(process.env.NODE_ENV === 'development'
- ? ['__webpack', 'sse']
+ ...(process.env.NODE_ENV === "development"
+ ? ["__webpack", "sse"]
: []),
]
/**
@@ -327,12 +327,12 @@ const config: NuxtConfig = {
build: {
templates: [
{
- src: './nuxt-template-overrides/App.js',
- dst: 'App.js',
+ src: "./nuxt-template-overrides/App.js",
+ dst: "App.js",
},
{
- src: './nuxt-template-overrides/index.js',
- dst: 'index.js',
+ src: "./nuxt-template-overrides/index.js",
+ dst: "index.js",
},
],
filenames,
@@ -341,27 +341,27 @@ const config: NuxtConfig = {
plugins: {
tailwindcss: {},
autoprefixer: {},
- 'postcss-focus-visible': {},
+ "postcss-focus-visible": {},
},
},
extend(config, ctx) {
// Enables use of IDE debuggers
- config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map'
+ config.devtool = ctx.isClient ? "source-map" : "inline-source-map"
// Mitigates import errors for Pinia
config.module?.rules.push({
test: /\.mjs$/,
include: /node_modules/,
- type: 'javascript/auto',
+ type: "javascript/auto",
})
},
},
storybook: {
port: 6006, // standard port for Storybook
- stories: ['~/**/*.stories.@(mdx|js)'],
+ stories: ["~/**/*.stories.@(mdx|js)"],
addons: [
{
- name: '@storybook/addon-essentials',
+ name: "@storybook/addon-essentials",
options: {
backgrounds: false,
viewport: true,
@@ -372,7 +372,7 @@ const config: NuxtConfig = {
parameters: {
options: {
storySort: {
- order: ['Introduction', ['Openverse UI']],
+ order: ["Introduction", ["Openverse UI"]],
},
},
viewport: {
diff --git a/prettier.config.js b/prettier.config.js
index 6b28007e9..1ee977803 100644
--- a/prettier.config.js
+++ b/prettier.config.js
@@ -4,19 +4,20 @@
// - https://github.com/WordPress/openverse/blob/main/prettier.config.frontend.js.jinja
module.exports = {
- trailingComma: 'es5',
+ trailingComma: "es5",
tabWidth: 2,
semi: false,
- singleQuote: true,
+ singleQuote: false,
+ proseWrap: "always",
overrides: [
{
- files: '*.yml',
+ files: "*.yml",
options: {
- singleQuote: false,
+ proseWrap: "preserve",
},
},
],
vueIndentScriptAndStyle: false,
- plugins: [require('prettier-plugin-tailwindcss')],
- tailwindConfig: 'tailwind.config.js',
+ plugins: [require("prettier-plugin-tailwindcss")],
+ tailwindConfig: "tailwind.config.js",
}
diff --git a/src/assets/fonts.css b/src/assets/fonts.css
index 4958fa268..87f0df3d0 100644
--- a/src/assets/fonts.css
+++ b/src/assets/fonts.css
@@ -1,19 +1,19 @@
/* Variable Fonts */
@supports (font-variation-settings: normal) {
@font-face {
- font-family: 'Inter';
+ font-family: "Inter";
font-style: normal;
font-weight: 100 900;
font-display: swap;
- src: url('~assets/fonts/Inter-Roman.var.woff2') format('woff2');
+ src: url("~assets/fonts/Inter-Roman.var.woff2") format("woff2");
}
@font-face {
- font-family: 'Inter';
+ font-family: "Inter";
font-style: italic;
font-weight: 100 900;
font-display: swap;
- src: url('~assets/fonts/Inter-Italic.var.woff2') format('woff2');
+ src: url("~assets/fonts/Inter-Italic.var.woff2") format("woff2");
}
}
@@ -24,9 +24,9 @@
font-family: Inter;
font-style: normal;
font-weight: 400;
- src: local('Inter-Regular'), local('Inter Regular'),
- url('~assets/fonts/Inter-Regular.woff2') format('woff2'),
- url('~assets/fonts/Inter-Regular.woff') format('woff');
+ src: local("Inter-Regular"), local("Inter Regular"),
+ url("~assets/fonts/Inter-Regular.woff2") format("woff2"),
+ url("~assets/fonts/Inter-Regular.woff") format("woff");
}
@font-face {
@@ -34,9 +34,9 @@
font-family: Inter;
font-style: italic;
font-weight: 100 900;
- src: local('Inter-Italic'), local('Inter Italic'),
- url('~assets/fonts/Inter-Italic.woff2') format('woff2'),
- url('~assets/fonts/Inter-Italic.woff') format('woff');
+ src: local("Inter-Italic"), local("Inter Italic"),
+ url("~assets/fonts/Inter-Italic.woff2") format("woff2"),
+ url("~assets/fonts/Inter-Italic.woff") format("woff");
}
@font-face {
@@ -44,9 +44,9 @@
font-family: Inter;
font-style: normal;
font-weight: 600;
- src: local('Inter-SemiBold'), local('Inter SemiBold'),
- url('~assets/fonts/Inter-SemiBold.woff2') format('woff2'),
- url('~assets/fonts/Inter-SemiBold.woff') format('woff');
+ src: local("Inter-SemiBold"), local("Inter SemiBold"),
+ url("~assets/fonts/Inter-SemiBold.woff2") format("woff2"),
+ url("~assets/fonts/Inter-SemiBold.woff") format("woff");
}
@font-face {
@@ -54,9 +54,9 @@
font-family: Inter;
font-style: italic;
font-weight: 600;
- src: local('Inter-SemiBoldItalic'), local('Inter SemiBoldItalic'),
- url('~assets/fonts/Inter-SemiBoldItalic.woff2') format('woff2'),
- url('~assets/fonts/Inter-SemiBoldItalic.woff') format('woff');
+ src: local("Inter-SemiBoldItalic"), local("Inter SemiBoldItalic"),
+ url("~assets/fonts/Inter-SemiBoldItalic.woff2") format("woff2"),
+ url("~assets/fonts/Inter-SemiBoldItalic.woff") format("woff");
}
@font-face {
@@ -64,9 +64,9 @@
font-family: Inter;
font-style: normal;
font-weight: 700;
- src: local('Inter-Bold'), local('Inter Bold'),
- url('~assets/fonts/Inter-Bold.woff2') format('woff2'),
- url('~assets/fonts/Inter-Bold.woff') format('woff');
+ src: local("Inter-Bold"), local("Inter Bold"),
+ url("~assets/fonts/Inter-Bold.woff2") format("woff2"),
+ url("~assets/fonts/Inter-Bold.woff") format("woff");
}
@font-face {
@@ -74,29 +74,29 @@
font-family: Inter;
font-style: italic;
font-weight: 700;
- src: local('Inter-BoldItalic'), local('Inter BoldItalic'),
- url('~assets/fonts/Inter-BoldItalic.woff2') format('woff2'),
- url('~assets/fonts/Inter-BoldItalic.woff') format('woff');
+ src: local("Inter-BoldItalic"), local("Inter BoldItalic"),
+ url("~assets/fonts/Inter-BoldItalic.woff2") format("woff2"),
+ url("~assets/fonts/Inter-BoldItalic.woff") format("woff");
}
}
@font-face {
- font-family: 'JetBrains Mono';
+ font-family: "JetBrains Mono";
font-style: normal;
font-weight: 400;
font-display: swap;
- src: local('JetBrainsMono-Regular'), local('JetBrains Mono Regular'),
- url('~assets/fonts/JetBrainsMono-Regular.woff2') format('woff2'),
- url('~assets/fonts/JetBrainsMono-Regular.woff') format('woff'),
- url('~assets/fonts/JetBrainsMono-Regular.otf') format('opentype');
+ src: local("JetBrainsMono-Regular"), local("JetBrains Mono Regular"),
+ url("~assets/fonts/JetBrainsMono-Regular.woff2") format("woff2"),
+ url("~assets/fonts/JetBrainsMono-Regular.woff") format("woff"),
+ url("~assets/fonts/JetBrainsMono-Regular.otf") format("opentype");
}
@font-face {
- font-family: 'JetBrains Mono';
+ font-family: "JetBrains Mono";
font-style: normal;
font-weight: 600;
font-display: swap;
- src: local('JetBrainsMono-Bold'), local('JetBrains Mono Bold'),
- url('~assets/fonts/JetBrainsMono-Bold.woff2') format('woff2'),
- url('~assets/fonts/JetBrainsMono-Bold.woff') format('woff'),
- url('~assets/fonts/JetBrainsMono-Bold.otf') format('opentype');
+ src: local("JetBrainsMono-Bold"), local("JetBrains Mono Bold"),
+ url("~assets/fonts/JetBrainsMono-Bold.woff2") format("woff2"),
+ url("~assets/fonts/JetBrainsMono-Bold.woff") format("woff"),
+ url("~assets/fonts/JetBrainsMono-Bold.otf") format("opentype");
}
diff --git a/src/components/.eslintrc.js b/src/components/.eslintrc.js
index c6ce3c271..a3cb577fd 100644
--- a/src/components/.eslintrc.js
+++ b/src/components/.eslintrc.js
@@ -1,12 +1,12 @@
module.exports = {
- extends: '../../.eslintrc.js',
+ extends: "../../.eslintrc.js",
rules: {
- 'unicorn/filename-case': [
- 'error',
+ "unicorn/filename-case": [
+ "error",
// Allow things like `Component.stories.js` and `Component.types.js`
{
- case: 'pascalCase',
- ignore: ['.eslintrc.js', '.*\\..*\\.js'],
+ case: "pascalCase",
+ ignore: [".eslintrc.js", ".*\\..*\\.js"],
},
],
},
diff --git a/src/components/LoadingIcon.vue b/src/components/LoadingIcon.vue
index 0abf4a824..18515c43e 100644
--- a/src/components/LoadingIcon.vue
+++ b/src/components/LoadingIcon.vue
@@ -9,7 +9,7 @@
<script>
export default {
- name: 'LoadingIcon',
+ name: "LoadingIcon",
}
</script>
diff --git a/src/components/TableSortIcon.vue b/src/components/TableSortIcon.vue
index cce5dbb74..1778873d4 100644
--- a/src/components/TableSortIcon.vue
+++ b/src/components/TableSortIcon.vue
@@ -25,10 +25,10 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
export default defineComponent({
- name: 'TableSortIcon',
+ name: "TableSortIcon",
props: {
active: {
type: Boolean,
diff --git a/src/components/VAllResultsGrid/VAllResultsGrid.vue b/src/components/VAllResultsGrid/VAllResultsGrid.vue
index beb13b413..f5a631ccf 100644
--- a/src/components/VAllResultsGrid/VAllResultsGrid.vue
+++ b/src/components/VAllResultsGrid/VAllResultsGrid.vue
@@ -50,25 +50,25 @@
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { useMediaStore } from '~/stores/media'
-import { useFocusFilters } from '~/composables/use-focus-filters'
-import { Focus } from '~/utils/focus-management'
+import { useMediaStore } from "~/stores/media"
+import { useFocusFilters } from "~/composables/use-focus-filters"
+import { Focus } from "~/utils/focus-management"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import VSnackbar from '~/components/VSnackbar.vue'
-import VImageCellSquare from '~/components/VAllResultsGrid/VImageCellSquare.vue'
-import VAudioCell from '~/components/VAllResultsGrid/VAudioCell.vue'
-import VLoadMore from '~/components/VLoadMore.vue'
-import VContentLink from '~/components/VContentLink/VContentLink.vue'
-import VGridSkeleton from '~/components/VSkeleton/VGridSkeleton.vue'
+import VSnackbar from "~/components/VSnackbar.vue"
+import VImageCellSquare from "~/components/VAllResultsGrid/VImageCellSquare.vue"
+import VAudioCell from "~/components/VAllResultsGrid/VAudioCell.vue"
+import VLoadMore from "~/components/VLoadMore.vue"
+import VContentLink from "~/components/VContentLink/VContentLink.vue"
+import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue"
export default defineComponent({
- name: 'VAllResultsGrid',
+ name: "VAllResultsGrid",
components: {
VSnackbar,
VImageCellSquare,
@@ -95,8 +95,8 @@ export default defineComponent({
const fetchState = computed(() => mediaStore.fetchState)
const errorHeader = computed(() => {
- const type = i18n.t('browse-page.search-form.audio')
- return i18n.t('browse-page.fetching-error', { type })
+ const type = i18n.t("browse-page.search-form.audio")
+ return i18n.t("browse-page.fetching-error", { type })
})
const resultCounts = computed(() => mediaStore.resultCountsPerMediaType)
diff --git a/src/components/VAllResultsGrid/VAudioCell.vue b/src/components/VAllResultsGrid/VAudioCell.vue
index 9dcc39558..6bdb5d3b4 100644
--- a/src/components/VAllResultsGrid/VAudioCell.vue
+++ b/src/components/VAllResultsGrid/VAudioCell.vue
@@ -3,11 +3,11 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { AudioDetail } from '~/types/media'
+import type { AudioDetail } from "~/types/media"
-import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
+import VAudioTrack from "~/components/VAudioTrack/VAudioTrack.vue"
export default defineComponent({
components: { VAudioTrack },
diff --git a/src/components/VAllResultsGrid/VImageCellSquare.vue b/src/components/VAllResultsGrid/VImageCellSquare.vue
index f0279963a..482b37089 100644
--- a/src/components/VAllResultsGrid/VImageCellSquare.vue
+++ b/src/components/VAllResultsGrid/VImageCellSquare.vue
@@ -33,24 +33,24 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { ImageDetail } from '~/types/media'
+import type { ImageDetail } from "~/types/media"
-import VLink from '~/components/VLink.vue'
-import VLicense from '~/components/VLicense/VLicense.vue'
+import VLink from "~/components/VLink.vue"
+import VLicense from "~/components/VLicense/VLicense.vue"
-import errorImage from '~/assets/image_not_available_placeholder.png'
+import errorImage from "~/assets/image_not_available_placeholder.png"
-const toAbsolutePath = (url: string, prefix = 'https://') => {
- if (url.indexOf('http://') >= 0 || url.indexOf('https://') >= 0) {
+const toAbsolutePath = (url: string, prefix = "https://") => {
+ if (url.indexOf("http://") >= 0 || url.indexOf("https://") >= 0) {
return url
}
return `${prefix}${url}`
}
export default defineComponent({
- name: 'VImageCell',
+ name: "VImageCell",
components: { VLink, VLicense },
props: {
image: {
@@ -60,7 +60,7 @@ export default defineComponent({
},
setup(props) {
const getImageUrl = () => {
- if (!props.image) return ''
+ if (!props.image) return ""
const url = props.image.thumbnail || props.image.url
return toAbsolutePath(url)
}
diff --git a/src/components/VAudioDetails/VAudioDetails.vue b/src/components/VAudioDetails/VAudioDetails.vue
index c960ec3af..a4cfe1dc0 100644
--- a/src/components/VAudioDetails/VAudioDetails.vue
+++ b/src/components/VAudioDetails/VAudioDetails.vue
@@ -2,7 +2,7 @@
<section class="audio-info">
<header class="mb-6 flex flex-row items-center justify-between">
<h2 class="heading-6 md:heading-5">
- {{ $t('audio-details.information') }}
+ {{ $t("audio-details.information") }}
</h2>
<VContentReportPopover :media="audio" />
</header>
@@ -24,7 +24,7 @@
</ul>
<dl v-if="audio">
<div v-if="audio.audio_set">
- <dt>{{ $t('audio-details.table.album') }}</dt>
+ <dt>{{ $t("audio-details.table.album") }}</dt>
<dd>
<VLink :href="audio.audio_set.foreign_landing_url">{{
audio.audio_set.title
@@ -32,14 +32,14 @@
</dd>
</div>
<div v-if="audio.category">
- <dt>{{ $t('audio-details.table.category') }}</dt>
+ <dt>{{ $t("audio-details.table.category") }}</dt>
<dd>
{{ $t(`filters.audio-categories.${audio.category}`) }}
</dd>
</div>
<div v-if="audio.sample_rate">
<dt>
- {{ $t('audio-details.table.sample-rate') }}
+ {{ $t("audio-details.table.sample-rate") }}
</dt>
<dd>
{{ audio.sample_rate }}
@@ -47,7 +47,7 @@
</div>
<div v-if="audio.filetype">
<dt>
- {{ $t('audio-details.table.filetype') }}
+ {{ $t("audio-details.table.filetype") }}
</dt>
<dd>
{{ audioFormats.toUpperCase() }}
@@ -55,7 +55,7 @@
</div>
<div>
<dt>
- {{ $t('audio-details.table.provider') }}
+ {{ $t("audio-details.table.provider") }}
</dt>
<dd>
<VLink :href="audio.foreign_landing_url">
@@ -65,7 +65,7 @@
</div>
<div v-if="audio.source && audio.sourceName !== audio.providerName">
<dt>
- {{ $t('audio-details.table.source') }}
+ {{ $t("audio-details.table.source") }}
</dt>
<dd>
{{ audio.sourceName }}
@@ -73,10 +73,10 @@
</div>
<div v-if="audio.genres && audio.genres.length > 0">
<dt>
- {{ $t('audio-details.table.genre') }}
+ {{ $t("audio-details.table.genre") }}
</dt>
<dd>
- {{ audio.genres.join(', ') }}
+ {{ audio.genres.join(", ") }}
</dd>
</div>
</dl>
@@ -86,17 +86,17 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { AudioDetail } from '~/types/media'
+import type { AudioDetail } from "~/types/media"
-import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'
-import VContentReportPopover from '~/components/VContentReport/VContentReportPopover.vue'
-import VLink from '~/components/VLink.vue'
-import VMediaTag from '~/components/VMediaTag/VMediaTag.vue'
+import VAudioThumbnail from "~/components/VAudioThumbnail/VAudioThumbnail.vue"
+import VContentReportPopover from "~/components/VContentReport/VContentReportPopover.vue"
+import VLink from "~/components/VLink.vue"
+import VMediaTag from "~/components/VMediaTag/VMediaTag.vue"
export default defineComponent({
- name: 'VAudioDetails',
+ name: "VAudioDetails",
components: { VAudioThumbnail, VContentReportPopover, VLink, VMediaTag },
props: {
audio: {
@@ -112,7 +112,7 @@ export default defineComponent({
)
altFormats.unshift(props.audio.filetype)
const uniqueFormats = new Set(altFormats)
- return [...uniqueFormats].join(', ')
+ return [...uniqueFormats].join(", ")
})
return { audioFormats }
diff --git a/src/components/VAudioDetails/VRelatedAudio.vue b/src/components/VAudioDetails/VRelatedAudio.vue
index 23570e639..0ddb96879 100644
--- a/src/components/VAudioDetails/VRelatedAudio.vue
+++ b/src/components/VAudioDetails/VRelatedAudio.vue
@@ -1,7 +1,7 @@
<template>
<aside :aria-label="$t('audio-details.related-audios')">
<h2 class="heading-6 lg:heading-6 mb-6">
- {{ $t('audio-details.related-audios') }}
+ {{ $t("audio-details.related-audios") }}
</h2>
<!-- Negative margin compensates for the `p-4` padding in row layout. -->
<div
@@ -18,24 +18,24 @@
<LoadingIcon v-show="fetchState.isFetching" />
</div>
<p v-show="!!fetchState.fetchingError">
- {{ $t('media-details.related-error') }}
+ {{ $t("media-details.related-error") }}
</p>
</aside>
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import type { FetchState } from '~/models/fetch-state'
-import type { AudioDetail } from '~/models/media'
+import type { FetchState } from "~/models/fetch-state"
+import type { AudioDetail } from "~/models/media"
-import LoadingIcon from '~/components/LoadingIcon.vue'
-import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
+import LoadingIcon from "~/components/LoadingIcon.vue"
+import VAudioTrack from "~/components/VAudioTrack/VAudioTrack.vue"
export default defineComponent({
- name: 'VRelatedAudio',
+ name: "VRelatedAudio",
components: { VAudioTrack, LoadingIcon },
props: {
media: {
@@ -51,7 +51,7 @@ export default defineComponent({
const uiStore = useUiStore()
const audioTrackSize = computed(() => {
- return uiStore.isBreakpoint('md') ? 'l' : 's'
+ return uiStore.isBreakpoint("md") ? "l" : "s"
})
return { audioTrackSize }
diff --git a/src/components/VAudioThumbnail/VAudioThumbnail.vue b/src/components/VAudioThumbnail/VAudioThumbnail.vue
index 2e6df162a..ece92bdf7 100644
--- a/src/components/VAudioThumbnail/VAudioThumbnail.vue
+++ b/src/components/VAudioThumbnail/VAudioThumbnail.vue
@@ -33,18 +33,18 @@ import {
onMounted,
defineComponent,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { rand, hash } from '~/utils/prng'
-import { lerp, dist, bezier, Point } from '~/utils/math'
-import type { AudioDetail } from '~/types/media'
-import { useI18n } from '~/composables/use-i18n'
+import { rand, hash } from "~/utils/prng"
+import { lerp, dist, bezier, Point } from "~/utils/math"
+import type { AudioDetail } from "~/types/media"
+import { useI18n } from "~/composables/use-i18n"
/**
* Displays the cover art for the audio in a square aspect ratio.
*/
export default defineComponent({
- name: 'VAudioThumbnail',
+ name: "VAudioThumbnail",
props: {
/**
* the details of the audio whose artwork is to be shown; The properties
@@ -58,7 +58,7 @@ export default defineComponent({
setup(props) {
const i18n = useI18n()
const helpText = i18n
- .t('audio-thumbnail.alt', {
+ .t("audio-thumbnail.alt", {
title: props.audio.title,
creator: props.audio.creator,
})
@@ -82,7 +82,7 @@ export default defineComponent({
const minRadius = 2
const maxRadius = 27
- const random = rand(hash(props.audio.title ?? ''))
+ const random = rand(hash(props.audio.title ?? ""))
const ctrlPts = Array.from(
{ length: 4 },
(_, idx) => [random() * canvasSize, (idx / 3) * canvasSize] as Point
diff --git a/src/components/VAudioThumbnail/meta/VAudioThumbnail.stories.mdx b/src/components/VAudioThumbnail/meta/VAudioThumbnail.stories.mdx
index d55e31c72..a1efba776 100644
--- a/src/components/VAudioThumbnail/meta/VAudioThumbnail.stories.mdx
+++ b/src/components/VAudioThumbnail/meta/VAudioThumbnail.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'
+import VAudioThumbnail from "~/components/VAudioThumbnail/VAudioThumbnail.vue"
<Meta title="Components/VAudioThumbnail" components={VAudioThumbnail} />
@@ -46,7 +46,7 @@ non-square, it will be cropped from the periphery.
<img
src="https://upload.wikimedia.org/wikipedia/commons/c/c6/500_x_500_SMPTE_Color_Bars.png"
- style={{ width: '120px' }}
+ style={{ width: "120px" }}
/>
<Canvas>
@@ -54,10 +54,10 @@ non-square, it will be cropped from the periphery.
name="Square"
args={{
audio: {
- title: 'SMPTE Color Bars',
- creator: 'Guy Macon',
+ title: "SMPTE Color Bars",
+ creator: "Guy Macon",
thumbnail:
- 'https://upload.wikimedia.org/wikipedia/commons/c/c6/500_x_500_SMPTE_Color_Bars.png',
+ "https://upload.wikimedia.org/wikipedia/commons/c/c6/500_x_500_SMPTE_Color_Bars.png",
},
}}
>
@@ -74,7 +74,7 @@ non-square, it will be cropped from the periphery.
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Cat_November_2010-1a.jpg/359px-Cat_November_2010-1a.jpg"
- style={{ width: '120px' }}
+ style={{ width: "120px" }}
/>
<Canvas>
@@ -82,10 +82,10 @@ non-square, it will be cropped from the periphery.
name="Portrait"
args={{
audio: {
- title: 'Cat November 2010-1a',
- creator: 'Alvesgaspar',
+ title: "Cat November 2010-1a",
+ creator: "Alvesgaspar",
thumbnail:
- 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Cat_November_2010-1a.jpg/359px-Cat_November_2010-1a.jpg',
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Cat_November_2010-1a.jpg/359px-Cat_November_2010-1a.jpg",
},
}}
>
@@ -95,14 +95,14 @@ non-square, it will be cropped from the periphery.
### Landscape
-**Sample image:** "Six weeks old cat (aka)" by
-André Karwath aka [Aka](https://commons.wikimedia.org/wiki/User:Aka)
+**Sample image:** "Six weeks old cat (aka)" by André Karwath aka
+[Aka](https://commons.wikimedia.org/wiki/User:Aka)
([Creative Commons](https://en.wikipedia.org/wiki/en:Creative_Commons)
[Attribution-Share Alike 2.5 Generic](https://creativecommons.org/licenses/by-sa/2.5/deed.en))
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Six_weeks_old_cat_(aka).jpg/320px-Six_weeks_old_cat_(aka).jpg"
- style={{ height: '120px' }}
+ style={{ height: "120px" }}
/>
<Canvas>
@@ -110,10 +110,10 @@ André Karwath aka [Aka](https://commons.wikimedia.org/wiki/User:Aka)
name="Landscape"
args={{
audio: {
- title: 'Six weeks old cat (aka)',
- creator: 'André Karwath aka Aka',
+ title: "Six weeks old cat (aka)",
+ creator: "André Karwath aka Aka",
thumbnail:
- 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Six_weeks_old_cat_(aka).jpg/320px-Six_weeks_old_cat_(aka).jpg',
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Six_weeks_old_cat_(aka).jpg/320px-Six_weeks_old_cat_(aka).jpg",
},
}}
>
@@ -130,8 +130,8 @@ In the absence of album art, a randomised artwork is generated.
name="Fallback"
args={{
audio: {
- title: 'Null',
- creator: 'Undefined',
+ title: "Null",
+ creator: "Undefined",
},
}}
>
diff --git a/src/components/VAudioTrack/VAudioTrack.vue b/src/components/VAudioTrack/VAudioTrack.vue
index c6309401a..6c68c84d8 100644
--- a/src/components/VAudioTrack/VAudioTrack.vue
+++ b/src/components/VAudioTrack/VAudioTrack.vue
@@ -53,44 +53,44 @@ import {
useContext,
useRoute,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useActiveAudio } from '~/composables/use-active-audio'
-import { defaultRef } from '~/composables/default-ref'
-import { useI18n } from '~/composables/use-i18n'
+import { useActiveAudio } from "~/composables/use-active-audio"
+import { defaultRef } from "~/composables/default-ref"
+import { useI18n } from "~/composables/use-i18n"
-import { useActiveMediaStore } from '~/stores/active-media'
-import { useMediaStore } from '~/stores/media'
+import { useActiveMediaStore } from "~/stores/active-media"
+import { useMediaStore } from "~/stores/media"
-import { AUDIO } from '~/constants/media'
+import { AUDIO } from "~/constants/media"
-import type { AudioDetail } from '~/types/media'
+import type { AudioDetail } from "~/types/media"
import {
AudioLayout,
AudioSize,
AudioStatus,
activeAudioStatus,
layoutMappings,
-} from '~/constants/audio'
-import { useSeekable } from '~/composables/use-seekable'
+} from "~/constants/audio"
+import { useSeekable } from "~/composables/use-seekable"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import VPlayPause from '~/components/VAudioTrack/VPlayPause.vue'
-import VWaveform from '~/components/VAudioTrack/VWaveform.vue'
-import VFullLayout from '~/components/VAudioTrack/layouts/VFullLayout.vue'
-import VRowLayout from '~/components/VAudioTrack/layouts/VRowLayout.vue'
-import VBoxLayout from '~/components/VAudioTrack/layouts/VBoxLayout.vue'
-import VGlobalLayout from '~/components/VAudioTrack/layouts/VGlobalLayout.vue'
-import VLink from '~/components/VLink.vue'
-import VWarningSuppressor from '~/components/VWarningSuppressor.vue'
+import VPlayPause from "~/components/VAudioTrack/VPlayPause.vue"
+import VWaveform from "~/components/VAudioTrack/VWaveform.vue"
+import VFullLayout from "~/components/VAudioTrack/layouts/VFullLayout.vue"
+import VRowLayout from "~/components/VAudioTrack/layouts/VRowLayout.vue"
+import VBoxLayout from "~/components/VAudioTrack/layouts/VBoxLayout.vue"
+import VGlobalLayout from "~/components/VAudioTrack/layouts/VGlobalLayout.vue"
+import VLink from "~/components/VLink.vue"
+import VWarningSuppressor from "~/components/VWarningSuppressor.vue"
/**
* Displays the waveform and basic information about the track, along with
* controls to play, pause or seek to a point on the track.
*/
export default defineComponent({
- name: 'VAudioTrack',
+ name: "VAudioTrack",
components: {
VPlayPause,
VWaveform,
@@ -117,7 +117,7 @@ export default defineComponent({
*/
layout: {
type: String as PropType<AudioLayout>,
- default: 'full',
+ default: "full",
},
/**
* the size of the component; Both 'box' and 'row' layouts offer multiple
@@ -128,7 +128,7 @@ export default defineComponent({
},
},
emits: {
- 'shift-tab': defineEvent<[KeyboardEvent]>(),
+ "shift-tab": defineEvent<[KeyboardEvent]>(),
interacted: defineEvent<[]>(),
},
setup(props, { emit }) {
@@ -140,7 +140,7 @@ export default defineComponent({
const activeAudio = useActiveAudio()
- const status = ref<AudioStatus>('paused')
+ const status = ref<AudioStatus>("paused")
const currentTime = ref(0)
const initLocalAudio = () => {
@@ -218,38 +218,38 @@ export default defineComponent({
const mediaStore = useMediaStore()
const setLoaded = () => {
- mediaStore.setMediaProperties('audio', props.audio.id, {
+ mediaStore.setMediaProperties("audio", props.audio.id, {
hasLoaded: true,
})
- status.value = 'playing'
+ status.value = "playing"
}
const setWaiting = () => {
- status.value = 'loading'
+ status.value = "loading"
}
const setPlaying = () => {
if (props.audio.hasLoaded) {
- status.value = 'playing'
+ status.value = "playing"
} else {
- status.value = 'loading'
+ status.value = "loading"
}
activeAudio.obj.value = localAudio
activeMediaStore.setActiveMediaItem({
- type: 'audio',
+ type: "audio",
id: props.audio.id,
})
updateTimeLoop()
}
const setPaused = () => {
- status.value = 'paused'
+ status.value = "paused"
activeMediaStore.pauseActiveMediaItem()
}
- const setPlayed = () => (status.value = 'played')
+ const setPlayed = () => (status.value = "played")
const setTimeWhenPaused = () => {
- if (status.value !== 'playing' && localAudio) {
+ if (status.value !== "playing" && localAudio) {
currentTime.value = localAudio.currentTime
- if (status.value === 'played') {
+ if (status.value === "played") {
// Set to pause to remove replay icon
- status.value = 'paused'
+ status.value = "paused"
}
}
}
@@ -257,7 +257,7 @@ export default defineComponent({
if (localAudio) {
return localAudio.duration
}
- if (typeof props.audio?.duration === 'number')
+ if (typeof props.audio?.duration === "number")
return props.audio.duration / 1e3
return 0
})
@@ -329,16 +329,16 @@ export default defineComponent({
// Check if the audio can be played successfully
localAudio?.play().catch((err) => {
- let errorMsg = ''
+ let errorMsg = ""
switch (err.name) {
- case 'NotAllowedError':
- errorMsg = 'err_unallowed'
+ case "NotAllowedError":
+ errorMsg = "err_unallowed"
break
- case 'NotSupportedError':
- errorMsg = 'err_unsupported'
+ case "NotSupportedError":
+ errorMsg = "err_unsupported"
break
default:
- errorMsg = 'err_unknown'
+ errorMsg = "err_unknown"
$sentry.captureException(err)
}
errorMsg = i18n.t(`audio-track.messages.${errorMsg}`).toString()
@@ -353,7 +353,7 @@ export default defineComponent({
(audio) => {
if (
audio !== localAudio &&
- (status.value === 'playing' || status.value === 'loading')
+ (status.value === "playing" || status.value === "loading")
) {
localAudio?.pause()
}
@@ -371,28 +371,28 @@ export default defineComponent({
* This function can safely ignore the `loading` status because
* that status is never toggled _to_.
*/
- const handleToggle = (state?: 'playing' | 'paused' | 'played') => {
+ const handleToggle = (state?: "playing" | "paused" | "played") => {
if (!state) {
switch (status.value) {
- case 'playing':
- state = 'paused'
+ case "playing":
+ state = "paused"
break
- case 'paused':
- case 'played':
- state = 'playing'
+ case "paused":
+ case "played":
+ state = "playing"
break
}
}
switch (state) {
- case 'playing':
+ case "playing":
play()
break
- case 'paused':
+ case "paused":
pause()
break
}
- emit('interacted')
+ emit("interacted")
}
/* Interface with VWaveform */
@@ -409,7 +409,7 @@ export default defineComponent({
if (localAudio) {
localAudio.currentTime = frac * duration.value
}
- emit('interacted')
+ emit("interacted")
}
/* Layout */
@@ -419,10 +419,10 @@ export default defineComponent({
* Sets default size if not provided.
*/
const layoutSize = computed(() => {
- if (props.layout === 'box' && !props.size) {
+ if (props.layout === "box" && !props.size) {
return undefined
}
- return props.size ?? 'm'
+ return props.size ?? "m"
})
/**
@@ -437,18 +437,18 @@ export default defineComponent({
* to set properties on the parent element depending on
* the layout in use.
*/
- const isComposite = computed(() => ['box', 'row'].includes(props.layout))
+ const isComposite = computed(() => ["box", "row"].includes(props.layout))
const layoutBasedProps = computed(() =>
isComposite.value
? {
href: `/audio/${props.audio.id}`,
class: [
- 'cursor-pointer',
+ "cursor-pointer",
{
- 'focus:ring-offset-[3px] focus:ring-[3px]':
- props.layout === 'box',
- 'focus:ring-offset-0 focus:ring-[1.5px]':
- props.layout === 'row',
+ "focus:ring-offset-[3px] focus:ring-[3px]":
+ props.layout === "box",
+ "focus:ring-offset-0 focus:ring-[1.5px]":
+ props.layout === "row",
},
],
}
@@ -456,16 +456,16 @@ export default defineComponent({
)
const ariaLabel = computed(() =>
isComposite.value
- ? i18n.t('audio-track.aria-label-interactive', {
+ ? i18n.t("audio-track.aria-label-interactive", {
title: props.audio.title,
})
- : i18n.t('audio-track.aria-label', { title: props.audio.title })
+ : i18n.t("audio-track.aria-label", { title: props.audio.title })
)
const togglePlayback = () => {
status.value = activeAudioStatus.includes(status.value)
- ? 'paused'
- : 'playing'
+ ? "paused"
+ : "playing"
handleToggle(status.value)
}
@@ -477,7 +477,7 @@ export default defineComponent({
onTogglePlayback: togglePlayback,
})
const handleKeydown = (event: KeyboardEvent) => {
- if (seekable.willBeHandled(event)) emit('interacted')
+ if (seekable.willBeHandled(event)) emit("interacted")
seekable.listeners.keydown(event)
}
diff --git a/src/components/VAudioTrack/VGlobalAudioTrack.vue b/src/components/VAudioTrack/VGlobalAudioTrack.vue
index f4b172006..d05d5e07e 100644
--- a/src/components/VAudioTrack/VGlobalAudioTrack.vue
+++ b/src/components/VAudioTrack/VGlobalAudioTrack.vue
@@ -32,28 +32,28 @@ import {
PropType,
ref,
watch,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useActiveAudio } from '~/composables/use-active-audio'
-import { defaultRef } from '~/composables/default-ref'
-import { useI18n } from '~/composables/use-i18n'
+import { useActiveAudio } from "~/composables/use-active-audio"
+import { defaultRef } from "~/composables/default-ref"
+import { useI18n } from "~/composables/use-i18n"
-import { useActiveMediaStore } from '~/stores/active-media'
-import { useMediaStore } from '~/stores/media'
+import { useActiveMediaStore } from "~/stores/active-media"
+import { useMediaStore } from "~/stores/media"
-import type { AudioDetail } from '~/types/media'
-import type { AudioStatus } from '~/constants/audio'
+import type { AudioDetail } from "~/types/media"
+import type { AudioStatus } from "~/constants/audio"
-import VPlayPause from '~/components/VAudioTrack/VPlayPause.vue'
-import VWaveform from '~/components/VAudioTrack/VWaveform.vue'
-import VGlobalLayout from '~/components/VAudioTrack/layouts/VGlobalLayout.vue'
+import VPlayPause from "~/components/VAudioTrack/VPlayPause.vue"
+import VWaveform from "~/components/VAudioTrack/VWaveform.vue"
+import VGlobalLayout from "~/components/VAudioTrack/layouts/VGlobalLayout.vue"
/**
* Displays the waveform and basic information about the track, along with
* controls to play, pause or seek to a point on the track.
*/
export default defineComponent({
- name: 'VGlobalAudioTrack',
+ name: "VGlobalAudioTrack",
components: {
VPlayPause,
VWaveform,
@@ -74,34 +74,34 @@ export default defineComponent({
const activeAudio = useActiveAudio()
const ariaLabel = computed(() =>
- i18n.t('audio-track.aria-label', { title: props.audio.title }).toString()
+ i18n.t("audio-track.aria-label", { title: props.audio.title }).toString()
)
- const status = ref<AudioStatus>('paused')
+ const status = ref<AudioStatus>("paused")
const currentTime = ref(0)
const duration = defaultRef(() => {
- if (typeof props.audio?.duration === 'number')
+ if (typeof props.audio?.duration === "number")
return props.audio.duration / 1e3
return 0
})
const setPlaying = () => {
if (props.audio.hasLoaded) {
- status.value = 'playing'
+ status.value = "playing"
} else {
- status.value = 'loading'
+ status.value = "loading"
}
updateTimeLoop()
}
- const setPaused = () => (status.value = 'paused')
- const setPlayed = () => (status.value = 'played')
+ const setPaused = () => (status.value = "paused")
+ const setPlayed = () => (status.value = "played")
const setTimeWhenPaused = (event: Event) => {
- if (status.value !== 'playing' && event.target) {
+ if (status.value !== "playing" && event.target) {
currentTime.value = (event.target as HTMLAudioElement).currentTime ?? 0
- if (status.value === 'played') {
+ if (status.value === "played") {
// Set to pause to remove replay icon
- status.value = 'paused'
+ status.value = "paused"
}
}
}
@@ -112,7 +112,7 @@ export default defineComponent({
const updateTimeLoop = () => {
if (
activeAudio.obj.value &&
- (status.value === 'playing' || status.value === 'loading')
+ (status.value === "playing" || status.value === "loading")
) {
currentTime.value = activeAudio.obj.value.currentTime
window.requestAnimationFrame(updateTimeLoop)
@@ -121,13 +121,13 @@ export default defineComponent({
const mediaStore = useMediaStore()
const setLoaded = () => {
- mediaStore.setMediaProperties('audio', props.audio.id, {
+ mediaStore.setMediaProperties("audio", props.audio.id, {
hasLoaded: true,
})
- status.value = 'playing'
+ status.value = "playing"
}
const setWaiting = () => {
- status.value = 'loading'
+ status.value = "loading"
}
const eventMap = {
@@ -198,24 +198,24 @@ export default defineComponent({
/* Interface with VPlayPause */
- const handleToggle = (state?: 'playing' | 'paused') => {
+ const handleToggle = (state?: "playing" | "paused") => {
if (!state) {
switch (status.value) {
- case 'playing':
- state = 'paused'
+ case "playing":
+ state = "paused"
break
- case 'paused':
- case 'played':
- state = 'playing'
+ case "paused":
+ case "played":
+ state = "playing"
break
}
}
switch (state) {
- case 'playing':
+ case "playing":
play()
break
- case 'paused':
+ case "paused":
pause()
break
}
diff --git a/src/components/VAudioTrack/VPlayPause.vue b/src/components/VAudioTrack/VPlayPause.vue
index e6584c370..2a7b979c1 100644
--- a/src/components/VAudioTrack/VPlayPause.vue
+++ b/src/components/VAudioTrack/VPlayPause.vue
@@ -30,17 +30,17 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { AudioLayout, AudioStatus, statusVerbMap } from '~/constants/audio'
-import { defineEvent } from '~/types/emits'
-import type { ButtonConnections, ButtonVariant } from '~/types/button'
+import { AudioLayout, AudioStatus, statusVerbMap } from "~/constants/audio"
+import { defineEvent } from "~/types/emits"
+import type { ButtonConnections, ButtonVariant } from "~/types/button"
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
-import playIcon from '~/assets/icons/play.svg'
-import pauseIcon from '~/assets/icons/pause.svg'
-import replayIcon from '~/assets/icons/replay.svg'
+import playIcon from "~/assets/icons/play.svg"
+import pauseIcon from "~/assets/icons/pause.svg"
+import replayIcon from "~/assets/icons/replay.svg"
const statusIconMap = {
playing: pauseIcon,
@@ -50,10 +50,10 @@ const statusIconMap = {
} as const
const layoutConnectionsMap: Record<AudioLayout, ButtonConnections> = {
- row: 'end',
- global: 'all',
- box: 'none',
- full: 'none',
+ row: "end",
+ global: "all",
+ box: "none",
+ full: "none",
} as const
/**
@@ -61,12 +61,12 @@ const layoutConnectionsMap: Record<AudioLayout, ButtonConnections> = {
* a media file.
*/
export default defineComponent({
- name: 'VPlayPause',
+ name: "VPlayPause",
components: { VIconButton },
inheritAttrs: false,
model: {
- prop: 'status',
- event: 'toggle',
+ prop: "status",
+ event: "toggle",
},
props: {
/**
@@ -81,7 +81,7 @@ export default defineComponent({
*/
layout: {
type: String as PropType<AudioLayout>,
- default: 'full',
+ default: "full",
},
/**
* whether the play-pause button can be focused by using the `Tab` key
@@ -92,11 +92,11 @@ export default defineComponent({
},
},
emits: {
- toggle: defineEvent<['paused' | 'playing']>(),
+ toggle: defineEvent<["paused" | "playing"]>(),
},
setup(props, { emit }) {
- const isPlaying = computed(() => props.status === 'playing')
- const isLoading = computed(() => props.status === 'loading')
+ const isPlaying = computed(() => props.status === "playing")
+ const isLoading = computed(() => props.status === "loading")
/**
* Get the button label based on the current status of the player.
*/
@@ -111,7 +111,7 @@ export default defineComponent({
* Sets the connections (none-rounded corners) for the button based on the layout.
*/
const buttonProps = computed(() => {
- const variant = 'plain--avoid' as ButtonVariant
+ const variant = "plain--avoid" as ButtonVariant
return { variant, connections: layoutConnectionsMap[props.layout] }
})
@@ -120,7 +120,7 @@ export default defineComponent({
if (!props.isTabbable) event.preventDefault() // to prevent focus
}
const handleClick = () => {
- emit('toggle', isPlaying.value || isLoading.value ? 'paused' : 'playing')
+ emit("toggle", isPlaying.value || isLoading.value ? "paused" : "playing")
}
return {
label,
diff --git a/src/components/VAudioTrack/VWaveform.vue b/src/components/VAudioTrack/VWaveform.vue
index 9f1303675..b2f011414 100644
--- a/src/components/VAudioTrack/VWaveform.vue
+++ b/src/components/VAudioTrack/VWaveform.vue
@@ -151,21 +151,21 @@ import {
PropType,
ref,
toRef,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { downsampleArray, upsampleArray } from '~/utils/resampling'
-import { timeFmt } from '~/utils/time-fmt'
-import { useSeekable } from '~/composables/use-seekable'
+import { downsampleArray, upsampleArray } from "~/utils/resampling"
+import { timeFmt } from "~/utils/time-fmt"
+import { useSeekable } from "~/composables/use-seekable"
-import type { AudioFeature } from '~/constants/audio'
+import type { AudioFeature } from "~/constants/audio"
-import useResizeObserver from '~/composables/use-resize-observer'
+import useResizeObserver from "~/composables/use-resize-observer"
-import { hash, rand as prng } from '~/utils/prng'
+import { hash, rand as prng } from "~/utils/prng"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import type { CSSProperties } from '@vue/runtime-dom'
+import type { CSSProperties } from "@vue/runtime-dom"
/**
* If the duration is above this threshold, the progress timestamp will show ms.
@@ -177,7 +177,7 @@ const MAX_SECONDS_FOR_MS = 1
* bars.
*/
export default defineComponent({
- name: 'VWaveform',
+ name: "VWaveform",
props: {
/**
* an array of heights of the bars; The waveform will be generated with
@@ -187,7 +187,7 @@ export default defineComponent({
type: Array as PropType<number[]>,
required: false,
validator: (val: unknown[]) =>
- val.every((item) => typeof item === 'number'),
+ val.every((item) => typeof item === "number"),
},
/**
* the message to display instead of the waveform; This is useful when
@@ -224,7 +224,7 @@ export default defineComponent({
*/
features: {
type: Array as PropType<AudioFeature[]>,
- default: () => ['timestamps', 'seek'],
+ default: () => ["timestamps", "seek"],
},
/**
* An object of notices to display when a feature is disabled.
@@ -267,7 +267,7 @@ export default defineComponent({
* keyboard events that also correspond to seeking.
*/
seeked: defineEvent<[number]>(),
- 'toggle-playback': defineEvent<[]>(),
+ "toggle-playback": defineEvent<[]>(),
},
setup(props, { emit }) {
/* Utils */
@@ -309,9 +309,9 @@ export default defineComponent({
/* Features */
- const showDuration = computed(() => props.features.includes('duration'))
- const showTimestamps = computed(() => props.features.includes('timestamps'))
- const isSeekable = computed(() => props.features.includes('seek'))
+ const showDuration = computed(() => props.features.includes("duration"))
+ const showTimestamps = computed(() => props.features.includes("timestamps"))
+ const isSeekable = computed(() => props.features.includes("seek"))
/* State */
@@ -355,7 +355,7 @@ export default defineComponent({
/* SVG drawing */
const viewBox = computed(() =>
- [0, 0, waveformDimens.value.width, waveformDimens.value.height].join(' ')
+ [0, 0, waveformDimens.value.width, waveformDimens.value.height].join(" ")
)
const spaceBefore = (index: number) => index * barWidth + index * barGap
const spaceAbove = (index: number) =>
@@ -412,14 +412,14 @@ export default defineComponent({
})
const { isSeeking: isSelfSeeking, ...seekable } = useSeekable({
- duration: toRef(props, 'duration'),
- currentTime: toRef(props, 'currentTime'),
+ duration: toRef(props, "duration"),
+ currentTime: toRef(props, "currentTime"),
isReady,
onSeek: (frac) => {
clearSeekProgress()
- emit('seeked', frac)
+ emit("seeked", frac)
},
- onTogglePlayback: () => emit('toggle-playback'),
+ onTogglePlayback: () => emit("toggle-playback"),
})
const waveformAttributes = computed(() => ({
// ARIA slider attributes are only added when interactive
@@ -439,7 +439,7 @@ export default defineComponent({
seekFrac.value = null
}
const seek = (event: MouseEvent) => {
- emit('seeked', getPositionFrac(event))
+ emit("seeked", getPositionFrac(event))
}
/* Dragging */
@@ -494,16 +494,16 @@ export default defineComponent({
})
const heightProperties = computed<CSSProperties>(() => ({
- '--usable-height': `${Math.floor(props.usableFrac * 100)}%`,
- '--unusable-height': `${Math.floor((1 - props.usableFrac) * 100)}%`,
+ "--usable-height": `${Math.floor(props.usableFrac * 100)}%`,
+ "--unusable-height": `${Math.floor((1 - props.usableFrac) * 100)}%`,
}))
const progressTimeLeft = computed<CSSProperties>(() => ({
- '--progress-time-left': `${progressBarWidth.value}px`,
+ "--progress-time-left": `${progressBarWidth.value}px`,
}))
const seekTimeLeft = computed<CSSProperties>(() => ({
- '--seek-time-left': `${seekBarWidth.value}px`,
+ "--seek-time-left": `${seekBarWidth.value}px`,
}))
return {
@@ -556,13 +556,13 @@ export default defineComponent({
.waveform {
--v-background-color: var(
--waveform-background-color,
- theme('colors.dark-charcoal.06')
+ theme("colors.dark-charcoal.06")
);
}
.timestamp {
@apply pointer-events-none absolute px-1 text-xs font-bold;
- top: calc(var(--unusable-height) + theme('spacing[0.5]'));
+ top: calc(var(--unusable-height) + theme("spacing[0.5]"));
}
.bg-background-var {
@@ -574,7 +574,7 @@ export default defineComponent({
}
.bars.with-space {
- height: calc(var(--usable-height) - 1rem - 2 * theme('spacing[0.5]'));
+ height: calc(var(--usable-height) - 1rem - 2 * theme("spacing[0.5]"));
}
.progress {
diff --git a/src/components/VAudioTrack/layouts/VBoxLayout.vue b/src/components/VAudioTrack/layouts/VBoxLayout.vue
index 9f561f207..e168d1a42 100644
--- a/src/components/VAudioTrack/layouts/VBoxLayout.vue
+++ b/src/components/VAudioTrack/layouts/VBoxLayout.vue
@@ -38,16 +38,16 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { AudioDetail } from '~/types/media'
-import type { AudioSize } from '~/constants/audio'
-import { useI18n } from '~/composables/use-i18n'
+import type { AudioDetail } from "~/types/media"
+import type { AudioSize } from "~/constants/audio"
+import { useI18n } from "~/composables/use-i18n"
-import VLicense from '~/components/VLicense/VLicense.vue'
+import VLicense from "~/components/VLicense/VLicense.vue"
export default defineComponent({
- name: 'VBoxLayout',
+ name: "VBoxLayout",
components: {
VLicense,
},
@@ -63,7 +63,7 @@ export default defineComponent({
},
setup(props) {
const i18n = useI18n()
- const isSmall = computed(() => props.size === 's')
+ const isSmall = computed(() => props.size === "s")
const width = computed(() => {
const magnitudes = {
@@ -91,7 +91,7 @@ export default defineComponent({
<style>
.box-track .waveform {
@apply flex-grow;
- --waveform-background-color: theme('colors.yellow');
+ --waveform-background-color: theme("colors.yellow");
}
.box-track .play-pause {
diff --git a/src/components/VAudioTrack/layouts/VFullLayout.vue b/src/components/VAudioTrack/layouts/VFullLayout.vue
index dbeb98bc8..4f3e6bf15 100644
--- a/src/components/VAudioTrack/layouts/VFullLayout.vue
+++ b/src/components/VAudioTrack/layouts/VFullLayout.vue
@@ -52,7 +52,7 @@
<span
class="hidden text-dark-charcoal-70 lg:block"
aria-hidden="true"
- >{{ $t('interpunct') }}</span
+ >{{ $t("interpunct") }}</span
>
<div>{{ timeFmt(audio.duration || 0, true) }}</div>
@@ -65,7 +65,7 @@
size="disabled"
class="order-1 self-center px-6 py-3 text-sr font-semibold ms-auto md:px-6 md:py-4 md:text-2xl lg:order-2"
>
- {{ $t('audio-details.weblink') }}
+ {{ $t("audio-details.weblink") }}
<VIcon
:icon-path="externalIcon"
:rtl-flip="true"
@@ -78,21 +78,21 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { AudioDetail } from '~/types/media'
-import { timeFmt } from '~/utils/time-fmt'
-import { AudioSize, AudioStatus, audioFeatures } from '~/constants/audio'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import type { AudioDetail } from "~/types/media"
+import { timeFmt } from "~/utils/time-fmt"
+import { AudioSize, AudioStatus, audioFeatures } from "~/constants/audio"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VLink from '~/components/VLink.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VLink from "~/components/VLink.vue"
-import externalIcon from '~/assets/icons/external-link.svg'
+import externalIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
- name: 'VFullLayout',
+ name: "VFullLayout",
components: { VButton, VIcon, VLink },
props: {
audio: {
@@ -111,11 +111,11 @@ export default defineComponent({
},
},
setup(props) {
- const isSmall = computed(() => props.size === 's')
+ const isSmall = computed(() => props.size === "s")
const featureFlagStore = useFeatureFlagStore()
const isNewHeaderEnabled = computed(() =>
- featureFlagStore.isOn('new_header')
+ featureFlagStore.isOn("new_header")
)
return {
@@ -136,7 +136,7 @@ export default defineComponent({
}
.full-track.isNewHeaderEnabled .waveform {
- --waveform-background-color: theme('colors.white');
+ --waveform-background-color: theme("colors.white");
}
.full-track .play-pause {
diff --git a/src/components/VAudioTrack/layouts/VGlobalLayout.vue b/src/components/VAudioTrack/layouts/VGlobalLayout.vue
index cadb0a9de..6360e1b8f 100644
--- a/src/components/VAudioTrack/layouts/VGlobalLayout.vue
+++ b/src/components/VAudioTrack/layouts/VGlobalLayout.vue
@@ -19,15 +19,15 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { AudioDetail } from '~/types/media'
+import type { AudioDetail } from "~/types/media"
-import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'
-import VLink from '~/components/VLink.vue'
+import VAudioThumbnail from "~/components/VAudioThumbnail/VAudioThumbnail.vue"
+import VLink from "~/components/VLink.vue"
export default defineComponent({
- name: 'VGlobalLayout',
+ name: "VGlobalLayout",
components: {
VAudioThumbnail,
VLink,
diff --git a/src/components/VAudioTrack/layouts/VRowLayout.vue b/src/components/VAudioTrack/layouts/VRowLayout.vue
index 4edb9c46a..28adfd2cb 100644
--- a/src/components/VAudioTrack/layouts/VRowLayout.vue
+++ b/src/components/VAudioTrack/layouts/VRowLayout.vue
@@ -45,7 +45,7 @@
<i18n tag="span" path="audio-track.creator">
<template #creator>{{ audio.creator }}</template> </i18n
><span v-show="isLarge" class="mx-2" aria-hidden="true">{{
- $t('interpunct')
+ $t("interpunct")
}}</span>
</div>
@@ -55,14 +55,14 @@
class="inline-block rounded-sm bg-dark-charcoal-06 p-1 font-semibold text-dark-charcoal"
>{{ timeFmt(audio.duration || 0, true) }}</span
><span class="mx-2" aria-hidden="true">{{
- $t('interpunct')
+ $t("interpunct")
}}</span>
</span>
<span v-if="audio.category">
<span>{{ $t(`filters.audio-categories.${audio.category}`) }}</span
><span class="mx-2" aria-hidden="true">{{
- $t('interpunct')
+ $t("interpunct")
}}</span>
</span>
@@ -96,17 +96,17 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { timeFmt } from '~/utils/time-fmt'
-import type { AudioDetail } from '~/types/media'
-import type { AudioSize } from '~/constants/audio'
+import { timeFmt } from "~/utils/time-fmt"
+import type { AudioDetail } from "~/types/media"
+import type { AudioSize } from "~/constants/audio"
-import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'
-import VLicense from '~/components/VLicense/VLicense.vue'
+import VAudioThumbnail from "~/components/VAudioThumbnail/VAudioThumbnail.vue"
+import VLicense from "~/components/VLicense/VLicense.vue"
export default defineComponent({
- name: 'VRowLayout',
+ name: "VRowLayout",
components: {
VAudioThumbnail,
VLicense,
@@ -127,11 +127,11 @@ export default defineComponent({
duration?: string
seek?: string
} = {}
- const features = ['timestamps', 'duration', 'seek']
+ const features = ["timestamps", "duration", "seek"]
- const isSmall = computed(() => props.size === 's')
- const isMedium = computed(() => props.size === 'm')
- const isLarge = computed(() => props.size === 'l')
+ const isSmall = computed(() => props.size === "s")
+ const isMedium = computed(() => props.size === "m")
+ const isLarge = computed(() => props.size === "l")
return {
timeFmt,
@@ -154,7 +154,7 @@ export default defineComponent({
.row-track .waveform {
@apply flex-grow;
- --waveform-background-color: theme('colors.tx');
+ --waveform-background-color: theme("colors.tx");
}
.row-track .waveform {
diff --git a/src/components/VAudioTrack/meta/VAudioTrack.stories.mdx b/src/components/VAudioTrack/meta/VAudioTrack.stories.mdx
index ceb0be346..96b7ffaf7 100644
--- a/src/components/VAudioTrack/meta/VAudioTrack.stories.mdx
+++ b/src/components/VAudioTrack/meta/VAudioTrack.stories.mdx
@@ -4,34 +4,34 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import { computed } from '@nuxtjs/composition-api'
+} from "@storybook/addon-docs"
+import { computed } from "@nuxtjs/composition-api"
-import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
+import VAudioTrack from "~/components/VAudioTrack/VAudioTrack.vue"
-import flacWaveform from './flac-waveform.json'
-import mp3Waveform from './mp3-waveform.json'
-import oggWaveform from './ogg-waveform.json'
-import wavWaveform from './wav-waveform.json'
+import flacWaveform from "./flac-waveform.json"
+import mp3Waveform from "./mp3-waveform.json"
+import oggWaveform from "./ogg-waveform.json"
+import wavWaveform from "./wav-waveform.json"
<Meta
title="Components/Audio track"
component={VAudioTrack}
argTypes={{
format: {
- defaultValue: 'mp3',
- options: ['mp3', 'ogg', 'flac', 'wav'],
- control: 'select',
+ defaultValue: "mp3",
+ options: ["mp3", "ogg", "flac", "wav"],
+ control: "select",
},
layout: {
- defaultValue: 'full',
- options: ['full', 'box', 'row', 'global'],
- control: 'select',
+ defaultValue: "full",
+ options: ["full", "box", "row", "global"],
+ control: "select",
},
size: {
- defaultValue: 'm',
- options: ['s', 'm', 'l'],
- control: 'select',
+ defaultValue: "m",
+ options: ["s", "m", "l"],
+ control: "select",
},
audio: {
control: false,
@@ -41,41 +41,41 @@ import wavWaveform from './wav-waveform.json'
export const commonAttrs = () => ({
id: Math.floor(Math.random() * 1e9).toString(),
- creator: 'Wolfgang Amadeus Mozart',
- creator_url: 'https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart',
- category: 'music',
+ creator: "Wolfgang Amadeus Mozart",
+ creator_url: "https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart",
+ category: "music",
thumbnail:
- 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Croce-Mozart-Detail.jpg/370px-Croce-Mozart-Detail.jpg',
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Croce-Mozart-Detail.jpg/370px-Croce-Mozart-Detail.jpg",
})
export const formatExamples = {
ogg: {
- title: 'Eine kleine Nachtmusik - 1. Allegro',
- url: 'https://upload.wikimedia.org/wikipedia/commons/2/24/Mozart_-_Eine_kleine_Nachtmusik_-_1._Allegro.ogg',
+ title: "Eine kleine Nachtmusik - 1. Allegro",
+ url: "https://upload.wikimedia.org/wikipedia/commons/2/24/Mozart_-_Eine_kleine_Nachtmusik_-_1._Allegro.ogg",
duration: 355e3,
peaks: oggWaveform.points,
- license: 'by-sa',
+ license: "by-sa",
},
mp3: {
title: 'Serenade No. 10 "Grand Partita" - VII. Finale. Molto Allegro',
- url: 'https://upload.wikimedia.org/wikipedia/commons/e/e1/Mozart%27s_Serenade_No._10_%22Grand_Partita%22_-_VII._Finale._Molto_Allegro_-_United_States_Marine_Band.mp3',
+ url: "https://upload.wikimedia.org/wikipedia/commons/e/e1/Mozart%27s_Serenade_No._10_%22Grand_Partita%22_-_VII._Finale._Molto_Allegro_-_United_States_Marine_Band.mp3",
duration: 206e3,
peaks: mp3Waveform.points,
- license: 'pdm',
+ license: "pdm",
},
wav: {
- title: 'Trio from Wind Serenade K. 388',
- url: 'https://upload.wikimedia.org/wikipedia/commons/b/b3/Mozart_Trio_from_Wind_Serenade_K388.wav',
+ title: "Trio from Wind Serenade K. 388",
+ url: "https://upload.wikimedia.org/wikipedia/commons/b/b3/Mozart_Trio_from_Wind_Serenade_K388.wav",
duration: 33e3,
peaks: wavWaveform.points,
- license: 'pdm',
+ license: "pdm",
},
flac: {
title: 'Piano Concerto No. 26 in D Major, KV 537 "Coronation", 1. Allegro',
- url: 'https://upload.wikimedia.org/wikipedia/commons/1/17/Mozart%3B_Piano_Concerto_No._26_in_D_Major%2C_KV_537_%22Coronation%22%2C_1._Allegro.flac',
+ url: "https://upload.wikimedia.org/wikipedia/commons/1/17/Mozart%3B_Piano_Concerto_No._26_in_D_Major%2C_KV_537_%22Coronation%22%2C_1._Allegro.flac",
duration: 808e3,
peaks: flacWaveform.points,
- license: 'pdm',
+ license: "pdm",
},
}
@@ -103,8 +103,8 @@ export const Template = (args) => ({
## Layouts
-The component can be rendered in a multiple different layouts, by
-specifying a `layout`. The layout can further be customised by the `size` prop.
+The component can be rendered in a multiple different layouts, by specifying a
+`layout`. The layout can further be customised by the `size` prop.
### Full (default)
@@ -131,10 +131,10 @@ specifying a `layout`. The layout can further be customised by the `size` prop.
name="Full (small)"
args={{
// layout: 'full', (default)
- size: 's',
+ size: "s",
}}
parameters={{
- viewport: { defaultViewport: 'sm' },
+ viewport: { defaultViewport: "sm" },
}}
>
{Template.bind({})}
@@ -149,8 +149,8 @@ specifying a `layout`. The layout can further be customised by the `size` prop.
<Story
name="Row (large)"
args={{
- layout: 'row',
- size: 'l',
+ layout: "row",
+ size: "l",
}}
>
{Template.bind({})}
@@ -163,7 +163,7 @@ specifying a `layout`. The layout can further be customised by the `size` prop.
<Story
name="Row (medium)"
args={{
- layout: 'row',
+ layout: "row",
// size: 'm', (default)
}}
>
@@ -177,11 +177,11 @@ specifying a `layout`. The layout can further be customised by the `size` prop.
<Story
name="Row (small)"
args={{
- layout: 'row',
- size: 's',
+ layout: "row",
+ size: "s",
}}
parameters={{
- viewport: { defaultViewport: 'sm' },
+ viewport: { defaultViewport: "sm" },
}}
>
{Template.bind({})}
@@ -199,8 +199,8 @@ dimension.
<Story
name="Box (large)"
args={{
- layout: 'box',
- size: 'l',
+ layout: "box",
+ size: "l",
}}
>
{Template.bind({})}
@@ -208,7 +208,7 @@ dimension.
<Story
name="Box (medium)"
args={{
- layout: 'box',
+ layout: "box",
// size: 'm', (default)
}}
>
@@ -222,11 +222,11 @@ dimension.
<Story
name="Box (small)"
args={{
- layout: 'box',
- size: 's',
+ layout: "box",
+ size: "s",
}}
parameters={{
- viewport: { defaultViewport: 'sm' },
+ viewport: { defaultViewport: "sm" },
}}
>
{Template.bind({})}
@@ -242,10 +242,10 @@ across pages when navigating.
<Story
name="Global"
args={{
- layout: 'global',
+ layout: "global",
}}
parameters={{
- viewport: { defaultViewport: 'sm' },
+ viewport: { defaultViewport: "sm" },
}}
>
{Template.bind({})}
diff --git a/src/components/VAudioTrack/meta/VPlayPause.stories.mdx b/src/components/VAudioTrack/meta/VPlayPause.stories.mdx
index 34b1bceed..3414126c5 100644
--- a/src/components/VAudioTrack/meta/VPlayPause.stories.mdx
+++ b/src/components/VAudioTrack/meta/VPlayPause.stories.mdx
@@ -4,26 +4,26 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VPlayPause from '~/components/VAudioTrack/VPlayPause.vue'
+import VPlayPause from "~/components/VAudioTrack/VPlayPause.vue"
<Meta
title="Components/Audio track/Play-pause toggle"
components={VPlayPause}
argTypes={{
status: {
- options: ['playing', 'paused', 'played'],
- defaultValue: 'paused',
- control: 'select',
+ options: ["playing", "paused", "played"],
+ defaultValue: "paused",
+ control: "select",
},
size: {
- defaultValue: 'medium',
- options: ['tiny', 'small', 'medium', 'extra-large'],
- control: 'select',
+ defaultValue: "medium",
+ options: ["tiny", "small", "medium", "extra-large"],
+ control: "select",
},
toggle: {
- action: 'toggle',
+ action: "toggle",
},
}}
/>
@@ -47,16 +47,15 @@ value of its `status` state.
## Size
-The button dimensions can be set by passing the
-`size` prop (see
+The button dimensions can be set by passing the `size` prop (see
[`VIconButton` docs](?path=/docs/components-viconbutton--default-story)).
<Canvas>
<Story
name="Default"
args={{
- status: 'playing',
- size: 'large',
+ status: "playing",
+ size: "large",
}}
>
{Template.bind({})}
@@ -82,7 +81,7 @@ export const vModelTemplate = () => ({
components: { VPlayPause },
data() {
return {
- status: 'played',
+ status: "played",
}
},
})
diff --git a/src/components/VAudioTrack/meta/VWaveform.stories.mdx b/src/components/VAudioTrack/meta/VWaveform.stories.mdx
index 9be7b2d84..558bdde9a 100644
--- a/src/components/VAudioTrack/meta/VWaveform.stories.mdx
+++ b/src/components/VAudioTrack/meta/VWaveform.stories.mdx
@@ -4,16 +4,16 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VWaveform from '~/components/VAudioTrack/VWaveform.vue'
+import VWaveform from "~/components/VAudioTrack/VWaveform.vue"
<Meta
title="Components/Audio track/Waveform"
components={VWaveform}
argTypes={{
seeked: {
- action: 'seeked',
+ action: "seeked",
},
}}
/>
@@ -49,7 +49,7 @@ Here 9 points are upsampled to as many as required to fill the viewport.
peaks: [0.5, 1, 0.5, 0, 0.5, 1, 0.5, 0, 0.5], // triangular wave with 9 points
currentTime: 2,
duration: 10,
- features: ['timestamps', 'duration', 'seek'],
+ features: ["timestamps", "duration", "seek"],
}}
>
{Template.bind({})}
@@ -70,7 +70,7 @@ Here 1000 points are downsampled to as many as required to fill the viewport.
), // sine wave with 1000 points
currentTime: 2,
duration: 10,
- features: ['timestamps', 'duration', 'seek'],
+ features: ["timestamps", "duration", "seek"],
}}
>
{Template.bind({})}
@@ -90,8 +90,8 @@ the `--waveform-background-color` CSS custom property on the component or on the
peaks: [0.5, 1, 0.5, 0, 0.5],
currentTime: 2,
duration: 10,
- features: ['timestamps', 'duration', 'seek'],
- style: { '--waveform-background-color': '#d7fcd4' },
+ features: ["timestamps", "duration", "seek"],
+ style: { "--waveform-background-color": "#d7fcd4" },
}}
>
{Template.bind({})}
@@ -122,7 +122,7 @@ contains both the bars and the timestamps so the actual bar height is less than
peaks: [0.5, 1, 0.5, 0, 0.5],
currentTime: 2,
duration: 10,
- features: ['timestamps', 'duration', 'seek'],
+ features: ["timestamps", "duration", "seek"],
usableFrac: 0.5,
}}
>
@@ -143,7 +143,7 @@ meet the design requirements and space/information density constraints. The
peaks: [0.5, 1, 0.5, 0, 0.5],
currentTime: 2,
duration: 10,
- features: ['timestamps', 'duration', 'seek'],
+ features: ["timestamps", "duration", "seek"],
}}
>
{Template.bind({})}
@@ -159,7 +159,7 @@ will animate up to their actual height when the prop is unset.
<Story
name="Message"
args={{
- message: 'Hello, World!',
+ message: "Hello, World!",
audioId: 123,
}}
>
diff --git a/src/components/VBackToSearchResultsLink.vue b/src/components/VBackToSearchResultsLink.vue
index e91085588..b8da3f72e 100644
--- a/src/components/VBackToSearchResultsLink.vue
+++ b/src/components/VBackToSearchResultsLink.vue
@@ -5,17 +5,17 @@
v-bind="$attrs"
>
<VIcon :icon-path="chevronIcon" :rtl-flip="true" />
- {{ $t('single-result.back') }}
+ {{ $t("single-result.back") }}
</VLink>
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VLink from '~/components/VLink.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VLink from "~/components/VLink.vue"
-import chevronIcon from '~/assets/icons/chevron-left.svg'
+import chevronIcon from "~/assets/icons/chevron-left.svg"
/**
* This link takes the user from a single result back to the list of all
diff --git a/src/components/VBanner/VBanners.vue b/src/components/VBanner/VBanners.vue
index 5b6aba5db..bfd74bce7 100644
--- a/src/components/VBanner/VBanners.vue
+++ b/src/components/VBanner/VBanners.vue
@@ -13,17 +13,17 @@
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { useUiStore } from '~/stores/ui'
-import type { TranslationBannerId } from '~/types/banners'
+import { useUiStore } from "~/stores/ui"
+import type { TranslationBannerId } from "~/types/banners"
export default defineComponent({
- name: 'VBanners',
+ name: "VBanners",
components: {
- VMigrationNotice: () => import('~/components/VBanner/VMigrationNotice.vue'),
+ VMigrationNotice: () => import("~/components/VBanner/VMigrationNotice.vue"),
VTranslationStatusBanner: () =>
- import('~/components/VBanner/VTranslationStatusBanner.vue'),
+ import("~/components/VBanner/VTranslationStatusBanner.vue"),
},
setup() {
const uiStore = useUiStore()
diff --git a/src/components/VBanner/VMigrationNotice.vue b/src/components/VBanner/VMigrationNotice.vue
index 8bac32880..6eebc5af4 100644
--- a/src/components/VBanner/VMigrationNotice.vue
+++ b/src/components/VBanner/VMigrationNotice.vue
@@ -5,10 +5,10 @@
@close="$emit('close')"
>
{{
- $t('migration-notice.intro', {
- 'cc-search': 'CC Search',
- openverse: 'Openverse',
- wordpress: 'WordPress',
+ $t("migration-notice.intro", {
+ "cc-search": "CC Search",
+ openverse: "Openverse",
+ wordpress: "WordPress",
})
}}
<i18n tag="span" path="migration-notice.more">
@@ -17,7 +17,7 @@
class="font-bold text-white underline"
href="https://wordpress.org/news/2021/05/welcome-to-openverse/"
>
- {{ $t('migration-notice.read') }}
+ {{ $t("migration-notice.read") }}
</VLink>
</template>
</i18n>
@@ -25,13 +25,13 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VNotificationBanner from '~/components/VBanner/VNotificationBanner.vue'
-import VLink from '~/components/VLink.vue'
+import VNotificationBanner from "~/components/VBanner/VNotificationBanner.vue"
+import VLink from "~/components/VLink.vue"
export default defineComponent({
- name: 'VMigrationNotice',
+ name: "VMigrationNotice",
components: { VLink, VNotificationBanner },
})
</script>
diff --git a/src/components/VBanner/VNotificationBanner.vue b/src/components/VBanner/VNotificationBanner.vue
index b74f509df..fcaf85823 100644
--- a/src/components/VBanner/VNotificationBanner.vue
+++ b/src/components/VBanner/VNotificationBanner.vue
@@ -24,24 +24,24 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import type { BannerId } from '~/types/banners'
+import type { BannerId } from "~/types/banners"
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
-import closeIcon from '~/assets/icons/close.svg'
+import closeIcon from "~/assets/icons/close.svg"
export default defineComponent({
- name: 'VNotificationBanner',
+ name: "VNotificationBanner",
components: {
VIconButton,
},
props: {
variant: {
- type: String as PropType<'announcement' | 'informational'>,
+ type: String as PropType<"announcement" | "informational">,
required: true,
},
id: {
@@ -54,7 +54,7 @@ export default defineComponent({
},
setup(_, { emit }) {
const handleClose = () => {
- emit('close')
+ emit("close")
}
return {
diff --git a/src/components/VBanner/VTranslationStatusBanner.vue b/src/components/VBanner/VTranslationStatusBanner.vue
index 7a0ff5589..a080c9304 100644
--- a/src/components/VBanner/VTranslationStatusBanner.vue
+++ b/src/components/VBanner/VTranslationStatusBanner.vue
@@ -7,12 +7,12 @@
>
{{
// eslint-disable-next-line @intlify/vue-i18n/no-raw-text
- '⚠️'
+ "⚠️"
}}
<i18n path="notification.translation.text">
<template #link>
<VLink :href="currentLocale.link" class="underline">{{
- $t('notification.translation.link')
+ $t("notification.translation.link")
}}</VLink>
</template>
<template #locale>
@@ -23,19 +23,19 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { BannerId } from '~/types/banners'
+import type { BannerId } from "~/types/banners"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import { createTranslationLink } from '~/utils/translation-banner'
+import { createTranslationLink } from "~/utils/translation-banner"
-import VLink from '~/components/VLink.vue'
-import VNotificationBanner from '~/components/VBanner/VNotificationBanner.vue'
+import VLink from "~/components/VLink.vue"
+import VNotificationBanner from "~/components/VBanner/VNotificationBanner.vue"
export default defineComponent({
- name: 'VTranslationStatusBanner',
+ name: "VTranslationStatusBanner",
components: {
VLink,
VNotificationBanner,
diff --git a/src/components/VBrand/VBrand.vue b/src/components/VBrand/VBrand.vue
index dd9c3b7aa..185609cc6 100644
--- a/src/components/VBrand/VBrand.vue
+++ b/src/components/VBrand/VBrand.vue
@@ -11,17 +11,17 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import OpenverseLogo from '~/assets/logo.svg?inline'
-import OpenverseBrand from '~/assets/brand.svg?inline'
+import OpenverseLogo from "~/assets/logo.svg?inline"
+import OpenverseBrand from "~/assets/brand.svg?inline"
/**
* Render the openverse logo and wordmark next to each other, while being
* accessible to screen-readers.
*/
export default defineComponent({
- name: 'VBrand',
+ name: "VBrand",
components: {
OpenverseLogo,
OpenverseBrand,
@@ -34,7 +34,7 @@ export default defineComponent({
srText: {
type: String,
required: false,
- default: 'Openverse',
+ default: "Openverse",
},
},
})
diff --git a/src/components/VBrand/meta/VBrand.stories.mdx b/src/components/VBrand/meta/VBrand.stories.mdx
index 0d499ea76..36bccbfdc 100644
--- a/src/components/VBrand/meta/VBrand.stories.mdx
+++ b/src/components/VBrand/meta/VBrand.stories.mdx
@@ -1,6 +1,6 @@
-import { Description, Canvas, Meta, Story } from '@storybook/addon-docs'
+import { Description, Canvas, Meta, Story } from "@storybook/addon-docs"
-import VBrand from '~/components/VBrand/VBrand.vue'
+import VBrand from "~/components/VBrand/VBrand.vue"
<Meta title="Components/VBrand" component={VBrand} />
@@ -30,7 +30,7 @@ utilities, including JIT values like `text-[18px]`.
<Story
name="Resized"
args={{
- class: 'text-6xl',
+ class: "text-6xl",
}}
>
{Template.bind({})}
diff --git a/src/components/VButton.vue b/src/components/VButton.vue
index 07bc640a6..9e6ad6268 100644
--- a/src/components/VButton.vue
+++ b/src/components/VButton.vue
@@ -34,24 +34,24 @@ import {
toRefs,
computed,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { warn } from '~/utils/console'
+import { warn } from "~/utils/console"
-import type { ProperlyExtractPropTypes } from '~/types/prop-extraction'
+import type { ProperlyExtractPropTypes } from "~/types/prop-extraction"
import {
ButtonConnections,
buttonForms,
ButtonSize,
ButtonType,
ButtonVariant,
-} from '~/types/button'
-import type { ButtonForm } from '~/types/button'
+} from "~/types/button"
+import type { ButtonForm } from "~/types/button"
-import VLink from '~/components/VLink.vue'
+import VLink from "~/components/VLink.vue"
export type ButtonProps = ProperlyExtractPropTypes<
- NonNullable<typeof VButton['props']>
+ NonNullable<typeof VButton["props"]>
>
/**
@@ -67,7 +67,7 @@ export type ButtonProps = ProperlyExtractPropTypes<
* adapted from Reakit's Button, Clickable, and Tabbable component implementations.
*/
const VButton = defineComponent({
- name: 'VButton',
+ name: "VButton",
components: { VLink },
props: {
/**
@@ -85,7 +85,7 @@ const VButton = defineComponent({
*/
as: {
type: String as PropType<ButtonForm>,
- default: 'button',
+ default: "button",
validate: (val: ButtonForm) => buttonForms.includes(val),
},
/**
@@ -98,7 +98,7 @@ const VButton = defineComponent({
*/
variant: {
type: String as PropType<ButtonVariant>,
- default: 'primary',
+ default: "primary",
},
/**
* Allows for programmatically setting the pressed state of a button,
@@ -118,7 +118,7 @@ const VButton = defineComponent({
*/
size: {
type: String as PropType<ButtonSize>,
- default: 'medium',
+ default: "medium",
},
/**
* Whether the button is disabled. Used alone this will only
@@ -151,7 +151,7 @@ const VButton = defineComponent({
*/
type: {
type: String as PropType<ButtonType>,
- default: 'button',
+ default: "button",
},
/**
* Whether the button is connected to another control and needs to have no rounded
@@ -162,7 +162,7 @@ const VButton = defineComponent({
*/
connections: {
type: String as PropType<ButtonConnections>,
- default: 'none',
+ default: "none",
},
},
setup(props, { attrs }) {
@@ -175,18 +175,18 @@ const VButton = defineComponent({
const typeRef = ref<ButtonType | undefined>(propsRef.type.value)
const supportsDisabledAttributeRef = ref(true)
- const isConnected = computed(() => props.connections !== 'none')
+ const isConnected = computed(() => props.connections !== "none")
const isActive = computed(() => {
return (
propsRef.pressed.value ||
- attrs['aria-pressed'] ||
- attrs['aria-expanded']
+ attrs["aria-pressed"] ||
+ attrs["aria-expanded"]
)
})
const isPlainDangerous = computed(() => {
- return propsRef.variant.value === 'plain--avoid'
+ return propsRef.variant.value === "plain--avoid"
})
watch(
@@ -208,10 +208,10 @@ const VButton = defineComponent({
watch(
propsRef.as,
(as) => {
- if (['VLink'].includes(as)) {
+ if (["VLink"].includes(as)) {
typeRef.value = undefined
supportsDisabledAttributeRef.value = false
- } else if (['a', 'NuxtLink'].includes(as)) {
+ } else if (["a", "NuxtLink"].includes(as)) {
warn(
`Please use \`VLink\` with an \`href\` prop instead of ${as} for the button component`
)
@@ -244,8 +244,8 @@ export default VButton
</script>
<style module>
-.button[disabled='disabled'],
-.button[aria-disabled='true'] {
+.button[disabled="disabled"],
+.button[aria-disabled="true"] {
@apply cursor-not-allowed;
}
@@ -278,8 +278,8 @@ a.button {
.secondary-pressed {
@apply border-tx bg-dark-charcoal text-white hover:border-tx hover:bg-dark-charcoal-90;
}
-.secondary[disabled='disabled'],
-.secondary[aria-disabled='true'] {
+.secondary[disabled="disabled"],
+.secondary[aria-disabled="true"] {
@apply border-tx bg-tx text-dark-charcoal-40;
}
@@ -293,10 +293,10 @@ a.button {
.secondary-bordered-pressed {
@apply bg-dark-charcoal text-white hover:border-tx hover:bg-dark-charcoal-90 focus-visible:bg-dark-charcoal-90;
}
-.secondary-filled[disabled='disabled'],
-.secondary-bordered[disabled='disabled'],
-.secondary-filled[aria-disabled='true'],
-.secondary-bordered[aria-disabled='true'] {
+.secondary-filled[disabled="disabled"],
+.secondary-bordered[disabled="disabled"],
+.secondary-filled[aria-disabled="true"],
+.secondary-bordered[aria-disabled="true"] {
@apply border-tx bg-dark-charcoal-10 text-dark-charcoal-40;
}
@@ -304,8 +304,8 @@ a.button {
@apply border-tx bg-tx px-0 text-sm font-semibold text-pink hover:underline focus-visible:ring focus-visible:ring-pink;
}
-.text[disabled='disabled'],
-.text[aria-disabled='true'] {
+.text[disabled="disabled"],
+.text[aria-disabled="true"] {
@apply border-tx bg-tx text-dark-charcoal-40;
}
@@ -341,12 +341,12 @@ https://www.figma.com/file/GIIQ4sDbaToCfFQyKMvzr8/Openverse-Design-Library?node-
@apply border-tx bg-dark-charcoal text-white hover:border-tx hover:bg-dark-charcoal-90;
}
-.action-menu[disabled='disabled'],
-.action-menu[aria-disabled='true'],
-.action-menu-muted[disabled='disabled'],
-.action-menu-muted[aria-disabled='true'],
-.action-menu-bordered[disabled='disabled'],
-.action-menu-bordered[aria-disabled='true'] {
+.action-menu[disabled="disabled"],
+.action-menu[aria-disabled="true"],
+.action-menu-muted[disabled="disabled"],
+.action-menu-muted[aria-disabled="true"],
+.action-menu-bordered[disabled="disabled"],
+.action-menu-bordered[aria-disabled="true"] {
@apply border-dark-charcoal-10 bg-dark-charcoal-10 text-dark-charcoal-40;
}
diff --git a/src/components/VCheckbox/VCheckbox.vue b/src/components/VCheckbox/VCheckbox.vue
index a7779552e..e0e0aedb1 100644
--- a/src/components/VCheckbox/VCheckbox.vue
+++ b/src/components/VCheckbox/VCheckbox.vue
@@ -19,13 +19,13 @@
</template>
<script lang="ts">
-import { computed, defineComponent, ref, watch } from '@nuxtjs/composition-api'
+import { computed, defineComponent, ref, watch } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
-import checkmark from '~/assets/icons/checkmark.svg'
+import checkmark from "~/assets/icons/checkmark.svg"
type CheckboxAttrs = {
name: string
@@ -40,7 +40,7 @@ type CheckboxAttrs = {
* Unlike the native checkbox, this component only has two states: checked / not checked.
*/
export default defineComponent({
- name: 'VCheckbox',
+ name: "VCheckbox",
components: {
VIcon,
},
@@ -97,12 +97,12 @@ export default defineComponent({
},
},
emits: {
- change: defineEvent<[Omit<CheckboxAttrs, 'disabled'>]>(),
+ change: defineEvent<[Omit<CheckboxAttrs, "disabled">]>(),
},
setup(props, { emit }) {
const localCheckedState = ref(props.checked || false)
const labelClasses = computed(() =>
- props.disabled ? 'text-dark-charcoal-70' : 'text-dark-charcoal'
+ props.disabled ? "text-dark-charcoal-70" : "text-dark-charcoal"
)
const inputAttrs = computed<CheckboxAttrs>(() => {
const attrs: CheckboxAttrs = {
@@ -129,7 +129,7 @@ export default defineComponent({
const onChange = () => {
localCheckedState.value = !localCheckedState.value
- emit('change', {
+ emit("change", {
name: inputAttrs.value.name,
value: inputAttrs.value.value,
checked: localCheckedState.value,
diff --git a/src/components/VCheckbox/meta/VCheckbox.stories.mdx b/src/components/VCheckbox/meta/VCheckbox.stories.mdx
index 4732f80bc..fb043f9eb 100644
--- a/src/components/VCheckbox/meta/VCheckbox.stories.mdx
+++ b/src/components/VCheckbox/meta/VCheckbox.stories.mdx
@@ -4,27 +4,27 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VCheckbox from '~/components/VCheckbox/VCheckbox.vue'
-import VLicense from '~/components/VLicense/VLicense.vue'
+import VCheckbox from "~/components/VCheckbox/VCheckbox.vue"
+import VLicense from "~/components/VLicense/VLicense.vue"
<Meta
title="Components/VCheckbox"
components={VCheckbox}
argTypes={{
change: {
- action: 'change',
+ action: "change",
},
}}
/>
export const checkboxArgTypes = {
- id: { control: { type: 'text' } },
- checked: { control: { type: 'boolean' } },
- name: { control: { type: 'text' } },
- value: { control: { type: 'text' } },
- disabled: { control: { type: 'boolean' } },
+ id: { control: { type: "text" } },
+ checked: { control: { type: "boolean" } },
+ name: { control: { type: "text" } },
+ value: { control: { type: "text" } },
+ disabled: { control: { type: "boolean" } },
}
export const Template = (args) => ({
@@ -45,9 +45,9 @@ export const Template = (args) => ({
<Story
name="Default"
args={{
- id: 'default',
- name: 'storybook',
- value: 'codeIsPoetry',
+ id: "default",
+ name: "storybook",
+ value: "codeIsPoetry",
}}
argTypes={checkboxArgTypes}
>
@@ -72,15 +72,17 @@ export const LicenseCheckboxTemplate = (args) => ({
## License Checkbox
-The checkbox label can be a string or another component. Here, we use a VLicense component, and set `checked` prop to `true` to set the checkbox as checked on render.
+The checkbox label can be a string or another component. Here, we use a VLicense
+component, and set `checked` prop to `true` to set the checkbox as checked on
+render.
<Canvas>
<Story
name="License Checkbox"
args={{
- id: 'cc-by',
- name: 'license',
- value: 'cc-by',
+ id: "cc-by",
+ name: "license",
+ value: "cc-by",
checked: true,
}}
argTypes={checkboxArgTypes}
diff --git a/src/components/VContentLink/VContentLink.vue b/src/components/VContentLink/VContentLink.vue
index 8578ee62c..75c277104 100644
--- a/src/components/VContentLink/VContentLink.vue
+++ b/src/components/VContentLink/VContentLink.vue
@@ -24,18 +24,18 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { useI18nResultsCount } from '~/composables/use-i18n-utilities'
-import { AUDIO, IMAGE, SupportedMediaType } from '~/constants/media'
+import { useI18nResultsCount } from "~/composables/use-i18n-utilities"
+import { AUDIO, IMAGE, SupportedMediaType } from "~/constants/media"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VLink from '~/components/VLink.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VLink from "~/components/VLink.vue"
-import audioIcon from '~/assets/icons/audio-wave.svg'
-import imageIcon from '~/assets/icons/image.svg'
+import audioIcon from "~/assets/icons/audio-wave.svg"
+import imageIcon from "~/assets/icons/image.svg"
const iconMapping = {
[AUDIO]: audioIcon,
@@ -43,7 +43,7 @@ const iconMapping = {
}
export default defineComponent({
- name: 'VContentLink',
+ name: "VContentLink",
components: { VIcon, VLink },
props: {
/**
@@ -69,7 +69,7 @@ export default defineComponent({
},
},
emits: {
- 'shift-tab': defineEvent<[KeyboardEvent]>(),
+ "shift-tab": defineEvent<[KeyboardEvent]>(),
},
setup(props) {
const iconPath = computed(() => iconMapping[props.mediaType])
diff --git a/src/components/VContentLink/meta/VContentLink.stories.js b/src/components/VContentLink/meta/VContentLink.stories.js
index d1ab539a6..419686a1d 100644
--- a/src/components/VContentLink/meta/VContentLink.stories.js
+++ b/src/components/VContentLink/meta/VContentLink.stories.js
@@ -1,22 +1,22 @@
-import VContentLink from '~/components/VContentLink/VContentLink.vue'
+import VContentLink from "~/components/VContentLink/VContentLink.vue"
export default {
- title: 'Components/VContentLink',
+ title: "Components/VContentLink",
component: VContentLink,
argTypes: {
mediaType: {
- options: ['audio', 'image'],
- control: { type: 'radio' },
+ options: ["audio", "image"],
+ control: { type: "radio" },
},
resultsCount: {
- control: { type: 'number' },
+ control: { type: "number" },
},
isSelected: {
- control: { type: 'boolean' },
+ control: { type: "boolean" },
},
layout: {
- options: ['stacked', 'horizontal'],
- control: { type: 'radio' },
+ options: ["stacked", "horizontal"],
+ control: { type: "radio" },
},
},
}
@@ -44,10 +44,10 @@ const TwoVContentLinkStory = () => ({
data() {
return {
types: [
- { mediaType: 'image', resultsCount: 4321 },
- { mediaType: 'audio', resultsCount: 1234 },
+ { mediaType: "image", resultsCount: 4321 },
+ { mediaType: "audio", resultsCount: 1234 },
],
- selected: 'audio',
+ selected: "audio",
}
},
methods: {
@@ -59,7 +59,7 @@ const TwoVContentLinkStory = () => ({
export const Default = VContentLinkStory.bind({})
Default.args = {
- mediaType: 'image',
+ mediaType: "image",
resultsCount: 5708,
isSelected: false,
}
@@ -74,13 +74,13 @@ const VContentLinkHorizontalStory = (args) => ({
export const Horizontal = VContentLinkHorizontalStory.bind({})
Horizontal.args = {
- mediaType: 'audio',
+ mediaType: "audio",
resultsCount: 4561,
isSelected: false,
- layout: 'horizontal',
+ layout: "horizontal",
}
export const Mobile = TwoVContentLinkStory.bind({})
Mobile.parameters = {
- viewport: { defaultViewport: 'xs' },
+ viewport: { defaultViewport: "xs" },
}
diff --git a/src/components/VContentPage.vue b/src/components/VContentPage.vue
index 3ae24581c..ef8c738a5 100644
--- a/src/components/VContentPage.vue
+++ b/src/components/VContentPage.vue
@@ -9,9 +9,9 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
export default defineComponent({
- name: 'VContentPage',
+ name: "VContentPage",
})
</script>
diff --git a/src/components/VContentReport/VContentReportButton.vue b/src/components/VContentReport/VContentReportButton.vue
index 793edfa99..c82123677 100644
--- a/src/components/VContentReport/VContentReportButton.vue
+++ b/src/components/VContentReport/VContentReportButton.vue
@@ -4,25 +4,25 @@
class="report-button font-semibold text-dark-charcoal-70 hover:underline"
>
<span class="text-sr md:hidden md:text-base">{{
- $t('media-details.content-report.short')
+ $t("media-details.content-report.short")
}}</span>
<span class="hidden text-sr md:inline md:text-base">{{
- $t('media-details.content-report.long')
+ $t("media-details.content-report.long")
}}</span>
<VIcon :icon-path="icons.flag" class="ms-2" />
</VButton>
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VButton from '~/components/VButton.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VButton from "~/components/VButton.vue"
-import flagIcon from '~/assets/icons/flag.svg'
+import flagIcon from "~/assets/icons/flag.svg"
export default defineComponent({
- name: 'VContentReportButton',
+ name: "VContentReportButton",
components: { VButton, VIcon },
setup() {
return {
diff --git a/src/components/VContentReport/VContentReportForm.vue b/src/components/VContentReport/VContentReportForm.vue
index 01c028318..e870944f0 100644
--- a/src/components/VContentReport/VContentReportForm.vue
+++ b/src/components/VContentReport/VContentReportForm.vue
@@ -2,7 +2,7 @@
<div id="content-report-form" class="w-80 p-6">
<div v-if="status === SENT">
<p class="heading-6 mb-4">
- {{ $t('media-details.content-report.success.title') }}
+ {{ $t("media-details.content-report.success.title") }}
</p>
<i18n
path="media-details.content-report.success.note"
@@ -21,23 +21,23 @@
<div v-else-if="status === FAILED">
<p class="heading-6 mb-4">
- {{ $t('media-details.content-report.failure.title') }}
+ {{ $t("media-details.content-report.failure.title") }}
</p>
<p class="text-sm">
- {{ $t('media-details.content-report.failure.note') }}
+ {{ $t("media-details.content-report.failure.note") }}
</p>
</div>
<!-- Main form -->
<div v-else>
<div class="heading-6 mb-4">
- {{ $t('media-details.content-report.long') }}
+ {{ $t("media-details.content-report.long") }}
</div>
<p class="mb-4 text-sm">
{{
- $t('media-details.content-report.form.disclaimer', {
- openverse: 'Openverse',
+ $t("media-details.content-report.form.disclaimer", {
+ openverse: "Openverse",
})
}}
</p>
@@ -45,7 +45,7 @@
<form class="text-sm" @submit="handleSubmit">
<fieldset class="flex flex-col">
<legend class="label-bold mb-4">
- {{ $t('media-details.content-report.form.question') }}
+ {{ $t("media-details.content-report.form.question") }}
</legend>
<VRadio
v-for="reason in reasons"
@@ -77,7 +77,7 @@
<div class="flex flex-row items-center justify-end gap-4">
<VButton variant="secondary-bordered" @click="handleCancel">
- {{ $t('media-details.content-report.form.cancel') }}
+ {{ $t("media-details.content-report.form.cancel") }}
</VButton>
<VButton
@@ -87,7 +87,7 @@
variant="secondary-filled"
:href="DMCA_FORM_URL"
>
- {{ $t('media-details.content-report.form.dmca.open') }}
+ {{ $t("media-details.content-report.form.dmca.open") }}
<VIcon :size="4" class="ms-1" :icon-path="icons.externalLink" />
</VButton>
<VButton
@@ -99,7 +99,7 @@
variant="secondary-filled"
:value="$t('media-details.content-report.form.submit')"
>
- {{ $t('media-details.content-report.form.submit') }}
+ {{ $t("media-details.content-report.form.submit") }}
</VButton>
</div>
</form>
@@ -108,9 +108,9 @@
</template>
<script>
-import { computed, defineComponent, ref } from '@nuxtjs/composition-api'
+import { computed, defineComponent, ref } from "@nuxtjs/composition-api"
-import ReportService from '~/data/report-service'
+import ReportService from "~/data/report-service"
import {
reasons,
@@ -120,19 +120,19 @@ import {
FAILED,
WIP,
DMCA_FORM_URL,
-} from '~/constants/content-report'
+} from "~/constants/content-report"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VRadio from '~/components/VRadio/VRadio.vue'
-import VDmcaNotice from '~/components/VContentReport/VDmcaNotice.vue'
-import VReportDescForm from '~/components/VContentReport/VReportDescForm.vue'
-import VLink from '~/components/VLink.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VRadio from "~/components/VRadio/VRadio.vue"
+import VDmcaNotice from "~/components/VContentReport/VDmcaNotice.vue"
+import VReportDescForm from "~/components/VContentReport/VReportDescForm.vue"
+import VLink from "~/components/VLink.vue"
-import externalLinkIcon from '~/assets/icons/external-link.svg'
+import externalLinkIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
- name: 'VContentReportForm',
+ name: "VContentReportForm",
components: {
VButton,
VIcon,
@@ -149,7 +149,7 @@ export default defineComponent({
},
setup(props) {
const service = props.reportService || ReportService
- const description = ref('')
+ const description = ref("")
/** @type {import('@nuxtjs/composition-api').Ref<string|null>} */
const status = ref(WIP)
@@ -160,7 +160,7 @@ export default defineComponent({
/* Buttons */
const handleCancel = () => {
selectedReason.value = null
- description.value = ''
+ description.value = ""
props.closeFn()
}
diff --git a/src/components/VContentReport/VContentReportPopover.vue b/src/components/VContentReport/VContentReportPopover.vue
index 1514925d3..d0a878c3e 100644
--- a/src/components/VContentReport/VContentReportPopover.vue
+++ b/src/components/VContentReport/VContentReportPopover.vue
@@ -27,18 +27,18 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
-import VPopover from '~/components/VPopover/VPopover.vue'
-import VContentReportButton from '~/components/VContentReport/VContentReportButton.vue'
-import VContentReportForm from '~/components/VContentReport/VContentReportForm.vue'
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
+import VPopover from "~/components/VPopover/VPopover.vue"
+import VContentReportButton from "~/components/VContentReport/VContentReportButton.vue"
+import VContentReportForm from "~/components/VContentReport/VContentReportForm.vue"
-import flagIcon from '~/assets/icons/flag.svg'
-import closeSmallIcon from '~/assets/icons/close-small.svg'
+import flagIcon from "~/assets/icons/flag.svg"
+import closeSmallIcon from "~/assets/icons/close-small.svg"
export default defineComponent({
- name: 'VContentReportPopover',
+ name: "VContentReportPopover",
components: {
VIconButton,
VPopover,
diff --git a/src/components/VContentReport/VDmcaNotice.vue b/src/components/VContentReport/VDmcaNotice.vue
index fab95365c..43c40daf8 100644
--- a/src/components/VContentReport/VDmcaNotice.vue
+++ b/src/components/VContentReport/VDmcaNotice.vue
@@ -9,7 +9,7 @@
:aria-label="$t('media-details.content-report.form.dmca.form')"
:href="DMCA_FORM_URL"
class="text-pink hover:underline"
- >{{ $t('media-details.content-report.form.dmca.form') }}</VLink
+ >{{ $t("media-details.content-report.form.dmca.form") }}</VLink
>
</template>
<template #source>
@@ -21,14 +21,14 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import { DMCA_FORM_URL } from '~/constants/content-report'
+import { DMCA_FORM_URL } from "~/constants/content-report"
-import VLink from '~/components/VLink.vue'
+import VLink from "~/components/VLink.vue"
export default defineComponent({
- name: 'VDmcaNotice',
+ name: "VDmcaNotice",
components: { VLink },
props: {
/**
diff --git a/src/components/VContentReport/VReportDescForm.vue b/src/components/VContentReport/VReportDescForm.vue
index 3616fedd5..99854fe6f 100644
--- a/src/components/VContentReport/VReportDescForm.vue
+++ b/src/components/VContentReport/VReportDescForm.vue
@@ -1,7 +1,7 @@
<template>
<label class="other-form block" for="description">
<span class="flex flex-row items-center justify-between">
- <span>{{ $t('media-details.content-report.form.other.note') }}</span>
+ <span>{{ $t("media-details.content-report.form.other.note") }}</span>
<span>{{
$t(`media-details.content-report.form.${reason}.sub-label`)
}}</span>
@@ -21,15 +21,15 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { reasons, OTHER, ReportReason } from '~/constants/content-report'
+import { reasons, OTHER, ReportReason } from "~/constants/content-report"
export default defineComponent({
- name: 'VReportDescForm',
+ name: "VReportDescForm",
model: {
- prop: 'content',
- event: 'input',
+ prop: "content",
+ event: "input",
},
props: {
/**
@@ -37,7 +37,7 @@ export default defineComponent({
*/
content: {
type: String,
- default: '',
+ default: "",
},
/**
* the reason selected for reporting the content
@@ -50,7 +50,7 @@ export default defineComponent({
setup(props, { emit }) {
const text = computed({
get: () => props.content,
- set: (val) => emit('input', val),
+ set: (val) => emit("input", val),
})
const isRequired = computed(() => props.reason === OTHER)
diff --git a/src/components/VContentReport/meta/VContentReportPopover.stories.mdx b/src/components/VContentReport/meta/VContentReportPopover.stories.mdx
index 7fb5487cd..94881af32 100644
--- a/src/components/VContentReport/meta/VContentReportPopover.stories.mdx
+++ b/src/components/VContentReport/meta/VContentReportPopover.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VContentReportPopover from '~/components/VContentReport/VContentReportPopover.vue'
+import VContentReportPopover from "~/components/VContentReport/VContentReportPopover.vue"
<Meta
title="Components/VContentReportPopover"
@@ -32,9 +32,9 @@ export const Template = (args) => ({
name="Default"
args={{
media: {
- identifier: '0aff3595-8168-440b-83ff-7a80b65dea42',
- foreign_landing_url: 'https://wordpress.org/openverse/',
- provider: 'provider',
+ identifier: "0aff3595-8168-440b-83ff-7a80b65dea42",
+ foreign_landing_url: "https://wordpress.org/openverse/",
+ provider: "provider",
},
}}
>
diff --git a/src/components/VContentSwitcher/VSearchTypeButton.vue b/src/components/VContentSwitcher/VSearchTypeButton.vue
index e9e26591e..acfa92a9a 100644
--- a/src/components/VContentSwitcher/VSearchTypeButton.vue
+++ b/src/components/VContentSwitcher/VSearchTypeButton.vue
@@ -16,37 +16,37 @@
</VButton>
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { ALL_MEDIA, AUDIO, IMAGE, MODEL_3D, VIDEO } from '~/constants/media'
-import useSearchType from '~/composables/use-search-type'
-import { useI18n } from '~/composables/use-i18n'
+import { ALL_MEDIA, AUDIO, IMAGE, MODEL_3D, VIDEO } from "~/constants/media"
+import useSearchType from "~/composables/use-search-type"
+import { useI18n } from "~/composables/use-i18n"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VButton from '~/components/VButton.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VButton from "~/components/VButton.vue"
-import caretDownIcon from '~/assets/icons/caret-down.svg'
+import caretDownIcon from "~/assets/icons/caret-down.svg"
const labels = {
- [ALL_MEDIA]: 'search-type.all',
- [IMAGE]: 'search-type.image',
- [AUDIO]: 'search-type.audio',
- [VIDEO]: 'search-type.video',
- [MODEL_3D]: 'search-type.model-3d',
+ [ALL_MEDIA]: "search-type.all",
+ [IMAGE]: "search-type.image",
+ [AUDIO]: "search-type.audio",
+ [VIDEO]: "search-type.video",
+ [MODEL_3D]: "search-type.model-3d",
}
/**
* This is the search type button that appears in the header, not on the homepage.
*/
export default defineComponent({
- name: 'VSearchTypeButton',
+ name: "VSearchTypeButton",
components: { VButton, VIcon },
props: {
a11yProps: {
type: Object,
default: () => ({
- 'aria-expanded': false,
- 'aria-haspopup': 'dialog',
+ "aria-expanded": false,
+ "aria-haspopup": "dialog",
}),
},
},
diff --git a/src/components/VContentSwitcher/VSearchTypeItem.vue b/src/components/VContentSwitcher/VSearchTypeItem.vue
index 667124a00..84a66b768 100644
--- a/src/components/VContentSwitcher/VSearchTypeItem.vue
+++ b/src/components/VContentSwitcher/VSearchTypeItem.vue
@@ -10,7 +10,7 @@
<VIcon :icon-path="icon" />
<span>{{ $t(`search-type.${item}`) }}</span>
<VPill v-if="isBeta" class="ms-auto">{{
- $t('search-type.status-beta')
+ $t("search-type.status-beta")
}}</VPill>
</VItem>
</template>
@@ -21,19 +21,19 @@ import {
useContext,
defineComponent,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { BETA, contentStatus, searchPath, SearchType } from '~/constants/media'
-import { isSearchTypeSupported, useSearchStore } from '~/stores/search'
+import { BETA, contentStatus, searchPath, SearchType } from "~/constants/media"
+import { isSearchTypeSupported, useSearchStore } from "~/stores/search"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VItem from '~/components/VItemGroup/VItem.vue'
-import VPill from '~/components/VPill.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VItem from "~/components/VItemGroup/VItem.vue"
+import VPill from "~/components/VPill.vue"
-import type { Dictionary } from 'vue-router/types/router'
+import type { Dictionary } from "vue-router/types/router"
export default defineComponent({
- name: 'VSearchTypeItem',
+ name: "VSearchTypeItem",
components: { VIcon, VItem, VPill },
props: {
/**
@@ -76,8 +76,8 @@ export default defineComponent({
* 'medium' size for mobile screens.
*/
size: {
- type: String as PropType<'small' | 'medium'>,
- default: 'small',
+ type: String as PropType<"small" | "medium">,
+ default: "small",
},
},
setup(props) {
@@ -104,7 +104,7 @@ export default defineComponent({
/**
* The query sets the filters that are applicable for the specific search type.
*/
- const component = computed(() => (props.useLinks ? 'VLink' : undefined))
+ const component = computed(() => (props.useLinks ? "VLink" : undefined))
return {
component,
href,
diff --git a/src/components/VContentSwitcher/VSearchTypePopover.vue b/src/components/VContentSwitcher/VSearchTypePopover.vue
index 778aacebb..8b68f6675 100644
--- a/src/components/VContentSwitcher/VSearchTypePopover.vue
+++ b/src/components/VContentSwitcher/VSearchTypePopover.vue
@@ -23,16 +23,16 @@
</template>
<script lang="ts">
-import { defineComponent, ref } from '@nuxtjs/composition-api'
+import { defineComponent, ref } from "@nuxtjs/composition-api"
-import VPopover from '~/components/VPopover/VPopover.vue'
-import VSearchTypeButton from '~/components/VContentSwitcher/VSearchTypeButton.vue'
-import VSearchTypes from '~/components/VContentSwitcher/VSearchTypes.vue'
+import VPopover from "~/components/VPopover/VPopover.vue"
+import VSearchTypeButton from "~/components/VContentSwitcher/VSearchTypeButton.vue"
+import VSearchTypes from "~/components/VContentSwitcher/VSearchTypes.vue"
-import checkIcon from '~/assets/icons/checkmark.svg'
+import checkIcon from "~/assets/icons/checkmark.svg"
export default defineComponent({
- name: 'VSearchTypePopover',
+ name: "VSearchTypePopover",
components: {
VPopover,
VSearchTypeButton,
diff --git a/src/components/VContentSwitcher/VSearchTypeRadio.vue b/src/components/VContentSwitcher/VSearchTypeRadio.vue
index 297b4c991..189b34e3e 100644
--- a/src/components/VContentSwitcher/VSearchTypeRadio.vue
+++ b/src/components/VContentSwitcher/VSearchTypeRadio.vue
@@ -17,22 +17,22 @@ import {
computed,
defineComponent,
type PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
import {
ALL_MEDIA,
AUDIO,
IMAGE,
type SupportedSearchType,
-} from '~/constants/media'
-import { defineEvent } from '~/types/emits'
+} from "~/constants/media"
+import { defineEvent } from "~/types/emits"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
-import audioIcon from '~/assets/icons/audio-wave.svg'
-import imageIcon from '~/assets/icons/image.svg'
-import allIcon from '~/assets/icons/all-content.svg'
+import audioIcon from "~/assets/icons/audio-wave.svg"
+import imageIcon from "~/assets/icons/image.svg"
+import allIcon from "~/assets/icons/all-content.svg"
const iconMapping = {
[AUDIO]: audioIcon,
@@ -40,13 +40,13 @@ const iconMapping = {
[ALL_MEDIA]: allIcon,
}
const labelMapping = {
- [AUDIO]: 'search-type.audio',
- [IMAGE]: 'search-type.image',
- [ALL_MEDIA]: 'search-type.all',
+ [AUDIO]: "search-type.audio",
+ [IMAGE]: "search-type.image",
+ [ALL_MEDIA]: "search-type.all",
}
export default defineComponent({
- name: 'VSearchTypeRadio',
+ name: "VSearchTypeRadio",
components: { VButton, VIcon },
props: {
/**
@@ -66,7 +66,7 @@ export default defineComponent({
},
setup(props, { emit }) {
const iconPath = computed(() => iconMapping[props.searchType])
- const handleClick = () => emit('select', props.searchType)
+ const handleClick = () => emit("select", props.searchType)
return { iconPath, handleClick, labelMapping }
},
})
diff --git a/src/components/VContentSwitcher/VSearchTypes.vue b/src/components/VContentSwitcher/VSearchTypes.vue
index 666dfcf96..7be6b69bf 100644
--- a/src/components/VContentSwitcher/VSearchTypes.vue
+++ b/src/components/VContentSwitcher/VSearchTypes.vue
@@ -48,17 +48,17 @@ import {
computed,
defineComponent,
type PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import useSearchType from '~/composables/use-search-type'
-import type { SearchType } from '~/constants/media'
-import { defineEvent } from '~/types/emits'
+import useSearchType from "~/composables/use-search-type"
+import type { SearchType } from "~/constants/media"
+import { defineEvent } from "~/types/emits"
-import VItemGroup from '~/components/VItemGroup/VItemGroup.vue'
-import VSearchTypeItem from '~/components/VContentSwitcher/VSearchTypeItem.vue'
+import VItemGroup from "~/components/VItemGroup/VItemGroup.vue"
+import VSearchTypeItem from "~/components/VContentSwitcher/VSearchTypeItem.vue"
export default defineComponent({
- name: 'VSearchTypes',
+ name: "VSearchTypes",
components: { VItemGroup, VSearchTypeItem },
props: {
/**
@@ -66,8 +66,8 @@ export default defineComponent({
* 'medium' size for larger screens.
*/
size: {
- type: String as PropType<'small' | 'medium'>,
- default: 'small',
+ type: String as PropType<"small" | "medium">,
+ default: "small",
},
/**
* Whether to use buttons for search type selection, or links to the specific search type search pages.
@@ -82,21 +82,21 @@ export default defineComponent({
},
setup(props, { emit }) {
const content = useSearchType()
- const bordered = computed(() => props.size === 'medium')
+ const bordered = computed(() => props.size === "medium")
const isActive = (item: SearchType) => item === content.activeType.value
const contentTypeGroups = computed(() => {
const base = [
{
- heading: 'heading',
+ heading: "heading",
items: content.types,
},
]
if (content.additionalTypes.value.length && props.useLinks) {
base.push({
- heading: 'additional',
+ heading: "additional",
items: content.additionalTypes.value,
})
}
@@ -106,7 +106,7 @@ export default defineComponent({
const selectItem = (item: SearchType) => {
content.setActiveType(item)
- emit('select', item)
+ emit("select", item)
}
return {
diff --git a/src/components/VContentSwitcher/meta/VSearchTypeButton.stories.mdx b/src/components/VContentSwitcher/meta/VSearchTypeButton.stories.mdx
index 5b8244e47..2339a857f 100644
--- a/src/components/VContentSwitcher/meta/VSearchTypeButton.stories.mdx
+++ b/src/components/VContentSwitcher/meta/VSearchTypeButton.stories.mdx
@@ -4,13 +4,13 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import allIcon from '~/assets/icons/all-content.svg'
-import audioIcon from '~/assets/icons/audio-content.svg'
-import imageIcon from '~/assets/icons/image-content.svg'
-import videoIcon from '~/assets/icons/video-content.svg'
-import model3dIcon from '~/assets/icons/model-3d.svg'
+import allIcon from "~/assets/icons/all-content.svg"
+import audioIcon from "~/assets/icons/audio-content.svg"
+import imageIcon from "~/assets/icons/image-content.svg"
+import videoIcon from "~/assets/icons/video-content.svg"
+import model3dIcon from "~/assets/icons/model-3d.svg"
export const icons = {
[ALL_MEDIA]: allIcon,
@@ -20,7 +20,7 @@ export const icons = {
[MODEL_3D]: model3dIcon,
}
-import VSearchTypeButton from '~/components/VContentSwitcher/VSearchTypeButton.vue'
+import VSearchTypeButton from "~/components/VContentSwitcher/VSearchTypeButton.vue"
import {
ALL_MEDIA,
AUDIO,
@@ -28,23 +28,23 @@ import {
MODEL_3D,
supportedSearchTypes,
VIDEO,
-} from '~/constants/media'
-import useSearchType from '~/composables/use-search-type'
+} from "~/constants/media"
+import useSearchType from "~/composables/use-search-type"
<Meta
title="Components/VContentSwitcher/VSearchTypeButton"
components={VSearchTypeButton}
argTypes={{
activeItem: {
- defaultValue: 'all',
+ defaultValue: "all",
options: supportedSearchTypes,
- control: 'select',
+ control: "select",
},
pressed: {
- control: 'boolean',
+ control: "boolean",
},
click: {
- action: 'click',
+ action: "click",
},
}}
/>
@@ -55,9 +55,9 @@ export const Template = (args) => ({
setup() {
const searchType = useSearchType()
searchType.setActiveType(args.activeItem)
- const a11yProps = { 'aria-haspopup': 'dialog' }
+ const a11yProps = { "aria-haspopup": "dialog" }
if (args.pressed) {
- a11yProps['aria-expanded'] = true
+ a11yProps["aria-expanded"] = true
}
args.a11yProps = a11yProps
return { args }
@@ -75,7 +75,7 @@ export const Template = (args) => ({
height="480px"
name="Default"
parameters={{
- viewport: { defaultViewport: 'lg' },
+ viewport: { defaultViewport: "lg" },
}}
args={{
activeItem: ALL_MEDIA,
@@ -90,11 +90,11 @@ export const Template = (args) => ({
height="480px"
name="Large with text label"
parameters={{
- viewport: { defaultViewport: 'lx' },
+ viewport: { defaultViewport: "lx" },
}}
args={{
activeItem: ALL_MEDIA,
- a11yProps: { 'aria-pressed': true },
+ a11yProps: { "aria-pressed": true },
}}
>
{Template.bind({})}
diff --git a/src/components/VContentSwitcher/meta/VSearchTypePopover.stories.mdx b/src/components/VContentSwitcher/meta/VSearchTypePopover.stories.mdx
index 7ccb8c9a0..46a0187d7 100644
--- a/src/components/VContentSwitcher/meta/VSearchTypePopover.stories.mdx
+++ b/src/components/VContentSwitcher/meta/VSearchTypePopover.stories.mdx
@@ -4,16 +4,16 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VSearchTypePopover from '~/components/VContentSwitcher/VSearchTypePopover.vue'
+import VSearchTypePopover from "~/components/VContentSwitcher/VSearchTypePopover.vue"
<Meta
title="Components/VContentSwitcher/VSearchTypePopover"
components={VSearchTypePopover}
argTypes={{
select: {
- action: 'select',
+ action: "select",
},
}}
/>
diff --git a/src/components/VContentSwitcher/meta/VSearchTypes.stories.mdx b/src/components/VContentSwitcher/meta/VSearchTypes.stories.mdx
index e2f22b834..84175870f 100644
--- a/src/components/VContentSwitcher/meta/VSearchTypes.stories.mdx
+++ b/src/components/VContentSwitcher/meta/VSearchTypes.stories.mdx
@@ -4,26 +4,26 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VSearchTypes from '~/components/VContentSwitcher/VSearchTypes.vue'
+import VSearchTypes from "~/components/VContentSwitcher/VSearchTypes.vue"
<Meta
title="Components/VContentSwitcher/VSearchTypes"
components={VSearchTypes}
argTypes={{
select: {
- action: 'select',
+ action: "select",
},
size: {
control: {
- type: 'select',
- options: ['small', 'medium'],
+ type: "select",
+ options: ["small", "medium"],
},
},
useLinks: {
control: {
- type: 'boolean',
+ type: "boolean",
},
},
}}
diff --git a/src/components/VContentSwitcherOld/VMobileMenuModal.vue b/src/components/VContentSwitcherOld/VMobileMenuModal.vue
index 1b111dd7d..0628d5800 100644
--- a/src/components/VContentSwitcherOld/VMobileMenuModal.vue
+++ b/src/components/VContentSwitcherOld/VMobileMenuModal.vue
@@ -31,20 +31,20 @@
</template>
<script lang="ts">
-import { computed, defineComponent, ref } from '@nuxtjs/composition-api'
+import { computed, defineComponent, ref } from "@nuxtjs/composition-api"
-import usePages from '~/composables/use-pages'
-import useSearchType from '~/composables/use-search-type'
+import usePages from "~/composables/use-pages"
+import useSearchType from "~/composables/use-search-type"
-import type { SupportedSearchType } from '~/constants/media'
+import type { SupportedSearchType } from "~/constants/media"
-import VModal from '~/components/VModal/VModal.vue'
-import VPageList from '~/components/VHeaderOld/VPageMenu/VPageList.vue'
-import VSearchTypeButtonOld from '~/components/VContentSwitcherOld/VSearchTypeButtonOld.vue'
-import VSearchTypesOld from '~/components/VContentSwitcherOld/VSearchTypesOld.vue'
+import VModal from "~/components/VModal/VModal.vue"
+import VPageList from "~/components/VHeaderOld/VPageMenu/VPageList.vue"
+import VSearchTypeButtonOld from "~/components/VContentSwitcherOld/VSearchTypeButtonOld.vue"
+import VSearchTypesOld from "~/components/VContentSwitcherOld/VSearchTypesOld.vue"
export default defineComponent({
- name: 'VMobileMenuModal',
+ name: "VMobileMenuModal",
components: {
VModal,
VPageList,
@@ -75,7 +75,7 @@ export default defineComponent({
: null
})
- const selectItem = (item: SupportedSearchType) => emit('select', item)
+ const selectItem = (item: SupportedSearchType) => emit("select", item)
const closeMenu = () => nodeRef.value?.close()
diff --git a/src/components/VContentSwitcherOld/VSearchTypeButtonOld.vue b/src/components/VContentSwitcherOld/VSearchTypeButtonOld.vue
index a3ba948cd..8f5ec645d 100644
--- a/src/components/VContentSwitcherOld/VSearchTypeButtonOld.vue
+++ b/src/components/VContentSwitcherOld/VSearchTypeButtonOld.vue
@@ -34,23 +34,23 @@ import {
inject,
PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { ALL_MEDIA, type SearchType } from '~/constants/media'
-import type { ButtonVariant } from '~/types/button'
+import { ALL_MEDIA, type SearchType } from "~/constants/media"
+import type { ButtonVariant } from "~/types/button"
-import useSearchType from '~/composables/use-search-type'
-import { useUiStore } from '~/stores/ui'
+import useSearchType from "~/composables/use-search-type"
+import { useUiStore } from "~/stores/ui"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VButton from '~/components/VButton.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VButton from "~/components/VButton.vue"
-import caretDownIcon from '~/assets/icons/caret-down.svg'
+import caretDownIcon from "~/assets/icons/caret-down.svg"
export default defineComponent({
- name: 'VSearchTypeButtonOld',
+ name: "VSearchTypeButtonOld",
components: { VButton, VIcon },
props: {
a11yProps: {
@@ -62,8 +62,8 @@ export default defineComponent({
default: ALL_MEDIA,
},
type: {
- type: String as PropType<'header' | 'searchbar'>,
- default: 'header',
+ type: String as PropType<"header" | "searchbar">,
+ default: "header",
},
},
setup(props) {
@@ -71,7 +71,7 @@ export default defineComponent({
const uiStore = useUiStore()
- const isHeaderScrolled = inject('isHeaderScrolled', ref(false))
+ const isHeaderScrolled = inject("isHeaderScrolled", ref(false))
const isDesktopLayout = computed(() => uiStore.isDesktopLayout)
@@ -80,34 +80,34 @@ export default defineComponent({
() => isHeaderScrolled.value && !isDesktopLayout.value
)
const sizeClasses = computed(() => {
- if (props.type === 'searchbar') {
- return 'h-12 px-2'
+ if (props.type === "searchbar") {
+ return "h-12 px-2"
} else if (isIconButton.value) {
- return 'w-10 h-10'
+ return "w-10 h-10"
} else {
/**
When there is a caret down icon (on 'md' screens), paddings are balanced,
without it, paddings need to be adjusted.
*/
- return 'ps-2 pe-3 md:px-2'
+ return "ps-2 pe-3 md:px-2"
}
})
const buttonVariant = computed<ButtonVariant>(() => {
- if (props.type === 'searchbar') {
- return 'action-menu'
+ if (props.type === "searchbar") {
+ return "action-menu"
} else {
return isDesktopLayout.value && !isHeaderScrolled.value
- ? 'action-menu-bordered'
- : 'action-menu'
+ ? "action-menu-bordered"
+ : "action-menu"
}
})
const buttonLabel = computed(() => {
return i18n.t(`search-type.${props.activeItem}`)
})
- const isInSearchBar = computed(() => props.type === 'searchbar')
- const isPressed = computed(() => Boolean(props.a11yProps['aria-expanded']))
+ const isInSearchBar = computed(() => props.type === "searchbar")
+ const isPressed = computed(() => Boolean(props.a11yProps["aria-expanded"]))
return {
buttonVariant,
diff --git a/src/components/VContentSwitcherOld/VSearchTypeItemOld.vue b/src/components/VContentSwitcherOld/VSearchTypeItemOld.vue
index 1c0213a5f..763ef145f 100644
--- a/src/components/VContentSwitcherOld/VSearchTypeItemOld.vue
+++ b/src/components/VContentSwitcherOld/VSearchTypeItemOld.vue
@@ -10,21 +10,21 @@
<VIcon :icon-path="icon" />
<span class="font-semibold">{{ $t(`search-type.${item}`) }}</span>
<VPill v-if="isBeta" class="ms-auto">{{
- $t('search-type.status-beta')
+ $t("search-type.status-beta")
}}</VPill>
</div>
</VItem>
</template>
<script>
-import { computed, useContext, defineComponent } from '@nuxtjs/composition-api'
+import { computed, useContext, defineComponent } from "@nuxtjs/composition-api"
-import { ALL_MEDIA, BETA, contentStatus } from '~/constants/media'
-import { useSearchStore } from '~/stores/search'
+import { ALL_MEDIA, BETA, contentStatus } from "~/constants/media"
+import { useSearchStore } from "~/stores/search"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VItem from '~/components/VItemGroup/VItem.vue'
-import VPill from '~/components/VPill.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VItem from "~/components/VItemGroup/VItem.vue"
+import VPill from "~/components/VPill.vue"
/** @typedef {import('@nuxtjs/composition-api').ExtractPropTypes<typeof propTypes>} Props */
const propTypes = {
@@ -35,7 +35,7 @@ const propTypes = {
useLinks: { type: Boolean, default: true },
}
export default defineComponent({
- name: 'VSearchTypeItemOld',
+ name: "VSearchTypeItemOld",
components: { VIcon, VItem, VPill },
props: propTypes,
setup(props) {
@@ -52,9 +52,9 @@ export default defineComponent({
return {}
}
return {
- as: 'VLink',
+ as: "VLink",
href: app.localePath({
- path: `/search/${props.item === ALL_MEDIA ? '' : props.item}`,
+ path: `/search/${props.item === ALL_MEDIA ? "" : props.item}`,
query: searchStore.computeQueryParams(props.item),
}),
}
diff --git a/src/components/VContentSwitcherOld/VSearchTypePopoverOld.vue b/src/components/VContentSwitcherOld/VSearchTypePopoverOld.vue
index 85bf0e995..1cc9f822c 100644
--- a/src/components/VContentSwitcherOld/VSearchTypePopoverOld.vue
+++ b/src/components/VContentSwitcherOld/VSearchTypePopoverOld.vue
@@ -30,27 +30,27 @@ import {
defineComponent,
PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import type { SearchType } from '~/constants/media'
-import { defineEvent } from '~/types/emits'
+import type { SearchType } from "~/constants/media"
+import { defineEvent } from "~/types/emits"
-import VPopover from '~/components/VPopover/VPopover.vue'
-import VSearchTypeButtonOld from '~/components/VContentSwitcherOld/VSearchTypeButtonOld.vue'
-import VSearchTypesOld from '~/components/VContentSwitcherOld/VSearchTypesOld.vue'
+import VPopover from "~/components/VPopover/VPopover.vue"
+import VSearchTypeButtonOld from "~/components/VContentSwitcherOld/VSearchTypeButtonOld.vue"
+import VSearchTypesOld from "~/components/VContentSwitcherOld/VSearchTypesOld.vue"
-import checkIcon from '~/assets/icons/checkmark.svg'
+import checkIcon from "~/assets/icons/checkmark.svg"
export default defineComponent({
- name: 'VSearchTypePopoverOld',
+ name: "VSearchTypePopoverOld",
components: {
VSearchTypeButtonOld,
VPopover,
VSearchTypesOld,
},
model: {
- prop: 'activeItem',
- event: 'select',
+ prop: "activeItem",
+ event: "select",
},
props: {
activeItem: {
@@ -58,8 +58,8 @@ export default defineComponent({
required: true,
},
placement: {
- type: String as PropType<'header' | 'searchbar'>,
- default: 'header',
+ type: String as PropType<"header" | "searchbar">,
+ default: "header",
},
},
emits: {
@@ -72,7 +72,7 @@ export default defineComponent({
* When in the searchbar, content switcher button has a border when the
* search bar group is hovered on.
*/
- const isInSearchBar = computed(() => props.placement === 'searchbar')
+ const isInSearchBar = computed(() => props.placement === "searchbar")
/**
* Only the contentMenuPopover needs to be closed programmatically
@@ -82,7 +82,7 @@ export default defineComponent({
}
const selectItem = (item: SearchType) => {
- emit('select', item)
+ emit("select", item)
}
return {
diff --git a/src/components/VContentSwitcherOld/VSearchTypesOld.vue b/src/components/VContentSwitcherOld/VSearchTypesOld.vue
index 3297baafa..1137fc1aa 100644
--- a/src/components/VContentSwitcherOld/VSearchTypesOld.vue
+++ b/src/components/VContentSwitcherOld/VSearchTypesOld.vue
@@ -36,17 +36,17 @@
</VItemGroup>
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { SearchType } from '~/constants/media'
-import useSearchType from '~/composables/use-search-type'
-import { defineEvent } from '~/types/emits'
+import type { SearchType } from "~/constants/media"
+import useSearchType from "~/composables/use-search-type"
+import { defineEvent } from "~/types/emits"
-import VItemGroup from '~/components/VItemGroup/VItemGroup.vue'
-import VSearchTypeItemOld from '~/components/VContentSwitcherOld/VSearchTypeItemOld.vue'
+import VItemGroup from "~/components/VItemGroup/VItemGroup.vue"
+import VSearchTypeItemOld from "~/components/VContentSwitcherOld/VSearchTypeItemOld.vue"
export default defineComponent({
- name: 'VSearchTypesOld',
+ name: "VSearchTypesOld",
components: { VItemGroup, VSearchTypeItemOld },
props: {
/**
@@ -54,8 +54,8 @@ export default defineComponent({
* 'medium' size for larger screens.
*/
size: {
- type: String as PropType<'small' | 'medium'>,
- default: 'small',
+ type: String as PropType<"small" | "medium">,
+ default: "small",
},
activeItem: {
type: String as PropType<SearchType>,
@@ -75,14 +75,14 @@ export default defineComponent({
const contentTypeGroups = computed(() => {
const base = [
{
- heading: 'heading',
+ heading: "heading",
items: content.types,
},
]
if (content.additionalTypes.value.length && props.useLinks) {
base.push({
- heading: 'additional',
+ heading: "additional",
items: content.additionalTypes.value,
})
}
@@ -90,9 +90,9 @@ export default defineComponent({
return base
})
- const bordered = computed(() => props.size === 'small')
+ const bordered = computed(() => props.size === "small")
const handleClick = (item) => {
- emit('select', item)
+ emit("select", item)
}
return {
content,
diff --git a/src/components/VContentSwitcherOld/meta/VSearchTypePopoverOld.stories.mdx b/src/components/VContentSwitcherOld/meta/VSearchTypePopoverOld.stories.mdx
index 973ab7aba..cfeb53eaa 100644
--- a/src/components/VContentSwitcherOld/meta/VSearchTypePopoverOld.stories.mdx
+++ b/src/components/VContentSwitcherOld/meta/VSearchTypePopoverOld.stories.mdx
@@ -4,18 +4,18 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import { ref } from '@nuxtjs/composition-api'
+import { ref } from "@nuxtjs/composition-api"
-import VSearchTypePopoverOld from '~/components/VContentSwitcherOld/VSearchTypePopoverOld.vue'
+import VSearchTypePopoverOld from "~/components/VContentSwitcherOld/VSearchTypePopoverOld.vue"
<Meta
title="Components/VSearchTypePopoverOld"
components={VSearchTypePopoverOld}
argTypes={{
select: {
- action: 'select',
+ action: "select",
},
}}
/>
@@ -53,7 +53,7 @@ export const vModelTemplate = () => ({
`,
components: { VSearchTypePopoverOld },
setup() {
- const item = ref('all')
+ const item = ref("all")
return { item }
},
})
diff --git a/src/components/VCopyButton.vue b/src/components/VCopyButton.vue
index a47bc4515..7475e5291 100644
--- a/src/components/VCopyButton.vue
+++ b/src/components/VCopyButton.vue
@@ -8,28 +8,28 @@
:data-clipboard-target="el"
>
<span v-if="!success">
- {{ $t('media-details.reuse.copy-license.copy-text') }}
+ {{ $t("media-details.reuse.copy-license.copy-text") }}
</span>
<span v-else>
- {{ $t('media-details.reuse.copy-license.copied') }}
+ {{ $t("media-details.reuse.copy-license.copied") }}
</span>
</VButton>
</template>
<script lang="ts">
-import Clipboard from 'clipboard'
+import Clipboard from "clipboard"
import {
defineComponent,
onBeforeUnmount,
onMounted,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import VButton from '~/components/VButton.vue'
+import VButton from "~/components/VButton.vue"
export default defineComponent({
- name: 'VCopyButton',
+ name: "VCopyButton",
components: { VButton },
props: {
el: {
@@ -41,7 +41,7 @@ export default defineComponent({
required: true,
},
},
- emits: ['copied', 'copy-failed'],
+ emits: ["copied", "copy-failed"],
setup(props, { emit }) {
const clipboard = ref<Clipboard | null>(null)
const success = ref(false)
@@ -55,7 +55,7 @@ export default defineComponent({
const onCopySuccess = (e: Clipboard.Event) => {
success.value = true
- emit('copied', { content: e.text })
+ emit("copied", { content: e.text })
setTimeout(() => {
success.value = false
@@ -67,7 +67,7 @@ export default defineComponent({
setFocusOnButton()
}
const onCopyError = (e: Clipboard.Event) => {
- emit('copy-failed')
+ emit("copy-failed")
e.clearSelection()
/* Restore focus on the button */
@@ -76,8 +76,8 @@ export default defineComponent({
onMounted(() => {
clipboard.value = new Clipboard(`#${props.id}`)
- clipboard.value.on('success', onCopySuccess)
- clipboard.value.on('error', onCopyError)
+ clipboard.value.on("success", onCopySuccess)
+ clipboard.value.on("error", onCopyError)
})
onBeforeUnmount(() => clipboard.value?.destroy())
diff --git a/src/components/VErrorSection/VErrorImage.vue b/src/components/VErrorSection/VErrorImage.vue
index 26f8a12d3..a47f0943d 100644
--- a/src/components/VErrorSection/VErrorImage.vue
+++ b/src/components/VErrorSection/VErrorImage.vue
@@ -12,14 +12,14 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { License, LicenseVersion } from '~/constants/license'
-import type { ErrorCode } from '~/constants/errors'
-import { AttributableMedia, getAttribution } from '~/utils/attribution-html'
-import { useI18n } from '~/composables/use-i18n'
+import type { License, LicenseVersion } from "~/constants/license"
+import type { ErrorCode } from "~/constants/errors"
+import { AttributableMedia, getAttribution } from "~/utils/attribution-html"
+import { useI18n } from "~/composables/use-i18n"
-import imageInfo from '~/assets/error_images/image_info.json'
+import imageInfo from "~/assets/error_images/image_info.json"
interface ErrorImage extends AttributableMedia {
src: string
@@ -32,7 +32,7 @@ interface ErrorImage extends AttributableMedia {
* results or a server error.
*/
export default defineComponent({
- name: 'VErrorImage',
+ name: "VErrorImage",
props: {
/**
* the code of the error, used to identify and render the appropriate image
diff --git a/src/components/VErrorSection/VErrorSection.vue b/src/components/VErrorSection/VErrorSection.vue
index 0fd2dc8d3..0402bbdb6 100644
--- a/src/components/VErrorSection/VErrorSection.vue
+++ b/src/components/VErrorSection/VErrorSection.vue
@@ -16,6 +16,6 @@
* This component sets the layout for showing error messages.
*/
export default {
- name: 'VErrorSection',
+ name: "VErrorSection",
}
</script>
diff --git a/src/components/VErrorSection/VNoResults.vue b/src/components/VErrorSection/VNoResults.vue
index 0e54322a4..7c38b5c4a 100644
--- a/src/components/VErrorSection/VNoResults.vue
+++ b/src/components/VErrorSection/VNoResults.vue
@@ -1,27 +1,27 @@
<template>
<div class="no-results text-center md:text-left">
<h1 class="break-words text-4xl md:text-6xl">
- {{ $t('no-results.heading', { query: query.q }) }}
+ {{ $t("no-results.heading", { query: query.q }) }}
</h1>
<h2
class="mt-10 text-base font-normal md:mt-16 md:text-3xl md:font-semibold"
>
- {{ $t('no-results.alternatives') }}
+ {{ $t("no-results.alternatives") }}
</h2>
<VExternalSourceList class="mt-4 md:mt-6" :type="type" :query="query" />
</div>
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { MediaType } from '~/constants/media'
-import type { ApiQueryParams } from '~/utils/search-query-transform'
+import type { MediaType } from "~/constants/media"
+import type { ApiQueryParams } from "~/utils/search-query-transform"
-import VExternalSourceList from '~/components/VExternalSearch/VExternalSourceList.vue'
+import VExternalSourceList from "~/components/VExternalSearch/VExternalSourceList.vue"
export default defineComponent({
- name: 'VNoResults',
+ name: "VNoResults",
components: { VExternalSourceList },
props: {
type: {
diff --git a/src/components/VErrorSection/VServerTimeout.vue b/src/components/VErrorSection/VServerTimeout.vue
index d4d022f85..1bf49d2be 100644
--- a/src/components/VErrorSection/VServerTimeout.vue
+++ b/src/components/VErrorSection/VServerTimeout.vue
@@ -1,11 +1,11 @@
<template>
<div class="server-timeout">
- <h4 class="text-5xl">{{ $t('server-timeout.heading') }}</h4>
+ <h4 class="text-5xl">{{ $t("server-timeout.heading") }}</h4>
</div>
</template>
<script>
export default {
- name: 'VServerTimeout',
+ name: "VServerTimeout",
}
</script>
diff --git a/src/components/VErrorSection/meta/VErrorSection.stories.mdx b/src/components/VErrorSection/meta/VErrorSection.stories.mdx
index 9db5e943f..1a0fc0cab 100644
--- a/src/components/VErrorSection/meta/VErrorSection.stories.mdx
+++ b/src/components/VErrorSection/meta/VErrorSection.stories.mdx
@@ -4,14 +4,14 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VErrorSection from '~/components/VErrorSection/VErrorSection.vue'
-import VErrorImage from '~/components/VErrorSection/VErrorImage.vue'
-import VNoResults from '~/components/VErrorSection/VNoResults.vue'
-import VServerTimeout from '~/components/VErrorSection/VServerTimeout.vue'
+import VErrorSection from "~/components/VErrorSection/VErrorSection.vue"
+import VErrorImage from "~/components/VErrorSection/VErrorImage.vue"
+import VNoResults from "~/components/VErrorSection/VNoResults.vue"
+import VServerTimeout from "~/components/VErrorSection/VServerTimeout.vue"
-import { NO_RESULT, SERVER_TIMEOUT } from '~/constants/errors'
+import { NO_RESULT, SERVER_TIMEOUT } from "~/constants/errors"
<Meta title="Components/VErrorSection" component={VErrorSection} />
@@ -45,13 +45,13 @@ export const NoResultsTemplate = (args) => ({
name="No result"
args={{
errorCode: NO_RESULT,
- type: 'image',
+ type: "image",
query: {
- license: '',
- license_type: '',
+ license: "",
+ license_type: "",
mature: false,
- q: 'sad person',
- searchBy: '',
+ q: "sad person",
+ searchBy: "",
},
}}
>
diff --git a/src/components/VExternalSearch/VExternalSearchForm.vue b/src/components/VExternalSearch/VExternalSearchForm.vue
index a9dde1ae0..3688ddcf6 100644
--- a/src/components/VExternalSearch/VExternalSearchForm.vue
+++ b/src/components/VExternalSearch/VExternalSearchForm.vue
@@ -47,17 +47,17 @@ import {
defineComponent,
PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import type { MediaType } from '~/constants/media'
-import type { ApiQueryParams } from '~/utils/search-query-transform'
-import { getFocusableElements } from '~/utils/focus-management'
-import { defineEvent } from '~/types/emits'
+import type { MediaType } from "~/constants/media"
+import type { ApiQueryParams } from "~/utils/search-query-transform"
+import { getFocusableElements } from "~/utils/focus-management"
+import { defineEvent } from "~/types/emits"
-import VExternalSourceList from './VExternalSourceList.vue'
+import VExternalSourceList from "./VExternalSourceList.vue"
export default defineComponent({
- name: 'VExternalSearchForm',
+ name: "VExternalSearchForm",
components: {
VExternalSourceList,
},
@@ -85,7 +85,7 @@ export default defineComponent({
const handleTab = (event: KeyboardEvent) => {
if (event.target === lastFocusableElement.value) {
- emit('tab', event)
+ emit("tab", event)
}
}
return {
diff --git a/src/components/VExternalSearch/VExternalSourceList.vue b/src/components/VExternalSearch/VExternalSourceList.vue
index 0bda9a805..d6d438348 100644
--- a/src/components/VExternalSearch/VExternalSourceList.vue
+++ b/src/components/VExternalSearch/VExternalSourceList.vue
@@ -13,7 +13,7 @@
variant="action-menu-bordered"
size="disabled"
class="caption-regular justify-between py-1 px-3 text-dark-charcoal pe-2"
- >{{ $t('external-sources.button').toString() }}
+ >{{ $t("external-sources.button").toString() }}
<VIcon
class="text-dark-charcoal-40 ms-1"
:class="a11yProps['aria-expanded'] ? 'rotate-180' : 'rotate-0'"
@@ -32,10 +32,10 @@
@click="close"
/>
<h2 class="description-bold mb-2 px-4 pt-5 text-start">
- {{ $t('external-sources.title') }}
+ {{ $t("external-sources.title") }}
</h2>
<p class="caption-regular mb-4 px-4 text-start">
- {{ $t('external-sources.caption', { openverse: 'Openverse' }) }}
+ {{ $t("external-sources.caption", { openverse: "Openverse" }) }}
</p>
<VButton
v-for="source in sources"
@@ -60,27 +60,27 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { getAdditionalSources } from '~/utils/get-additional-sources'
-import type { ApiQueryParams } from '~/utils/search-query-transform'
-import type { MediaType } from '~/constants/media'
+import { getAdditionalSources } from "~/utils/get-additional-sources"
+import type { ApiQueryParams } from "~/utils/search-query-transform"
+import type { MediaType } from "~/constants/media"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
-import VPopover from '~/components/VPopover/VPopover.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
+import VPopover from "~/components/VPopover/VPopover.vue"
-import externalLinkIcon from '~/assets/icons/external-link.svg'
-import caretDownIcon from '~/assets/icons/caret-down.svg'
-import closeSmallIcon from '~/assets/icons/close-small.svg'
+import externalLinkIcon from "~/assets/icons/external-link.svg"
+import caretDownIcon from "~/assets/icons/caret-down.svg"
+import closeSmallIcon from "~/assets/icons/close-small.svg"
/**
* This component renders a list of pre-populated links to additional sources
* when there are insufficient or zero search results.
*/
export default defineComponent({
- name: 'VExternalSourceList',
+ name: "VExternalSourceList",
components: { VButton, VIcon, VIconButton, VPopover },
props: {
/**
diff --git a/src/components/VExternalSearch/meta/VExternalSourceList.stories.mdx b/src/components/VExternalSearch/meta/VExternalSourceList.stories.mdx
index f34ba7a46..55f0643d1 100644
--- a/src/components/VExternalSearch/meta/VExternalSourceList.stories.mdx
+++ b/src/components/VExternalSearch/meta/VExternalSourceList.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VExternalSourceList from '~/components/VExternalSearch/VExternalSourceList.vue'
+import VExternalSourceList from "~/components/VExternalSearch/VExternalSourceList.vue"
<Meta title="Components/VExternalSourceList" component={VExternalSourceList} />
@@ -30,8 +30,8 @@ export const Template = (args) => ({
<Story
name="Images"
args={{
- type: 'image',
- query: { q: 'cat' },
+ type: "image",
+ query: { q: "cat" },
}}
>
{Template.bind({})}
@@ -44,8 +44,8 @@ export const Template = (args) => ({
<Story
name="Audio"
args={{
- type: 'audio',
- query: { q: 'cat' },
+ type: "audio",
+ query: { q: "cat" },
}}
>
{Template.bind({})}
@@ -58,8 +58,8 @@ export const Template = (args) => ({
<Story
name="Video"
args={{
- type: 'video',
- query: { q: 'cat' },
+ type: "video",
+ query: { q: "cat" },
}}
>
{Template.bind({})}
@@ -72,8 +72,8 @@ export const Template = (args) => ({
<Story
name="3D models"
args={{
- type: 'model-3d',
- query: { q: 'cat' },
+ type: "model-3d",
+ query: { q: "cat" },
}}
>
{Template.bind({})}
diff --git a/src/components/VFilters/VFilterChecklist.vue b/src/components/VFilters/VFilterChecklist.vue
index 5e0c7ea57..9baa315f8 100644
--- a/src/components/VFilters/VFilterChecklist.vue
+++ b/src/components/VFilters/VFilterChecklist.vue
@@ -57,24 +57,24 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { useSearchStore } from '~/stores/search'
-import { useI18n } from '~/composables/use-i18n'
-import type { NonMatureFilterCategory, FilterItem } from '~/constants/filters'
-import { defineEvent } from '~/types/emits'
-import { getElements } from '~/utils/license'
+import { useSearchStore } from "~/stores/search"
+import { useI18n } from "~/composables/use-i18n"
+import type { NonMatureFilterCategory, FilterItem } from "~/constants/filters"
+import { defineEvent } from "~/types/emits"
+import { getElements } from "~/utils/license"
-import VLicenseExplanation from '~/components/VFilters/VLicenseExplanation.vue'
-import VCheckbox from '~/components/VCheckbox/VCheckbox.vue'
-import VLicense from '~/components/VLicense/VLicense.vue'
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
-import VPopover from '~/components/VPopover/VPopover.vue'
+import VLicenseExplanation from "~/components/VFilters/VLicenseExplanation.vue"
+import VCheckbox from "~/components/VCheckbox/VCheckbox.vue"
+import VLicense from "~/components/VLicense/VLicense.vue"
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
+import VPopover from "~/components/VPopover/VPopover.vue"
-import helpIcon from '~/assets/icons/help.svg'
-import closeSmallIcon from '~/assets/icons/close-small.svg'
+import helpIcon from "~/assets/icons/help.svg"
+import closeSmallIcon from "~/assets/icons/close-small.svg"
type toggleFilterPayload = {
filterType: NonMatureFilterCategory
@@ -82,7 +82,7 @@ type toggleFilterPayload = {
}
export default defineComponent({
- name: 'FilterCheckList',
+ name: "FilterCheckList",
components: {
VCheckbox,
VButton,
@@ -110,34 +110,34 @@ export default defineComponent({
},
},
emits: {
- 'toggle-filter': defineEvent<[toggleFilterPayload]>(),
+ "toggle-filter": defineEvent<[toggleFilterPayload]>(),
},
setup(props, { emit }) {
const i18n = useI18n()
const itemName = computed(() => {
- return props.filterType === 'searchBy'
- ? i18n.t('filters.search-by.title')
+ return props.filterType === "searchBy"
+ ? i18n.t("filters.search-by.title")
: props.title
})
const itemLabel = (item: FilterItem) =>
- ['audioProviders', 'imageProviders'].indexOf(props.filterType) > -1
+ ["audioProviders", "imageProviders"].indexOf(props.filterType) > -1
? item.name
: i18n.t(item.name)
const onValueChange = ({ value }: { value: string }) => {
- emit('toggle-filter', {
+ emit("toggle-filter", {
code: value,
filterType: props.filterType,
})
}
const getLicenseExplanationCloseAria = (license) => {
- const elements = getElements(license).filter((icon) => icon !== 'cc')
+ const elements = getElements(license).filter((icon) => icon !== "cc")
const descriptions = elements
.map((element) => i18n.t(`browse-page.license-description.${element}`))
- .join(' ')
- const close = i18n.t('modal.close-named', {
- name: i18n.t('browse-page.aria.license-explanation'),
+ .join(" ")
+ const close = i18n.t("modal.close-named", {
+ name: i18n.t("browse-page.aria.license-explanation"),
})
return `${descriptions} - ${close}`
}
diff --git a/src/components/VFilters/VLicenseExplanation.vue b/src/components/VFilters/VLicenseExplanation.vue
index 1fb0bcec8..9feaaf19a 100644
--- a/src/components/VFilters/VLicenseExplanation.vue
+++ b/src/components/VFilters/VLicenseExplanation.vue
@@ -2,10 +2,10 @@
<div class="license-explanation w-70 max-w-xs p-6">
<h5 class="text-base font-semibold">
<template v-if="isLicense(license)">{{
- $t('filters.license-explanation.license-definition')
+ $t("filters.license-explanation.license-definition")
}}</template>
<template v-else>{{
- $t('filters.license-explanation.mark-definition', {
+ $t("filters.license-explanation.mark-definition", {
mark: license.toUpperCase(),
})
}}</template>
@@ -27,7 +27,7 @@
>
<template #read-more>
<VLink :href="`${getLicenseUrl(license)}`">{{
- $t('filters.license-explanation.more.read-more')
+ $t("filters.license-explanation.more.read-more")
}}</VLink>
</template>
<template #mark>{{ license.toUpperCase() }}</template>
@@ -36,21 +36,21 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import { getLicenseUrl, isLicense } from '~/utils/license'
+import { getLicenseUrl, isLicense } from "~/utils/license"
-import type { License } from '~/constants/license'
+import type { License } from "~/constants/license"
-import VLicenseElements from '~/components/VLicense/VLicenseElements.vue'
-import VLink from '~/components/VLink.vue'
+import VLicenseElements from "~/components/VLicense/VLicenseElements.vue"
+import VLink from "~/components/VLink.vue"
/**
* Renders the explanation of the license passed to it by breaking it down to
* its constituent clauses.
*/
export default defineComponent({
- name: 'VLicenseExplanation',
+ name: "VLicenseExplanation",
components: {
VLicenseElements,
VLink,
diff --git a/src/components/VFilters/VSearchGridFilter.vue b/src/components/VFilters/VSearchGridFilter.vue
index b18a31005..e211aae37 100644
--- a/src/components/VFilters/VSearchGridFilter.vue
+++ b/src/components/VFilters/VSearchGridFilter.vue
@@ -5,7 +5,7 @@
class="relative mb-6 flex items-center justify-between"
>
<h4 id="filters-heading" class="caption-bold uppercase">
- {{ $t('filter-list.filter-by') }}
+ {{ $t("filter-list.filter-by") }}
</h4>
<VButton
v-show="isAnyFilterApplied"
@@ -15,7 +15,7 @@
@click="clearFilters"
@keydown.shift.tab.exact="focusFilterButton"
>
- {{ $t('filter-list.clear') }}
+ {{ $t("filter-list.clear") }}
</VButton>
</header>
<form
@@ -38,7 +38,7 @@
class="flex justify-between md:hidden"
>
<VButton variant="primary" @click="$emit('close')">
- {{ $t('filter-list.show') }}
+ {{ $t("filter-list.show") }}
</VButton>
</footer>
</section>
@@ -53,21 +53,21 @@ import {
useRoute,
useRouter,
watch,
-} from '@nuxtjs/composition-api'
-import { kebab } from 'case'
+} from "@nuxtjs/composition-api"
+import { kebab } from "case"
-import { useSearchStore } from '~/stores/search'
-import { areQueriesEqual } from '~/utils/search-query-transform'
-import { Focus, focusIn, getFocusableElements } from '~/utils/focus-management'
-import type { NonMatureFilterCategory } from '~/constants/filters'
-import { useFocusFilters } from '~/composables/use-focus-filters'
-import { defineEvent } from '~/types/emits'
+import { useSearchStore } from "~/stores/search"
+import { areQueriesEqual } from "~/utils/search-query-transform"
+import { Focus, focusIn, getFocusableElements } from "~/utils/focus-management"
+import type { NonMatureFilterCategory } from "~/constants/filters"
+import { useFocusFilters } from "~/composables/use-focus-filters"
+import { defineEvent } from "~/types/emits"
-import VFilterChecklist from '~/components/VFilters/VFilterChecklist.vue'
-import VButton from '~/components/VButton.vue'
+import VFilterChecklist from "~/components/VFilters/VFilterChecklist.vue"
+import VButton from "~/components/VButton.vue"
export default defineComponent({
- name: 'VSearchGridFilter',
+ name: "VSearchGridFilter",
components: {
VButton,
VFilterChecklist,
@@ -109,8 +109,8 @@ export default defineComponent({
() => Object.keys(filters.value) as NonMatureFilterCategory[]
)
const filterTypeTitle = (filterType: string) =>
- filterType === 'searchBy'
- ? ''
+ filterType === "searchBy"
+ ? ""
: i18n.t(`filters.${kebab(filterType)}.title`)
/**
@@ -163,7 +163,7 @@ export default defineComponent({
if (!props.changeTabOrder) return
if (lastFocusableElement.value === event.target) {
event.preventDefault()
- focusIn(document.querySelector('main'), Focus.First)
+ focusIn(document.querySelector("main"), Focus.First)
}
}
/**
diff --git a/src/components/VFilters/meta/VLicenseExplanation.stories.mdx b/src/components/VFilters/meta/VLicenseExplanation.stories.mdx
index 0490c6bb1..7f630fc2f 100644
--- a/src/components/VFilters/meta/VLicenseExplanation.stories.mdx
+++ b/src/components/VFilters/meta/VLicenseExplanation.stories.mdx
@@ -4,11 +4,11 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VLicenseExplanation from '~/components/VFilters/VLicenseExplanation.vue'
+import VLicenseExplanation from "~/components/VFilters/VLicenseExplanation.vue"
-import { ALL_LICENSES } from '~/constants/license'
+import { ALL_LICENSES } from "~/constants/license"
<Meta
title="Components/VLicenseExplanation"
@@ -17,7 +17,7 @@ import { ALL_LICENSES } from '~/constants/license'
license: {
defaultValue: ALL_LICENSES[0],
options: ALL_LICENSES,
- control: 'select',
+ control: "select",
},
}}
/>
diff --git a/src/components/VFooter/VFooter.vue b/src/components/VFooter/VFooter.vue
index 3b06e4a50..95c99c2c6 100644
--- a/src/components/VFooter/VFooter.vue
+++ b/src/components/VFooter/VFooter.vue
@@ -35,30 +35,30 @@ import {
defineComponent,
PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { CSSProperties } from '@vue/runtime-dom'
+import { CSSProperties } from "@vue/runtime-dom"
-import usePages from '~/composables/use-pages'
-import useResizeObserver from '~/composables/use-resize-observer'
+import usePages from "~/composables/use-pages"
+import useResizeObserver from "~/composables/use-resize-observer"
-import { SCREEN_SIZES } from '~/constants/screens'
+import { SCREEN_SIZES } from "~/constants/screens"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import type { SelectFieldProps } from '~/components/VSelectField/VSelectField.vue'
-import VLink from '~/components/VLink.vue'
-import VBrand from '~/components/VBrand/VBrand.vue'
-import VLanguageSelect from '~/components/VLanguageSelect/VLanguageSelect.vue'
-import VPageLinks from '~/components/VHeader/VPageLinks.vue'
-import VWordPressLink from '~/components/VHeader/VWordPressLink.vue'
+import type { SelectFieldProps } from "~/components/VSelectField/VSelectField.vue"
+import VLink from "~/components/VLink.vue"
+import VBrand from "~/components/VBrand/VBrand.vue"
+import VLanguageSelect from "~/components/VLanguageSelect/VLanguageSelect.vue"
+import VPageLinks from "~/components/VHeader/VPageLinks.vue"
+import VWordPressLink from "~/components/VHeader/VWordPressLink.vue"
/**
* The footer is the section displayed at the bottom of a page. It can contain
* some branding, links to other pages and an option to change the language.
*/
export default defineComponent({
- name: 'VFooter',
+ name: "VFooter",
components: {
VWordPressLink,
VPageLinks,
@@ -73,7 +73,7 @@ export default defineComponent({
* displayed.
*/
mode: {
- type: String as PropType<'internal' | 'content'>,
+ type: String as PropType<"internal" | "content">,
required: false,
},
languageProps: {
@@ -85,7 +85,7 @@ export default defineComponent({
const uiStore = useUiStore()
const { all: allPages, current: currentPage } = usePages(true)
- const isContentMode = computed(() => props.mode === 'content')
+ const isContentMode = computed(() => props.mode === "content")
/** JS-based responsiveness */
const footerEl = ref<HTMLElement | null>(null)
@@ -106,7 +106,7 @@ export default defineComponent({
)
const linkColumnHeight = computed<CSSProperties>(() => ({
- '--link-col-height': Math.ceil(Object.keys(allPages).length / 2),
+ "--link-col-height": Math.ceil(Object.keys(allPages).length / 2),
}))
return {
diff --git a/src/components/VFooter/meta/VFooter.stories.mdx b/src/components/VFooter/meta/VFooter.stories.mdx
index 5301c7870..963c73143 100644
--- a/src/components/VFooter/meta/VFooter.stories.mdx
+++ b/src/components/VFooter/meta/VFooter.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VFooter from '~/components/VFooter/VFooter.vue'
+import VFooter from "~/components/VFooter/VFooter.vue"
<Meta title="Components/VFooter" component={VFooter} />
@@ -33,8 +33,8 @@ It contains links to internal pages.
<Story
name="Content"
height="200px"
- parameters={{ layout: 'fullscreen' }}
- args={{ mode: 'content' }}
+ parameters={{ layout: "fullscreen" }}
+ args={{ mode: "content" }}
>
{Template.bind({})}
</Story>
@@ -49,8 +49,8 @@ internal pages move to the header instead.
<Story
name="Internal"
height="200px"
- parameters={{ layout: 'fullscreen' }}
- args={{ mode: 'internal' }}
+ parameters={{ layout: "fullscreen" }}
+ args={{ mode: "internal" }}
>
{Template.bind({})}
</Story>
diff --git a/src/components/VFourOhFour.vue b/src/components/VFourOhFour.vue
index f49849276..78d0b2bae 100644
--- a/src/components/VFourOhFour.vue
+++ b/src/components/VFourOhFour.vue
@@ -24,7 +24,7 @@
<div class="spacer grow" />
<div class="z-10 grow-[3] space-y-4 lg:space-y-6">
<h1 class="heading-5 lg:heading-2 mb-6 lg:mb-10 lg:leading-tight">
- {{ $t('404.title') }}
+ {{ $t("404.title") }}
</h1>
<p class="label-bold lg:heading-6">
<i18n path="404.main">
@@ -46,30 +46,30 @@
</template>
<script>
-import { defineComponent, useContext, useRouter } from '@nuxtjs/composition-api'
+import { defineComponent, useContext, useRouter } from "@nuxtjs/composition-api"
-import { useSearchStore } from '~/stores/search'
+import { useSearchStore } from "~/stores/search"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import { ALL_MEDIA, searchPath } from '~/constants/media'
+import { ALL_MEDIA, searchPath } from "~/constants/media"
-import VStandaloneSearchBar from '~/components/VHeader/VSearchBar/VStandaloneSearchBar.vue'
-import VLink from '~/components/VLink.vue'
-import VBrand from '~/components/VBrand/VBrand.vue'
-import VFooter from '~/components/VFooter/VFooter.vue'
+import VStandaloneSearchBar from "~/components/VHeader/VSearchBar/VStandaloneSearchBar.vue"
+import VLink from "~/components/VLink.vue"
+import VBrand from "~/components/VBrand/VBrand.vue"
+import VFooter from "~/components/VFooter/VFooter.vue"
-import Oops from '~/assets/oops.svg'
+import Oops from "~/assets/oops.svg"
export default defineComponent({
- name: 'VFourOhFour',
+ name: "VFourOhFour",
components: {
VLink,
VStandaloneSearchBar,
VBrand,
VFooter,
},
- props: ['error'],
+ props: ["error"],
setup() {
const searchStore = useSearchStore()
const { app } = useContext()
@@ -90,7 +90,7 @@ export default defineComponent({
}
const featureFlagStore = useFeatureFlagStore()
- const isNewHeaderEnabled = featureFlagStore.isOn('new_header')
+ const isNewHeaderEnabled = featureFlagStore.isOn("new_header")
return {
handleSearch,
@@ -101,9 +101,9 @@ export default defineComponent({
head: {
meta: [
{
- hid: 'theme-color',
- name: 'theme-color',
- content: '#ffe033',
+ hid: "theme-color",
+ name: "theme-color",
+ content: "#ffe033",
},
],
},
diff --git a/src/components/VGlobalAudioSection/VGlobalAudioSection.vue b/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
index b7753a991..638e76699 100644
--- a/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
+++ b/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
@@ -17,25 +17,25 @@ import {
watch,
computed,
defineComponent,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { AUDIO } from '~/constants/media'
-import { useActiveAudio } from '~/composables/use-active-audio'
+import { AUDIO } from "~/constants/media"
+import { useActiveAudio } from "~/composables/use-active-audio"
-import { useActiveMediaStore } from '~/stores/active-media'
-import { useMediaStore } from '~/stores/media'
-import { useSingleResultStore } from '~/stores/media/single-result'
-import { useUiStore } from '~/stores/ui'
+import { useActiveMediaStore } from "~/stores/active-media"
+import { useMediaStore } from "~/stores/media"
+import { useSingleResultStore } from "~/stores/media/single-result"
+import { useUiStore } from "~/stores/ui"
-import type { AudioDetail } from '~/types/media'
+import type { AudioDetail } from "~/types/media"
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
-import VGlobalAudioTrack from '~/components/VAudioTrack/VGlobalAudioTrack.vue'
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
+import VGlobalAudioTrack from "~/components/VAudioTrack/VGlobalAudioTrack.vue"
-import closeIcon from '~/assets/icons/close-small.svg'
+import closeIcon from "~/assets/icons/close-small.svg"
export default defineComponent({
- name: 'VGlobalAudioSection',
+ name: "VGlobalAudioSection",
components: {
VGlobalAudioTrack,
VIconButton,
@@ -73,7 +73,7 @@ export default defineComponent({
const handleError = (event: Event) => {
if (!(event.target instanceof HTMLAudioElement)) {
- activeMediaStore.setMessage({ message: 'err_unknown' })
+ activeMediaStore.setMessage({ message: "err_unknown" })
return
}
const error = event.target.error
@@ -81,19 +81,19 @@ export default defineComponent({
let errorMsg
switch (error.code) {
case error.MEDIA_ERR_ABORTED:
- errorMsg = 'err_aborted'
+ errorMsg = "err_aborted"
break
case error.MEDIA_ERR_NETWORK:
- errorMsg = 'err_network'
+ errorMsg = "err_network"
break
case error.MEDIA_ERR_DECODE:
- errorMsg = 'err_decode'
+ errorMsg = "err_decode"
break
case error.MEDIA_ERR_SRC_NOT_SUPPORTED:
- errorMsg = 'err_unsupported'
+ errorMsg = "err_unsupported"
break
default:
- errorMsg = 'err_unknown'
+ errorMsg = "err_unknown"
}
activeMediaStore.setMessage({ message: errorMsg })
}
@@ -102,10 +102,10 @@ export default defineComponent({
activeAudio.obj,
(audio, _, onInvalidate) => {
if (!audio) return
- audio.addEventListener('error', handleError)
+ audio.addEventListener("error", handleError)
onInvalidate(() => {
- audio.removeEventListener('error', handleError)
+ audio.removeEventListener("error", handleError)
})
},
{ immediate: true }
@@ -127,10 +127,10 @@ export default defineComponent({
const routeValue = computed(() => route.value)
watch(routeValue, (newRouteVal, oldRouteVal) => {
if (
- (oldRouteVal.name?.includes('audio') &&
- !newRouteVal.name?.includes('audio')) ||
+ (oldRouteVal.name?.includes("audio") &&
+ !newRouteVal.name?.includes("audio")) ||
(uiStore.isDesktopLayout &&
- newRouteVal.name?.includes('audio-id') &&
+ newRouteVal.name?.includes("audio-id") &&
newRouteVal.params.id != activeMediaStore.id)
) {
activeAudio.obj.value?.pause()
diff --git a/src/components/VHeader/VFilterButton.vue b/src/components/VHeader/VFilterButton.vue
index 443cec0cc..33f9e5524 100644
--- a/src/components/VHeader/VFilterButton.vue
+++ b/src/components/VHeader/VFilterButton.vue
@@ -24,19 +24,19 @@
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { useSearchStore } from '~/stores/search'
-import { defineEvent } from '~/types/emits'
-import { useI18n } from '~/composables/use-i18n'
+import { useSearchStore } from "~/stores/search"
+import { defineEvent } from "~/types/emits"
+import { useI18n } from "~/composables/use-i18n"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
-import filterIcon from '~/assets/icons/filter.svg'
+import filterIcon from "~/assets/icons/filter.svg"
export default defineComponent({
- name: 'VFilterButton',
+ name: "VFilterButton",
components: {
VIcon,
VButton,
@@ -69,11 +69,11 @@ export default defineComponent({
*/
const xlMinLabel = computed(() =>
filtersAreApplied.value
- ? i18n.tc('header.filter-button.with-count', filterCount.value)
- : i18n.t('header.filter-button.simple')
+ ? i18n.tc("header.filter-button.with-count", filterCount.value)
+ : i18n.t("header.filter-button.simple")
)
const lgMaxLabel = computed(() =>
- filtersAreApplied ? filterCount.value : ''
+ filtersAreApplied ? filterCount.value : ""
)
return {
diff --git a/src/components/VHeader/VHeaderDesktop.vue b/src/components/VHeader/VHeaderDesktop.vue
index 03134b9d5..146a99ebc 100644
--- a/src/components/VHeader/VHeaderDesktop.vue
+++ b/src/components/VHeader/VHeaderDesktop.vue
@@ -54,36 +54,36 @@ import {
ref,
useContext,
useRouter,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useMediaStore } from '~/stores/media'
-import { isSearchTypeSupported, useSearchStore } from '~/stores/search'
-import { useUiStore } from '~/stores/ui'
+import { useMediaStore } from "~/stores/media"
+import { isSearchTypeSupported, useSearchStore } from "~/stores/search"
+import { useUiStore } from "~/stores/ui"
-import { ALL_MEDIA, searchPath, supportedMediaTypes } from '~/constants/media'
-import { IsHeaderScrolledKey, IsSidebarVisibleKey } from '~/types/provides'
+import { ALL_MEDIA, searchPath, supportedMediaTypes } from "~/constants/media"
+import { IsHeaderScrolledKey, IsSidebarVisibleKey } from "~/types/provides"
-import { useI18n } from '~/composables/use-i18n'
-import { useI18nResultsCount } from '~/composables/use-i18n-utilities'
-import { useFocusFilters } from '~/composables/use-focus-filters'
-import useSearchType from '~/composables/use-search-type'
+import { useI18n } from "~/composables/use-i18n"
+import { useI18nResultsCount } from "~/composables/use-i18n-utilities"
+import { useFocusFilters } from "~/composables/use-focus-filters"
+import useSearchType from "~/composables/use-search-type"
-import { Focus } from '~/utils/focus-management'
-import { ensureFocus } from '~/utils/reakit-utils/focus'
+import { Focus } from "~/utils/focus-management"
+import { ensureFocus } from "~/utils/reakit-utils/focus"
-import VFilterButton from '~/components/VHeader/VFilterButton.vue'
-import VSearchBar from '~/components/VHeader/VSearchBar/VSearchBar.vue'
-import VLogoButton from '~/components/VHeader/VLogoButton.vue'
-import VSearchBarButton from '~/components/VHeader/VHeaderMobile/VSearchBarButton.vue'
-import VSearchTypePopover from '~/components/VContentSwitcher/VSearchTypePopover.vue'
+import VFilterButton from "~/components/VHeader/VFilterButton.vue"
+import VSearchBar from "~/components/VHeader/VSearchBar/VSearchBar.vue"
+import VLogoButton from "~/components/VHeader/VLogoButton.vue"
+import VSearchBarButton from "~/components/VHeader/VHeaderMobile/VSearchBarButton.vue"
+import VSearchTypePopover from "~/components/VContentSwitcher/VSearchTypePopover.vue"
-import closeIcon from '~/assets/icons/close-small.svg'
+import closeIcon from "~/assets/icons/close-small.svg"
/**
* The desktop search header.
*/
export default defineComponent({
- name: 'VHeaderDesktop',
+ name: "VHeaderDesktop",
components: {
VFilterButton,
VLogoButton,
@@ -117,8 +117,8 @@ export default defineComponent({
* Shows the loading state or result count.
*/
const searchStatus = computed(() => {
- if (searchStore.searchTerm === '') return ''
- if (isFetching.value) return i18n.t('header.loading')
+ if (searchStore.searchTerm === "") return ""
+ if (isFetching.value) return i18n.t("header.loading")
return getI18nCount(resultsCount.value)
})
@@ -139,8 +139,8 @@ export default defineComponent({
})
const clearSearchTerm = () => {
- searchTerm.value = ''
- ensureFocus(searchBarRef.value?.$el.querySelector('input') as HTMLElement)
+ searchTerm.value = ""
+ ensureFocus(searchBarRef.value?.$el.querySelector("input") as HTMLElement)
}
const selectSearchType = async (type) => {
@@ -178,11 +178,11 @@ export default defineComponent({
* to run and fetch new media.
*/
const handleSearch = async () => {
- window.scrollTo({ top: 0, left: 0, behavior: 'auto' })
+ window.scrollTo({ top: 0, left: 0, behavior: "auto" })
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
const searchType = searchStore.searchType
- if (!searchTermChanged.value || searchTerm.value === '') return
+ if (!searchTermChanged.value || searchTerm.value === "") return
if (searchTermChanged.value) {
await mediaStore.clearMedia()
diff --git a/src/components/VHeader/VHeaderInternal.vue b/src/components/VHeader/VHeaderInternal.vue
index 73899126f..53e4f02e8 100644
--- a/src/components/VHeader/VHeaderInternal.vue
+++ b/src/components/VHeader/VHeaderInternal.vue
@@ -67,24 +67,24 @@ import {
ref,
useRoute,
watch,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import usePages from '~/composables/use-pages'
+import usePages from "~/composables/use-pages"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import VHomeLink from '~/components/VHeader/VHomeLink.vue'
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
-import VPageLinks from '~/components/VHeader/VPageLinks.vue'
-import VModal from '~/components/VModal/VModal.vue'
+import VHomeLink from "~/components/VHeader/VHomeLink.vue"
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
+import VPageLinks from "~/components/VHeader/VPageLinks.vue"
+import VModal from "~/components/VModal/VModal.vue"
-import VWordPressLink from '~/components/VHeader/VWordPressLink.vue'
+import VWordPressLink from "~/components/VHeader/VWordPressLink.vue"
-import closeIcon from '~/assets/icons/close.svg'
-import menuIcon from '~/assets/icons/menu.svg'
+import closeIcon from "~/assets/icons/close.svg"
+import menuIcon from "~/assets/icons/menu.svg"
export default defineComponent({
- name: 'VHeaderInternal',
+ name: "VHeaderInternal",
components: {
VWordPressLink,
VHomeLink,
diff --git a/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue b/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
index f18bcd018..e272b86f4 100644
--- a/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
+++ b/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
@@ -20,12 +20,12 @@
</VSearchBarButton>
</template>
<script lang="ts">
-import VSearchBarButton from '~/components/VHeader/VHeaderMobile/VSearchBarButton.vue'
+import VSearchBarButton from "~/components/VHeader/VHeaderMobile/VSearchBarButton.vue"
-import sourceIcon from '~/assets/icons/source.svg'
+import sourceIcon from "~/assets/icons/source.svg"
export default {
- name: 'VContentSettingsButton',
+ name: "VContentSettingsButton",
components: { VSearchBarButton },
props: {
isPressed: {
diff --git a/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vue b/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vue
index 3b118a418..80135790e 100644
--- a/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vue
+++ b/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vue
@@ -23,10 +23,10 @@
>
<template #tabs>
<VTab id="content-settings" size="medium" class="category me-4">{{
- $t('search-type.heading')
+ $t("search-type.heading")
}}</VTab>
<VTab id="filters" size="medium" class="category">{{
- $t('filters.title')
+ $t("filters.title")
}}</VTab>
<VIconButton
class="self-center ms-auto hover:bg-dark-charcoal hover:text-white"
@@ -60,27 +60,27 @@
</VModal>
</template>
<script lang="ts">
-import { computed, defineComponent, ref } from '@nuxtjs/composition-api'
+import { computed, defineComponent, ref } from "@nuxtjs/composition-api"
-import { useSearchStore } from '~/stores/search'
+import { useSearchStore } from "~/stores/search"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import VButton from '~/components/VButton.vue'
-import VContentSettingsButton from '~/components/VHeader/VHeaderMobile/VContentSettingsButton.vue'
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
-import VModal from '~/components/VModal/VModal.vue'
-import VSearchGridFilter from '~/components/VFilters/VSearchGridFilter.vue'
-import VSearchTypes from '~/components/VContentSwitcher/VSearchTypes.vue'
-import VShowResultsButton from '~/components/VHeader/VHeaderMobile/VShowResultsButton.vue'
-import VTab from '~/components/VTabs/VTab.vue'
-import VTabPanel from '~/components/VTabs/VTabPanel.vue'
-import VTabs from '~/components/VTabs/VTabs.vue'
+import VButton from "~/components/VButton.vue"
+import VContentSettingsButton from "~/components/VHeader/VHeaderMobile/VContentSettingsButton.vue"
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
+import VModal from "~/components/VModal/VModal.vue"
+import VSearchGridFilter from "~/components/VFilters/VSearchGridFilter.vue"
+import VSearchTypes from "~/components/VContentSwitcher/VSearchTypes.vue"
+import VShowResultsButton from "~/components/VHeader/VHeaderMobile/VShowResultsButton.vue"
+import VTab from "~/components/VTabs/VTab.vue"
+import VTabPanel from "~/components/VTabs/VTabPanel.vue"
+import VTabs from "~/components/VTabs/VTabs.vue"
-import closeIcon from '~/assets/icons/close-small.svg'
+import closeIcon from "~/assets/icons/close-small.svg"
export default defineComponent({
- name: 'VContentSettingsModal',
+ name: "VContentSettingsModal",
components: {
VButton,
VContentSettingsButton,
@@ -105,15 +105,15 @@ export default defineComponent({
)
const i18n = useI18n()
const searchStore = useSearchStore()
- const selectedTab = ref<'content-settings' | 'filters'>('content-settings')
- const changeSelectedTab = (tab: 'content-settings' | 'filters') => {
+ const selectedTab = ref<"content-settings" | "filters">("content-settings")
+ const changeSelectedTab = (tab: "content-settings" | "filters") => {
selectedTab.value = tab
}
const areFiltersSelected = computed(() => searchStore.isAnyFilterApplied)
const showClearFiltersButton = computed(
- () => selectedTab.value === 'filters'
+ () => selectedTab.value === "filters"
)
const isClearButtonDisabled = computed(
() => !searchStore.isAnyFilterApplied
@@ -121,8 +121,8 @@ export default defineComponent({
const appliedFilterCount = computed(() => searchStore.appliedFilterCount)
const clearFiltersLabel = computed(() =>
searchStore.isAnyFilterApplied
- ? i18n.tc('filter-list.clear-numbered', appliedFilterCount.value)
- : i18n.t('filter-list.clear')
+ ? i18n.tc("filter-list.clear-numbered", appliedFilterCount.value)
+ : i18n.t("filter-list.clear")
)
const clearFilters = () => {
diff --git a/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue b/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
index f70b569e1..05fdfea68 100644
--- a/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
+++ b/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
@@ -107,30 +107,30 @@ import {
useContext,
useRouter,
watch,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { ensureFocus } from '~/utils/reakit-utils/focus'
-import { cyclicShift } from '~/utils/math'
+import { ensureFocus } from "~/utils/reakit-utils/focus"
+import { cyclicShift } from "~/utils/math"
-import { searchPath } from '~/constants/media'
-import { keycodes } from '~/constants/key-codes'
+import { searchPath } from "~/constants/media"
+import { keycodes } from "~/constants/key-codes"
-import { IsHeaderScrolledKey } from '~/types/provides'
+import { IsHeaderScrolledKey } from "~/types/provides"
-import { useI18n } from '~/composables/use-i18n'
-import { useI18nResultsCount } from '~/composables/use-i18n-utilities'
+import { useI18n } from "~/composables/use-i18n"
+import { useI18nResultsCount } from "~/composables/use-i18n-utilities"
-import { useMediaStore } from '~/stores/media'
-import { isSearchTypeSupported, useSearchStore } from '~/stores/search'
+import { useMediaStore } from "~/stores/media"
+import { isSearchTypeSupported, useSearchStore } from "~/stores/search"
-import VLogoButton from '~/components/VHeader/VLogoButton.vue'
-import VInputModal from '~/components/VModal/VInputModal.vue'
-import VContentSettingsModal from '~/components/VHeader/VHeaderMobile/VContentSettingsModal.vue'
-import VRecentSearches from '~/components/VRecentSearches/VRecentSearches.vue'
-import VSearchBarButton from '~/components/VHeader/VHeaderMobile/VSearchBarButton.vue'
+import VLogoButton from "~/components/VHeader/VLogoButton.vue"
+import VInputModal from "~/components/VModal/VInputModal.vue"
+import VContentSettingsModal from "~/components/VHeader/VHeaderMobile/VContentSettingsModal.vue"
+import VRecentSearches from "~/components/VRecentSearches/VRecentSearches.vue"
+import VSearchBarButton from "~/components/VHeader/VHeaderMobile/VSearchBarButton.vue"
-import closeIcon from '~/assets/icons/close-small.svg'
-import chevronLeftIcon from '~/assets/icons/chevron-left.svg'
+import closeIcon from "~/assets/icons/close-small.svg"
+import chevronLeftIcon from "~/assets/icons/chevron-left.svg"
/**
* Displays a text field for a search query and is attached to an action button
@@ -138,7 +138,7 @@ import chevronLeftIcon from '~/assets/icons/chevron-left.svg'
* displayed in the bar itself.
*/
export default defineComponent({
- name: 'VHeaderMobile',
+ name: "VHeaderMobile",
components: {
VContentSettingsModal,
VInputModal,
@@ -168,8 +168,8 @@ export default defineComponent({
* Shows the loading state or result count.
*/
const searchStatus = computed<string>(() => {
- if (searchStore.searchTerm === '') return ''
- if (isFetching.value) return i18n.t('header.loading').toString()
+ if (searchStore.searchTerm === "") return ""
+ if (isFetching.value) return i18n.t("header.loading").toString()
return getI18nCount(resultsCount.value)
})
@@ -205,11 +205,11 @@ export default defineComponent({
* to run and fetch new media.
*/
const handleSearch = async () => {
- window.scrollTo({ top: 0, left: 0, behavior: 'auto' })
+ window.scrollTo({ top: 0, left: 0, behavior: "auto" })
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
const searchType = searchStore.searchType
- if (!searchTermChanged.value || searchTerm.value === '') return
+ if (!searchTermChanged.value || searchTerm.value === "") return
if (searchTermChanged.value) {
await mediaStore.clearMedia()
@@ -245,7 +245,7 @@ export default defineComponent({
})
} else {
isRecentSearchesModalOpen.value = false
- if (localSearchTerm.value === '' && searchStore.searchTerm !== '') {
+ if (localSearchTerm.value === "" && searchStore.searchTerm !== "") {
localSearchTerm.value = searchStore.searchTerm
}
}
@@ -256,7 +256,7 @@ export default defineComponent({
}
const clearSearchText = () => {
- searchTerm.value = ''
+ searchTerm.value = ""
if (searchInputRef.value) {
ensureFocus(searchInputRef.value)
}
diff --git a/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue b/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
index 1ad79f94e..76dc05de1 100644
--- a/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
+++ b/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
@@ -22,10 +22,10 @@
</VIconButton>
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
/**
* The buttons placed inside the mobile search bar in the header.
@@ -34,7 +34,7 @@ import VIconButton from '~/components/VIconButton/VIconButton.vue'
* accessibility requirements.
*/
export default defineComponent({
- name: 'VSearchBarButton',
+ name: "VSearchBarButton",
components: { VIcon, VIconButton },
props: {
/**
@@ -57,7 +57,7 @@ export default defineComponent({
*/
innerAreaClasses: {
type: String,
- default: '',
+ default: "",
},
/**
* Whether the icon should be flipped when the page is in RTL mode.
diff --git a/src/components/VHeader/VHeaderMobile/VShowResultsButton.vue b/src/components/VHeader/VHeaderMobile/VShowResultsButton.vue
index e443ac3a5..a88dc101d 100644
--- a/src/components/VHeader/VHeaderMobile/VShowResultsButton.vue
+++ b/src/components/VHeader/VHeaderMobile/VShowResultsButton.vue
@@ -29,29 +29,29 @@
/>
</svg>
<span class="sr-only">
- {{ $t('header.loading') }}
+ {{ $t("header.loading") }}
</span>
</span>
<!-- To preserve the button width when state changes, this element is not
removed from the DOM, only hidden and muted. -->
<span :class="{ 'opacity-0': isFetching }" :aria-hidden="isFetching">
- {{ $t('header.see-results') }}
+ {{ $t("header.see-results") }}
</span>
</VButton>
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import VButton from '~/components/VButton.vue'
+import VButton from "~/components/VButton.vue"
/**
* This button dismisses the open modal for changing content types or applying
* filters and takes the user back to the results.
*/
export default defineComponent({
- name: 'VShowResultsButton',
+ name: "VShowResultsButton",
components: { VButton },
props: {
/**
diff --git a/src/components/VHeader/VHomeLink.vue b/src/components/VHeader/VHomeLink.vue
index b4c58e5cf..d15c39cf8 100644
--- a/src/components/VHeader/VHomeLink.vue
+++ b/src/components/VHeader/VHomeLink.vue
@@ -9,13 +9,13 @@
</template>
<script lang="ts">
-import { type PropType, defineComponent } from '@nuxtjs/composition-api'
+import { type PropType, defineComponent } from "@nuxtjs/composition-api"
-import VBrand from '~/components/VBrand/VBrand.vue'
-import VLink from '~/components/VLink.vue'
+import VBrand from "~/components/VBrand/VBrand.vue"
+import VLink from "~/components/VLink.vue"
export default defineComponent({
- name: 'VHomeLink',
+ name: "VHomeLink",
components: {
VBrand,
VLink,
@@ -28,8 +28,8 @@ export default defineComponent({
* @default 'light'
*/
variant: {
- type: String as PropType<'light' | 'dark'>,
- default: 'light',
+ type: String as PropType<"light" | "dark">,
+ default: "light",
},
},
})
diff --git a/src/components/VHeader/VLogoButton.vue b/src/components/VHeader/VLogoButton.vue
index c4cc8c632..3c1c7c006 100644
--- a/src/components/VHeader/VLogoButton.vue
+++ b/src/components/VHeader/VLogoButton.vue
@@ -15,13 +15,13 @@
</VButton>
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VLogoLoader from '~/components/VLogoLoader/VLogoLoader.vue'
-import VButton from '~/components/VButton.vue'
+import VLogoLoader from "~/components/VLogoLoader/VLogoLoader.vue"
+import VButton from "~/components/VButton.vue"
export default defineComponent({
- name: 'VLogoButton',
+ name: "VLogoButton",
components: { VLogoLoader, VButton },
props: {
isFetching: {
diff --git a/src/components/VHeader/VPageLinks.vue b/src/components/VHeader/VPageLinks.vue
index cd8218f2c..0077a5fc8 100644
--- a/src/components/VHeader/VPageLinks.vue
+++ b/src/components/VHeader/VPageLinks.vue
@@ -22,14 +22,14 @@ import {
type PropType,
defineComponent,
useRoute,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import usePages from '~/composables/use-pages'
+import usePages from "~/composables/use-pages"
-import VNavLink from '~/components/VNavLink/VNavLink.vue'
+import VNavLink from "~/components/VNavLink/VNavLink.vue"
export default defineComponent({
- name: 'VPageLinks',
+ name: "VPageLinks",
components: {
VNavLink,
},
@@ -41,8 +41,8 @@ export default defineComponent({
* @default 'light'
*/
mode: {
- type: String as PropType<'light' | 'dark'>,
- default: 'light',
+ type: String as PropType<"light" | "dark">,
+ default: "light",
},
/**
* Pass the tailwind classes to style the nav links.
@@ -51,7 +51,7 @@ export default defineComponent({
*/
navLinkClasses: {
type: String,
- default: '',
+ default: "",
},
},
setup(_, { emit }) {
@@ -60,7 +60,7 @@ export default defineComponent({
const onClick = (link: string) => {
if (link === route.value.path) {
- emit('close')
+ emit("close")
}
}
diff --git a/src/components/VHeader/VSearchBar/VSearchBar.vue b/src/components/VHeader/VSearchBar/VSearchBar.vue
index 196fd604a..76ab9e023 100644
--- a/src/components/VHeader/VSearchBar/VSearchBar.vue
+++ b/src/components/VHeader/VSearchBar/VSearchBar.vue
@@ -60,24 +60,24 @@ import {
defineComponent,
PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { onClickOutside } from '@vueuse/core'
+import { onClickOutside } from "@vueuse/core"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import { useSearchStore } from '~/stores/search'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { useSearchStore } from "~/stores/search"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import { keycodes } from '~/constants/key-codes'
+import { keycodes } from "~/constants/key-codes"
-import { cyclicShift } from '~/utils/math'
+import { cyclicShift } from "~/utils/math"
import VInputField, {
FIELD_SIZES,
-} from '~/components/VInputField/VInputField.vue'
-import VSearchButton from '~/components/VHeader/VSearchBar/VSearchButton.vue'
-import VRecentSearches from '~/components/VRecentSearches/VRecentSearches.vue'
+} from "~/components/VInputField/VInputField.vue"
+import VSearchButton from "~/components/VHeader/VSearchBar/VSearchButton.vue"
+import VRecentSearches from "~/components/VRecentSearches/VRecentSearches.vue"
/**
* The search bar displayed on the search page.
@@ -89,7 +89,7 @@ import VRecentSearches from '~/components/VRecentSearches/VRecentSearches.vue'
* displayed in the bar itself.
*/
export default defineComponent({
- name: 'VSearchBar',
+ name: "VSearchBar",
components: { VRecentSearches, VInputField, VSearchButton },
inheritAttrs: false,
props: {
@@ -98,7 +98,7 @@ export default defineComponent({
*/
value: {
type: String,
- default: '',
+ default: "",
},
size: {
type: String as PropType<keyof typeof FIELD_SIZES>,
@@ -118,19 +118,19 @@ export default defineComponent({
const inputFieldRef = ref<InstanceType<typeof VInputField> | null>(null)
const modelMedium = computed<string>({
- get: () => props.value ?? '',
+ get: () => props.value ?? "",
set: (value: string) => {
- emit('input', value)
+ emit("input", value)
},
})
const handleSearch = () => {
- emit('submit')
+ emit("submit")
}
/* Recent searches */
const featureFlagStore = useFeatureFlagStore()
- const isNewHeaderEnabled = featureFlagStore.isOn('new_header')
+ const isNewHeaderEnabled = featureFlagStore.isOn("new_header")
const searchStore = useSearchStore()
@@ -138,10 +138,10 @@ export default defineComponent({
const recentClasses = computed(() => {
// Calculated by adding 8px to all heights defined in `VInputField.vue`.
const FIELD_OFFSETS = {
- small: 'top-12',
- medium: 'top-14',
- large: 'top-16',
- standalone: 'top-[65px] md:top-[77px]',
+ small: "top-12",
+ medium: "top-14",
+ large: "top-16",
+ standalone: "top-[65px] md:top-[77px]",
} as const
return FIELD_OFFSETS[props.size]
})
diff --git a/src/components/VHeader/VSearchBar/VSearchButton.vue b/src/components/VHeader/VSearchBar/VSearchButton.vue
index d55a01762..5615c9f0d 100644
--- a/src/components/VHeader/VSearchBar/VSearchButton.vue
+++ b/src/components/VHeader/VSearchBar/VSearchButton.vue
@@ -17,27 +17,27 @@
]"
>
<VIcon v-show="isIcon" :icon-path="searchIcon" />
- <span v-show="!isIcon">{{ $t('search.search') }}</span>
+ <span v-show="!isIcon">{{ $t("search.search") }}</span>
</VButton>
</template>
<script lang="ts">
-import { defineComponent, computed, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, computed, PropType } from "@nuxtjs/composition-api"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VButton from '~/components/VButton.vue'
-import type { FieldSize } from '~/components/VInputField/VInputField.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VButton from "~/components/VButton.vue"
+import type { FieldSize } from "~/components/VInputField/VInputField.vue"
-import searchIcon from '~/assets/icons/search.svg'
+import searchIcon from "~/assets/icons/search.svg"
/**
* The search button used in the search bar on the homepage and on the 404 page,
* and on the search page.
* TODO: remove when `new_header` is default: only on the search page with the `new_header`.
*/
export default defineComponent({
- name: 'VSearchButton',
+ name: "VSearchButton",
components: { VIcon, VButton },
props: {
size: {
@@ -45,8 +45,8 @@ export default defineComponent({
required: true,
},
route: {
- type: String as PropType<'home' | '404' | 'search'>,
- validator: (v: string) => ['home', '404', 'search'].includes(v),
+ type: String as PropType<"home" | "404" | "search">,
+ validator: (v: string) => ["home", "404", "search"].includes(v),
},
},
setup(props) {
@@ -57,7 +57,7 @@ export default defineComponent({
* everywhere else it has an icon.
*/
const isIcon = computed(() => {
- if (props.route !== 'home') {
+ if (props.route !== "home") {
return true
} else {
return !uiStore.isDesktopLayout
@@ -67,10 +67,10 @@ export default defineComponent({
const sizeClasses = computed(() =>
isIcon.value
? {
- small: 'w-10 md:w-12',
- medium: 'w-12',
- large: 'w-14',
- standalone: 'w-[57px] md:w-[69px]',
+ small: "w-10 md:w-12",
+ medium: "w-12",
+ large: "w-14",
+ standalone: "w-[57px] md:w-[69px]",
}[props.size]
: undefined
)
diff --git a/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue b/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue
index 774944f0d..1b0618026 100644
--- a/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue
+++ b/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue
@@ -39,11 +39,11 @@ import {
defineComponent,
PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import VSearchButton from '~/components/VHeader/VSearchBar/VSearchButton.vue'
+import VSearchButton from "~/components/VHeader/VSearchBar/VSearchButton.vue"
/**
* Displays a search input for a search query and is attached to an action button
@@ -53,12 +53,12 @@ import VSearchButton from '~/components/VHeader/VSearchBar/VSearchButton.vue'
* is not removed.
*/
export default defineComponent({
- name: 'VStandaloneSearchBar',
+ name: "VStandaloneSearchBar",
components: { VSearchButton },
props: {
route: {
- type: String as PropType<'home' | '404'>,
- default: 'home',
+ type: String as PropType<"home" | "404">,
+ default: "home",
},
},
emits: {
@@ -71,11 +71,11 @@ export default defineComponent({
const handleSearch = () => {
const searchTerm = inputRef.value?.value.trim()
if (searchTerm) {
- emit('submit', searchTerm)
+ emit("submit", searchTerm)
}
}
- const isHomeRoute = computed(() => props.route === 'home')
+ const isHomeRoute = computed(() => props.route === "home")
return {
inputRef,
diff --git a/src/components/VHeader/VSearchBar/meta/VSearchBar.stories.mdx b/src/components/VHeader/VSearchBar/meta/VSearchBar.stories.mdx
index 6162105b0..08661a4bf 100644
--- a/src/components/VHeader/VSearchBar/meta/VSearchBar.stories.mdx
+++ b/src/components/VHeader/VSearchBar/meta/VSearchBar.stories.mdx
@@ -4,18 +4,18 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import VSearchBar from '~/components/VHeader/VSearchBar/VSearchBar.vue'
+} from "@storybook/addon-docs"
+import VSearchBar from "~/components/VHeader/VSearchBar/VSearchBar.vue"
<Meta
title="Components/VHeader/Search bar"
component={VSearchBar}
argTypes={{
input: {
- action: 'input',
+ action: "input",
},
submit: {
- action: 'submit',
+ action: "submit",
},
}}
/>
@@ -47,8 +47,8 @@ button is clicked.
<Story
name="Default"
args={{
- value: 'Search query',
- size: 'medium',
+ value: "Search query",
+ size: "medium",
}}
>
{Template.bind({})}
@@ -72,7 +72,7 @@ export const vModelTemplate = (args) => ({
components: { VSearchBar },
data() {
return {
- text: 'Hello, World!',
+ text: "Hello, World!",
}
},
setup() {
@@ -92,8 +92,8 @@ easy `<input>` attributes like placeholders or HTML validations.
<Story
name="With placeholder"
args={{
- placeholder: 'Search query',
- size: 'large',
+ placeholder: "Search query",
+ size: "large",
}}
>
{Template.bind({})}
diff --git a/src/components/VHeader/VWordPressLink.vue b/src/components/VHeader/VWordPressLink.vue
index 3da861936..d2d194f8b 100644
--- a/src/components/VHeader/VWordPressLink.vue
+++ b/src/components/VHeader/VWordPressLink.vue
@@ -17,19 +17,19 @@
</VLink>
</template>
<script lang="ts">
-import { PropType } from '@nuxtjs/composition-api'
+import { PropType } from "@nuxtjs/composition-api"
-import VLink from '~/components/VLink.vue'
+import VLink from "~/components/VLink.vue"
-import WordPress from '~/assets/wordpress.svg?inline'
+import WordPress from "~/assets/wordpress.svg?inline"
export default {
- name: 'VWordPressLink',
+ name: "VWordPressLink",
components: { VLink, WordPress },
props: {
mode: {
- type: String as PropType<'dark' | 'light'>,
- default: 'light',
+ type: String as PropType<"dark" | "light">,
+ default: "light",
},
},
}
diff --git a/src/components/VHeader/meta/VContentSettingsModal.stories.mdx b/src/components/VHeader/meta/VContentSettingsModal.stories.mdx
index 67927e22f..20fe95716 100644
--- a/src/components/VHeader/meta/VContentSettingsModal.stories.mdx
+++ b/src/components/VHeader/meta/VContentSettingsModal.stories.mdx
@@ -4,23 +4,23 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VContentSettingsModal from '~/components/VHeader/VHeaderMobile/VContentSettingsModal.vue'
-import VModalTarget from '~/components/VModal/VModalTarget'
+import VContentSettingsModal from "~/components/VHeader/VHeaderMobile/VContentSettingsModal.vue"
+import VModalTarget from "~/components/VModal/VModalTarget"
<Meta
title="Components/VHeader/VHeaderMobile/VContentSettingsModal"
components={VContentSettingsModal}
argTypes={{
close: {
- action: 'close',
+ action: "close",
},
select: {
- action: 'select',
+ action: "select",
},
change: {
- action: 'change',
+ action: "change",
},
}}
/>
diff --git a/src/components/VHeader/meta/VFilterButton.stories.mdx b/src/components/VHeader/meta/VFilterButton.stories.mdx
index c972fe424..302f249a6 100644
--- a/src/components/VHeader/meta/VFilterButton.stories.mdx
+++ b/src/components/VHeader/meta/VFilterButton.stories.mdx
@@ -4,27 +4,27 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import VFilterButton from '~/components/VHeader/VFilterButton.vue'
-import { useSearchStore } from '~/stores/search'
-import { filterData, mediaFilterKeys } from '~/constants/filters'
-import { IMAGE } from '~/constants/media'
+} from "@storybook/addon-docs"
+import VFilterButton from "~/components/VHeader/VFilterButton.vue"
+import { useSearchStore } from "~/stores/search"
+import { filterData, mediaFilterKeys } from "~/constants/filters"
+import { IMAGE } from "~/constants/media"
<Meta
title="Components/VHeader/VFilterButton"
component={VFilterButton}
argTypes={{
pressed: {
- type: 'boolean',
+ type: "boolean",
},
appliedFilters: {
- type: 'number',
+ type: "number",
},
toggle: {
- action: 'toggle',
+ action: "toggle",
},
tab: {
- action: 'tab',
+ action: "tab",
},
}}
/>
@@ -66,17 +66,16 @@ export const Template = (args, { argTypes }) => ({
<ArgsTable of={VFilterButton} />
-The button opens and closes the filters sidebar. It also shows how many filters are applied
-in the mobile view.
-the field receives an input. It also emits the `search` event when the search
-button is clicked.
+The button opens and closes the filters sidebar. It also shows how many filters
+are applied in the mobile view. the field receives an input. It also emits the
+`search` event when the search button is clicked.
<Canvas>
<Story
name="Default"
parameters={{
viewport: {
- defaultViewport: 'lg',
+ defaultViewport: "lg",
},
}}
>
@@ -89,7 +88,7 @@ button is clicked.
name="With text label"
parameters={{
viewport: {
- defaultViewport: 'xl',
+ defaultViewport: "xl",
},
}}
>
diff --git a/src/components/VHeader/meta/VHeaderDesktop.stories.mdx b/src/components/VHeader/meta/VHeaderDesktop.stories.mdx
index c79510218..f21b0b3fa 100644
--- a/src/components/VHeader/meta/VHeaderDesktop.stories.mdx
+++ b/src/components/VHeader/meta/VHeaderDesktop.stories.mdx
@@ -4,8 +4,8 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import VHeaderDesktop from '~/components/VHeader/VHeaderDesktop.vue'
+} from "@storybook/addon-docs"
+import VHeaderDesktop from "~/components/VHeader/VHeaderDesktop.vue"
<Meta title="Components/VHeader/VHeaderDesktop" component={VHeaderDesktop} />
@@ -24,7 +24,8 @@ export const Template = (args) => ({
<ArgsTable of={VHeaderDesktop} />
-The header component used for screens on breakpoints wider than `lg`. Fixed on scroll, search bar, content switcher, pages menu and filters button.
+The header component used for screens on breakpoints wider than `lg`. Fixed on
+scroll, search bar, content switcher, pages menu and filters button.
<Canvas>
<Story name="Default">{Template.bind({})}</Story>
diff --git a/src/components/VHeader/meta/VHeaderInternal.stories.mdx b/src/components/VHeader/meta/VHeaderInternal.stories.mdx
index 2d4a51cb4..a8735da99 100644
--- a/src/components/VHeader/meta/VHeaderInternal.stories.mdx
+++ b/src/components/VHeader/meta/VHeaderInternal.stories.mdx
@@ -1,6 +1,6 @@
-import { Canvas, Description, Meta, Story } from '@storybook/addon-docs'
-import VHeaderInternal from '~/components/VHeader/VHeaderInternal.vue'
-import VModalTarget from '~/components/VModal/VModalTarget.vue'
+import { Canvas, Description, Meta, Story } from "@storybook/addon-docs"
+import VHeaderInternal from "~/components/VHeader/VHeaderInternal.vue"
+import VModalTarget from "~/components/VModal/VModalTarget.vue"
<Meta title="Components/VHeader/VHeaderInternal" component={VHeaderInternal} />
@@ -16,7 +16,8 @@ export const Template = (args) => ({
<Description of={VHeaderInternal} />
-The header component used on non-search pages. Fixed on scroll. Has links to the internal pages.
+The header component used on non-search pages. Fixed on scroll. Has links to the
+internal pages.
<Canvas>
<Story name="Default">{Template.bind({})}</Story>
diff --git a/src/components/VHeader/meta/VHeaderMobile.stories.mdx b/src/components/VHeader/meta/VHeaderMobile.stories.mdx
index 3c64bc62a..5d5788f30 100644
--- a/src/components/VHeader/meta/VHeaderMobile.stories.mdx
+++ b/src/components/VHeader/meta/VHeaderMobile.stories.mdx
@@ -4,8 +4,8 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import VHeaderMobile from '~/components/VHeader/VHeaderMobile/VHeaderMobile.vue'
+} from "@storybook/addon-docs"
+import VHeaderMobile from "~/components/VHeader/VHeaderMobile/VHeaderMobile.vue"
<Meta
title="Components/VHeader/VHeaderMobile/VHeaderMobile"
@@ -27,7 +27,8 @@ export const Template = (args) => ({
<ArgsTable of={VHeaderMobile} />
-The header component used for screens up to `lg` breakpoint. Fixed on scroll, search bar, content switcher, pages menu and filters button.
+The header component used for screens up to `lg` breakpoint. Fixed on scroll,
+search bar, content switcher, pages menu and filters button.
<Canvas>
<Story name="Default">{Template.bind({})}</Story>
diff --git a/src/components/VHeader/meta/VSearchBarButton.stories.mdx b/src/components/VHeader/meta/VSearchBarButton.stories.mdx
index 88207eef6..5d6cf28db 100644
--- a/src/components/VHeader/meta/VSearchBarButton.stories.mdx
+++ b/src/components/VHeader/meta/VSearchBarButton.stories.mdx
@@ -4,13 +4,13 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import VContentSettingsButton from '~/components/VHeader/VHeaderMobile/VContentSettingsButton'
-import VSearchBarButton from '~/components/VHeader/VHeaderMobile/VSearchBarButton.vue'
+} from "@storybook/addon-docs"
+import VContentSettingsButton from "~/components/VHeader/VHeaderMobile/VContentSettingsButton"
+import VSearchBarButton from "~/components/VHeader/VHeaderMobile/VSearchBarButton.vue"
-import closeIcon from '~/assets/icons/close-small.svg'
-import chevronLeftIcon from '~/assets/icons/chevron-left.svg'
-import sourceIcon from '~/assets/icons/source.svg'
+import closeIcon from "~/assets/icons/close-small.svg"
+import chevronLeftIcon from "~/assets/icons/chevron-left.svg"
+import sourceIcon from "~/assets/icons/source.svg"
<Meta
title="Components/VHeader/VHeaderMobile/VSearchBarButton"
@@ -18,29 +18,29 @@ import sourceIcon from '~/assets/icons/source.svg'
argTypes={{
iconPath: {
control: {
- type: 'select',
+ type: "select",
options: [closeIcon, chevronLeftIcon, sourceIcon],
default: closeIcon,
},
},
innerSize: {
control: {
- type: 'select',
+ type: "select",
options: [6, 8],
},
},
rtlFlip: {
control: {
- type: 'boolean',
+ type: "boolean",
},
},
innerAreaClasses: {
control: {
- type: 'text',
+ type: "text",
},
},
click: {
- action: 'click',
+ action: "click",
},
}}
/>
@@ -80,8 +80,9 @@ export const contentSettingsTemplate = (args) => ({
## Content Settings button with filters selected
-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.
+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="Content Settings Button with filters selected">
diff --git a/src/components/VHeader/meta/VShowResultsButton.stories.mdx b/src/components/VHeader/meta/VShowResultsButton.stories.mdx
index d3e882102..3caefe8f1 100644
--- a/src/components/VHeader/meta/VShowResultsButton.stories.mdx
+++ b/src/components/VHeader/meta/VShowResultsButton.stories.mdx
@@ -4,9 +4,9 @@ import {
ArgsTable,
Canvas,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VShowResultsButton from '~/components/VHeader/VHeaderMobile/VShowResultsButton.vue'
+import VShowResultsButton from "~/components/VHeader/VHeaderMobile/VShowResultsButton.vue"
<Meta
title="Components/VHeader/VHeaderMobile/VShowResultsButton"
diff --git a/src/components/VHeaderOld/README.md b/src/components/VHeaderOld/README.md
index bacafa99d..4506dcfac 100644
--- a/src/components/VHeaderOld/README.md
+++ b/src/components/VHeaderOld/README.md
@@ -1,6 +1,10 @@
# VHeaderOld
-The sticky header at the top of the page. On the homepage and the content pages, it shows one version, and on the Search page it additionally has a Content Switcher, collapsed menu for page links, and a filters button. On mobile, the header only shows the logo and close button when the overlay/flyout menu (containing pages, the content switcher, and filters) is open.
+The sticky header at the top of the page. On the homepage and the content pages,
+it shows one version, and on the Search page it additionally has a Content
+Switcher, collapsed menu for page links, and a filters button. On mobile, the
+header only shows the logo and close button when the overlay/flyout menu
+(containing pages, the content switcher, and filters) is open.
## Components
@@ -10,4 +14,5 @@ The sticky header at the top of the page. On the homepage and the content pages,
### VFilterButton
-This button toggles the filter drawer on desktop. On mobile, it opens the mobile drawer menu, set to the filters pane.
+This button toggles the filter drawer on desktop. On mobile, it opens the mobile
+drawer menu, set to the filters pane.
diff --git a/src/components/VHeaderOld/VFilterButtonOld.vue b/src/components/VHeaderOld/VFilterButtonOld.vue
index 025960708..626a992b5 100644
--- a/src/components/VHeaderOld/VFilterButtonOld.vue
+++ b/src/components/VHeaderOld/VFilterButtonOld.vue
@@ -28,22 +28,22 @@
</template>
<script lang="ts">
-import { computed, defineComponent, inject, ref } from '@nuxtjs/composition-api'
+import { computed, defineComponent, inject, ref } from "@nuxtjs/composition-api"
-import { useSearchStore } from '~/stores/search'
-import { useUiStore } from '~/stores/ui'
+import { useSearchStore } from "~/stores/search"
+import { useUiStore } from "~/stores/ui"
-import type { ButtonVariant } from '~/types/button'
-import { defineEvent } from '~/types/emits'
-import { useI18n } from '~/composables/use-i18n'
+import type { ButtonVariant } from "~/types/button"
+import { defineEvent } from "~/types/emits"
+import { useI18n } from "~/composables/use-i18n"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
-import filterIcon from '~/assets/icons/filter.svg'
+import filterIcon from "~/assets/icons/filter.svg"
export default defineComponent({
- name: 'VFilterButtonOld',
+ name: "VFilterButtonOld",
components: {
VIcon,
VButton,
@@ -68,7 +68,7 @@ export default defineComponent({
const searchStore = useSearchStore()
const uiStore = useUiStore()
- const isHeaderScrolled = inject('isHeaderScrolled', ref(false))
+ const isHeaderScrolled = inject("isHeaderScrolled", ref(false))
const filterCount = computed(() => searchStore.appliedFilterCount)
const filtersAreApplied = computed(() => filterCount.value > 0)
@@ -79,14 +79,14 @@ export default defineComponent({
const variant = computed(() => {
// Show the bordered state by default, unless below md
let value: ButtonVariant = uiStore.isDesktopLayout
- ? 'action-menu-bordered'
- : 'action-menu'
+ ? "action-menu-bordered"
+ : "action-menu"
if (isHeaderScrolled.value) {
- value = 'action-menu'
+ value = "action-menu"
}
if (filtersAreApplied.value) {
- value = 'action-menu-muted'
+ value = "action-menu-muted"
}
return value
})
@@ -99,14 +99,14 @@ export default defineComponent({
*/
const mdMinLabel = computed(() =>
filtersAreApplied.value
- ? i18n.tc('header.filter-button.with-count', filterCount.value)
- : i18n.t('header.filter-button.simple')
+ ? i18n.tc("header.filter-button.with-count", filterCount.value)
+ : i18n.t("header.filter-button.simple")
)
const smMaxLabel = computed(() =>
isHeaderScrolled.value
? filterCount.value
- : i18n.tc('header.filter-button.with-count', filterCount.value)
+ : i18n.tc("header.filter-button.with-count", filterCount.value)
)
return {
diff --git a/src/components/VHeaderOld/VHeaderFilter.vue b/src/components/VHeaderOld/VHeaderFilter.vue
index 96d7a24b3..3e333c728 100644
--- a/src/components/VHeaderOld/VHeaderFilter.vue
+++ b/src/components/VHeaderOld/VHeaderFilter.vue
@@ -33,22 +33,22 @@ import {
watch,
computed,
onBeforeUnmount,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'
-import { useFocusFilters } from '~/composables/use-focus-filters'
+import { useBodyScrollLock } from "~/composables/use-body-scroll-lock"
+import { useFocusFilters } from "~/composables/use-focus-filters"
-import { Focus } from '~/utils/focus-management'
-import { defineEvent } from '~/types/emits'
+import { Focus } from "~/utils/focus-management"
+import { defineEvent } from "~/types/emits"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import VModalContent from '~/components/VModal/VModalContent.vue'
-import VSearchGridFilter from '~/components/VFilters/VSearchGridFilter.vue'
-import VFilterButtonOld from '~/components/VHeaderOld/VFilterButtonOld.vue'
+import VModalContent from "~/components/VModal/VModalContent.vue"
+import VSearchGridFilter from "~/components/VFilters/VSearchGridFilter.vue"
+import VFilterButtonOld from "~/components/VHeaderOld/VFilterButtonOld.vue"
export default defineComponent({
- name: 'VHeaderFilter',
+ name: "VHeaderFilter",
components: {
VFilterButtonOld,
VModalContent,
@@ -81,7 +81,7 @@ export default defineComponent({
() => !props.disabled && uiStore.isFilterVisible
)
watch(isFilterVisible, (visible) => {
- emit(visible ? 'open' : 'close')
+ emit(visible ? "open" : "close")
})
const { lock, unlock } = useBodyScrollLock({ nodeRef })
diff --git a/src/components/VHeaderOld/VHeaderMenu.vue b/src/components/VHeaderOld/VHeaderMenu.vue
index 0df836462..dfb6aa650 100644
--- a/src/components/VHeaderOld/VHeaderMenu.vue
+++ b/src/components/VHeaderOld/VHeaderMenu.vue
@@ -5,21 +5,21 @@ import {
ref,
useContext,
useRouter,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { ALL_MEDIA, searchPath, supportedMediaTypes } from '~/constants/media'
-import useSearchType from '~/composables/use-search-type'
-import { useMediaStore } from '~/stores/media'
-import { useSearchStore } from '~/stores/search'
-import { useUiStore } from '~/stores/ui'
+import { ALL_MEDIA, searchPath, supportedMediaTypes } from "~/constants/media"
+import useSearchType from "~/composables/use-search-type"
+import { useMediaStore } from "~/stores/media"
+import { useSearchStore } from "~/stores/search"
+import { useUiStore } from "~/stores/ui"
-import VMobileMenuModal from '~/components/VContentSwitcherOld/VMobileMenuModal.vue'
-import VSearchTypePopoverOld from '~/components/VContentSwitcherOld/VSearchTypePopoverOld.vue'
-import VDesktopPageMenu from '~/components/VHeaderOld/VPageMenu/VDesktopPageMenu.vue'
-import VMobilePageMenu from '~/components/VHeaderOld/VPageMenu/VMobilePageMenu.vue'
+import VMobileMenuModal from "~/components/VContentSwitcherOld/VMobileMenuModal.vue"
+import VSearchTypePopoverOld from "~/components/VContentSwitcherOld/VSearchTypePopoverOld.vue"
+import VDesktopPageMenu from "~/components/VHeaderOld/VPageMenu/VDesktopPageMenu.vue"
+import VMobilePageMenu from "~/components/VHeaderOld/VPageMenu/VMobilePageMenu.vue"
export default defineComponent({
- name: 'VHeaderMenu',
+ name: "VHeaderMenu",
components: {
VMobileMenuModal,
VSearchTypePopoverOld,
@@ -84,17 +84,17 @@ export default defineComponent({
if (!this.isSearchRoute) {
return this.isDesktopLayout ? h(VDesktopPageMenu) : h(VMobilePageMenu)
} else if (this.isDesktopLayout) {
- return h('div', { class: 'flex flex-grow justify-between gap-x-2' }, [
+ return h("div", { class: "flex flex-grow justify-between gap-x-2" }, [
h(VDesktopPageMenu),
h(VSearchTypePopoverOld, {
props: { activeItem: this.content.activeType.value },
- ref: 'menuModalRef',
+ ref: "menuModalRef",
on: { select: this.selectSearchType },
}),
])
} else {
return h(VMobileMenuModal, {
- ref: 'menuModalRef',
+ ref: "menuModalRef",
props: { activeItem: this.content.activeType.value },
on: {
select: this.selectSearchType,
diff --git a/src/components/VHeaderOld/VHeaderOld.vue b/src/components/VHeaderOld/VHeaderOld.vue
index 2e3304eea..99e3d61c8 100644
--- a/src/components/VHeaderOld/VHeaderOld.vue
+++ b/src/components/VHeaderOld/VHeaderOld.vue
@@ -56,34 +56,34 @@ import {
ref,
useContext,
useRouter,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { ALL_MEDIA, searchPath } from '~/constants/media'
-import { useMatchSearchRoutes } from '~/composables/use-match-routes'
-import { useI18n } from '~/composables/use-i18n'
-import { useI18nResultsCount } from '~/composables/use-i18n-utilities'
+import { ALL_MEDIA, searchPath } from "~/constants/media"
+import { useMatchSearchRoutes } from "~/composables/use-match-routes"
+import { useI18n } from "~/composables/use-i18n"
+import { useI18nResultsCount } from "~/composables/use-i18n-utilities"
-import { useMediaStore } from '~/stores/media'
-import { isSearchTypeSupported, useSearchStore } from '~/stores/search'
-import { useUiStore } from '~/stores/ui'
+import { useMediaStore } from "~/stores/media"
+import { isSearchTypeSupported, useSearchStore } from "~/stores/search"
+import { useUiStore } from "~/stores/ui"
-import { IsSidebarVisibleKey } from '~/types/provides'
+import { IsSidebarVisibleKey } from "~/types/provides"
-import VLogoButtonOld from '~/components/VHeaderOld/VLogoButtonOld.vue'
-import VHeaderFilter from '~/components/VHeaderOld/VHeaderFilter.vue'
-import VSearchBarOld from '~/components/VHeaderOld/VSearchBar/VSearchBarOld.vue'
-import VHeaderMenu from '~/components/VHeaderOld/VHeaderMenu.vue'
+import VLogoButtonOld from "~/components/VHeaderOld/VLogoButtonOld.vue"
+import VHeaderFilter from "~/components/VHeaderOld/VHeaderFilter.vue"
+import VSearchBarOld from "~/components/VHeaderOld/VSearchBar/VSearchBarOld.vue"
+import VHeaderMenu from "~/components/VHeaderOld/VHeaderMenu.vue"
-import closeIcon from '~/assets/icons/close.svg'
+import closeIcon from "~/assets/icons/close.svg"
const menus = {
- FILTERS: 'filters',
- CONTENT_SWITCHER: 'content-switcher',
+ FILTERS: "filters",
+ CONTENT_SWITCHER: "content-switcher",
}
-type HeaderMenu = 'filters' | 'content-switcher'
+type HeaderMenu = "filters" | "content-switcher"
export default defineComponent({
- name: 'VHeaderOld',
+ name: "VHeaderOld",
components: {
VLogoButtonOld,
VHeaderFilter,
@@ -101,19 +101,19 @@ export default defineComponent({
const { matches: isSearchRoute } = useMatchSearchRoutes()
- const isHeaderScrolled = inject('isHeaderScrolled', ref(false))
- const headerHasTwoRows = inject('headerHasTwoRows')
+ const isHeaderScrolled = inject("isHeaderScrolled", ref(false))
+ const headerHasTwoRows = inject("headerHasTwoRows")
const isSidebarVisible = inject(IsSidebarVisibleKey)
const isDesktopLayout = computed(() => uiStore.isDesktopLayout)
const searchBarSize = computed(() => {
if (isDesktopLayout.value) {
- return 'medium'
+ return "medium"
} else if (isHeaderScrolled.value) {
- return 'small'
+ return "small"
} else {
- return 'large'
+ return "large"
}
})
@@ -141,8 +141,8 @@ export default defineComponent({
* Shows the loading state or result count.
*/
const searchStatus = computed(() => {
- if (!isSearchRoute.value || searchStore.searchTerm === '') return ''
- if (isFetching.value) return i18n.t('header.loading')
+ if (!isSearchRoute.value || searchStore.searchTerm === "") return ""
+ if (isFetching.value) return i18n.t("header.loading")
return getI18nCount(resultsCount.value)
})
@@ -178,14 +178,14 @@ export default defineComponent({
* to run and fetch new media.
*/
const handleSearch = async () => {
- window.scrollTo({ top: 0, left: 0, behavior: 'auto' })
+ window.scrollTo({ top: 0, left: 0, behavior: "auto" })
const searchType = isSearchRoute.value
? searchStore.searchType
: ALL_MEDIA
if (
isSearchRoute.value &&
- (!searchTermChanged.value || searchTerm.value === '')
+ (!searchTermChanged.value || searchTerm.value === "")
)
return
if (searchTermChanged.value) {
diff --git a/src/components/VHeaderOld/VLogoButtonOld.vue b/src/components/VHeaderOld/VLogoButtonOld.vue
index 27d864e0c..115aa61f5 100644
--- a/src/components/VHeaderOld/VLogoButtonOld.vue
+++ b/src/components/VHeaderOld/VLogoButtonOld.vue
@@ -28,15 +28,15 @@
</VButton>
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VLogoLoader from '~/components/VLogoLoader/VLogoLoader.vue'
-import VButton from '~/components/VButton.vue'
+import VLogoLoader from "~/components/VLogoLoader/VLogoLoader.vue"
+import VButton from "~/components/VButton.vue"
-import OpenverseLogoText from '~/assets/icons/openverse-logo-text.svg'
+import OpenverseLogoText from "~/assets/icons/openverse-logo-text.svg"
export default defineComponent({
- name: 'VLogoButtonOld',
+ name: "VLogoButtonOld",
components: { VLogoLoader, VButton },
props: {
isFetching: {
diff --git a/src/components/VHeaderOld/VPageMenu/VDesktopPageMenu.vue b/src/components/VHeaderOld/VPageMenu/VDesktopPageMenu.vue
index 118ec1aba..9dcae6d1f 100644
--- a/src/components/VHeaderOld/VPageMenu/VDesktopPageMenu.vue
+++ b/src/components/VHeaderOld/VPageMenu/VDesktopPageMenu.vue
@@ -15,14 +15,14 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VPopover from '~/components/VPopover/VPopover.vue'
-import VPageMenuButton from '~/components/VHeaderOld/VPageMenu/VPageMenuButton.vue'
-import VPageList from '~/components/VHeaderOld/VPageMenu/VPageList.vue'
+import VPopover from "~/components/VPopover/VPopover.vue"
+import VPageMenuButton from "~/components/VHeaderOld/VPageMenu/VPageMenuButton.vue"
+import VPageList from "~/components/VHeaderOld/VPageMenu/VPageList.vue"
export default defineComponent({
- name: 'VDesktopPageMenu',
+ name: "VDesktopPageMenu",
components: {
VPageMenuButton,
VPageList,
diff --git a/src/components/VHeaderOld/VPageMenu/VMobilePageMenu.vue b/src/components/VHeaderOld/VPageMenu/VMobilePageMenu.vue
index 224a12999..1251bf55b 100644
--- a/src/components/VHeaderOld/VPageMenu/VMobilePageMenu.vue
+++ b/src/components/VHeaderOld/VPageMenu/VMobilePageMenu.vue
@@ -13,14 +13,14 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VModal from '~/components/VModal/VModal.vue'
-import VPageMenuButton from '~/components/VHeaderOld/VPageMenu/VPageMenuButton.vue'
-import VPageList from '~/components/VHeaderOld/VPageMenu/VPageList.vue'
+import VModal from "~/components/VModal/VModal.vue"
+import VPageMenuButton from "~/components/VHeaderOld/VPageMenu/VPageMenuButton.vue"
+import VPageList from "~/components/VHeaderOld/VPageMenu/VPageList.vue"
export default defineComponent({
- name: 'VMobilePageMenu',
+ name: "VMobilePageMenu",
components: { VModal, VPageMenuButton, VPageList },
})
</script>
diff --git a/src/components/VHeaderOld/VPageMenu/VPageList.vue b/src/components/VHeaderOld/VPageMenu/VPageList.vue
index a5bda7ef4..cc136aa26 100644
--- a/src/components/VHeaderOld/VPageMenu/VPageList.vue
+++ b/src/components/VHeaderOld/VPageMenu/VPageList.vue
@@ -26,30 +26,30 @@
</VItemGroup>
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import usePages from '~/composables/use-pages'
+import usePages from "~/composables/use-pages"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VItem from '~/components/VItemGroup/VItem.vue'
-import VItemGroup from '~/components/VItemGroup/VItemGroup.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VItem from "~/components/VItemGroup/VItem.vue"
+import VItemGroup from "~/components/VItemGroup/VItemGroup.vue"
-import externalLinkIcon from '~/assets/icons/external-link.svg'
+import externalLinkIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
- name: 'VPageMenuPopover',
+ name: "VPageMenuPopover",
components: { VIcon, VItem, VItemGroup },
props: {
layout: {
- type: String as PropType<'vertical' | 'columns'>,
- default: 'vertical',
+ type: String as PropType<"vertical" | "columns">,
+ default: "vertical",
},
},
setup() {
const pages = usePages()
- const isLinkExternal = (item) => !item.link.startsWith('/')
- const getLinkProps = (item) => ({ as: 'VLink', href: item.link })
+ const isLinkExternal = (item) => !item.link.startsWith("/")
+ const getLinkProps = (item) => ({ as: "VLink", href: item.link })
return {
getLinkProps,
diff --git a/src/components/VHeaderOld/VPageMenu/VPageMenuButton.vue b/src/components/VHeaderOld/VPageMenu/VPageMenuButton.vue
index 71c3bc639..0c578e904 100644
--- a/src/components/VHeaderOld/VPageMenu/VPageMenuButton.vue
+++ b/src/components/VHeaderOld/VPageMenu/VPageMenuButton.vue
@@ -12,17 +12,17 @@
</VButton>
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VButton from '~/components/VButton.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VButton from "~/components/VButton.vue"
-import ellipsisIcon from '~/assets/icons/ellipsis.svg'
+import ellipsisIcon from "~/assets/icons/ellipsis.svg"
export default defineComponent({
- name: 'VPageMenuButton',
+ name: "VPageMenuButton",
components: { VButton, VIcon },
props: {
a11yProps: {},
diff --git a/src/components/VHeaderOld/VSearchBar/VSearchBarOld.vue b/src/components/VHeaderOld/VSearchBar/VSearchBarOld.vue
index f94f2f7ba..0f9fe5e7a 100644
--- a/src/components/VHeaderOld/VSearchBar/VSearchBarOld.vue
+++ b/src/components/VHeaderOld/VSearchBar/VSearchBarOld.vue
@@ -26,14 +26,14 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
import VInputFieldOld, {
FIELD_SIZES,
-} from '~/components/VInputFieldOld/VInputFieldOld.vue'
-import VSearchButtonOld from '~/components/VHeaderOld/VSearchBar/VSearchButtonOld.vue'
+} from "~/components/VInputFieldOld/VInputFieldOld.vue"
+import VSearchButtonOld from "~/components/VHeaderOld/VSearchBar/VSearchButtonOld.vue"
/**
* Displays a text field for a search query and is attached to an action button
@@ -41,7 +41,7 @@ import VSearchButtonOld from '~/components/VHeaderOld/VSearchBar/VSearchButtonOl
* displayed in the bar itself.
*/
export default defineComponent({
- name: 'VSearchBarOld',
+ name: "VSearchBarOld",
components: { VInputFieldOld, VSearchButtonOld },
inheritAttrs: false,
props: {
@@ -50,7 +50,7 @@ export default defineComponent({
*/
value: {
type: String,
- default: '',
+ default: "",
},
size: {
type: String as PropType<keyof typeof FIELD_SIZES>,
@@ -73,11 +73,11 @@ export default defineComponent({
const searchText = computed(() => props.value)
const updateSearchText = (val: string) => {
- emit('input', val)
+ emit("input", val)
}
const handleSearch = () => {
- emit('submit')
+ emit("submit")
}
return {
diff --git a/src/components/VHeaderOld/VSearchBar/VSearchButtonOld.vue b/src/components/VHeaderOld/VSearchBar/VSearchButtonOld.vue
index f0a7d59f0..5cdebff97 100644
--- a/src/components/VHeaderOld/VSearchBar/VSearchButtonOld.vue
+++ b/src/components/VHeaderOld/VSearchBar/VSearchButtonOld.vue
@@ -13,19 +13,19 @@
</template>
<script lang="ts">
-import { defineComponent, computed, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, computed, PropType } from "@nuxtjs/composition-api"
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VButton from '~/components/VButton.vue'
-import type { FieldSize } from '~/components/VInputFieldOld/VInputFieldOld.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VButton from "~/components/VButton.vue"
+import type { FieldSize } from "~/components/VInputFieldOld/VInputFieldOld.vue"
-import searchIcon from '~/assets/icons/search.svg'
+import searchIcon from "~/assets/icons/search.svg"
/**
* The search button used in the search bar on the search page with the `old_header`.
*/
export default defineComponent({
- name: 'VSearchButtonOld',
+ name: "VSearchButtonOld",
components: { VIcon, VButton },
inheritAttrs: false,
props: {
@@ -37,9 +37,9 @@ export default defineComponent({
setup(props) {
const sizeClasses = computed(() => {
return {
- small: 'w-10 md:w-12 h-10 md:h-12',
- medium: 'w-12 h-12',
- large: 'w-14 h-14',
+ small: "w-10 md:w-12 h-10 md:h-12",
+ medium: "w-12 h-12",
+ large: "w-14 h-14",
}[props.size]
})
diff --git a/src/components/VHeaderOld/VSearchBar/meta/VSearchBarOld.stories.mdx b/src/components/VHeaderOld/VSearchBar/meta/VSearchBarOld.stories.mdx
index 0c400ec0d..92f2b0078 100644
--- a/src/components/VHeaderOld/VSearchBar/meta/VSearchBarOld.stories.mdx
+++ b/src/components/VHeaderOld/VSearchBar/meta/VSearchBarOld.stories.mdx
@@ -4,18 +4,18 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import VSearchBarOld from '~/components/VHeaderOld/VSearchBar/VSearchBarOld.vue'
+} from "@storybook/addon-docs"
+import VSearchBarOld from "~/components/VHeaderOld/VSearchBar/VSearchBarOld.vue"
<Meta
title="Components/VHeaderOld/Search bar"
component={VSearchBarOld}
argTypes={{
input: {
- action: 'input',
+ action: "input",
},
submit: {
- action: 'submit',
+ action: "submit",
},
}}
/>
@@ -45,8 +45,8 @@ button is clicked.
<Story
name="Default"
args={{
- value: 'Search query',
- size: 'medium',
+ value: "Search query",
+ size: "medium",
}}
>
{Template.bind({})}
@@ -68,7 +68,7 @@ export const vModelTemplate = () => ({
components: { VSearchBarOld },
data() {
return {
- text: 'Hello, World!',
+ text: "Hello, World!",
}
},
})
@@ -77,16 +77,17 @@ export const vModelTemplate = () => ({
<Story name="v-model">{vModelTemplate.bind({})}</Story>
</Canvas>
-The `VSearchBarOld` component passes all attributes down to the inner `InputField`
-which itself applies all its attributes to its inner `<input>` element. So it's
-easy `<input>` attributes like placeholders or HTML validations.
+The `VSearchBarOld` component passes all attributes down to the inner
+`InputField` which itself applies all its attributes to its inner `<input>`
+element. So it's easy `<input>` attributes like placeholders or HTML
+validations.
<Canvas>
<Story
name="With placeholder"
args={{
- placeholder: 'Search query',
- size: 'large',
+ placeholder: "Search query",
+ size: "large",
}}
>
{Template.bind({})}
diff --git a/src/components/VHeaderOld/meta/VFilterButtonOld.stories.mdx b/src/components/VHeaderOld/meta/VFilterButtonOld.stories.mdx
index 65fde0b60..225ee567f 100644
--- a/src/components/VHeaderOld/meta/VFilterButtonOld.stories.mdx
+++ b/src/components/VHeaderOld/meta/VFilterButtonOld.stories.mdx
@@ -4,32 +4,32 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import { provide, ref } from '@nuxtjs/composition-api'
+} from "@storybook/addon-docs"
+import { provide, ref } from "@nuxtjs/composition-api"
-import { useSearchStore } from '~/stores/search'
-import { useUiStore } from '~/stores/ui'
+import { useSearchStore } from "~/stores/search"
+import { useUiStore } from "~/stores/ui"
-import { filterData, mediaFilterKeys } from '~/constants/filters'
-import { IMAGE } from '~/constants/media'
+import { filterData, mediaFilterKeys } from "~/constants/filters"
+import { IMAGE } from "~/constants/media"
-import VFilterButtonOld from '~/components/VHeaderOld/VFilterButtonOld.vue'
+import VFilterButtonOld from "~/components/VHeaderOld/VFilterButtonOld.vue"
<Meta
title="Components/VHeaderOld/VFilterButtonOld"
component={VFilterButtonOld}
argTypes={{
pressed: {
- type: 'boolean',
+ type: "boolean",
},
appliedFilters: {
- type: 'number',
+ type: "number",
},
scrolled: {
- type: 'boolean',
+ type: "boolean",
},
isMinMd: {
- type: 'boolean',
+ type: "boolean",
},
}}
/>
@@ -61,7 +61,7 @@ export const Template = (args, { argTypes }) => ({
}
applyNFilters(args.appliedFilters)
if (args.scrolled) {
- provide('isHeaderScrolled', ref(true))
+ provide("isHeaderScrolled", ref(true))
}
if (args.isMinMd) {
const uiStore = useUiStore()
@@ -77,10 +77,9 @@ export const Template = (args, { argTypes }) => ({
<ArgsTable of={VFilterButtonOld} />
-The button opens and closes the filters sidebar. It also shows how many filters are applied
-in the mobile view.
-the field receives an input. It also emits the `search` event when the search
-button is clicked.
+The button opens and closes the filters sidebar. It also shows how many filters
+are applied in the mobile view. the field receives an input. It also emits the
+`search` event when the search button is clicked.
<Canvas>
<Story name="Default">{Template.bind({})}</Story>
@@ -91,7 +90,7 @@ button is clicked.
name="Mobile Scrolled"
parameters={{
viewport: {
- defaultViewport: 'sm',
+ defaultViewport: "sm",
},
}}
>
diff --git a/src/components/VHeaderOld/meta/VHeader.stories.mdx b/src/components/VHeaderOld/meta/VHeader.stories.mdx
index 710671b4a..c1cbf2ff8 100644
--- a/src/components/VHeaderOld/meta/VHeader.stories.mdx
+++ b/src/components/VHeaderOld/meta/VHeader.stories.mdx
@@ -4,18 +4,18 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import VHeaderOld from '~/components/VHeaderOld/VHeaderOld.vue'
+} from "@storybook/addon-docs"
+import VHeaderOld from "~/components/VHeaderOld/VHeaderOld.vue"
<Meta
title="Components/VHeader/VHeader"
component={VHeaderOld}
argTypes={{
input: {
- action: 'input',
+ action: "input",
},
submit: {
- action: 'submit',
+ action: "submit",
},
}}
/>
@@ -35,7 +35,8 @@ export const Template = (args) => ({
<ArgsTable of={VHeaderOld} />
-The header component. Fixed on scroll, search bar, content switcher, pages menu and filters button.
+The header component. Fixed on scroll, search bar, content switcher, pages menu
+and filters button.
<Canvas>
<Story name="Default">{Template.bind({})}</Story>
diff --git a/src/components/VIcon/VIcon.vue b/src/components/VIcon/VIcon.vue
index a8f4e1b72..be7cd4cf1 100644
--- a/src/components/VIcon/VIcon.vue
+++ b/src/components/VIcon/VIcon.vue
@@ -12,9 +12,9 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import { isTest } from '~/utils/node-env'
+import { isTest } from "~/utils/node-env"
export type IconPath = string
export type IconProps = {
@@ -29,14 +29,14 @@ export type IconProps = {
* Displays the given icon in a 24px × 24px square.
*/
export default defineComponent({
- name: 'VIcon',
+ name: "VIcon",
props: {
/**
*
*/
viewBox: {
type: String,
- default: '0 0 24 24',
+ default: "0 0 24 24",
},
/**
* the path to the icon SVG; In a bundled application like Openverse,
@@ -55,7 +55,7 @@ export default defineComponent({
*/
gId: {
type: String,
- default: 'icon',
+ default: "icon",
},
/**
* The size of the icon based on tailwind values. Possible values:
@@ -81,7 +81,7 @@ export default defineComponent({
</script>
<style scoped>
-[dir='rtl'] .v-icon.rtl-flip {
+[dir="rtl"] .v-icon.rtl-flip {
@apply -scale-x-100 transform;
}
</style>
diff --git a/src/components/VIcon/meta/VIcon.stories.mdx b/src/components/VIcon/meta/VIcon.stories.mdx
index ce9ecc934..b747633dd 100644
--- a/src/components/VIcon/meta/VIcon.stories.mdx
+++ b/src/components/VIcon/meta/VIcon.stories.mdx
@@ -4,12 +4,12 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
-import replayIcon from '~/assets/icons/replay.svg'
-import externalLinkIcon from '~/assets/icons/external-link.svg'
+import replayIcon from "~/assets/icons/replay.svg"
+import externalLinkIcon from "~/assets/icons/external-link.svg"
<Meta title="Components/VIcon" component={VIcon} />
@@ -32,7 +32,7 @@ like Webpack, importing an SVG (with the right loaders) will give the path to
that SVG.
```js
-import iconSvg from '~/path/to/icon' // contains the URL path to the SVG
+import iconSvg from "~/path/to/icon" // contains the URL path to the SVG
```
You can then pass this imported value as the `iconPath` prop.
diff --git a/src/components/VIconButton/VIconButton.vue b/src/components/VIconButton/VIconButton.vue
index 3d9a5ea92..2c42b25eb 100644
--- a/src/components/VIconButton/VIconButton.vue
+++ b/src/components/VIconButton/VIconButton.vue
@@ -18,24 +18,24 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { ButtonType } from '~/types/button'
+import type { ButtonType } from "~/types/button"
-import VIcon, { type IconProps } from '~/components/VIcon/VIcon.vue'
-import VButton, { type ButtonProps } from '~/components/VButton.vue'
+import VIcon, { type IconProps } from "~/components/VIcon/VIcon.vue"
+import VButton, { type ButtonProps } from "~/components/VButton.vue"
const SIZE_MAP = Object.freeze({
- tiny: { icon: 6, button: 'w-6 h-6' },
- small: { icon: 6, button: 'w-10 h-10' },
- medium: { icon: 6, button: 'w-12 h-12' },
- large: { icon: 8, button: 'w-14 h-14' },
- 'extra-large': { icon: 12, button: 'w-20 h-20' },
+ tiny: { icon: 6, button: "w-6 h-6" },
+ small: { icon: 6, button: "w-10 h-10" },
+ medium: { icon: 6, button: "w-12 h-12" },
+ large: { icon: 8, button: "w-14 h-14" },
+ "extra-large": { icon: 12, button: "w-20 h-20" },
} as const)
type Size = keyof typeof SIZE_MAP
export default defineComponent({
- name: 'VIconButton',
+ name: "VIconButton",
components: { VIcon, VButton },
props: {
/**
@@ -44,7 +44,7 @@ export default defineComponent({
*/
size: {
type: String as PropType<Size>,
- default: 'medium',
+ default: "medium",
validator: (val: string) => Object.keys(SIZE_MAP).includes(val),
},
/**
@@ -61,11 +61,11 @@ export default defineComponent({
*/
buttonProps: {
type: Object as PropType<ButtonProps>,
- default: () => ({ variant: 'plain' }),
+ default: () => ({ variant: "plain" }),
},
},
setup(props, { attrs }) {
- const type = (attrs['type'] ?? 'button') as ButtonType
+ const type = (attrs["type"] ?? "button") as ButtonType
const buttonSizeClasses = computed(() => SIZE_MAP[props.size].button)
const iconSize = computed(() => SIZE_MAP[props.size].icon)
diff --git a/src/components/VIconButton/meta/VIconButton.stories.mdx b/src/components/VIconButton/meta/VIconButton.stories.mdx
index 637470ee6..9232a4bdb 100644
--- a/src/components/VIconButton/meta/VIconButton.stories.mdx
+++ b/src/components/VIconButton/meta/VIconButton.stories.mdx
@@ -4,20 +4,20 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VIconButton from '~/components/VIconButton/VIconButton.vue'
+import VIconButton from "~/components/VIconButton/VIconButton.vue"
-import replayIcon from '~/assets/icons/replay.svg'
+import replayIcon from "~/assets/icons/replay.svg"
<Meta
title="Components/VIconButton"
component={VIconButton}
argTypes={{
size: {
- defaultValue: 'medium',
- options: ['tiny', 'small', 'medium', 'large', 'extra-large'],
- control: 'select',
+ defaultValue: "medium",
+ options: ["tiny", "small", "medium", "large", "extra-large"],
+ control: "select",
},
}}
/>
diff --git a/src/components/VImageDetails/VImageDetails.vue b/src/components/VImageDetails/VImageDetails.vue
index ce46ca034..f9997fc5d 100644
--- a/src/components/VImageDetails/VImageDetails.vue
+++ b/src/components/VImageDetails/VImageDetails.vue
@@ -2,7 +2,7 @@
<section class="w-full">
<div class="mb-6 flex flex-row items-center justify-between">
<h2 class="heading-6 md:heading-5">
- {{ $t('image-details.information.title') }}
+ {{ $t("image-details.information.title") }}
</h2>
<VContentReportPopover :media="image" />
</div>
@@ -16,15 +16,15 @@
</ul>
<dl>
<div>
- <dt>{{ $t('image-details.information.type') }}</dt>
+ <dt>{{ $t("image-details.information.type") }}</dt>
<dd class="uppercase">{{ imgType }}</dd>
</div>
<div v-if="image.providerName !== image.sourceName">
- <dt>{{ $t('image-details.information.provider') }}</dt>
+ <dt>{{ $t("image-details.information.provider") }}</dt>
<dd>{{ image.providerName }}</dd>
</div>
<div>
- <dt>{{ $t('image-details.information.source') }}</dt>
+ <dt>{{ $t("image-details.information.source") }}</dt>
<dd>
<VLink :href="image.foreign_landing_url" class="text-pink">{{
image.sourceName
@@ -32,11 +32,11 @@
</dd>
</div>
<div>
- <dt>{{ $t('image-details.information.dimensions') }}</dt>
+ <dt>{{ $t("image-details.information.dimensions") }}</dt>
<dd>
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
{{ imageWidth }} &times; {{ imageHeight }}
- {{ $t('image-details.information.pixels') }}
+ {{ $t("image-details.information.pixels") }}
</dd>
</div>
</dl>
@@ -44,16 +44,16 @@
</template>
<script>
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import VContentReportPopover from '~/components/VContentReport/VContentReportPopover.vue'
-import VLink from '~/components/VLink.vue'
-import VMediaTag from '~/components/VMediaTag/VMediaTag.vue'
+import VContentReportPopover from "~/components/VContentReport/VContentReportPopover.vue"
+import VLink from "~/components/VLink.vue"
+import VMediaTag from "~/components/VMediaTag/VMediaTag.vue"
export default defineComponent({
- name: 'VImageDetails',
+ name: "VImageDetails",
components: { VContentReportPopover, VLink, VMediaTag },
props: {
image: {
@@ -75,12 +75,12 @@ export default defineComponent({
const imgType = computed(() => {
if (props.imageType) {
- if (props.imageType.split('/').length > 1) {
- return props.imageType.split('/')[1].toUpperCase()
+ if (props.imageType.split("/").length > 1) {
+ return props.imageType.split("/")[1].toUpperCase()
}
return props.imageType
}
- return i18n.t('image-details.information.unknown')
+ return i18n.t("image-details.information.unknown")
})
return { imgType }
diff --git a/src/components/VImageDetails/VRelatedImages.vue b/src/components/VImageDetails/VRelatedImages.vue
index 8f5a88cc8..9ac240c82 100644
--- a/src/components/VImageDetails/VRelatedImages.vue
+++ b/src/components/VImageDetails/VRelatedImages.vue
@@ -1,7 +1,7 @@
<template>
<aside>
<h2 class="heading-6 md:heading-5 mb-6">
- {{ $t('image-details.related-images') }}
+ {{ $t("image-details.related-images") }}
</h2>
<VLoadingIcon v-if="fetchState.isFetching" />
<VImageGrid
@@ -13,16 +13,16 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { ImageDetail } from '~/types/media'
-import type { FetchState } from '~/types/fetch-state'
+import type { ImageDetail } from "~/types/media"
+import type { FetchState } from "~/types/fetch-state"
-import VImageGrid from '~/components/VImageGrid/VImageGrid.vue'
-import VLoadingIcon from '~/components/LoadingIcon.vue'
+import VImageGrid from "~/components/VImageGrid/VImageGrid.vue"
+import VLoadingIcon from "~/components/LoadingIcon.vue"
export default defineComponent({
- name: 'VRelatedImages',
+ name: "VRelatedImages",
components: { VImageGrid, VLoadingIcon },
props: {
media: {
diff --git a/src/components/VImageGrid/VImageCell.vue b/src/components/VImageGrid/VImageCell.vue
index 1ffc12ae4..18ebbc3e3 100644
--- a/src/components/VImageGrid/VImageCell.vue
+++ b/src/components/VImageGrid/VImageCell.vue
@@ -35,14 +35,14 @@ import {
defineComponent,
PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import type { ImageDetail } from '~/types/media'
+import type { ImageDetail } from "~/types/media"
-import VLicense from '~/components/VLicense/VLicense.vue'
-import VLink from '~/components/VLink.vue'
+import VLicense from "~/components/VLicense/VLicense.vue"
+import VLink from "~/components/VLink.vue"
-import errorImage from '~/assets/image_not_available_placeholder.png'
+import errorImage from "~/assets/image_not_available_placeholder.png"
const minAspect = 3 / 4
const maxAspect = 16 / 9
@@ -50,15 +50,15 @@ const panoramaAspect = 21 / 9
const minRowWidth = 450
const widthBasis = minRowWidth / maxAspect
-const toAbsolutePath = (url: string, prefix = 'https://') => {
- if (url.indexOf('http://') >= 0 || url.indexOf('https://') >= 0) {
+const toAbsolutePath = (url: string, prefix = "https://") => {
+ if (url.indexOf("http://") >= 0 || url.indexOf("https://") >= 0) {
return url
}
return `${prefix}${url}`
}
export default defineComponent({
- name: 'VImageCell',
+ name: "VImageCell",
components: { VLicense, VLink },
props: {
image: {
diff --git a/src/components/VImageGrid/VImageGrid.vue b/src/components/VImageGrid/VImageGrid.vue
index 859851894..ebe2c498e 100644
--- a/src/components/VImageGrid/VImageGrid.vue
+++ b/src/components/VImageGrid/VImageGrid.vue
@@ -25,18 +25,18 @@
* or display 'No More Media'.
* Used to display both image search results, and related images.
*/
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { FetchState } from '~/types/fetch-state'
-import type { ImageDetail } from '~/types/media'
+import type { FetchState } from "~/types/fetch-state"
+import type { ImageDetail } from "~/types/media"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import VLoadMore from '~/components/VLoadMore.vue'
-import VImageCell from '~/components/VImageGrid/VImageCell.vue'
+import VLoadMore from "~/components/VLoadMore.vue"
+import VImageCell from "~/components/VImageGrid/VImageCell.vue"
export default defineComponent({
- name: 'ImageGrid',
+ name: "ImageGrid",
components: { VLoadMore, VImageCell },
props: {
images: {
@@ -59,7 +59,7 @@ export default defineComponent({
},
},
emits: {
- 'shift-tab': defineEvent(),
+ "shift-tab": defineEvent(),
},
setup(props, { emit }) {
const isError = computed(() => Boolean(props.fetchState.fetchingError))
@@ -67,7 +67,7 @@ export default defineComponent({
const handleShiftTab = (event: KeyboardEvent, index: number) => {
if (index === 0) {
event.preventDefault()
- emit('shift-tab')
+ emit("shift-tab")
}
}
@@ -85,7 +85,7 @@ export default defineComponent({
* single, 100% wide image.
*/
- content: '';
+ content: "";
flex-grow: 999999999;
}
}
diff --git a/src/components/VInputField/VInputField.vue b/src/components/VInputField/VInputField.vue
index c5de3ac44..519785d03 100644
--- a/src/components/VInputField/VInputField.vue
+++ b/src/components/VInputField/VInputField.vue
@@ -35,15 +35,15 @@ import {
computed,
defineComponent,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
export const FIELD_SIZES = {
- small: 'h-10 text-md',
- medium: 'h-12',
- large: 'h-14',
- standalone: 'h-full',
+ small: "h-10 text-md",
+ medium: "h-12",
+ large: "h-14",
+ standalone: "h-full",
} as const
export type FieldSize = keyof typeof FIELD_SIZES
@@ -51,11 +51,11 @@ export type FieldSize = keyof typeof FIELD_SIZES
* Provides a control to enter text as input.
*/
export default defineComponent({
- name: 'VInputField',
+ name: "VInputField",
inheritAttrs: false,
model: {
- prop: 'modelValue',
- event: 'update:modelValue',
+ prop: "modelValue",
+ event: "update:modelValue",
},
props: {
/**
@@ -63,7 +63,7 @@ export default defineComponent({
*/
modelValue: {
type: String,
- default: '',
+ default: "",
},
/**
* the textual content of the label associated with this input field; This
@@ -88,7 +88,7 @@ export default defineComponent({
type: Array,
default: () => [],
validator: (v: string[]) =>
- v.every((item) => ['start', 'end'].includes(item)),
+ v.every((item) => ["start", "end"].includes(item)),
},
/**
* Small size is for mobile header/scrolled
@@ -104,9 +104,9 @@ export default defineComponent({
},
// using non-native event name to ensure the two are not mixed
emits: {
- 'update:modelValue': defineEvent<[string]>(),
+ "update:modelValue": defineEvent<[string]>(),
},
- expose: ['focusInput'],
+ expose: ["focusInput"],
setup(props, { emit, attrs }) {
const inputEl = ref<HTMLInputElement | null>(null)
@@ -114,10 +114,10 @@ export default defineComponent({
inputEl.value?.focus()
}
- const type = typeof attrs['type'] === 'string' ? attrs['type'] : 'text'
+ const type = typeof attrs["type"] === "string" ? attrs["type"] : "text"
const updateModelValue = (event: Event) => {
- emit('update:modelValue', (event.target as HTMLInputElement).value)
+ emit("update:modelValue", (event.target as HTMLInputElement).value)
}
const sizeClass = computed(() => FIELD_SIZES[props.size])
diff --git a/src/components/VInputField/meta/VInputField.stories.mdx b/src/components/VInputField/meta/VInputField.stories.mdx
index 14542e8cf..3af57987a 100644
--- a/src/components/VInputField/meta/VInputField.stories.mdx
+++ b/src/components/VInputField/meta/VInputField.stories.mdx
@@ -4,16 +4,16 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VInputField from '~/components/VInputField/VInputField.vue'
+import VInputField from "~/components/VInputField/VInputField.vue"
<Meta
title="Components/VInputField"
component={VInputField}
argTypes={{
- 'update:modelValue': {
- action: 'update:modelValue',
+ "update:modelValue": {
+ action: "update:modelValue",
},
}}
/>
@@ -43,7 +43,7 @@ the field receives an input.
<Story
name="Default"
args={{
- value: 'Text goes here',
+ value: "Text goes here",
}}
>
{Template.bind({})}
@@ -64,7 +64,7 @@ export const vModelTemplate = () => ({
components: { VInputField },
data() {
return {
- text: 'Hello, World!',
+ text: "Hello, World!",
}
},
})
@@ -81,7 +81,7 @@ change the type as the field is specifically designed for text.
<Story
name="With placeholder"
args={{
- placeholder: 'Enter something here',
+ placeholder: "Enter something here",
}}
>
{Template.bind({})}
@@ -96,7 +96,7 @@ via the `labelText` prop.
<Story
name="With label text"
args={{
- labelText: 'Label:',
+ labelText: "Label:",
}}
>
{Template.bind({})}
@@ -130,7 +130,7 @@ seamless. The field has no border or rounded corners on the connected sides.
<Story
name="With connections"
args={{
- connectionSides: ['start', 'end'],
+ connectionSides: ["start", "end"],
}}
>
{Template.bind({})}
diff --git a/src/components/VInputFieldOld/VInputFieldOld.vue b/src/components/VInputFieldOld/VInputFieldOld.vue
index 1993cd142..c13fc94cc 100644
--- a/src/components/VInputFieldOld/VInputFieldOld.vue
+++ b/src/components/VInputFieldOld/VInputFieldOld.vue
@@ -27,15 +27,15 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
export const FIELD_SIZES = {
- small: 'h-10 text-md',
- medium: 'h-12',
- large: 'h-14',
- standalone: 'h-full',
+ small: "h-10 text-md",
+ medium: "h-12",
+ large: "h-14",
+ standalone: "h-full",
} as const
export type FieldSize = keyof typeof FIELD_SIZES
@@ -43,11 +43,11 @@ export type FieldSize = keyof typeof FIELD_SIZES
* Provides a control to enter text as input.
*/
export default defineComponent({
- name: 'VInputFieldOld',
+ name: "VInputFieldOld",
inheritAttrs: false,
model: {
- prop: 'modelValue',
- event: 'update:modelValue',
+ prop: "modelValue",
+ event: "update:modelValue",
},
props: {
/**
@@ -55,7 +55,7 @@ export default defineComponent({
*/
modelValue: {
type: String,
- default: '',
+ default: "",
},
/**
* the textual content of the label associated with this input field; This
@@ -80,7 +80,7 @@ export default defineComponent({
type: Array,
default: () => [],
validator: (v: string[]) =>
- v.every((item) => ['start', 'end'].includes(item)),
+ v.every((item) => ["start", "end"].includes(item)),
},
/**
* Small size is for mobile header/scrolled
@@ -96,13 +96,13 @@ export default defineComponent({
},
// using non-native event name to ensure the two are not mixed
emits: {
- 'update:modelValue': defineEvent<[string]>(),
+ "update:modelValue": defineEvent<[string]>(),
},
setup(props, { emit, attrs }) {
- const type = typeof attrs['type'] === 'string' ? attrs['type'] : 'text'
+ const type = typeof attrs["type"] === "string" ? attrs["type"] : "text"
const updateModelValue = (event: Event) => {
- emit('update:modelValue', (event.target as HTMLInputElement).value)
+ emit("update:modelValue", (event.target as HTMLInputElement).value)
}
const sizeClass = computed(() => FIELD_SIZES[props.size])
diff --git a/src/components/VInputFieldOld/meta/VInputFieldOld.stories.mdx b/src/components/VInputFieldOld/meta/VInputFieldOld.stories.mdx
index 4d9544fb1..a08b5971d 100644
--- a/src/components/VInputFieldOld/meta/VInputFieldOld.stories.mdx
+++ b/src/components/VInputFieldOld/meta/VInputFieldOld.stories.mdx
@@ -4,16 +4,16 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VInputFieldOld from '~/components/VInputFieldOld/VInputFieldOld.vue'
+import VInputFieldOld from "~/components/VInputFieldOld/VInputFieldOld.vue"
<Meta
title="Components/VInputFieldOld"
component={VInputFieldOld}
argTypes={{
- 'update:modelValue': {
- action: 'update:modelValue',
+ "update:modelValue": {
+ action: "update:modelValue",
},
}}
/>
@@ -43,7 +43,7 @@ the field receives an input.
<Story
name="Default"
args={{
- value: 'Text goes here',
+ value: "Text goes here",
}}
>
{Template.bind({})}
@@ -64,7 +64,7 @@ export const vModelTemplate = () => ({
components: { VInputFieldOld },
data() {
return {
- text: 'Hello, World!',
+ text: "Hello, World!",
}
},
})
@@ -81,7 +81,7 @@ change the type as the field is specifically designed for text.
<Story
name="With placeholder"
args={{
- placeholder: 'Enter something here',
+ placeholder: "Enter something here",
}}
>
{Template.bind({})}
@@ -96,7 +96,7 @@ via the `labelText` prop.
<Story
name="With label text"
args={{
- labelText: 'Label:',
+ labelText: "Label:",
}}
>
{Template.bind({})}
@@ -130,7 +130,7 @@ seamless. The field has no border or rounded corners on the connected sides.
<Story
name="With connections"
args={{
- connectionSides: ['start', 'end'],
+ connectionSides: ["start", "end"],
}}
>
{Template.bind({})}
diff --git a/src/components/VItemGroup/VItem.vue b/src/components/VItemGroup/VItem.vue
index c876a7ba6..5883f31f7 100644
--- a/src/components/VItemGroup/VItem.vue
+++ b/src/components/VItemGroup/VItem.vue
@@ -59,23 +59,23 @@ import {
computed,
watch,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { warn } from '~/utils/console'
+import { warn } from "~/utils/console"
import {
VItemGroupContextKey,
VItemGroupFocusContextKey,
-} from '~/types/item-group'
+} from "~/types/item-group"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import { VPopoverContentContextKey } from '~/components/VPopover/VPopoverContent.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import { VPopoverContentContextKey } from "~/components/VPopover/VPopoverContent.vue"
-import checkmark from '~/assets/icons/checkmark.svg'
+import checkmark from "~/assets/icons/checkmark.svg"
export default defineComponent({
- name: 'VItem',
+ name: "VItem",
components: { VButton, VIcon },
inheritAttrs: false,
props: {
@@ -99,9 +99,9 @@ export default defineComponent({
* @variants 'button', 'VLink'
*/
as: {
- type: String as PropType<'button' | 'VLink'>,
- default: 'button',
- validator: (val: string) => ['button', 'VLink'].includes(val),
+ type: String as PropType<"button" | "VLink">,
+ default: "button",
+ validator: (val: string) => ["button", "VLink"].includes(val),
},
},
/**
@@ -112,7 +112,7 @@ export default defineComponent({
* However, with current Vue 2 setup, if VItem is a link (a or NuxtLink), it is
* necessary to add native modifier to handle click event: `@click.native='handler'`.
*/
- emits: ['click'],
+ emits: ["click"],
setup(props) {
const focusContext = inject(VItemGroupFocusContextKey)
const isFocused = ref(false)
@@ -121,12 +121,12 @@ export default defineComponent({
if (!contextProps || !focusContext) {
throw new Error(
- 'Do not use `VItem` outside of a `VItemGroup`. Use `VButton` instead.'
+ "Do not use `VItem` outside of a `VItemGroup`. Use `VButton` instead."
)
}
if (isInPopover && contextProps.bordered) {
- warn('Bordered popover items are not supported')
+ warn("Bordered popover items are not supported")
}
watch(
@@ -137,7 +137,7 @@ export default defineComponent({
const tabIndex = computed(() => {
// If outside a radiogroup then everything can be tabbable in order
- if (contextProps.type !== 'radiogroup') return 0
+ if (contextProps.type !== "radiogroup") return 0
// If no items are selected then all can be tabbable to ensure it is possible to enter into the group
if (
focusContext.selectedCount.value === 0 &&
diff --git a/src/components/VItemGroup/VItemGroup.vue b/src/components/VItemGroup/VItemGroup.vue
index 96cf958cb..395bf93d1 100644
--- a/src/components/VItemGroup/VItemGroup.vue
+++ b/src/components/VItemGroup/VItemGroup.vue
@@ -26,24 +26,24 @@ import {
ref,
readonly,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import { keycodes } from '~/constants/key-codes'
-import { ensureFocus } from '~/utils/reakit-utils/focus'
+import { keycodes } from "~/constants/key-codes"
+import { ensureFocus } from "~/utils/reakit-utils/focus"
import type {
ItemGroupDirection,
ItemGroupSize,
ItemGroupType,
-} from '~/types/item-group'
+} from "~/types/item-group"
import {
itemGroupDirections,
itemGroupSizes,
itemGroupTypes,
VItemGroupContextKey,
VItemGroupFocusContextKey,
-} from '~/types/item-group'
+} from "~/types/item-group"
const arrows = [
keycodes.ArrowUp,
@@ -53,7 +53,7 @@ const arrows = [
]
export default defineComponent({
- name: 'VItemGroup',
+ name: "VItemGroup",
props: {
/**
* The direction to render the items in.
@@ -62,7 +62,7 @@ export default defineComponent({
*/
direction: {
type: String as PropType<ItemGroupDirection>,
- default: 'vertical',
+ default: "vertical",
validate: (v: string) =>
(itemGroupDirections as unknown as string[]).includes(v),
},
@@ -92,7 +92,7 @@ export default defineComponent({
*/
type: {
type: String as PropType<ItemGroupType>,
- default: 'menu',
+ default: "menu",
validate: (v: string) =>
(itemGroupTypes as unknown as string[]).includes(v),
},
@@ -103,7 +103,7 @@ export default defineComponent({
*/
size: {
type: String as PropType<ItemGroupSize>,
- default: 'small',
+ default: "small",
validate: (v: string) =>
(itemGroupSizes as unknown as string[]).includes(v),
},
@@ -124,8 +124,8 @@ export default defineComponent({
* @param rtl
*/
const resolveArrow = (ltr: string, rtl: string) => {
- return i18n.localeProperties.dir === 'rtl' &&
- props.direction === 'horizontal'
+ return i18n.localeProperties.dir === "rtl" &&
+ props.direction === "horizontal"
? rtl
: ltr
}
@@ -139,7 +139,7 @@ export default defineComponent({
// While VItem ultimately renders a button at the moment, that could change in the future, so using a data attribute selector makes it more flexible for the future
const items = Array.from<HTMLElement>(
- nodeRef.value?.querySelectorAll('[data-item-group-item]')
+ nodeRef.value?.querySelectorAll("[data-item-group-item]")
)
const targetIndex = items.findIndex((item) => item === target)
diff --git a/src/components/VItemGroup/meta/VItemGroup.stories.js b/src/components/VItemGroup/meta/VItemGroup.stories.js
index 419978770..ecacb3a77 100644
--- a/src/components/VItemGroup/meta/VItemGroup.stories.js
+++ b/src/components/VItemGroup/meta/VItemGroup.stories.js
@@ -1,30 +1,30 @@
-import { ref } from '@nuxtjs/composition-api'
+import { ref } from "@nuxtjs/composition-api"
-import { itemGroupDirections } from '~/types/item-group'
+import { itemGroupDirections } from "~/types/item-group"
-import VItemGroup from '~/components/VItemGroup/VItemGroup.vue'
-import VItem from '~/components/VItemGroup/VItem.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VPopover from '~/components/VPopover/VPopover.vue'
-import VButton from '~/components/VButton.vue'
+import VItemGroup from "~/components/VItemGroup/VItemGroup.vue"
+import VItem from "~/components/VItemGroup/VItem.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VPopover from "~/components/VPopover/VPopover.vue"
+import VButton from "~/components/VButton.vue"
-import replay from '~/assets/icons/replay.svg'
+import replay from "~/assets/icons/replay.svg"
-import pause from '~/assets/icons/pause.svg'
-import play from '~/assets/icons/play.svg'
-import close from '~/assets/icons/close.svg'
+import pause from "~/assets/icons/pause.svg"
+import play from "~/assets/icons/play.svg"
+import close from "~/assets/icons/close.svg"
const icons = [close, pause, play, replay]
export default {
component: VItemGroup,
- title: 'Components/VItemGroup',
+ title: "Components/VItemGroup",
args: {
direction: {
- type: 'radio',
+ type: "radio",
options: itemGroupDirections,
},
- bordered: 'boolean',
+ bordered: "boolean",
},
}
@@ -66,7 +66,7 @@ const DefaultStory = (args) => ({
export const Default = DefaultStory.bind({})
Default.args = {
- direction: 'vertical',
+ direction: "vertical",
bordered: true,
}
@@ -116,7 +116,7 @@ const MenuStory = (args) => ({
export const Menu = MenuStory.bind({})
Menu.args = {
- direction: 'vertical',
+ direction: "vertical",
bordered: true,
}
@@ -165,6 +165,6 @@ const PopoverStory = (args) => ({
export const Popover = PopoverStory.bind({})
Popover.args = {
- direction: 'vertical',
+ direction: "vertical",
bordered: false,
}
diff --git a/src/components/VLanguageSelect/VLanguageSelect.vue b/src/components/VLanguageSelect/VLanguageSelect.vue
index e1202170e..ea0b6e62a 100644
--- a/src/components/VLanguageSelect/VLanguageSelect.vue
+++ b/src/components/VLanguageSelect/VLanguageSelect.vue
@@ -14,25 +14,25 @@
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
import VSelectField, {
type Choice,
-} from '~/components/VSelectField/VSelectField.vue'
+} from "~/components/VSelectField/VSelectField.vue"
-import type { LocaleObject } from '@nuxtjs/i18n'
+import type { LocaleObject } from "@nuxtjs/i18n"
-import globeIcon from '~/assets/icons/globe.svg'
+import globeIcon from "~/assets/icons/globe.svg"
/**
* Presents a way for the users to change the app locale and use a translated
* version of the app.
*/
export default defineComponent({
- name: 'VLanguageSelect',
+ name: "VLanguageSelect",
components: { VSelectField, VIcon },
inheritAttrs: false,
setup() {
diff --git a/src/components/VLanguageSelect/meta/VLanguageSelect.stories.mdx b/src/components/VLanguageSelect/meta/VLanguageSelect.stories.mdx
index ff1f56282..71d83c639 100644
--- a/src/components/VLanguageSelect/meta/VLanguageSelect.stories.mdx
+++ b/src/components/VLanguageSelect/meta/VLanguageSelect.stories.mdx
@@ -1,6 +1,6 @@
-import { Description, Meta, Canvas, Story } from '@storybook/addon-docs'
+import { Description, Meta, Canvas, Story } from "@storybook/addon-docs"
-import VLanguageSelect from '~/components/VLanguageSelect/VLanguageSelect.vue'
+import VLanguageSelect from "~/components/VLanguageSelect/VLanguageSelect.vue"
<Meta title="Components/VLanguageSelect" component={VLanguageSelect} />
diff --git a/src/components/VLicense/VLicense.vue b/src/components/VLicense/VLicense.vue
index 474450ad7..3ec0fd1ab 100644
--- a/src/components/VLicense/VLicense.vue
+++ b/src/components/VLicense/VLicense.vue
@@ -17,20 +17,20 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { License, LICENSE_ICONS } from '~/constants/license'
-import { getFullLicenseName, getElements } from '~/utils/license'
-import { useI18n } from '~/composables/use-i18n'
+import { License, LICENSE_ICONS } from "~/constants/license"
+import { getFullLicenseName, getElements } from "~/utils/license"
+import { useI18n } from "~/composables/use-i18n"
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
/**
* Displays the icons for the license along with a readable display name for the
* license.
*/
export default defineComponent({
- name: 'VLicense',
+ name: "VLicense",
components: { VIcon },
props: {
/**
@@ -63,7 +63,7 @@ export default defineComponent({
const licenseName = computed(() => {
return {
readable: i18n.t(`license-readable-names.${props.license}`).toString(),
- full: getFullLicenseName(props.license, '', i18n),
+ full: getFullLicenseName(props.license, "", i18n),
}
})
diff --git a/src/components/VLicense/VLicenseElements.vue b/src/components/VLicense/VLicenseElements.vue
index 4a1c797ae..4d11b9e78 100644
--- a/src/components/VLicense/VLicenseElements.vue
+++ b/src/components/VLicense/VLicenseElements.vue
@@ -21,17 +21,17 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { License } from '~/constants/license'
-import { LICENSE_ICONS } from '~/constants/license'
-import { useUiStore } from '~/stores/ui'
-import { getElements } from '~/utils/license'
+import type { License } from "~/constants/license"
+import { LICENSE_ICONS } from "~/constants/license"
+import { useUiStore } from "~/stores/ui"
+import { getElements } from "~/utils/license"
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
export default defineComponent({
- name: 'VLicenseElements',
+ name: "VLicenseElements",
components: { VIcon },
props: {
/**
@@ -46,16 +46,16 @@ export default defineComponent({
* the size of the icons and text
*/
size: {
- type: String as PropType<'big' | 'small'>,
- default: 'big',
+ type: String as PropType<"big" | "small">,
+ default: "big",
},
},
setup(props) {
const elementNames = computed(() =>
- getElements(props.license).filter((icon) => icon !== 'cc')
+ getElements(props.license).filter((icon) => icon !== "cc")
)
- const isSmall = computed(() => props.size === 'small')
+ const isSmall = computed(() => props.size === "small")
const uiStore = useUiStore()
const isMobile = computed(() => !uiStore.isDesktopLayout)
diff --git a/src/components/VLicense/meta/VLicense.stories.mdx b/src/components/VLicense/meta/VLicense.stories.mdx
index 71c5695da..6d938bf72 100644
--- a/src/components/VLicense/meta/VLicense.stories.mdx
+++ b/src/components/VLicense/meta/VLicense.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VLicense from '~/components/VLicense/VLicense.vue'
+import VLicense from "~/components/VLicense/VLicense.vue"
<Meta title="Components/VLicense" component={VLicense} />
@@ -39,7 +39,7 @@ It can display CC licenses.
<Story
name="CC BY"
args={{
- license: 'by',
+ license: "by",
}}
>
{Template.bind({})}
@@ -47,7 +47,7 @@ It can display CC licenses.
<Story
name="CC BY-SA"
args={{
- license: 'by-sa',
+ license: "by-sa",
}}
>
{Template.bind({})}
@@ -55,7 +55,7 @@ It can display CC licenses.
<Story
name="CC BY-ND"
args={{
- license: 'by-nd',
+ license: "by-nd",
}}
>
{Template.bind({})}
@@ -63,7 +63,7 @@ It can display CC licenses.
<Story
name="CC BY-NC"
args={{
- license: 'by-nc',
+ license: "by-nc",
}}
>
{Template.bind({})}
@@ -71,7 +71,7 @@ It can display CC licenses.
<Story
name="CC BY-NC-SA"
args={{
- license: 'by-nc-sa',
+ license: "by-nc-sa",
}}
>
{Template.bind({})}
@@ -79,7 +79,7 @@ It can display CC licenses.
<Story
name="CC BY-NC-ND"
args={{
- license: 'by-nc-nd',
+ license: "by-nc-nd",
}}
>
{Template.bind({})}
@@ -97,7 +97,7 @@ It can also display some public domain licenses.
<Story
name="CC0"
args={{
- license: 'cc0',
+ license: "cc0",
}}
>
{Template.bind({})}
@@ -105,7 +105,7 @@ It can also display some public domain licenses.
<Story
name="PDM"
args={{
- license: 'pdm',
+ license: "pdm",
}}
>
{Template.bind({})}
@@ -123,7 +123,7 @@ It can also display some deprecated CC licenses.
<Story
name="CC Sampling+"
args={{
- license: 'sampling+',
+ license: "sampling+",
}}
>
{Template.bind({})}
@@ -131,7 +131,7 @@ It can also display some deprecated CC licenses.
<Story
name="CC NC-Sampling+"
args={{
- license: 'nc-sampling+',
+ license: "nc-sampling+",
}}
>
{Template.bind({})}
@@ -144,7 +144,7 @@ It can also show only the license icons.
<Story
name="Only icons"
args={{
- license: 'by-nc-sa',
+ license: "by-nc-sa",
hideName: true,
}}
>
diff --git a/src/components/VLicense/meta/VLicenseElements.stories.mdx b/src/components/VLicense/meta/VLicenseElements.stories.mdx
index e24a45eaa..63100aab0 100644
--- a/src/components/VLicense/meta/VLicenseElements.stories.mdx
+++ b/src/components/VLicense/meta/VLicenseElements.stories.mdx
@@ -4,24 +4,24 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VLicenseElements from '~/components/VLicense/VLicenseElements.vue'
-import { ALL_LICENSES } from '~/constants/license'
+import VLicenseElements from "~/components/VLicense/VLicenseElements.vue"
+import { ALL_LICENSES } from "~/constants/license"
<Meta
title="Components/VLicenseElements"
component={VLicenseElements}
argTypes={{
license: {
- default: 'by',
+ default: "by",
options: ALL_LICENSES,
- control: 'select',
+ control: "select",
},
size: {
- default: 'big',
- options: ['big', 'small'],
- control: 'select',
+ default: "big",
+ options: ["big", "small"],
+ control: "select",
},
}}
/>
@@ -48,7 +48,7 @@ export const Template = (args) => ({
<Story
name="Big"
args={{
- license: 'by-nc-nd',
+ license: "by-nc-nd",
}}
>
{Template.bind({})}
@@ -61,8 +61,8 @@ export const Template = (args) => ({
<Story
name="Small"
args={{
- license: 'by-nc-nd',
- size: 'small',
+ license: "by-nc-nd",
+ size: "small",
}}
>
{Template.bind({})}
diff --git a/src/components/VLink.vue b/src/components/VLink.vue
index 324c31656..e5d21df26 100644
--- a/src/components/VLink.vue
+++ b/src/components/VLink.vue
@@ -39,21 +39,21 @@
* Internal links use `NuxtLink` component with `to` attribute set to `localePath(href)`
* External links use `a` element set to open in a new tab and not raise an error with the current iframe setup.
*/
-import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'
+import { computed, defineComponent, useContext } from "@nuxtjs/composition-api"
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
-import externalLinkIcon from '~/assets/icons/external-link.svg'
+import externalLinkIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
- name: 'VLink',
+ name: "VLink",
components: { VIcon },
props: {
href: {
type: String,
required: false,
validator: (v: string | undefined) =>
- (typeof v === 'string' && v.length > 0) || typeof v === 'undefined',
+ (typeof v === "string" && v.length > 0) || typeof v === "undefined",
},
/**
* whether to render the external link icon next to links that point away
@@ -69,12 +69,12 @@ export default defineComponent({
function checkHref(
p: typeof props
): p is { href: string; showExternalIcon: boolean } {
- return typeof p.href === 'string' && !['', '#'].includes(p.href)
+ return typeof p.href === "string" && !["", "#"].includes(p.href)
}
const hasHref = computed(() => checkHref(props))
const isInternal = computed(
- () => hasHref.value && props.href?.startsWith('/')
+ () => hasHref.value && props.href?.startsWith("/")
)
const isNuxtLink = computed(() => hasHref.value && isInternal.value)
diff --git a/src/components/VLoadMore.vue b/src/components/VLoadMore.vue
index 4a0226fc8..899afa1ed 100644
--- a/src/components/VLoadMore.vue
+++ b/src/components/VLoadMore.vue
@@ -11,16 +11,16 @@
</VButton>
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { useMediaStore } from '~/stores/media'
-import { useSearchStore } from '~/stores/search'
-import { useI18n } from '~/composables/use-i18n'
+import { useMediaStore } from "~/stores/media"
+import { useSearchStore } from "~/stores/search"
+import { useI18n } from "~/composables/use-i18n"
-import VButton from '~/components/VButton.vue'
+import VButton from "~/components/VButton.vue"
export default defineComponent({
- name: 'VLoadMore',
+ name: "VLoadMore",
components: {
VButton,
},
@@ -39,7 +39,7 @@ export default defineComponent({
*/
const canLoadMore = computed(
() =>
- searchStore.searchTerm !== '' &&
+ searchStore.searchTerm !== "" &&
!mediaStore.fetchState.fetchingError &&
!mediaStore.fetchState.isFinished &&
mediaStore.resultCount > 0
@@ -61,8 +61,8 @@ export default defineComponent({
const buttonLabel = computed(() =>
isFetching.value
- ? i18n.t('browse-page.loading')
- : i18n.t('browse-page.load')
+ ? i18n.t("browse-page.loading")
+ : i18n.t("browse-page.load")
)
return {
diff --git a/src/components/VLogoLoader/VLogoLoader.vue b/src/components/VLogoLoader/VLogoLoader.vue
index ebb139936..cd36cc45c 100644
--- a/src/components/VLogoLoader/VLogoLoader.vue
+++ b/src/components/VLogoLoader/VLogoLoader.vue
@@ -41,16 +41,16 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import { useReducedMotion } from '~/composables/use-media-query'
+import { useReducedMotion } from "~/composables/use-media-query"
export default defineComponent({
- name: 'VLogoLoader',
+ name: "VLogoLoader",
props: {
status: {
- type: String as PropType<'loading' | 'idle'>,
- default: 'idle',
+ type: String as PropType<"loading" | "idle">,
+ default: "idle",
},
autoResize: {
type: Boolean,
diff --git a/src/components/VLogoLoader/meta/VLogoLoader.stories.mdx b/src/components/VLogoLoader/meta/VLogoLoader.stories.mdx
index 139e08e29..ea2eb9684 100644
--- a/src/components/VLogoLoader/meta/VLogoLoader.stories.mdx
+++ b/src/components/VLogoLoader/meta/VLogoLoader.stories.mdx
@@ -4,19 +4,19 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VLink from '~/components/VLink.vue'
-import VLogoLoader from '~/components/VLogoLoader/VLogoLoader.vue'
+import VLink from "~/components/VLink.vue"
+import VLogoLoader from "~/components/VLogoLoader/VLogoLoader.vue"
<Meta
title="Components/VLogoLoader"
component={VLogoLoader}
argTypes={{
status: {
- default: 'idle',
- options: ['loading', 'idle'],
- control: { type: 'radio' },
+ default: "idle",
+ options: ["loading", "idle"],
+ control: { type: "radio" },
},
}}
/>
@@ -42,7 +42,7 @@ The component can exist in two states.
### Idle
<Canvas>
- <Story name="Idle" args={{ status: 'idle' }}>
+ <Story name="Idle" args={{ status: "idle" }}>
{Template.bind({})}
</Story>
</Canvas>
@@ -58,8 +58,8 @@ for toggling this setting for your particular OS.
<Story
name="Loading"
args={{
- status: 'loading',
- loadingLabel: 'Loading images',
+ status: "loading",
+ loadingLabel: "Loading images",
}}
>
{Template.bind({})}
@@ -84,8 +84,8 @@ export const LinkTemplate = (args) => ({
<Story
name="Link"
args={{
- status: 'loading',
- loadingLabel: 'Loading images',
+ status: "loading",
+ loadingLabel: "Loading images",
}}
>
{LinkTemplate.bind({})}
diff --git a/src/components/VMediaInfo/VCopyLicense.vue b/src/components/VMediaInfo/VCopyLicense.vue
index f0861a33a..f5d694486 100644
--- a/src/components/VMediaInfo/VCopyLicense.vue
+++ b/src/components/VMediaInfo/VCopyLicense.vue
@@ -1,7 +1,7 @@
<template>
<div>
<h3 id="copy-license-title" class="description-bold md:heading-6 mb-4">
- {{ $t('media-details.reuse.copy-license.title') }}
+ {{ $t("media-details.reuse.copy-license.title") }}
</h3>
<VTabs label="#copy-license-title" :selected-id="tabs[0]">
@@ -29,20 +29,20 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import { AttributionOptions, getAttribution } from '~/utils/attribution-html'
-import type { Media } from '~/types/media'
-import { useI18n } from '~/composables/use-i18n'
+import { AttributionOptions, getAttribution } from "~/utils/attribution-html"
+import type { Media } from "~/types/media"
+import { useI18n } from "~/composables/use-i18n"
-import VTabs from '~/components/VTabs/VTabs.vue'
-import VTab from '~/components/VTabs/VTab.vue'
-import VLicenseTabPanel from '~/components/VMediaInfo/VLicenseTabPanel.vue'
+import VTabs from "~/components/VTabs/VTabs.vue"
+import VTab from "~/components/VTabs/VTab.vue"
+import VLicenseTabPanel from "~/components/VMediaInfo/VLicenseTabPanel.vue"
-const tabs = ['rich', 'html', 'plain']
+const tabs = ["rich", "html", "plain"]
export default defineComponent({
- name: 'VCopyLicense',
+ name: "VCopyLicense",
components: { VTabs, VTab, VLicenseTabPanel },
props: {
media: {
diff --git a/src/components/VMediaInfo/VLicenseTabPanel.vue b/src/components/VMediaInfo/VLicenseTabPanel.vue
index a77446556..c1915e36c 100644
--- a/src/components/VMediaInfo/VLicenseTabPanel.vue
+++ b/src/components/VMediaInfo/VLicenseTabPanel.vue
@@ -15,13 +15,13 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VCopyButton from '~/components/VCopyButton.vue'
-import VTabPanel from '~/components/VTabs/VTabPanel.vue'
+import VCopyButton from "~/components/VCopyButton.vue"
+import VTabPanel from "~/components/VTabs/VTabPanel.vue"
export default defineComponent({
- name: 'VLicenseTabPanel',
+ name: "VLicenseTabPanel",
components: {
VCopyButton,
VTabPanel,
diff --git a/src/components/VMediaInfo/VMediaLicense.vue b/src/components/VMediaInfo/VMediaLicense.vue
index 723270c0e..73cf77d3a 100644
--- a/src/components/VMediaInfo/VMediaLicense.vue
+++ b/src/components/VMediaInfo/VMediaLicense.vue
@@ -30,7 +30,7 @@
<VLink
:aria-label="$t('media-details.aria.attribution.tool')"
:href="licenseUrl"
- >{{ $t('media-details.reuse.tool.link') }}</VLink
+ >{{ $t("media-details.reuse.tool.link") }}</VLink
>
</template>
</i18n>
@@ -39,18 +39,18 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { getFullLicenseName, isLicense as isLicenseFn } from '~/utils/license'
-import { useI18n } from '~/composables/use-i18n'
+import { getFullLicenseName, isLicense as isLicenseFn } from "~/utils/license"
+import { useI18n } from "~/composables/use-i18n"
-import type { License, LicenseVersion } from '~/constants/license'
+import type { License, LicenseVersion } from "~/constants/license"
-import VLicenseElements from '~/components/VLicense/VLicenseElements.vue'
-import VLink from '~/components/VLink.vue'
+import VLicenseElements from "~/components/VLicense/VLicenseElements.vue"
+import VLink from "~/components/VLink.vue"
export default defineComponent({
- name: 'VMediaLicense',
+ name: "VMediaLicense",
components: { VLicenseElements, VLink },
props: {
license: {
@@ -70,7 +70,7 @@ export default defineComponent({
const i18n = useI18n()
const isLicense = computed(() => isLicenseFn(props.license))
const headerText = computed(() => {
- const licenseOrTool = isLicense.value ? 'license' : 'tool'
+ const licenseOrTool = isLicense.value ? "license" : "tool"
return i18n.t(`media-details.reuse.${licenseOrTool}-header`)
})
const fullLicenseName = computed(() =>
diff --git a/src/components/VMediaInfo/VMediaReuse.vue b/src/components/VMediaInfo/VMediaReuse.vue
index 185c49dca..1f0d4f18a 100644
--- a/src/components/VMediaInfo/VMediaReuse.vue
+++ b/src/components/VMediaInfo/VMediaReuse.vue
@@ -4,11 +4,11 @@
class="media-reuse"
>
<h2 class="heading-6 md:heading-5 mb-4">
- {{ $t('media-details.reuse.title') }}
+ {{ $t("media-details.reuse.title") }}
</h2>
<p class="text-base font-normal leading-[130%]">
{{
- $t('media-details.reuse.description', {
+ $t("media-details.reuse.description", {
media: media.frontendMediaType,
})
}}
@@ -25,15 +25,15 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { Media } from '~/types/media'
+import type { Media } from "~/types/media"
-import VCopyLicense from '~/components/VMediaInfo/VCopyLicense.vue'
-import VMediaLicense from '~/components/VMediaInfo/VMediaLicense.vue'
+import VCopyLicense from "~/components/VMediaInfo/VCopyLicense.vue"
+import VMediaLicense from "~/components/VMediaInfo/VMediaLicense.vue"
export default defineComponent({
- name: 'VMediaReuse',
+ name: "VMediaReuse",
components: { VCopyLicense, VMediaLicense },
props: {
media: {
diff --git a/src/components/VMediaInfo/meta/VMediaLicense.stories.mdx b/src/components/VMediaInfo/meta/VMediaLicense.stories.mdx
index b5c15a350..9a8254d9e 100644
--- a/src/components/VMediaInfo/meta/VMediaLicense.stories.mdx
+++ b/src/components/VMediaInfo/meta/VMediaLicense.stories.mdx
@@ -4,12 +4,12 @@ import {
Description,
Meta,
ArgsTable,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VMediaLicense from '~/components/VMediaInfo/VMediaLicense.vue'
+import VMediaLicense from "~/components/VMediaInfo/VMediaLicense.vue"
-import { ALL_LICENSES, LICENSE_VERSIONS } from '~/constants/license'
-import { getLicenseUrl } from '~/utils/license'
+import { ALL_LICENSES, LICENSE_VERSIONS } from "~/constants/license"
+import { getLicenseUrl } from "~/utils/license"
export const Template = (args) => ({
template: `<VMediaLicense v-bind="args"/>`,
@@ -26,12 +26,12 @@ export const Template = (args) => ({
license: {
defaultValue: ALL_LICENSES[0],
options: ALL_LICENSES,
- control: 'select',
+ control: "select",
},
licenseVersion: {
defaultValue: LICENSE_VERSIONS[0],
options: LICENSE_VERSIONS,
- control: 'select',
+ control: "select",
},
}}
/>
@@ -59,9 +59,9 @@ It can display CC licenses.
<Story
name="CC BY"
args={{
- license: 'by',
- licenseVersion: '4.0',
- licenseUrl: getLicenseUrl('by', '4.0'),
+ license: "by",
+ licenseVersion: "4.0",
+ licenseUrl: getLicenseUrl("by", "4.0"),
}}
>
{Template.bind({})}
@@ -69,9 +69,9 @@ It can display CC licenses.
<Story
name="CC BY-SA"
args={{
- license: 'by-sa',
- licenseVersion: '4.0',
- licenseUrl: getLicenseUrl('by-sa', '4.0'),
+ license: "by-sa",
+ licenseVersion: "4.0",
+ licenseUrl: getLicenseUrl("by-sa", "4.0"),
}}
>
{Template.bind({})}
@@ -79,9 +79,9 @@ It can display CC licenses.
<Story
name="CC BY-ND"
args={{
- license: 'by-nd',
- licenseVersion: '4.0',
- licenseUrl: getLicenseUrl('by-nd', '4.0'),
+ license: "by-nd",
+ licenseVersion: "4.0",
+ licenseUrl: getLicenseUrl("by-nd", "4.0"),
}}
>
{Template.bind({})}
@@ -89,9 +89,9 @@ It can display CC licenses.
<Story
name="CC BY-NC"
args={{
- license: 'by-nc',
- licenseVersion: '4.0',
- licenseUrl: getLicenseUrl('by-nc', '4.0'),
+ license: "by-nc",
+ licenseVersion: "4.0",
+ licenseUrl: getLicenseUrl("by-nc", "4.0"),
}}
>
{Template.bind({})}
@@ -99,9 +99,9 @@ It can display CC licenses.
<Story
name="CC BY-NC-SA"
args={{
- license: 'by-nc-sa',
- licenseVersion: '4.0',
- licenseUrl: getLicenseUrl('by-nc-sa', '4.0'),
+ license: "by-nc-sa",
+ licenseVersion: "4.0",
+ licenseUrl: getLicenseUrl("by-nc-sa", "4.0"),
}}
>
{Template.bind({})}
@@ -109,9 +109,9 @@ It can display CC licenses.
<Story
name="CC BY-NC-ND"
args={{
- license: 'by-nc-nd',
- licenseVersion: '4.0',
- licenseUrl: getLicenseUrl('by-nc-nd', '4.0'),
+ license: "by-nc-nd",
+ licenseVersion: "4.0",
+ licenseUrl: getLicenseUrl("by-nc-nd", "4.0"),
}}
>
{Template.bind({})}
@@ -129,9 +129,9 @@ It can also display some public domain licenses.
<Story
name="CC0"
args={{
- license: 'cc0',
- licenseVersion: '1.0',
- licenseUrl: getLicenseUrl('cc0', '1.0'),
+ license: "cc0",
+ licenseVersion: "1.0",
+ licenseUrl: getLicenseUrl("cc0", "1.0"),
}}
>
{Template.bind({})}
@@ -139,9 +139,9 @@ It can also display some public domain licenses.
<Story
name="PDM"
args={{
- license: 'pdm',
- licenseVersion: '1.0',
- licenseUrl: getLicenseUrl('pdm', '4.0'),
+ license: "pdm",
+ licenseVersion: "1.0",
+ licenseUrl: getLicenseUrl("pdm", "4.0"),
}}
>
{Template.bind({})}
@@ -159,9 +159,9 @@ It can also display some deprecated CC licenses.
<Story
name="CC Sampling+"
args={{
- license: 'sampling+',
- licenseVersion: '',
- licenseUrl: getLicenseUrl('sampling+', ''),
+ license: "sampling+",
+ licenseVersion: "",
+ licenseUrl: getLicenseUrl("sampling+", ""),
}}
>
{Template.bind({})}
@@ -169,9 +169,9 @@ It can also display some deprecated CC licenses.
<Story
name="CC NC-Sampling+"
args={{
- license: 'nc-sampling+',
- licenseVersion: '',
- licenseUrl: getLicenseUrl('nc-sampling+', ''),
+ license: "nc-sampling+",
+ licenseVersion: "",
+ licenseUrl: getLicenseUrl("nc-sampling+", ""),
}}
>
{Template.bind({})}
diff --git a/src/components/VMediaInfo/meta/v-media-reuse.stories.mdx b/src/components/VMediaInfo/meta/v-media-reuse.stories.mdx
index 55b505ac2..bb60ce89d 100644
--- a/src/components/VMediaInfo/meta/v-media-reuse.stories.mdx
+++ b/src/components/VMediaInfo/meta/v-media-reuse.stories.mdx
@@ -4,26 +4,26 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VMediaReuse from '~/components/VMediaInfo/VMediaReuse.vue'
+import VMediaReuse from "~/components/VMediaInfo/VMediaReuse.vue"
export const image = {
- id: 'f9384235-b72e-4f1e-9b05-e1b116262a29',
- frontendMediaType: 'image',
- title: 'Cat',
- originalTitle: 'Cat',
- foreign_landing_url: 'https://www.flickr.com/photos/7788419@N05/15218475961',
- url: 'https://live.staticflickr.com/3903/15218475961_963a4c116e_b.jpg',
- creator: 'strogoscope',
- creator_url: 'https://www.flickr.com/photos/7788419@N05',
- license: 'by',
- license_version: '2.0',
- license_url: 'https://creativecommons.org/licenses/by/2.0/',
- provider: 'flickr',
- source: 'flickr',
+ id: "f9384235-b72e-4f1e-9b05-e1b116262a29",
+ frontendMediaType: "image",
+ title: "Cat",
+ originalTitle: "Cat",
+ foreign_landing_url: "https://www.flickr.com/photos/7788419@N05/15218475961",
+ url: "https://live.staticflickr.com/3903/15218475961_963a4c116e_b.jpg",
+ creator: "strogoscope",
+ creator_url: "https://www.flickr.com/photos/7788419@N05",
+ license: "by",
+ license_version: "2.0",
+ license_url: "https://creativecommons.org/licenses/by/2.0/",
+ provider: "flickr",
+ source: "flickr",
detail_url:
- 'http://localhost:49153/v1/images/f9384235-b72e-4f1e-9b05-e1b116262a29/',
+ "http://localhost:49153/v1/images/f9384235-b72e-4f1e-9b05-e1b116262a29/",
}
<Meta title="Components/VMediaInfo/VMediaReuse" components={VMediaReuse} />
diff --git a/src/components/VMediaTag/VMediaTag.vue b/src/components/VMediaTag/VMediaTag.vue
index b563c4aef..80fa32abd 100644
--- a/src/components/VMediaTag/VMediaTag.vue
+++ b/src/components/VMediaTag/VMediaTag.vue
@@ -14,10 +14,10 @@
* Displays a tag associated with a media item. If set up as a link, it can be
* used as a link to find other items that are similarly tagged.
*/
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
export default defineComponent({
- name: 'MediaTag',
+ name: "MediaTag",
props: {
/**
* the HTML tag or Vue component to use as the root node; A non-interactive
@@ -25,7 +25,7 @@ export default defineComponent({
*/
tag: {
type: String,
- default: 'span',
+ default: "span",
},
},
})
diff --git a/src/components/VMediaTag/meta/VMediaTag.stories.mdx b/src/components/VMediaTag/meta/VMediaTag.stories.mdx
index 2cf04ad3c..5c3addfa7 100644
--- a/src/components/VMediaTag/meta/VMediaTag.stories.mdx
+++ b/src/components/VMediaTag/meta/VMediaTag.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VMediaTag from '~/components/VMediaTag/VMediaTag'
+import VMediaTag from "~/components/VMediaTag/VMediaTag"
<Meta title="Components/VMediaTag" component={VMediaTag} />
@@ -31,15 +31,15 @@ By default, the component is a transparent wrapper over `<span>`.
</Canvas>
The root node of the tag can be overridden to a different HTML tag or a Vue
-component, e.g. `VLink`. Any additional classes, such as for hover and
-focus states on interactive elements, can be applied to add to the base styles.
+component, e.g. `VLink`. Any additional classes, such as for hover and focus
+states on interactive elements, can be applied to add to the base styles.
<Canvas>
<Story
name="Custom node"
args={{
- tag: 'a',
- href: 'https://wordpress.org/',
+ tag: "a",
+ href: "https://wordpress.org/",
}}
>
{Template.bind({})}
diff --git a/src/components/VModal/VInputModal.vue b/src/components/VModal/VInputModal.vue
index 8e5509d6b..1df365b45 100644
--- a/src/components/VModal/VInputModal.vue
+++ b/src/components/VModal/VInputModal.vue
@@ -27,17 +27,17 @@ import {
watch,
toRef,
ComponentInstance,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { Portal as VTeleport } from 'portal-vue'
+import { Portal as VTeleport } from "portal-vue"
-import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'
-import { useDialogContent } from '~/composables/use-dialog-content'
+import { useBodyScrollLock } from "~/composables/use-body-scroll-lock"
+import { useDialogContent } from "~/composables/use-dialog-content"
-import type { SetupContext } from 'vue'
+import type { SetupContext } from "vue"
export default defineComponent({
- name: 'VInputModal',
+ name: "VInputModal",
components: { VTeleport },
/**
@@ -60,16 +60,16 @@ export default defineComponent({
/**
* Fires when the popover opens, regardless of reason. There are no extra parameters.
*/
- 'open',
+ "open",
/**
* Fires when the popover closes, regardless of reason. There are no extra parameters.
*/
- 'close',
+ "close",
],
setup(props, { emit }) {
const focusTrapRef = ref<ComponentInstance | null>(null)
- const visibleRef = toRef(props, 'isActive')
+ const visibleRef = toRef(props, "isActive")
const internalVisibleRef = ref<boolean>(
props.isActive === undefined ? false : visibleRef.value
)
@@ -96,21 +96,21 @@ export default defineComponent({
internalVisibleRef.value = true
lock()
if (props.isActive !== internalVisibleRef.value) {
- emit('open')
+ emit("open")
}
}
const close = () => {
internalVisibleRef.value = false
unlock()
- emit('close')
+ emit("close")
}
const dialogRef = ref<HTMLElement | null>(null)
const { onKeyDown, onBlur } = useDialogContent({
dialogRef,
- visibleRef: toRef(props, 'isActive'),
+ visibleRef: toRef(props, "isActive"),
autoFocusOnShowRef: ref(true),
autoFocusOnHideRef: ref(false),
triggerElementRef: ref(null),
@@ -118,7 +118,7 @@ export default defineComponent({
trapFocusRef: ref(true),
hideRef: ref(close),
hideOnEscRef: ref(true),
- emit: emit as SetupContext['emit'],
+ emit: emit as SetupContext["emit"],
})
return {
diff --git a/src/components/VModal/VModal.vue b/src/components/VModal/VModal.vue
index 70ca360c5..ceb76b778 100644
--- a/src/components/VModal/VModal.vue
+++ b/src/components/VModal/VModal.vue
@@ -46,16 +46,16 @@ import {
toRef,
PropType,
Ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'
+import { useBodyScrollLock } from "~/composables/use-body-scroll-lock"
-import type { ModalColorMode, ModalVariant } from '~/types/modal'
+import type { ModalColorMode, ModalVariant } from "~/types/modal"
-import VModalContent from '~/components/VModal/VModalContent.vue'
+import VModalContent from "~/components/VModal/VModalContent.vue"
export default defineComponent({
- name: 'VModal',
+ name: "VModal",
components: { VModalContent },
/**
* NB: Most of these technically default to `undefined` so that the underlying `VPopoverContent`
@@ -125,7 +125,7 @@ export default defineComponent({
*/
variant: {
type: String as PropType<ModalVariant>,
- default: 'default',
+ default: "default",
},
/**
* The color mode of the modal content.
@@ -136,7 +136,7 @@ export default defineComponent({
*/
mode: {
type: String as PropType<ModalColorMode>,
- default: 'light',
+ default: "light",
},
/**
* This props allows for the modal to be opened or closed programmatically.
@@ -150,31 +150,31 @@ export default defineComponent({
},
modalContentClasses: {
type: String,
- default: '',
+ default: "",
},
},
emits: [
/**
* Fires when the popover opens, regardless of reason. There are no extra parameters.
*/
- 'open',
+ "open",
/**
* Fires when the popover closes, regardless of reason. There are no extra parameters.
*/
- 'close',
+ "close",
],
setup(props, { emit }) {
- const visibleRef = toRef(props, 'visible')
+ const visibleRef = toRef(props, "visible")
const internalVisibleRef: Ref<boolean> = ref<boolean>(
- typeof props.visible === 'undefined' ? false : props.visible
+ typeof props.visible === "undefined" ? false : props.visible
)
const nodeRef = ref<null | HTMLElement>(null)
const triggerContainerRef = ref<HTMLElement | null>(null)
const triggerA11yProps = reactive({
- 'aria-expanded': false,
- 'aria-haspopup': 'dialog',
+ "aria-expanded": false,
+ "aria-haspopup": "dialog",
})
const triggerRef = computed(
@@ -182,7 +182,7 @@ export default defineComponent({
)
watch(internalVisibleRef, (visible) => {
- triggerA11yProps['aria-expanded'] = visible
+ triggerA11yProps["aria-expanded"] = visible
})
/**
@@ -205,14 +205,14 @@ export default defineComponent({
internalVisibleRef.value = true
lock()
if (props.visible !== internalVisibleRef.value) {
- emit('open')
+ emit("open")
}
}
const close = () => {
internalVisibleRef.value = false
unlock()
- emit('close')
+ emit("close")
}
const onTriggerClick = () => {
diff --git a/src/components/VModal/VModalContent.vue b/src/components/VModal/VModalContent.vue
index 6f428cef1..02fadc045 100644
--- a/src/components/VModal/VModalContent.vue
+++ b/src/components/VModal/VModalContent.vue
@@ -44,7 +44,7 @@
class="text-sr md:text-base md:text-white"
@click="hide()"
>
- {{ $t('modal.close') }}
+ {{ $t("modal.close") }}
<VIcon :icon-path="closeIcon" class="ms-2" :size="5" />
</VButton>
</div>
@@ -71,26 +71,26 @@ import {
ref,
computed,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { Portal as VTeleport } from 'portal-vue'
+import { Portal as VTeleport } from "portal-vue"
-import { useDialogContent } from '~/composables/use-dialog-content'
-import { warn } from '~/utils/console'
+import { useDialogContent } from "~/composables/use-dialog-content"
+import { warn } from "~/utils/console"
-import type { ModalColorMode, ModalVariant } from '~/types/modal'
+import type { ModalColorMode, ModalVariant } from "~/types/modal"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VLogoButtonOld from '~/components/VHeaderOld/VLogoButtonOld.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VLogoButtonOld from "~/components/VHeaderOld/VLogoButtonOld.vue"
-import closeIcon from '~/assets/icons/close.svg'
+import closeIcon from "~/assets/icons/close.svg"
/**
* Renders the inner content of a modal and manages focus.
*/
export default defineComponent({
- name: 'VModalContent',
+ name: "VModalContent",
components: { VTeleport, VButton, VIcon, VLogoButtonOld },
props: {
visible: {
@@ -131,11 +131,11 @@ export default defineComponent({
},
variant: {
type: String as PropType<ModalVariant>,
- default: 'default',
+ default: "default",
},
mode: {
type: String as PropType<ModalColorMode>,
- default: 'light',
+ default: "light",
},
/**
* The tailwind classes to apply to the modal backdrop element.
@@ -143,12 +143,12 @@ export default defineComponent({
*/
contentClasses: {
type: String,
- default: '',
+ default: "",
},
},
setup(props, { emit, attrs }) {
- if (!attrs['aria-label'] && !attrs['aria-labelledby']) {
- warn('You should provide either `aria-label` or `aria-labelledby` props.')
+ if (!attrs["aria-label"] && !attrs["aria-labelledby"]) {
+ warn("You should provide either `aria-label` or `aria-labelledby` props.")
}
const propsRefs = toRefs(props)
diff --git a/src/components/VModal/VModalTarget.vue b/src/components/VModal/VModalTarget.vue
index bfffce444..67859acfa 100644
--- a/src/components/VModal/VModalTarget.vue
+++ b/src/components/VModal/VModalTarget.vue
@@ -3,11 +3,11 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
-import { PortalTarget } from 'portal-vue'
+import { defineComponent } from "@nuxtjs/composition-api"
+import { PortalTarget } from "portal-vue"
export default defineComponent({
- name: 'VModalTarget',
+ name: "VModalTarget",
components: { PortalTarget },
})
</script>
diff --git a/src/components/VModal/meta/VModal.stories.js b/src/components/VModal/meta/VModal.stories.js
index 4a271a31d..c58368f51 100644
--- a/src/components/VModal/meta/VModal.stories.js
+++ b/src/components/VModal/meta/VModal.stories.js
@@ -1,22 +1,22 @@
-import { ref, computed } from '@nuxtjs/composition-api'
+import { ref, computed } from "@nuxtjs/composition-api"
-import VModal from '~/components/VModal/VModal.vue'
-import VModalTarget from '~/components/VModal/VModalTarget.vue'
-import VButton from '~/components/VButton.vue'
-import VPopover from '~/components/VPopover/VPopover.vue'
+import VModal from "~/components/VModal/VModal.vue"
+import VModalTarget from "~/components/VModal/VModalTarget.vue"
+import VButton from "~/components/VButton.vue"
+import VPopover from "~/components/VPopover/VPopover.vue"
export default {
component: VModal,
- title: 'Components/VModal',
+ title: "Components/VModal",
argTypes: {
- hideOnEsc: 'boolean',
- hideOnClickOutside: 'boolean',
- autoFocusOnShow: 'boolean',
- autoFocusOnHide: 'boolean',
- label: 'text',
- labelledBy: 'text',
+ hideOnEsc: "boolean",
+ hideOnClickOutside: "boolean",
+ autoFocusOnShow: "boolean",
+ autoFocusOnHide: "boolean",
+ label: "text",
+ labelledBy: "text",
useCustomInitialFocus: {
- type: 'boolean',
+ type: "boolean",
default: false,
},
},
diff --git a/src/components/VNavLink/VNavLink.vue b/src/components/VNavLink/VNavLink.vue
index 9319c5a0a..18b627ef8 100644
--- a/src/components/VNavLink/VNavLink.vue
+++ b/src/components/VNavLink/VNavLink.vue
@@ -14,12 +14,12 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import VLink from '~/components/VLink.vue'
+import VLink from "~/components/VLink.vue"
export default defineComponent({
- name: 'VNavLink',
+ name: "VNavLink",
components: {
VLink,
},
@@ -29,8 +29,8 @@ export default defineComponent({
default: false,
},
mode: {
- type: String as PropType<'light' | 'dark'>,
- default: 'dark',
+ type: String as PropType<"light" | "dark">,
+ default: "dark",
},
link: {
type: String,
diff --git a/src/components/VNavLink/meta/VNavLink.stories.mdx b/src/components/VNavLink/meta/VNavLink.stories.mdx
index a6143bcc5..4ff141fa1 100644
--- a/src/components/VNavLink/meta/VNavLink.stories.mdx
+++ b/src/components/VNavLink/meta/VNavLink.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VNavLink from '~/components/VNavLink/VNavLink.vue'
+import VNavLink from "~/components/VNavLink/VNavLink.vue"
export const Template = (args) => ({
template: `<VNavLink link="/about" v-bind="args" v-on="args">About</VNavLink>`,
@@ -20,11 +20,11 @@ export const Template = (args) => ({
title="Components/VNavLink"
component={VNavLink}
argTypes={{
- isActive: { control: { type: 'boolean' } },
- mode: { control: { type: 'select', options: ['dark', 'light'] } },
- variant: { control: { type: 'select', options: ['inline', 'column'] } },
- link: { control: { type: 'text' } },
- click: { action: 'click' },
+ isActive: { control: { type: "boolean" } },
+ mode: { control: { type: "select", options: ["dark", "light"] } },
+ variant: { control: { type: "select", options: ["inline", "column"] } },
+ link: { control: { type: "text" } },
+ click: { action: "click" },
}}
/>
diff --git a/src/components/VPill.vue b/src/components/VPill.vue
index 163792894..f5a04e0b3 100644
--- a/src/components/VPill.vue
+++ b/src/components/VPill.vue
@@ -7,9 +7,9 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
export default defineComponent({
- name: 'VPill',
+ name: "VPill",
})
</script>
diff --git a/src/components/VPopover/VPopover.vue b/src/components/VPopover/VPopover.vue
index f4162b659..38596df5d 100644
--- a/src/components/VPopover/VPopover.vue
+++ b/src/components/VPopover/VPopover.vue
@@ -50,16 +50,16 @@ import {
reactive,
computed,
PropType,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { zIndexValidator } from '~/constants/z-indices'
+import { zIndexValidator } from "~/constants/z-indices"
-import VPopoverContent from '~/components/VPopover/VPopoverContent.vue'
+import VPopoverContent from "~/components/VPopover/VPopoverContent.vue"
-import type { Placement, PositioningStrategy } from '@popperjs/core'
+import type { Placement, PositioningStrategy } from "@popperjs/core"
export default defineComponent({
- name: 'VPopover',
+ name: "VPopover",
components: { VPopoverContent },
/**
* NB: Most of these technically default to `undefined` so that the underlying `VPopoverContent`
@@ -132,7 +132,7 @@ export default defineComponent({
*/
zIndex: {
type: [Number, String],
- default: 'popover', // named z-index
+ default: "popover", // named z-index
validator: zIndexValidator,
},
/**
@@ -145,19 +145,19 @@ export default defineComponent({
/**
* Fires when the popover opens, regardless of reason. There are no extra parameters.
*/
- 'open',
+ "open",
/**
* Fires when the popover closes, regardless of reason. There are no extra parameters.
*/
- 'close',
+ "close",
],
setup(_, { emit }) {
const visibleRef = ref(false)
const triggerContainerRef = ref<HTMLElement | null>(null)
const triggerA11yProps = reactive({
- 'aria-expanded': false,
- 'aria-haspopup': 'dialog',
+ "aria-expanded": false,
+ "aria-haspopup": "dialog",
})
const triggerRef = computed(() =>
@@ -167,17 +167,17 @@ export default defineComponent({
)
watch(visibleRef, (visible) => {
- triggerA11yProps['aria-expanded'] = visible
+ triggerA11yProps["aria-expanded"] = visible
})
const open = () => {
visibleRef.value = true
- emit('open')
+ emit("open")
}
const close = () => {
visibleRef.value = false
- emit('close')
+ emit("close")
}
const onTriggerClick = () => {
diff --git a/src/components/VPopover/VPopoverContent.vue b/src/components/VPopover/VPopoverContent.vue
index d532e98a8..7419d2681 100644
--- a/src/components/VPopover/VPopoverContent.vue
+++ b/src/components/VPopover/VPopoverContent.vue
@@ -28,29 +28,29 @@ import {
InjectionKey,
PropType,
computed,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
import {
Placement,
placements as popoverPlacements,
PositioningStrategy,
-} from '@popperjs/core'
+} from "@popperjs/core"
-import { usePopoverContent } from '~/composables/use-popover-content'
-import { warn } from '~/utils/console'
-import { defineEvent } from '~/types/emits'
+import { usePopoverContent } from "~/composables/use-popover-content"
+import { warn } from "~/utils/console"
+import { defineEvent } from "~/types/emits"
-import { zIndexValidator } from '~/constants/z-indices'
+import { zIndexValidator } from "~/constants/z-indices"
-import type { CSSProperties } from '@vue/runtime-dom'
-import type { SetupContext } from 'vue'
+import type { CSSProperties } from "@vue/runtime-dom"
+import type { SetupContext } from "vue"
export const VPopoverContentContextKey = Symbol(
- 'VPopoverContentContextKey'
+ "VPopoverContentContextKey"
) as InjectionKey<boolean>
export default defineComponent({
- name: 'VPopoverContent',
+ name: "VPopoverContent",
props: {
visible: {
type: Boolean,
@@ -84,14 +84,14 @@ export default defineComponent({
},
placement: {
type: String as PropType<Placement>,
- default: 'bottom-end',
+ default: "bottom-end",
validate: (v: string) =>
(popoverPlacements as unknown as string[]).includes(v),
},
strategy: {
type: String as PropType<PositioningStrategy>,
- default: 'absolute',
- validate: (v: string) => ['absolute', 'fixed'].includes(v),
+ default: "absolute",
+ validate: (v: string) => ["absolute", "fixed"].includes(v),
},
zIndex: {
type: [String, Number],
@@ -111,8 +111,8 @@ export default defineComponent({
emits: { keydown: defineEvent(), blur: defineEvent() },
setup(props, { emit, attrs }) {
provide(VPopoverContentContextKey, true)
- if (!attrs['aria-label'] && !attrs['aria-labelledby']) {
- warn('You should provide either `aria-label` or `aria-labelledby` props.')
+ if (!attrs["aria-label"] && !attrs["aria-labelledby"]) {
+ warn("You should provide either `aria-label` or `aria-labelledby` props.")
}
const propsRefs = toRefs(props)
@@ -121,7 +121,7 @@ export default defineComponent({
const { onKeyDown, onBlur, maxHeightRef } = usePopoverContent({
popoverRef,
popoverPropsRefs: propsRefs,
- emit: emit as SetupContext['emit'],
+ emit: emit as SetupContext["emit"],
})
const heightProperties = computed(() => {
@@ -129,7 +129,7 @@ export default defineComponent({
const maxHeight = maxHeightRef.value
return maxHeight && props.clippable
- ? ({ '--popover-height': `${maxHeight}px` } as CSSProperties)
+ ? ({ "--popover-height": `${maxHeight}px` } as CSSProperties)
: ({} as CSSProperties)
})
diff --git a/src/components/VPopover/meta/VPopover.stories.js b/src/components/VPopover/meta/VPopover.stories.js
index d01710ed7..b6e98833b 100644
--- a/src/components/VPopover/meta/VPopover.stories.js
+++ b/src/components/VPopover/meta/VPopover.stories.js
@@ -1,24 +1,24 @@
-import { placements as popoverPlacements } from '@popperjs/core'
+import { placements as popoverPlacements } from "@popperjs/core"
-import { log } from '~/utils/console'
+import { log } from "~/utils/console"
-import VPopover from '~/components/VPopover/VPopover.vue'
-import VButton from '~/components/VButton.vue'
+import VPopover from "~/components/VPopover/VPopover.vue"
+import VButton from "~/components/VButton.vue"
export default {
component: VPopover,
- title: 'Components/VPopover',
+ title: "Components/VPopover",
argTypes: {
- hideOnEsc: 'boolean',
- hideOnClickOutside: 'boolean',
- autoFocusOnShow: 'boolean',
- autoFocusOnHide: 'boolean',
+ hideOnEsc: "boolean",
+ hideOnClickOutside: "boolean",
+ autoFocusOnShow: "boolean",
+ autoFocusOnHide: "boolean",
placement: {
- type: 'radio',
+ type: "radio",
options: [...popoverPlacements],
},
- label: 'text',
- labelledBy: 'text',
+ label: "text",
+ labelledBy: "text",
},
}
@@ -40,8 +40,8 @@ const SinglePopoverStory = (args, { argTypes }) => ({
`,
components: { VPopover, VButton },
setup() {
- const onOpen = () => log('opened!')
- const onClose = () => log('closed!')
+ const onOpen = () => log("opened!")
+ const onClose = () => log("closed!")
return { onOpen, onClose }
},
diff --git a/src/components/VRadio/VRadio.vue b/src/components/VRadio/VRadio.vue
index 69288086d..2187118fd 100644
--- a/src/components/VRadio/VRadio.vue
+++ b/src/components/VRadio/VRadio.vue
@@ -22,21 +22,21 @@
</template>
<script>
-import { computed } from '@nuxtjs/composition-api'
+import { computed } from "@nuxtjs/composition-api"
-import Radiomark from '~/assets/icons/radiomark.svg?inline'
+import Radiomark from "~/assets/icons/radiomark.svg?inline"
/**
* Renders a radio input field, useful for choosing one of a few options that
* can all be presented on the screen at once.
*/
export default {
- name: 'VRadio',
+ name: "VRadio",
components: { Radiomark },
inheritAttrs: false,
model: {
- prop: 'modelValue',
- event: 'change',
+ prop: "modelValue",
+ event: "change",
},
props: {
/**
@@ -58,13 +58,13 @@ export default {
*/
modelValue: {
type: String,
- default: '',
+ default: "",
},
},
setup(props, { emit }) {
const isChecked = computed(() => props.value === props.modelValue)
const handleInput = () => {
- emit('change', props.value)
+ emit("change", props.value)
}
return {
diff --git a/src/components/VRadio/meta/VRadio.stories.mdx b/src/components/VRadio/meta/VRadio.stories.mdx
index bdaf2295e..088404dad 100644
--- a/src/components/VRadio/meta/VRadio.stories.mdx
+++ b/src/components/VRadio/meta/VRadio.stories.mdx
@@ -4,16 +4,16 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VRadio from '~/components/VRadio/VRadio.vue'
+import VRadio from "~/components/VRadio/VRadio.vue"
<Meta
title="Components/VRadio"
components={VRadio}
argTypes={{
change: {
- action: 'change',
+ action: "change",
},
}}
/>
@@ -38,9 +38,9 @@ export const Template = (args, { argTypes }) => ({
<Story
name="Default"
args={{
- id: 'default',
- value: 'value',
- modelValue: 'modelValue', // if same as value, radio is checked
+ id: "default",
+ value: "value",
+ modelValue: "modelValue", // if same as value, radio is checked
}}
>
{Template.bind({})}
@@ -57,9 +57,9 @@ change the type as the field is specifically designed as a radio.
<Story
name="Disabled"
args={{
- id: 'disabled',
- value: 'value',
- modelValue: 'modelValue', // if same as value, radio is checked
+ id: "disabled",
+ value: "value",
+ modelValue: "modelValue", // if same as value, radio is checked
disabled: true,
}}
>
diff --git a/src/components/VRecentSearches/VRecentSearches.vue b/src/components/VRecentSearches/VRecentSearches.vue
index 061e0e89d..9e54a33ba 100644
--- a/src/components/VRecentSearches/VRecentSearches.vue
+++ b/src/components/VRecentSearches/VRecentSearches.vue
@@ -10,7 +10,7 @@
>
<!-- Left margin to align with the text of recent searches. -->
<span class="category mx-2 my-1">
- {{ $t('recent-searches.heading') }}
+ {{ $t("recent-searches.heading") }}
</span>
<VButton
v-show="entries.length"
@@ -19,7 +19,7 @@
:aria-label="$t('recent-searches.clear.label').toString()"
@click="handleClear"
>
- {{ $t('recent-searches.clear.text') }}
+ {{ $t("recent-searches.clear.text") }}
</VButton>
</div>
@@ -46,28 +46,28 @@
<!-- eslint-enable -->
</ul>
<span v-else class="description-regular mx-2 my-3">
- {{ $t('recent-searches.none') }}
+ {{ $t("recent-searches.none") }}
</span>
<span class="caption-regular mx-2 my-3 text-dark-charcoal-70">
- {{ $t('recent-searches.disclaimer') }}
+ {{ $t("recent-searches.disclaimer") }}
</span>
</div>
</template>
<script lang="ts">
-import { defineComponent, type PropType } from '@nuxtjs/composition-api'
+import { defineComponent, type PropType } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-import VButton from '~/components/VButton.vue'
+import VButton from "~/components/VButton.vue"
/**
* List the recent searches of the user allowing them to go back to a previous
* search. These searches are saved locally and never shared with the server.
*/
export default defineComponent({
- name: 'VRecentSearches',
+ name: "VRecentSearches",
components: { VButton },
props: {
/**
@@ -97,10 +97,10 @@ export default defineComponent({
},
setup(_, { emit }) {
const handleClick = (idx: number) => {
- emit('select', idx)
+ emit("select", idx)
}
const handleClear = () => {
- emit('clear')
+ emit("clear")
}
return {
diff --git a/src/components/VRecentSearches/meta/VRecentSearches.stories.mdx b/src/components/VRecentSearches/meta/VRecentSearches.stories.mdx
index e47845d94..a5a6c4a10 100644
--- a/src/components/VRecentSearches/meta/VRecentSearches.stories.mdx
+++ b/src/components/VRecentSearches/meta/VRecentSearches.stories.mdx
@@ -4,19 +4,19 @@ import {
Meta,
Canvas,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VRecentSearches from '~/components/VRecentSearches/VRecentSearches.vue'
+import VRecentSearches from "~/components/VRecentSearches/VRecentSearches.vue"
<Meta
title="Components/VRecentSearches"
component={VRecentSearches}
argTypes={{
select: {
- action: 'select',
+ action: "select",
},
clear: {
- action: 'clear',
+ action: "clear",
},
}}
/>
@@ -40,7 +40,7 @@ export const Template = (args) => ({
<Story
name="Default"
args={{
- entries: ['addition', 'subtraction', 'multiplication', 'division'],
+ entries: ["addition", "subtraction", "multiplication", "division"],
}}
>
{Template.bind({})}
diff --git a/src/components/VScrollButton.vue b/src/components/VScrollButton.vue
index f8c389aab..44d6eccfa 100644
--- a/src/components/VScrollButton.vue
+++ b/src/components/VScrollButton.vue
@@ -20,15 +20,15 @@
</template>
<script lang="ts">
-import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { computed, defineComponent } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
+import { defineEvent } from "~/types/emits"
-const positionWithoutSidebar = 'ltr:right-4 rtl:left-4'
-const positionWithSidebar = 'ltr:right-[21rem] rtl:left-[21rem]'
+const positionWithoutSidebar = "ltr:right-4 rtl:left-4"
+const positionWithSidebar = "ltr:right-[21rem] rtl:left-[21rem]"
export default defineComponent({
- name: 'VScrollButton',
+ name: "VScrollButton",
props: {
isFilterSidebarVisible: {
type: Boolean,
@@ -45,7 +45,7 @@ export default defineComponent({
: positionWithoutSidebar
)
const scrollToTop = () => {
- window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
+ window.scrollTo({ top: 0, left: 0, behavior: "smooth" })
}
return { hClass, scrollToTop }
},
diff --git a/src/components/VSearchGrid.vue b/src/components/VSearchGrid.vue
index 2a2310d5b..6028c6a00 100644
--- a/src/components/VSearchGrid.vue
+++ b/src/components/VSearchGrid.vue
@@ -35,22 +35,22 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType } from '@nuxtjs/composition-api'
+import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
-import { ALL_MEDIA, IMAGE, SearchType, mediaTypes } from '~/constants/media'
-import { NO_RESULT } from '~/constants/errors'
-import { defineEvent } from '~/types/emits'
-import type { ApiQueryParams } from '~/utils/search-query-transform'
-import type { FetchState } from '~/types/fetch-state'
+import { ALL_MEDIA, IMAGE, SearchType, mediaTypes } from "~/constants/media"
+import { NO_RESULT } from "~/constants/errors"
+import { defineEvent } from "~/types/emits"
+import type { ApiQueryParams } from "~/utils/search-query-transform"
+import type { FetchState } from "~/types/fetch-state"
-import VExternalSearchForm from '~/components/VExternalSearch/VExternalSearchForm.vue'
-import VErrorSection from '~/components/VErrorSection/VErrorSection.vue'
-import VErrorImage from '~/components/VErrorSection/VErrorImage.vue'
-import VNoResults from '~/components/VErrorSection/VNoResults.vue'
-import VSearchResultsTitle from '~/components/VSearchResultsTitle.vue'
+import VExternalSearchForm from "~/components/VExternalSearch/VExternalSearchForm.vue"
+import VErrorSection from "~/components/VErrorSection/VErrorSection.vue"
+import VErrorImage from "~/components/VErrorSection/VErrorImage.vue"
+import VNoResults from "~/components/VErrorSection/VNoResults.vue"
+import VSearchResultsTitle from "~/components/VSearchResultsTitle.vue"
export default defineComponent({
- name: 'VSearchGrid',
+ name: "VSearchGrid",
components: {
VErrorSection,
VExternalSearchForm,
@@ -88,7 +88,7 @@ export default defineComponent({
// noResult is hard-coded for search types that are not currently
// supported by Openverse built-in search
return props.supported
- ? props.query.q !== '' && props.resultsCount === 0
+ ? props.query.q !== "" && props.resultsCount === 0
: false
})
diff --git a/src/components/VSearchResultsTitle.vue b/src/components/VSearchResultsTitle.vue
index 2d30865fc..162bab6f0 100644
--- a/src/components/VSearchResultsTitle.vue
+++ b/src/components/VSearchResultsTitle.vue
@@ -8,14 +8,14 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
const sizes = {
- DEFAULT: 'default',
- LARGE: 'large',
+ DEFAULT: "default",
+ LARGE: "large",
}
export default defineComponent({
- name: 'VSearchResultsTitle',
+ name: "VSearchResultsTitle",
props: {
size: {
required: false,
diff --git a/src/components/VSelectField/VSelectField.vue b/src/components/VSelectField/VSelectField.vue
index 52be27652..877606e0e 100644
--- a/src/components/VSelectField/VSelectField.vue
+++ b/src/components/VSelectField/VSelectField.vue
@@ -27,14 +27,14 @@
</template>
<script lang="ts">
-import { defineComponent, computed, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, computed, PropType } from "@nuxtjs/composition-api"
-import { defineEvent } from '~/types/emits'
-import { ProperlyExtractPropTypes } from '~/types/prop-extraction'
+import { defineEvent } from "~/types/emits"
+import { ProperlyExtractPropTypes } from "~/types/prop-extraction"
-import VIcon from '~/components/VIcon/VIcon.vue'
+import VIcon from "~/components/VIcon/VIcon.vue"
-import caretDownIcon from '~/assets/icons/caret-down.svg'
+import caretDownIcon from "~/assets/icons/caret-down.svg"
/**
* Represents a singular valid option of the dropdown.
@@ -47,24 +47,24 @@ export interface Choice {
}
export type SelectFieldProps = ProperlyExtractPropTypes<
- NonNullable<typeof VSelectField['props']>
+ NonNullable<typeof VSelectField["props"]>
>
/**
* This field present many viable choices of which any one may be selected.
*/
const VSelectField = defineComponent({
- name: 'VSelectField',
+ name: "VSelectField",
components: { VIcon },
inheritAttrs: false,
model: {
- prop: 'modelValue',
- event: 'update:modelValue',
+ prop: "modelValue",
+ event: "update:modelValue",
},
props: {
modelValue: {
type: String,
- default: '',
+ default: "",
},
/**
* the text to associate with the blank value option; Skipping this prop
@@ -100,14 +100,14 @@ const VSelectField = defineComponent({
},
// using non-native event name to ensure the two are not mixed
emits: {
- 'update:modelValue': defineEvent<[string]>(),
+ "update:modelValue": defineEvent<[string]>(),
},
setup(props, { emit, attrs, slots }) {
- const fieldName = computed(() => attrs['name'] ?? props.fieldId)
+ const fieldName = computed(() => attrs["name"] ?? props.fieldId)
const modelMedium = computed<string>({
- get: () => props.modelValue ?? '',
+ get: () => props.modelValue ?? "",
set: (value: string) => {
- emit('update:modelValue', value)
+ emit("update:modelValue", value)
},
})
diff --git a/src/components/VSelectField/meta/VSelectField.stories.mdx b/src/components/VSelectField/meta/VSelectField.stories.mdx
index 1ee215a28..4d790c82a 100644
--- a/src/components/VSelectField/meta/VSelectField.stories.mdx
+++ b/src/components/VSelectField/meta/VSelectField.stories.mdx
@@ -4,20 +4,20 @@ import {
Meta,
Canvas,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import { ref } from '@nuxtjs/composition-api'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VSelectField from '~/components/VSelectField/VSelectField.vue'
+import { ref } from "@nuxtjs/composition-api"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VSelectField from "~/components/VSelectField/VSelectField.vue"
-import radioIcon from '~/assets/icons/radiomark.svg'
+import radioIcon from "~/assets/icons/radiomark.svg"
<Meta
title="Components/VSelectField"
component={VSelectField}
argTypes={{
- 'update:modelValue': {
- action: 'update:modelValue',
+ "update:modelValue": {
+ action: "update:modelValue",
},
}}
/>
@@ -32,13 +32,13 @@ export const Template = (args) => ({
})
export const baseArgs = {
- fieldId: 'fruit',
- blankText: 'Fruit',
- labelText: 'Fruit',
+ fieldId: "fruit",
+ blankText: "Fruit",
+ labelText: "Fruit",
choices: [
- { key: 'a', text: 'Apple' },
- { key: 'b', text: 'Banana' },
- { key: 'c', text: 'Cantaloupe' },
+ { key: "a", text: "Apple" },
+ { key: "b", text: "Banana" },
+ { key: "c", text: "Cantaloupe" },
],
}
@@ -66,7 +66,7 @@ export const vModelTemplate = (args) => ({
`,
components: { VSelectField },
setup() {
- const choice = ref('a')
+ const choice = ref("a")
return { choice, args }
},
})
@@ -123,10 +123,10 @@ export const ConstraintTemplate = (args) => ({
args={{
...baseArgs,
choices: [
- { key: 'short', text: 'Kiwi' },
+ { key: "short", text: "Kiwi" },
{
- key: 'long',
- text: 'Bob Gordon American Elderberry',
+ key: "long",
+ text: "Bob Gordon American Elderberry",
},
],
}}
@@ -141,7 +141,7 @@ There is a variant of the select field without the border, currently used only
on the 404 page.
<Canvas>
- <Story name="Without border" args={{ ...baseArgs, variant: 'borderless' }}>
+ <Story name="Without border" args={{ ...baseArgs, variant: "borderless" }}>
{Template.bind({})}
</Story>
</Canvas>
diff --git a/src/components/VSkeleton/VAudioTrackSkeleton.vue b/src/components/VSkeleton/VAudioTrackSkeleton.vue
index e8a9fd09e..0d96bb5a3 100644
--- a/src/components/VSkeleton/VAudioTrackSkeleton.vue
+++ b/src/components/VSkeleton/VAudioTrackSkeleton.vue
@@ -31,10 +31,10 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
export default defineComponent({
- name: 'VAudioTrackSkeleton',
+ name: "VAudioTrackSkeleton",
methods: {
getRandomSize(max = 250, min = 70) {
return Math.floor(Math.random() * (max - min) + min)
@@ -57,9 +57,9 @@ export default defineComponent({
animation: shimmer 3s infinite linear;
background: linear-gradient(
to right,
- theme('colors.dark-charcoal.10') 4%,
- theme('colors.dark-charcoal.20') 25%,
- theme('colors.dark-charcoal.10') 36%
+ theme("colors.dark-charcoal.10") 4%,
+ theme("colors.dark-charcoal.20") 25%,
+ theme("colors.dark-charcoal.10") 36%
);
background-size: 1000px 100%;
}
diff --git a/src/components/VSkeleton/VBone.vue b/src/components/VSkeleton/VBone.vue
index b947517fa..f9e25a745 100644
--- a/src/components/VSkeleton/VBone.vue
+++ b/src/components/VSkeleton/VBone.vue
@@ -3,10 +3,10 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
export default defineComponent({
- name: 'VBone',
+ name: "VBone",
props: { shimmer: { type: Boolean, default: true } },
})
</script>
@@ -25,9 +25,9 @@ export default defineComponent({
animation: shimmer 3s infinite linear;
background: linear-gradient(
to right,
- theme('colors.dark-charcoal.10') 4%,
- theme('colors.dark-charcoal.20') 25%,
- theme('colors.dark-charcoal.10') 36%
+ theme("colors.dark-charcoal.10") 4%,
+ theme("colors.dark-charcoal.20") 25%,
+ theme("colors.dark-charcoal.10") 36%
);
background-size: 1000px 100%;
}
diff --git a/src/components/VSkeleton/VGridSkeleton.vue b/src/components/VSkeleton/VGridSkeleton.vue
index 2de6261a7..68e5d488e 100644
--- a/src/components/VSkeleton/VGridSkeleton.vue
+++ b/src/components/VSkeleton/VGridSkeleton.vue
@@ -27,26 +27,26 @@
* Display placeholder elements while waiting for the actual elements to be
* loaded in the results views.
*/
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
-import type { SupportedSearchType } from '~/constants/media'
+import type { SupportedSearchType } from "~/constants/media"
-import VAudioTrackSkeleton from '~/components/VSkeleton/VAudioTrackSkeleton.vue'
-import VBone from '~/components/VSkeleton/VBone.vue'
+import VAudioTrackSkeleton from "~/components/VSkeleton/VAudioTrackSkeleton.vue"
+import VBone from "~/components/VSkeleton/VBone.vue"
export default defineComponent({
- name: 'VGridSkeleton',
+ name: "VGridSkeleton",
components: { VAudioTrackSkeleton, VBone },
props: {
isForTab: {
type: String as PropType<SupportedSearchType>,
- default: 'image',
+ default: "image",
},
numElems: {
type: Number,
default: function () {
- if (this.isForTab === 'all') return 20
- if (this.isForTab === 'image') return 30
+ if (this.isForTab === "all") return 20
+ if (this.isForTab === "image") return 30
return 8
},
},
diff --git a/src/components/VSkeleton/meta/VGridSkeleton.stories.mdx b/src/components/VSkeleton/meta/VGridSkeleton.stories.mdx
index ce4fc823e..6e44e265b 100644
--- a/src/components/VSkeleton/meta/VGridSkeleton.stories.mdx
+++ b/src/components/VSkeleton/meta/VGridSkeleton.stories.mdx
@@ -4,9 +4,9 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VGridSkeleton from '~/components/VSkeleton/VGridSkeleton.vue'
+import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue"
<Meta title="Components/Skeleton" component={VGridSkeleton} />
@@ -27,7 +27,7 @@ export const Template = (args) => ({
## Grid skeleton for "All" tab
<Canvas>
- <Story name="All tab" args={{ isForTab: 'all' }}>
+ <Story name="All tab" args={{ isForTab: "all" }}>
{Template.bind({})}
</Story>
</Canvas>
@@ -35,7 +35,7 @@ export const Template = (args) => ({
## Grid skeleton for "Image" tab
<Canvas>
- <Story name="Image tab" args={{ isForTab: 'image' }}>
+ <Story name="Image tab" args={{ isForTab: "image" }}>
{Template.bind({})}
</Story>
</Canvas>
@@ -43,7 +43,7 @@ export const Template = (args) => ({
## List skeleton for "Audio" tab
<Canvas>
- <Story name="Audio tab" args={{ isForTab: 'audio' }}>
+ <Story name="Audio tab" args={{ isForTab: "audio" }}>
{Template.bind({})}
</Story>
</Canvas>
diff --git a/src/components/VSketchFabViewer.vue b/src/components/VSketchFabViewer.vue
index ffab4a9c8..58d45cc8d 100644
--- a/src/components/VSketchFabViewer.vue
+++ b/src/components/VSketchFabViewer.vue
@@ -20,13 +20,13 @@ import {
ref,
onMounted,
useContext,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useI18n } from '~/composables/use-i18n'
-import { loadScript } from '~/utils/load-script'
+import { useI18n } from "~/composables/use-i18n"
+import { loadScript } from "~/utils/load-script"
const sketchfabUrl =
- 'https://static.sketchfab.com/api/sketchfab-viewer-1.10.1.js'
+ "https://static.sketchfab.com/api/sketchfab-viewer-1.10.1.js"
interface SketchfabConfig {
error(e: unknown): void
@@ -47,19 +47,19 @@ export default defineComponent({
required: true,
},
},
- emits: ['failure'],
+ emits: ["failure"],
setup(props, { emit }) {
const i18n = useI18n()
const label = i18n
- .t('sketchfab-iframe-title', { sketchfab: 'Sketchfab' })
+ .t("sketchfab-iframe-title", { sketchfab: "Sketchfab" })
.toString()
const node = ref<Element | undefined>()
const { $sentry } = useContext()
const initSketchfab = async () => {
await loadScript(sketchfabUrl)
- if (typeof window.Sketchfab === 'undefined') {
- $sentry.captureMessage('Unable to find window.Sketchfab after loading')
+ if (typeof window.Sketchfab === "undefined") {
+ $sentry.captureMessage("Unable to find window.Sketchfab after loading")
return
}
@@ -73,7 +73,7 @@ export default defineComponent({
sf.init(props.uid, {
error: (e: unknown) => {
$sentry.captureException(e)
- emit('failure')
+ emit("failure")
},
})
}
diff --git a/src/components/VSkipToContentContainer.vue b/src/components/VSkipToContentContainer.vue
index 2d59c44ac..dfd2092d7 100644
--- a/src/components/VSkipToContentContainer.vue
+++ b/src/components/VSkipToContentContainer.vue
@@ -6,19 +6,19 @@
class="z-50 mt-2 ms-2 focus:fixed focus:absolute"
:class="$style.skipButton"
@click="skipToContent"
- >{{ $t('skip-to-content') }}</VButton
+ >{{ $t("skip-to-content") }}</VButton
>
</VTeleport>
</div>
</template>
<script>
-import { defineComponent, ref } from '@nuxtjs/composition-api'
-import { Portal as VTeleport } from 'portal-vue'
+import { defineComponent, ref } from "@nuxtjs/composition-api"
+import { Portal as VTeleport } from "portal-vue"
-import { ensureFocus, getFirstTabbableIn } from '~/utils/reakit-utils/focus'
+import { ensureFocus, getFirstTabbableIn } from "~/utils/reakit-utils/focus"
-import VButton from '~/components/VButton.vue'
+import VButton from "~/components/VButton.vue"
/**
* Demarcates the section that the "skip to content"
@@ -29,7 +29,7 @@ import VButton from '~/components/VButton.vue'
* button will not render.
*/
export default defineComponent({
- name: 'VSkipToContentContainer',
+ name: "VSkipToContentContainer",
components: { VTeleport, VButton },
props: {
initialFocusNode: {
diff --git a/src/components/VSnackbar.vue b/src/components/VSnackbar.vue
index 8aa8303bd..7638eb639 100644
--- a/src/components/VSnackbar.vue
+++ b/src/components/VSnackbar.vue
@@ -15,14 +15,14 @@
</template>
<script lang="ts">
-import { defineComponent, PropType } from '@nuxtjs/composition-api'
+import { defineComponent, PropType } from "@nuxtjs/composition-api"
export default defineComponent({
- name: 'VSnackbar',
+ name: "VSnackbar",
props: {
size: {
- type: String as PropType<'small' | 'large'>,
- default: 'small',
+ type: String as PropType<"small" | "large">,
+ default: "small",
},
/**
* whether the snackbar is visible or hidden
diff --git a/src/components/VSourcesTable.vue b/src/components/VSourcesTable.vue
index 3e7f2a810..a4af9eaa9 100644
--- a/src/components/VSourcesTable.vue
+++ b/src/components/VSourcesTable.vue
@@ -12,7 +12,7 @@
@keypress.enter="sortTable('display_name')"
>
<span class="flex w-full flex-row items-center justify-between">
- {{ $t('sources.providers.source') }}
+ {{ $t("sources.providers.source") }}
<TableSortIcon :active="sorting.field === 'display_name'" />
</span>
</th>
@@ -22,7 +22,7 @@
@keypress.enter="sortTable('source_url')"
>
<span class="flex w-full flex-row items-center justify-between">
- {{ $t('sources.providers.domain') }}
+ {{ $t("sources.providers.domain") }}
<TableSortIcon :active="sorting.field === 'source_url'" />
</span>
</th>
@@ -32,7 +32,7 @@
@keypress.enter="sortTable('media_count')"
>
<span class="flex w-full flex-row items-center justify-between">
- {{ $t('sources.providers.item') }}
+ {{ $t("sources.providers.item") }}
<TableSortIcon :active="sorting.field === 'media_count'" />
</span>
</th>
@@ -62,21 +62,21 @@ import {
defineComponent,
PropType,
reactive,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useProviderStore } from '~/stores/provider'
-import { useGetLocaleFormattedNumber } from '~/composables/use-get-locale-formatted-number'
+import { useProviderStore } from "~/stores/provider"
+import { useGetLocaleFormattedNumber } from "~/composables/use-get-locale-formatted-number"
-import type { SupportedMediaType } from '~/constants/media'
-import type { MediaProvider } from '~/types/media-provider'
+import type { SupportedMediaType } from "~/constants/media"
+import type { MediaProvider } from "~/types/media-provider"
-import TableSortIcon from '~/components/TableSortIcon.vue'
-import VLink from '~/components/VLink.vue'
+import TableSortIcon from "~/components/TableSortIcon.vue"
+import VLink from "~/components/VLink.vue"
-import externalLinkIcon from '~/assets/icons/external-link.svg'
+import externalLinkIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
- name: 'VSourcesTable',
+ name: "VSourcesTable",
components: {
TableSortIcon,
VLink,
@@ -89,14 +89,14 @@ export default defineComponent({
},
setup(props) {
const sorting = reactive({
- direction: 'asc',
- field: 'display_name' as keyof Omit<MediaProvider, 'logo_url'>,
+ direction: "asc",
+ field: "display_name" as keyof Omit<MediaProvider, "logo_url">,
})
- function sortTable(field: keyof Omit<MediaProvider, 'logo_url'>) {
- let direction = 'asc'
+ function sortTable(field: keyof Omit<MediaProvider, "logo_url">) {
+ let direction = "asc"
if (field === sorting.field) {
- direction = sorting.direction === 'asc' ? 'desc' : 'asc'
+ direction = sorting.direction === "asc" ? "desc" : "asc"
}
sorting.direction = direction
@@ -104,10 +104,10 @@ export default defineComponent({
}
function cleanSourceUrlForPresentation(url: string) {
- const stripProtocol = (s: string) => s.replace(/https?:\/\//, '')
+ const stripProtocol = (s: string) => s.replace(/https?:\/\//, "")
const stripLeadingWww = (s: string) =>
- s.startsWith('www.') ? s.replace('www.', '') : s
- const removeAfterSlash = (s: string) => s.split('/')[0]
+ s.startsWith("www.") ? s.replace("www.", "") : s
+ const removeAfterSlash = (s: string) => s.split("/")[0]
return removeAfterSlash(stripLeadingWww(stripProtocol(url)))
}
@@ -118,7 +118,7 @@ export default defineComponent({
function compareProviders(prov1: MediaProvider, prov2: MediaProvider) {
let field1 = prov1[sorting.field]
let field2 = prov2[sorting.field]
- if (sorting.field === 'source_url') {
+ if (sorting.field === "source_url") {
field1 = cleanSourceUrlForPresentation(field1 as string)
field2 = cleanSourceUrlForPresentation(field2 as string)
}
@@ -130,7 +130,7 @@ export default defineComponent({
const sortedProviders = computed(() => {
const providers = providerStore.providers[props.media]
providers.sort(compareProviders)
- return sorting.direction === 'asc' ? providers : providers.reverse()
+ return sorting.direction === "asc" ? providers : providers.reverse()
})
return {
diff --git a/src/components/VTabs/VTab.vue b/src/components/VTabs/VTab.vue
index 305473e4e..95910f221 100644
--- a/src/components/VTabs/VTab.vue
+++ b/src/components/VTabs/VTab.vue
@@ -31,17 +31,17 @@ import {
onUnmounted,
type PropType,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { tabsContextKey } from '~/types/tabs'
-import { keycodes } from '~/constants/key-codes'
-import { getDomElement } from '~/utils/dom'
-import { Focus, focusIn } from '~/utils/focus-management'
+import { tabsContextKey } from "~/types/tabs"
+import { keycodes } from "~/constants/key-codes"
+import { getDomElement } from "~/utils/dom"
+import { Focus, focusIn } from "~/utils/focus-management"
-import VButton from '~/components/VButton.vue'
+import VButton from "~/components/VButton.vue"
export default defineComponent({
- name: 'VTab',
+ name: "VTab",
components: { VButton },
props: {
/**
@@ -60,8 +60,8 @@ export default defineComponent({
required: true,
},
size: {
- type: String as PropType<'default' | 'large' | 'medium'>,
- default: 'default',
+ type: String as PropType<"default" | "large" | "medium">,
+ default: "default",
},
},
setup(props) {
@@ -79,7 +79,7 @@ export default defineComponent({
const handleFocus = () => {
if (props.disabled) return
- if (tabContext.activation.value === 'auto') {
+ if (tabContext.activation.value === "auto") {
tabContext.setSelectedId(props.id)
}
getDomElement(internalTabRef)?.focus()
@@ -112,7 +112,7 @@ export default defineComponent({
documentDir?: string
) => {
let forward = arrowKeyCode === keycodes.ArrowRight
- if (documentDir === 'rtl') {
+ if (documentDir === "rtl") {
forward = !forward
}
return forward ? Focus.Next : Focus.Previous
@@ -172,12 +172,12 @@ export default defineComponent({
}
const tabProps = computed(() => ({
- 'aria-controls': `panel-${props.id}`,
- 'aria-selected': isSelected.value,
+ "aria-controls": `panel-${props.id}`,
+ "aria-selected": isSelected.value,
disabled: props.disabled ? true : undefined,
}))
- const isManual = computed(() => tabContext.activation.value === 'manual')
+ const isManual = computed(() => tabContext.activation.value === "manual")
return {
internalTabRef,
diff --git a/src/components/VTabs/VTabPanel.vue b/src/components/VTabs/VTabPanel.vue
index c03d10a5e..f04b6e0ba 100644
--- a/src/components/VTabs/VTabPanel.vue
+++ b/src/components/VTabs/VTabPanel.vue
@@ -19,12 +19,12 @@ import {
onMounted,
onUnmounted,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { tabsContextKey } from '~/types/tabs'
+import { tabsContextKey } from "~/types/tabs"
export default defineComponent({
- name: 'VTabPanel',
+ name: "VTabPanel",
props: {
/**
* Tabpanel id should be the same as the controlling tab id.
@@ -60,9 +60,9 @@ export default defineComponent({
const isSelected = computed(() => props.id === tabContext.selectedId.value)
const panelVariantStyle = computed(() =>
- tabContext.variant.value === 'bordered'
- ? 'border rounded-sm first:rounded-tl-none'
- : 'border-t'
+ tabContext.variant.value === "bordered"
+ ? "border rounded-sm first:rounded-tl-none"
+ : "border-t"
)
return {
diff --git a/src/components/VTabs/VTabs.vue b/src/components/VTabs/VTabs.vue
index 61e9086ec..92f814767 100644
--- a/src/components/VTabs/VTabs.vue
+++ b/src/components/VTabs/VTabs.vue
@@ -19,13 +19,13 @@ import {
PropType,
provide,
ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { tabsContextKey } from '~/types/tabs'
-import type { TabsState, TabVariant } from '~/types/tabs'
-import { defineEvent } from '~/types/emits'
+import { tabsContextKey } from "~/types/tabs"
+import type { TabsState, TabVariant } from "~/types/tabs"
+import { defineEvent } from "~/types/emits"
-import closeIcon from '~/assets/icons/close-small.svg'
+import closeIcon from "~/assets/icons/close-small.svg"
/**
* VTabs is an accessible implementation of tabs component that displays one panel at a time.
@@ -38,7 +38,7 @@ import closeIcon from '~/assets/icons/close-small.svg'
* To link the VTab to VTabPanel, make sure to pass the same `id` to both.
*/
export default defineComponent({
- name: 'VTabs',
+ name: "VTabs",
props: {
/**
* Accessible name label to use for the tablist.
@@ -69,7 +69,7 @@ export default defineComponent({
*/
variant: {
type: String as PropType<TabVariant>,
- default: 'bordered',
+ default: "bordered",
},
/**
* To ensure that a panel is visible on SSR, before we can run `onMounted` hook to register panel.
@@ -83,7 +83,7 @@ export default defineComponent({
*/
tablistStyle: {
type: String,
- default: '',
+ default: "",
},
},
emits: {
@@ -91,35 +91,35 @@ export default defineComponent({
close: defineEvent(),
},
setup(props, { emit }) {
- const selectedId = ref<TabsState['selectedId']['value']>(props.selectedId)
- const tabs = ref<TabsState['tabs']['value']>([])
- const panels = ref<TabsState['panels']['value']>([])
+ const selectedId = ref<TabsState["selectedId"]["value"]>(props.selectedId)
+ const tabs = ref<TabsState["tabs"]["value"]>([])
+ const panels = ref<TabsState["panels"]["value"]>([])
const closeButtonRef = ref<HTMLElement | null>(null)
const tabGroupContext: TabsState = {
selectedId,
- activation: computed(() => (props.manual ? 'manual' : 'auto')),
+ activation: computed(() => (props.manual ? "manual" : "auto")),
variant: computed(() =>
- props.variant === 'bordered' ? 'bordered' : 'plain'
+ props.variant === "bordered" ? "bordered" : "plain"
),
tabs,
panels,
setSelectedId(id: string) {
if (selectedId.value === id) return
selectedId.value = id
- emit('change', id)
+ emit("change", id)
},
- registerTab(tab: typeof tabs['value'][number]) {
+ registerTab(tab: typeof tabs["value"][number]) {
if (!tabs.value.includes(tab)) tabs.value.push(tab)
},
- unregisterTab(tab: typeof tabs['value'][number]) {
+ unregisterTab(tab: typeof tabs["value"][number]) {
let idx = tabs.value.indexOf(tab)
if (idx !== -1) tabs.value.splice(idx, 1)
},
- registerPanel(panel: typeof panels['value'][number]) {
+ registerPanel(panel: typeof panels["value"][number]) {
if (!panels.value.includes(panel)) panels.value.push(panel)
},
- unregisterPanel(panel: typeof panels['value'][number]) {
+ unregisterPanel(panel: typeof panels["value"][number]) {
let idx = panels.value.indexOf(panel)
if (idx !== -1) panels.value.splice(idx, 1)
},
@@ -127,9 +127,9 @@ export default defineComponent({
provide(tabsContextKey, tabGroupContext)
const accessibleLabel = computed(() =>
- props.label.startsWith('#')
- ? { 'aria-labelledby': props.label.slice(1) }
- : { 'aria-label': props.label }
+ props.label.startsWith("#")
+ ? { "aria-labelledby": props.label.slice(1) }
+ : { "aria-label": props.label }
)
return {
diff --git a/src/components/VTabs/meta/VTabs.stories.mdx b/src/components/VTabs/meta/VTabs.stories.mdx
index 9acef4afd..a3e05e613 100644
--- a/src/components/VTabs/meta/VTabs.stories.mdx
+++ b/src/components/VTabs/meta/VTabs.stories.mdx
@@ -4,25 +4,25 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
+} from "@storybook/addon-docs"
-import VTabs from '~/components/VTabs/VTabs.vue'
-import VTabPanel from '~/components/VTabs/VTabPanel.vue'
-import VTab from '~/components/VTabs/VTab.vue'
+import VTabs from "~/components/VTabs/VTabs.vue"
+import VTabPanel from "~/components/VTabs/VTabPanel.vue"
+import VTab from "~/components/VTabs/VTab.vue"
<Meta
title="Components/VTabs"
component={VTabs}
argTypes={{
variant: {
- options: ['bordered', 'plain'],
- control: { type: 'radio' },
+ options: ["bordered", "plain"],
+ control: { type: "radio" },
},
close: {
- action: 'close',
+ action: "close",
},
change: {
- action: 'change',
+ action: "change",
},
}}
/>
@@ -50,15 +50,15 @@ export const Template = (args) => ({
## Default tabs
-By default, tabs are bordered and use automatic activation of the tab panel when the tab is focused on,
-such as the attribution panels in Openverse.
+By default, tabs are bordered and use automatic activation of the tab panel when
+the tab is focused on, such as the attribution panels in Openverse.
<Canvas>
<Story
name="Default"
args={{
- label: 'Default tabs story',
- selectedId: '1',
+ label: "Default tabs story",
+ selectedId: "1",
}}
>
{Template.bind({})}
@@ -67,16 +67,20 @@ such as the attribution panels in Openverse.
### Navigation
-`←` and `→`: changes the focused (and selected, if not manual) tab to previous or next. Tab navigation wraps, so if you click `→` on the last tab,
-you select the first tab.
+`←` and `→`: changes the focused (and selected, if not manual) tab to previous
+or next. Tab navigation wraps, so if you click `→` on the last tab, you select
+the first tab.
-`tab`: navigate to the tablist and then to the selected tabpanel. The tabs use 'rowing index' to only allow to tab to the currently selected tab using keyboard.
+`tab`: navigate to the tablist and then to the selected tabpanel. The tabs use
+'rowing index' to only allow to tab to the currently selected tab using
+keyboard.
`home`, `end`: set the first or the last tab as focused (or selected).
## Manual plain tabs
-To activate the tabs using keyboard, you need to focus on the tab you want by using the `Tab` key, and then click `Space` or `Enter`.
+To activate the tabs using keyboard, you need to focus on the tab you want by
+using the `Tab` key, and then click `Space` or `Enter`.
These tabs also use the second available variant, `plain`.
@@ -84,10 +88,10 @@ These tabs also use the second available variant, `plain`.
<Story
name="Manual plain tabs"
args={{
- label: 'Manual plain tabs',
- selectedId: '1',
+ label: "Manual plain tabs",
+ selectedId: "1",
manual: true,
- variant: 'plain',
+ variant: "plain",
}}
>
{Template.bind({})}
diff --git a/src/components/VWarningSuppressor.vue b/src/components/VWarningSuppressor.vue
index 3f4e4e9fb..8ffc86734 100644
--- a/src/components/VWarningSuppressor.vue
+++ b/src/components/VWarningSuppressor.vue
@@ -5,13 +5,13 @@
</template>
<script lang="ts">
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
/**
* A `div` replacement component useful for suppressing warnings
* about `.native` modifiers on non-components.
*/
export default defineComponent({
- name: 'VWarningSuppressor',
+ name: "VWarningSuppressor",
})
</script>
diff --git a/src/components/meta/VBackToSearchResultsLink.stories.mdx b/src/components/meta/VBackToSearchResultsLink.stories.mdx
index 09df6c1e0..3743b54f8 100644
--- a/src/components/meta/VBackToSearchResultsLink.stories.mdx
+++ b/src/components/meta/VBackToSearchResultsLink.stories.mdx
@@ -1,6 +1,6 @@
-import { Description, Meta, Canvas, Story } from '@storybook/addon-docs'
+import { Description, Meta, Canvas, Story } from "@storybook/addon-docs"
-import VBackToSearchResultsLink from '~/components/VBackToSearchResultsLink.vue'
+import VBackToSearchResultsLink from "~/components/VBackToSearchResultsLink.vue"
<Meta
title="Components/VBackToSearchResultsLink"
@@ -20,7 +20,7 @@ export const Template = (args) => ({
<Description of={VBackToSearchResultsLink} />
<Canvas>
- <Story name="Default" args={{ href: '#' }}>
+ <Story name="Default" args={{ href: "#" }}>
{Template.bind({})}
</Story>
</Canvas>
diff --git a/src/components/meta/VButton.stories.mdx b/src/components/meta/VButton.stories.mdx
index 185b0198c..2bb4f1a5e 100644
--- a/src/components/meta/VButton.stories.mdx
+++ b/src/components/meta/VButton.stories.mdx
@@ -4,10 +4,10 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import { buttonForms, buttonSizes, buttonVariants } from '~/types/button'
-import VButton from '~/components/VButton.vue'
-import { capital } from 'case'
+} from "@storybook/addon-docs"
+import { buttonForms, buttonSizes, buttonVariants } from "~/types/button"
+import VButton from "~/components/VButton.vue"
+import { capital } from "case"
<Meta title="Components/VButton" components={VButton} />
@@ -20,7 +20,7 @@ export const Template = (args) => ({
components: { VButton },
methods: {
onClick() {
- window.alert('hello!')
+ window.alert("hello!")
},
},
setup() {
@@ -38,25 +38,25 @@ export const Template = (args) => ({
<Story
name="VButton"
parameters={{
- viewport: { defaultViewport: 'sm' },
+ viewport: { defaultViewport: "sm" },
}}
argTypes={{
as: {
options: buttonForms,
- control: { type: 'radio' },
+ control: { type: "radio" },
},
variant: {
options: buttonVariants,
- control: { type: 'select' },
+ control: { type: "select" },
},
- pressed: { control: 'boolean' },
+ pressed: { control: "boolean" },
size: {
options: buttonSizes,
- control: { type: 'radio' },
+ control: { type: "radio" },
},
- disabled: { control: 'boolean' },
- focusableWhenDisabled: { control: 'boolean' },
- type: { control: 'text' },
+ disabled: { control: "boolean" },
+ focusableWhenDisabled: { control: "boolean" },
+ type: { control: "text" },
}}
>
{Template.bind({})}
@@ -89,20 +89,20 @@ export const VariantsTemplate = (args) => ({
### Primary
-The style used for Call-to-action buttons, such as the 'Search' button or 'Get this media item' buttons.
-It is a pink button.
+The style used for Call-to-action buttons, such as the 'Search' button or 'Get
+this media item' buttons. It is a pink button.
<Canvas>
<Story
name="primary"
- args={{ variants: ['primary'] }}
+ args={{ variants: ["primary"] }}
argTypes={{
- pressed: { control: 'boolean' },
+ pressed: { control: "boolean" },
size: {
options: buttonSizes,
- control: { type: 'radio' },
+ control: { type: "radio" },
},
- disabled: { control: 'boolean' },
+ disabled: { control: "boolean" },
}}
>
{VariantsTemplate.bind({})}
@@ -113,19 +113,20 @@ It is a pink button.
The styles used for other buttons.
-There are three variants of secondary buttons: filled, bordered and text (without border).
+There are three variants of secondary buttons: filled, bordered and text
+(without border).
<Canvas>
<Story
name="secondary"
- args={{ variants: ['secondary-bordered', 'secondary-filled', 'secondary'] }}
+ args={{ variants: ["secondary-bordered", "secondary-filled", "secondary"] }}
argTypes={{
- pressed: { control: 'boolean' },
+ pressed: { control: "boolean" },
size: {
options: buttonSizes,
- control: { type: 'radio' },
+ control: { type: "radio" },
},
- disabled: { control: 'boolean' },
+ disabled: { control: "boolean" },
}}
>
{VariantsTemplate.bind({})}
@@ -136,25 +137,29 @@ There are three variants of secondary buttons: filled, bordered and text (withou
The styles used for header 'action-menu' buttons.
-'action-menu' also has no border and no background. On hover, there is a light border. It is used in the desktop header buttons and for the content type switcher inside the searchbar.
+'action-menu' also has no border and no background. On hover, there is a light
+border. It is used in the desktop header buttons and for the content type
+switcher inside the searchbar.
-'action-menu-bordered' has a border but no background. It is used in the desktop header buttons when the (old) header is scrolled.
+'action-menu-bordered' has a border but no background. It is used in the desktop
+header buttons when the (old) header is scrolled.
-'action-menu-muted' has a light charcoal background. It is used for filters when some filters are applied.
+'action-menu-muted' has a light charcoal background. It is used for filters when
+some filters are applied.
<Canvas>
<Story
name="action-menu"
args={{
- variants: ['action-menu', 'action-menu-bordered', 'action-menu-muted'],
+ variants: ["action-menu", "action-menu-bordered", "action-menu-muted"],
}}
argTypes={{
- pressed: { control: 'boolean' },
+ pressed: { control: "boolean" },
size: {
options: buttonSizes,
- control: { type: 'radio' },
+ control: { type: "radio" },
},
- disabled: { control: 'boolean' },
+ disabled: { control: "boolean" },
}}
>
{VariantsTemplate.bind({})}
diff --git a/src/components/meta/VPill.stories.js b/src/components/meta/VPill.stories.js
index 1da57a52f..9192504f8 100644
--- a/src/components/meta/VPill.stories.js
+++ b/src/components/meta/VPill.stories.js
@@ -1,7 +1,7 @@
-import VPill from '~/components/VPill.vue'
+import VPill from "~/components/VPill.vue"
export default {
- title: 'Components/VPill',
+ title: "Components/VPill",
component: VPill,
}
diff --git a/src/components/meta/VSnackbar.stories.mdx b/src/components/meta/VSnackbar.stories.mdx
index ebc4aed4d..a90f6469e 100644
--- a/src/components/meta/VSnackbar.stories.mdx
+++ b/src/components/meta/VSnackbar.stories.mdx
@@ -4,18 +4,18 @@ import {
Description,
Meta,
Story,
-} from '@storybook/addon-docs'
-import { ref } from '@nuxtjs/composition-api'
+} from "@storybook/addon-docs"
+import { ref } from "@nuxtjs/composition-api"
-import VSnackbar from '~/components/VSnackbar.vue'
+import VSnackbar from "~/components/VSnackbar.vue"
<Meta
title="Components/VSnackbar"
components={VSnackbar}
argTypes={{
size: {
- options: ['large', 'small'],
- control: { type: 'radio' },
+ options: ["large", "small"],
+ control: { type: "radio" },
},
}}
/>
@@ -48,7 +48,7 @@ export const Template = (args) => ({
<Canvas>
<Story
name="Default"
- args={{ defaultSlot: 'Your message goes here.', size: 'small' }}
+ args={{ defaultSlot: "Your message goes here.", size: "small" }}
inline={false}
>
{Template.bind({})}
diff --git a/src/composables/default-ref.ts b/src/composables/default-ref.ts
index a746a3add..0724f87f3 100644
--- a/src/composables/default-ref.ts
+++ b/src/composables/default-ref.ts
@@ -1,6 +1,6 @@
-import { computed, ref, UnwrapRef } from '@nuxtjs/composition-api'
+import { computed, ref, UnwrapRef } from "@nuxtjs/composition-api"
-const NotSet = Symbol('NotSet')
+const NotSet = Symbol("NotSet")
/**
* Produces a `computed` that returns a default value until
diff --git a/src/composables/use-active-audio.ts b/src/composables/use-active-audio.ts
index 3431e6467..1e4e1c8cc 100644
--- a/src/composables/use-active-audio.ts
+++ b/src/composables/use-active-audio.ts
@@ -1,4 +1,4 @@
-import { ref } from '@nuxtjs/composition-api'
+import { ref } from "@nuxtjs/composition-api"
/**
* This global ref is SSR safe because it will only
diff --git a/src/composables/use-body-scroll-lock.ts b/src/composables/use-body-scroll-lock.ts
index f0d26acd3..0a6979f23 100644
--- a/src/composables/use-body-scroll-lock.ts
+++ b/src/composables/use-body-scroll-lock.ts
@@ -1,6 +1,6 @@
-import { Ref, ref, watch } from '@nuxtjs/composition-api'
+import { Ref, ref, watch } from "@nuxtjs/composition-api"
-import { getDocument } from '~/utils/reakit-utils/dom'
+import { getDocument } from "~/utils/reakit-utils/dom"
/**
* Creates a utility for locking body scrolling for a particular node.
@@ -32,7 +32,7 @@ export function useBodyScrollLock({
locked.value = true
const document = getDocument(nodeRef.value)
scrollY = window.scrollY
- document.body.style.position = 'fixed'
+ document.body.style.position = "fixed"
document.body.style.top = `-${scrollY}px`
}
@@ -43,8 +43,8 @@ export function useBodyScrollLock({
locked.value = false
const document = getDocument(nodeRef.value)
- document.body.style.position = ''
- document.body.style.top = ''
+ document.body.style.position = ""
+ document.body.style.top = ""
if (scrollY) {
window.scrollTo(0, scrollY)
scrollY = null
diff --git a/src/composables/use-browser-detection.ts b/src/composables/use-browser-detection.ts
index 3019e5d4c..a40cb49d9 100644
--- a/src/composables/use-browser-detection.ts
+++ b/src/composables/use-browser-detection.ts
@@ -1,4 +1,4 @@
-import { useContext } from '@nuxtjs/composition-api'
+import { useContext } from "@nuxtjs/composition-api"
export const useBrowserDetection = () => {
const { app } = useContext()
diff --git a/src/composables/use-dialog-content.ts b/src/composables/use-dialog-content.ts
index 2c89f11e3..b66b881b4 100644
--- a/src/composables/use-dialog-content.ts
+++ b/src/composables/use-dialog-content.ts
@@ -1,10 +1,10 @@
-import { useFocusOnShow } from '~/composables/use-focus-on-show'
-import { useFocusOnHide } from '~/composables/use-focus-on-hide'
-import { useHideOnClickOutside } from '~/composables/use-hide-on-click-outside'
-import { useFocusOnBlur } from '~/composables/use-focus-on-blur'
+import { useFocusOnShow } from "~/composables/use-focus-on-show"
+import { useFocusOnHide } from "~/composables/use-focus-on-hide"
+import { useHideOnClickOutside } from "~/composables/use-hide-on-click-outside"
+import { useFocusOnBlur } from "~/composables/use-focus-on-blur"
-import type { Ref } from '@nuxtjs/composition-api'
-import type { SetupContext } from 'vue'
+import type { Ref } from "@nuxtjs/composition-api"
+import type { SetupContext } from "vue"
type Props = {
dialogRef: Ref<HTMLElement | null>
@@ -17,7 +17,7 @@ type Props = {
hideOnEscRef: Ref<boolean>
initialFocusElementRef?: Ref<HTMLElement | null>
hideRef: Ref<() => void>
- emit: SetupContext['emit']
+ emit: SetupContext["emit"]
}
export function useDialogContent({ emit, ...props }: Props) {
@@ -41,10 +41,10 @@ export function useDialogContent({ emit, ...props }: Props) {
})
const onKeyDown = (event: KeyboardEvent) => {
- emit('keydown', event)
+ emit("keydown", event)
if (event.defaultPrevented) return
- if (event.key !== 'Escape') return
+ if (event.key !== "Escape") return
if (!props.hideOnEscRef.value) return
event.stopPropagation()
@@ -52,7 +52,7 @@ export function useDialogContent({ emit, ...props }: Props) {
}
const onBlur = (event: FocusEvent) => {
- emit('blur', event)
+ emit("blur", event)
focusOnBlur(event)
}
diff --git a/src/composables/use-event-listener-outside.ts b/src/composables/use-event-listener-outside.ts
index 306105c73..a493eabce 100644
--- a/src/composables/use-event-listener-outside.ts
+++ b/src/composables/use-event-listener-outside.ts
@@ -1,6 +1,6 @@
-import { Ref, ref, watch } from '@nuxtjs/composition-api'
+import { Ref, ref, watch } from "@nuxtjs/composition-api"
-import { contains, getDocument, isInDocument } from '~/utils/reakit-utils/dom'
+import { contains, getDocument, isInDocument } from "~/utils/reakit-utils/dom"
interface Props {
/**
diff --git a/src/composables/use-event-listener.ts b/src/composables/use-event-listener.ts
index 0cb76bb55..8913ecf7a 100644
--- a/src/composables/use-event-listener.ts
+++ b/src/composables/use-event-listener.ts
@@ -5,10 +5,10 @@ import {
onBeforeUnmount,
unref,
Ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
const isComponentInstance = (o: unknown): o is { $el: unknown } =>
- !!o && typeof (o as { $el: unknown }).$el !== 'undefined'
+ !!o && typeof (o as { $el: unknown }).$el !== "undefined"
export type MaybeRef<T> = Ref<T> | T
@@ -19,8 +19,8 @@ export type MaybeRef<T> = Ref<T> | T
*/
export function useEventListener<T extends EventTarget>(
target: MaybeRef<T | { $el: T }>,
- event: Parameters<T['addEventListener']>[0],
- handler: Parameters<T['addEventListener']>[1],
+ event: Parameters<T["addEventListener"]>[0],
+ handler: Parameters<T["addEventListener"]>[1],
options = {}
) {
// if it's a reactive ref, use a watcher
diff --git a/src/composables/use-focus-filters.ts b/src/composables/use-focus-filters.ts
index 0b1de53d4..49fbb0a0c 100644
--- a/src/composables/use-focus-filters.ts
+++ b/src/composables/use-focus-filters.ts
@@ -1,5 +1,5 @@
-import { Focus, focusIn } from '~/utils/focus-management'
-import { useUiStore } from '~/stores/ui'
+import { Focus, focusIn } from "~/utils/focus-management"
+import { useUiStore } from "~/stores/ui"
export const useFocusFilters = () => {
const focusFilterSidebar = (event?: KeyboardEvent, focus = Focus.Last) => {
@@ -8,7 +8,7 @@ export const useFocusFilters = () => {
if (event) event.preventDefault()
// Prevent over-tabbing to the element after the target one
// Cannot use refs when using portals (for sidebar)
- const filtersSidebarElement = document.getElementById('filters')
+ const filtersSidebarElement = document.getElementById("filters")
if (filtersSidebarElement) {
focusIn(filtersSidebarElement, focus)
}
@@ -18,7 +18,7 @@ export const useFocusFilters = () => {
const uiStore = useUiStore()
if (uiStore.isDesktopLayout && uiStore.isFilterVisible) {
if (event) event.preventDefault()
- const filterButton = document.getElementById('filter-button')
+ const filterButton = document.getElementById("filter-button")
if (filterButton) {
filterButton.focus()
}
diff --git a/src/composables/use-focus-on-blur.ts b/src/composables/use-focus-on-blur.ts
index 8ce24a5d2..db29d8178 100644
--- a/src/composables/use-focus-on-blur.ts
+++ b/src/composables/use-focus-on-blur.ts
@@ -1,6 +1,6 @@
-import { Ref, ref, watch } from '@nuxtjs/composition-api'
+import { Ref, ref, watch } from "@nuxtjs/composition-api"
-import { getActiveElement, getDocument } from '~/utils/reakit-utils/dom'
+import { getActiveElement, getDocument } from "~/utils/reakit-utils/dom"
type Props = {
dialogRef: Ref<HTMLElement | null>
@@ -14,7 +14,7 @@ function isActualElement(
const elementAsElement = element as Element
return !!(
elementAsElement.tagName &&
- elementAsElement.tagName !== 'HTML' &&
+ elementAsElement.tagName !== "HTML" &&
elementAsElement !== getDocument(elementAsElement).body
)
}
diff --git a/src/composables/use-focus-on-hide.ts b/src/composables/use-focus-on-hide.ts
index 3655e0016..345c62080 100644
--- a/src/composables/use-focus-on-hide.ts
+++ b/src/composables/use-focus-on-hide.ts
@@ -1,7 +1,7 @@
-import { Ref, watch } from '@nuxtjs/composition-api'
+import { Ref, watch } from "@nuxtjs/composition-api"
-import { contains, getActiveElement } from '~/utils/reakit-utils/dom'
-import { ensureFocus, isTabbable } from '~/utils/reakit-utils/focus'
+import { contains, getActiveElement } from "~/utils/reakit-utils/dom"
+import { ensureFocus, isTabbable } from "~/utils/reakit-utils/focus"
type Props = {
dialogRef: Ref<HTMLElement | null>
@@ -19,7 +19,7 @@ function hidByFocusingAnotherElement(popover: HTMLElement) {
if (contains(popover, activeElement)) return false
if (isTabbable(activeElement)) return true
- return activeElement.getAttribute('data-popover') === 'true'
+ return activeElement.getAttribute("data-popover") === "true"
}
export const useFocusOnHide = ({
diff --git a/src/composables/use-focus-on-show.ts b/src/composables/use-focus-on-show.ts
index 7e53d4f1f..667d889b4 100644
--- a/src/composables/use-focus-on-show.ts
+++ b/src/composables/use-focus-on-show.ts
@@ -1,12 +1,12 @@
-import { nextTick, ref, watch, Ref } from '@nuxtjs/composition-api'
+import { nextTick, ref, watch, Ref } from "@nuxtjs/composition-api"
-import { warn } from '~/utils/console'
+import { warn } from "~/utils/console"
import {
ensureFocus,
getFirstTabbableIn,
hasFocusWithin,
-} from '~/utils/reakit-utils/focus'
-import { useFocusTrap } from '~/composables/use-focus-trap'
+} from "~/utils/reakit-utils/focus"
+import { useFocusTrap } from "~/composables/use-focus-trap"
export const noFocusableElementWarning =
"It's recommended to have at least one tabbable element inside dialog. The dialog element has been automatically focused. If this is the intended behavior, pass `tabIndex={0}` to the dialog element to disable this warning."
diff --git a/src/composables/use-focus-trap.ts b/src/composables/use-focus-trap.ts
index 034e1c3ac..48f1f6ef3 100644
--- a/src/composables/use-focus-trap.ts
+++ b/src/composables/use-focus-trap.ts
@@ -1,18 +1,18 @@
// Copied from https://github.com/vueuse/vueuse/blob/91ec77418298eb252899125ab37c160718a3e078/packages/integrations/useFocusTrap/index.ts
// Importing it directly from the vueuse/integration causes an import error
-import { tryOnScopeDispose, unrefElement } from '@vueuse/core'
+import { tryOnScopeDispose, unrefElement } from "@vueuse/core"
-import { ref, watch } from 'vue-demi'
-import { createFocusTrap } from 'focus-trap'
+import { ref, watch } from "vue-demi"
+import { createFocusTrap } from "focus-trap"
-import type { Ref } from 'vue-demi'
-import type { Fn, MaybeElementRef } from '@vueuse/core'
+import type { Ref } from "vue-demi"
+import type { Fn, MaybeElementRef } from "@vueuse/core"
import type {
ActivateOptions,
DeactivateOptions,
FocusTrap,
Options,
-} from 'focus-trap'
+} from "focus-trap"
export interface UseFocusTrapOptions extends Options {
/**
@@ -122,7 +122,7 @@ export function useFocusTrap(
// Focus if immediate is set to true
if (immediate) activate()
},
- { flush: 'sync' }
+ { flush: "sync" }
)
// Cleanup on unmount
diff --git a/src/composables/use-get-locale-formatted-number.ts b/src/composables/use-get-locale-formatted-number.ts
index 0c1960cc7..9778c145d 100644
--- a/src/composables/use-get-locale-formatted-number.ts
+++ b/src/composables/use-get-locale-formatted-number.ts
@@ -1,16 +1,16 @@
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
const WESTERN_ARABIC_NUMERALS = [
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
]
/**
@@ -30,6 +30,6 @@ export const useGetLocaleFormattedNumber = () => {
return testFormat
}
- return n.toLocaleString('en')
+ return n.toLocaleString("en")
}
}
diff --git a/src/composables/use-hide-on-click-outside.ts b/src/composables/use-hide-on-click-outside.ts
index ff1c4056e..5167143c4 100644
--- a/src/composables/use-hide-on-click-outside.ts
+++ b/src/composables/use-hide-on-click-outside.ts
@@ -1,7 +1,7 @@
-import { ref, watch, computed, Ref } from '@nuxtjs/composition-api'
+import { ref, watch, computed, Ref } from "@nuxtjs/composition-api"
-import { getDocument } from '~/utils/reakit-utils/dom'
-import { useEventListenerOutside } from '~/composables/use-event-listener-outside'
+import { getDocument } from "~/utils/reakit-utils/dom"
+import { useEventListenerOutside } from "~/composables/use-event-listener-outside"
type Props = {
dialogRef: Ref<HTMLElement | null>
@@ -16,9 +16,9 @@ function useMouseDownTargetRef({
visibleRef,
hideOnClickOutsideRef,
}: {
- dialogRef: Props['dialogRef']
- visibleRef: Props['visibleRef']
- hideOnClickOutsideRef: Props['hideOnClickOutsideRef']
+ dialogRef: Props["dialogRef"]
+ visibleRef: Props["visibleRef"]
+ hideOnClickOutsideRef: Props["hideOnClickOutsideRef"]
}): Ref<EventTarget> {
const mouseDownTargetRef = ref()
@@ -30,9 +30,9 @@ function useMouseDownTargetRef({
const document = getDocument(popover)
const onMouseDown = (event: MouseEvent) =>
(mouseDownTargetRef.value = event.target)
- document.addEventListener('mousedown', onMouseDown)
+ document.addEventListener("mousedown", onMouseDown)
onInvalidate(() => {
- document.removeEventListener('mousedown', onMouseDown)
+ document.removeEventListener("mousedown", onMouseDown)
})
},
{ immediate: true }
@@ -61,7 +61,7 @@ export function useHideOnClickOutside({
useEventListenerOutside({
containerRef: dialogRef,
triggerRef: triggerElementRef,
- eventType: 'click',
+ eventType: "click",
listener: (event: Event) => {
if (mouseDownTargetRef.value === event.target) {
// Make sure the element that has been clicked is the same that last
@@ -77,7 +77,7 @@ export function useHideOnClickOutside({
useEventListenerOutside({
containerRef: dialogRef,
triggerRef: triggerElementRef,
- eventType: 'focusin',
+ eventType: "focusin",
listener: (event: Event) => {
const document = getDocument(dialogRef.value)
if (event.target !== document) {
diff --git a/src/composables/use-i18n-sync.ts b/src/composables/use-i18n-sync.ts
index 138942929..8436cc4ba 100644
--- a/src/composables/use-i18n-sync.ts
+++ b/src/composables/use-i18n-sync.ts
@@ -1,8 +1,8 @@
-import { computed, useContext } from '@nuxtjs/composition-api'
+import { computed, useContext } from "@nuxtjs/composition-api"
-import type { LocaleObject } from '@nuxtjs/i18n'
+import type { LocaleObject } from "@nuxtjs/i18n"
-const BASE_URL = 'https://translate.wordpress.org/projects/meta/openverse/'
+const BASE_URL = "https://translate.wordpress.org/projects/meta/openverse/"
export function useI18nSync() {
const { app } = useContext()
@@ -13,13 +13,13 @@ export function useI18nSync() {
})
const needsTranslationBanner = computed(() => {
- if (!currentLocale.value || currentLocale.value.code === 'en') return false
+ if (!currentLocale.value || currentLocale.value.code === "en") return false
return (currentLocale.value?.translated ?? 100) <= 90
})
const translationLink = computed(
- () => `${BASE_URL}${currentLocale.value?.code || 'en'}/default/`
+ () => `${BASE_URL}${currentLocale.value?.code || "en"}/default/`
)
return {
diff --git a/src/composables/use-i18n-utilities.ts b/src/composables/use-i18n-utilities.ts
index 6bf01203f..c12f04a4d 100644
--- a/src/composables/use-i18n-utilities.ts
+++ b/src/composables/use-i18n-utilities.ts
@@ -1,14 +1,14 @@
-import { useGetLocaleFormattedNumber } from '~/composables/use-get-locale-formatted-number'
-import { useI18n } from '~/composables/use-i18n'
+import { useGetLocaleFormattedNumber } from "~/composables/use-get-locale-formatted-number"
+import { useI18n } from "~/composables/use-i18n"
/**
* Not using dynamically-generated keys to ensure that
* correct line is shown in the 'po' locale files
*/
const i18nKeys = {
- noResult: 'browse-page.all-no-results',
- result: 'browse-page.all-result-count',
- more: 'browse-page.all-result-count-more',
+ noResult: "browse-page.all-no-results",
+ result: "browse-page.all-result-count",
+ more: "browse-page.all-result-count-more",
}
/**
@@ -21,10 +21,10 @@ export function useI18nResultsCount() {
const getI18nCount = (resultsCount: number) => {
const countKey =
resultsCount === 0
- ? 'noResult'
+ ? "noResult"
: resultsCount >= 10000
- ? 'more'
- : 'result'
+ ? "more"
+ : "result"
const fullKey = i18nKeys[countKey]
const localeCount = getLocaleFormattedNumber(resultsCount)
return i18n.tc(fullKey, resultsCount, { localeCount })
diff --git a/src/composables/use-i18n.ts b/src/composables/use-i18n.ts
index dde14b013..6377bdc32 100644
--- a/src/composables/use-i18n.ts
+++ b/src/composables/use-i18n.ts
@@ -1,4 +1,4 @@
-import { useContext } from '@nuxtjs/composition-api'
+import { useContext } from "@nuxtjs/composition-api"
/**
* This composable exists to make it easy to mock the i18n context
diff --git a/src/composables/use-layout.ts b/src/composables/use-layout.ts
index 11540fc0f..b2acc6a69 100644
--- a/src/composables/use-layout.ts
+++ b/src/composables/use-layout.ts
@@ -1,13 +1,13 @@
-import { useWindowSize, watchThrottled } from '@vueuse/core'
+import { useWindowSize, watchThrottled } from "@vueuse/core"
-import type { Breakpoint } from '~/constants/screens'
-import { ALL_SCREEN_SIZES } from '~/constants/screens'
-import { useUiStore } from '~/stores/ui'
+import type { Breakpoint } from "~/constants/screens"
+import { ALL_SCREEN_SIZES } from "~/constants/screens"
+import { useUiStore } from "~/stores/ui"
const widthToBreakpoint = (width: number): Breakpoint => {
const bp = Object.entries(ALL_SCREEN_SIZES).find(
([, bpWidth]) => width >= bpWidth
- ) ?? ['xs', 0]
+ ) ?? ["xs", 0]
return bp[0] as Breakpoint
}
diff --git a/src/composables/use-match-routes.ts b/src/composables/use-match-routes.ts
index 488d5c324..cbcccaf00 100644
--- a/src/composables/use-match-routes.ts
+++ b/src/composables/use-match-routes.ts
@@ -4,9 +4,9 @@ import {
useRoute,
useRouter,
Ref,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { ALL_MEDIA, searchTypes, supportedSearchTypes } from '~/constants/media'
+import { ALL_MEDIA, searchTypes, supportedSearchTypes } from "~/constants/media"
/**
* Reactive property that returns true only on the matching routes.
@@ -42,7 +42,7 @@ export const useMatchRoute = (
*/
export const useMatchSearchRoutes = () => {
const routes = [
- 'search',
+ "search",
...searchTypes
.filter((type) => type !== ALL_MEDIA)
.map((type) => `search-${type}`),
@@ -63,4 +63,4 @@ export const useMatchSingleResultRoutes = () => {
return useMatchRoute(routes)
}
-export const useMatchHomeRoute = () => useMatchRoute(['index'])
+export const useMatchHomeRoute = () => useMatchRoute(["index"])
diff --git a/src/composables/use-media-query.ts b/src/composables/use-media-query.ts
index b4cf9df3d..1cd8f669b 100644
--- a/src/composables/use-media-query.ts
+++ b/src/composables/use-media-query.ts
@@ -1,15 +1,15 @@
/* this implementation is from https://github.com/vueuse/vueuse/packages/core/useMediaQuery/
which, in turn, is ported from https://github.com/logaretm/vue-use-web by Abdelrahman Awad */
-import { computed, ref, watchEffect } from '@nuxtjs/composition-api'
+import { computed, ref, watchEffect } from "@nuxtjs/composition-api"
-import { resolveUnref } from '@vueuse/core'
+import { resolveUnref } from "@vueuse/core"
-import { SCREEN_SIZES, Breakpoint } from '~/constants/screens'
-import { defaultWindow } from '~/constants/window'
-import { tryOnScopeDispose } from '~/utils/try-on-scope-dispose'
-import { useSupported } from '~/composables/use-supported'
+import { SCREEN_SIZES, Breakpoint } from "~/constants/screens"
+import { defaultWindow } from "~/constants/window"
+import { tryOnScopeDispose } from "~/utils/try-on-scope-dispose"
+import { useSupported } from "~/composables/use-supported"
-import type { MaybeComputedRef } from '@vueuse/core'
+import type { MaybeComputedRef } from "@vueuse/core"
interface Options {
shouldPassInSSR?: boolean
@@ -27,8 +27,8 @@ export function useMediaQuery(
const isSupported = useSupported(
() =>
window &&
- 'matchMedia' in window &&
- typeof window.matchMedia === 'function'
+ "matchMedia" in window &&
+ typeof window.matchMedia === "function"
)
let mediaQuery: MediaQueryList | undefined
@@ -36,8 +36,8 @@ export function useMediaQuery(
const cleanup = () => {
if (!mediaQuery) return
- if ('removeEventListener' in mediaQuery) {
- mediaQuery.removeEventListener('change', update)
+ if ("removeEventListener" in mediaQuery) {
+ mediaQuery.removeEventListener("change", update)
} else {
// @ts-expect-error deprecated API
mediaQuery.removeListener(update)
@@ -56,8 +56,8 @@ export function useMediaQuery(
mediaQuery = window.matchMedia(resolveUnref(query))
matches.value = mediaQuery.matches
- if ('addEventListener' in mediaQuery) {
- mediaQuery.addEventListener('change', update)
+ if ("addEventListener" in mediaQuery) {
+ mediaQuery.addEventListener("change", update)
} else {
// @ts-expect-error deprecated API
mediaQuery.addListener(update)
@@ -71,7 +71,7 @@ export function useMediaQuery(
return matches
}
-const isBpXs = (bp: Breakpoint): bp is 'xs' => bp === 'xs'
+const isBpXs = (bp: Breakpoint): bp is "xs" => bp === "xs"
/**
* Check whether the current screen meets
@@ -100,5 +100,5 @@ export const isMinScreen = (
* Check if the user prefers reduced motion or not.
*/
export function useReducedMotion(options?: Options) {
- return useMediaQuery('(prefers-reduced-motion: reduce)', options)
+ return useMediaQuery("(prefers-reduced-motion: reduce)", options)
}
diff --git a/src/composables/use-pages.ts b/src/composables/use-pages.ts
index d789bc116..9cd717907 100644
--- a/src/composables/use-pages.ts
+++ b/src/composables/use-pages.ts
@@ -1,4 +1,4 @@
-import { computed, useContext, useRoute } from '@nuxtjs/composition-api'
+import { computed, useContext, useRoute } from "@nuxtjs/composition-api"
export default function usePages(isNew = false) {
const { app } = useContext()
@@ -6,71 +6,71 @@ export default function usePages(isNew = false) {
const pages = isNew
? [
{
- id: 'about',
- name: 'navigation.about',
- link: app.localePath('/about'),
+ id: "about",
+ name: "navigation.about",
+ link: app.localePath("/about"),
},
{
- id: 'licenses',
- name: 'navigation.licenses',
- link: 'https://creativecommons.org/about/cclicenses/',
+ id: "licenses",
+ name: "navigation.licenses",
+ link: "https://creativecommons.org/about/cclicenses/",
},
{
- id: 'get-involved',
- name: 'navigation.get-involved',
- link: 'https://make.wordpress.org/openverse/handbook/',
+ id: "get-involved",
+ name: "navigation.get-involved",
+ link: "https://make.wordpress.org/openverse/handbook/",
},
{
- id: 'api',
- name: 'navigation.api',
- link: 'https://api.openverse.engineering/v1/',
+ id: "api",
+ name: "navigation.api",
+ link: "https://api.openverse.engineering/v1/",
},
{
- id: 'privacy',
- name: 'navigation.privacy',
- link: app.localePath('/privacy'),
+ id: "privacy",
+ name: "navigation.privacy",
+ link: app.localePath("/privacy"),
},
{
- id: 'feedback',
- name: 'navigation.feedback',
- link: app.localePath('/feedback'),
+ id: "feedback",
+ name: "navigation.feedback",
+ link: app.localePath("/feedback"),
},
]
: [
{
- id: 'about',
- name: 'header.about-nav-item',
- link: app.localePath('/about'),
+ id: "about",
+ name: "header.about-nav-item",
+ link: app.localePath("/about"),
},
{
- id: 'sources',
- name: 'header.source-nav-item',
- link: app.localePath('/sources'),
+ id: "sources",
+ name: "header.source-nav-item",
+ link: app.localePath("/sources"),
},
{
- id: 'licenses',
- name: 'header.licenses-nav-item',
- link: 'https://creativecommons.org/about/cclicenses/',
+ id: "licenses",
+ name: "header.licenses-nav-item",
+ link: "https://creativecommons.org/about/cclicenses/",
},
{
- id: 'search-help',
- name: 'header.search-guide-nav-item',
- link: app.localePath('/search-help'),
+ id: "search-help",
+ name: "header.search-guide-nav-item",
+ link: app.localePath("/search-help"),
},
{
- id: 'feedback',
- name: 'header.feedback-nav-item',
- link: app.localePath('/feedback'),
+ id: "feedback",
+ name: "header.feedback-nav-item",
+ link: app.localePath("/feedback"),
},
{
- id: 'api',
- name: 'header.api-nav-item',
- link: 'https://api.openverse.engineering/v1/',
+ id: "api",
+ name: "header.api-nav-item",
+ link: "https://api.openverse.engineering/v1/",
},
{
- id: 'privacy',
- name: 'navigation.privacy',
- link: app.localePath('/privacy'),
+ id: "privacy",
+ name: "navigation.privacy",
+ link: app.localePath("/privacy"),
},
]
@@ -80,7 +80,7 @@ export default function usePages(isNew = false) {
* We need to remove the locale suffix to match the page id.
*/
const currentPageId = computed<string>(
- () => route.value?.name?.split('__')[0] ?? ''
+ () => route.value?.name?.split("__")[0] ?? ""
)
return { all: pages, current: currentPageId }
diff --git a/src/composables/use-popover-content.ts b/src/composables/use-popover-content.ts
index aa75497e1..1f5bcc8fc 100644
--- a/src/composables/use-popover-content.ts
+++ b/src/composables/use-popover-content.ts
@@ -1,16 +1,16 @@
-import { ref } from '@nuxtjs/composition-api'
+import { ref } from "@nuxtjs/composition-api"
-import { PopoverContentProps, usePopper } from '~/composables/use-popper'
+import { PopoverContentProps, usePopper } from "~/composables/use-popper"
-import { useDialogContent } from '~/composables/use-dialog-content'
+import { useDialogContent } from "~/composables/use-dialog-content"
-import type { SetupContext } from 'vue'
-import type { Ref, ToRefs } from '@nuxtjs/composition-api'
+import type { SetupContext } from "vue"
+import type { Ref, ToRefs } from "@nuxtjs/composition-api"
type Props = {
popoverRef: Ref<HTMLElement | null>
popoverPropsRefs: ToRefs<PopoverContentProps>
- emit: SetupContext['emit']
+ emit: SetupContext["emit"]
}
export function usePopoverContent({
diff --git a/src/composables/use-popper.ts b/src/composables/use-popper.ts
index 016d2d474..c43efbf69 100644
--- a/src/composables/use-popper.ts
+++ b/src/composables/use-popper.ts
@@ -1,12 +1,12 @@
-import { ref, watch, Ref, ToRefs } from '@nuxtjs/composition-api'
+import { ref, watch, Ref, ToRefs } from "@nuxtjs/composition-api"
import {
createPopper,
detectOverflow,
Instance,
Placement,
PositioningStrategy,
-} from '@popperjs/core'
-import { useWindowSize } from '@vueuse/core'
+} from "@popperjs/core"
+import { useWindowSize } from "@vueuse/core"
export type PopoverContentProps = {
visible: boolean
@@ -54,15 +54,15 @@ export function usePopper({ popoverRef, popoverPropsRefs }: Props) {
strategy,
modifiers: [
{
- name: 'eventListeners',
+ name: "eventListeners",
enabled: visible,
},
{
- name: 'arrow',
+ name: "arrow",
enabled: false,
},
{
- name: 'offset',
+ name: "offset",
options: {
offset: [0, 8],
},
diff --git a/src/composables/use-resize-observer.ts b/src/composables/use-resize-observer.ts
index e0fbf2655..53562aeec 100644
--- a/src/composables/use-resize-observer.ts
+++ b/src/composables/use-resize-observer.ts
@@ -1,6 +1,6 @@
-import { ref, onMounted, onBeforeUnmount } from '@nuxtjs/composition-api'
+import { ref, onMounted, onBeforeUnmount } from "@nuxtjs/composition-api"
-import type { Ref } from '@nuxtjs/composition-api'
+import type { Ref } from "@nuxtjs/composition-api"
interface Options {
initialWidth?: number
diff --git a/src/composables/use-search-type.ts b/src/composables/use-search-type.ts
index 6ba76343a..e3784f3a0 100644
--- a/src/composables/use-search-type.ts
+++ b/src/composables/use-search-type.ts
@@ -1,4 +1,4 @@
-import { computed, ref } from '@nuxtjs/composition-api'
+import { computed, ref } from "@nuxtjs/composition-api"
import {
ALL_MEDIA,
@@ -9,16 +9,16 @@ import {
additionalSearchTypes,
supportedSearchTypes,
SearchType,
-} from '~/constants/media'
+} from "~/constants/media"
-import { useSearchStore } from '~/stores/search'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { useSearchStore } from "~/stores/search"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import allIcon from '~/assets/icons/all-content.svg'
-import audioIcon from '~/assets/icons/audio-content.svg'
-import imageIcon from '~/assets/icons/image-content.svg'
-import videoIcon from '~/assets/icons/video-content.svg'
-import model3dIcon from '~/assets/icons/model-3d.svg'
+import allIcon from "~/assets/icons/all-content.svg"
+import audioIcon from "~/assets/icons/audio-content.svg"
+import imageIcon from "~/assets/icons/image-content.svg"
+import videoIcon from "~/assets/icons/video-content.svg"
+import model3dIcon from "~/assets/icons/model-3d.svg"
const icons = {
[ALL_MEDIA]: allIcon,
@@ -36,7 +36,7 @@ export default function useSearchType() {
const featureFlagStore = useFeatureFlagStore()
const additionalTypes = computed(() =>
- featureFlagStore.isOn('external_sources') ? additionalSearchTypes : []
+ featureFlagStore.isOn("external_sources") ? additionalSearchTypes : []
)
const searchTypes = [...supportedSearchTypes]
diff --git a/src/composables/use-seekable.ts b/src/composables/use-seekable.ts
index 4e5888f65..dd42b3a6a 100644
--- a/src/composables/use-seekable.ts
+++ b/src/composables/use-seekable.ts
@@ -1,7 +1,7 @@
-import { computed, ToRefs, ref } from '@nuxtjs/composition-api'
+import { computed, ToRefs, ref } from "@nuxtjs/composition-api"
-import { useI18n } from '~/composables/use-i18n'
-import { keycodes } from '~/constants/key-codes'
+import { useI18n } from "~/composables/use-i18n"
+import { keycodes } from "~/constants/key-codes"
export interface UseSeekableOptions
extends ToRefs<{
@@ -23,16 +23,16 @@ export const useSeekable = ({
const i18n = useI18n()
const attributes = computed(() => ({
- 'aria-role': 'slider',
- 'aria-valuemax': duration.value,
- 'aria-valuenow': currentTime.value,
- 'aria-valuetext': i18n
- .tc('waveform.current-time', currentTime.value, {
+ "aria-role": "slider",
+ "aria-valuemax": duration.value,
+ "aria-valuenow": currentTime.value,
+ "aria-valuetext": i18n
+ .tc("waveform.current-time", currentTime.value, {
time: currentTime.value,
})
.toString(),
- 'aria-orientation': 'horizontal' as const,
- 'aria-valuemin': '0',
+ "aria-orientation": "horizontal" as const,
+ "aria-valuemin": "0",
}))
const seekDelta = 1 // seconds
@@ -52,9 +52,9 @@ export const useSeekable = ({
const { key, shiftKey, metaKey } = event
if (metaKey) {
// Always false on Windows
- onSeek(key.includes('Left') ? 0 : 1)
+ onSeek(key.includes("Left") ? 0 : 1)
} else {
- const direction = key.includes('Left') ? -1 : 1
+ const direction = key.includes("Left") ? -1 : 1
const magnitude = shiftKey ? modSeekDeltaFrac.value : seekDeltaFrac.value
const delta = magnitude * direction
onSeek(currentFrac.value + delta)
diff --git a/src/composables/use-supported.ts b/src/composables/use-supported.ts
index 232652fc9..cee33b4e9 100644
--- a/src/composables/use-supported.ts
+++ b/src/composables/use-supported.ts
@@ -1,6 +1,6 @@
-import { Ref, ref } from '@nuxtjs/composition-api'
+import { Ref, ref } from "@nuxtjs/composition-api"
-import { tryOnMounted } from '~/utils/try-on-mounted'
+import { tryOnMounted } from "~/utils/try-on-mounted"
export function useSupported(callback: () => unknown, sync = false) {
const isSupported = ref() as Ref<boolean>
diff --git a/src/composables/use-window-scroll.ts b/src/composables/use-window-scroll.ts
index f93e29229..8ad5b36aa 100644
--- a/src/composables/use-window-scroll.ts
+++ b/src/composables/use-window-scroll.ts
@@ -1,9 +1,9 @@
// code taken from Vueuse
-import { throttle } from 'throttle-debounce'
-import { ref } from '@nuxtjs/composition-api'
+import { throttle } from "throttle-debounce"
+import { ref } from "@nuxtjs/composition-api"
-import { defaultWindow } from '~/constants/window'
-import { useEventListener } from '~/composables/use-event-listener'
+import { defaultWindow } from "~/constants/window"
+import { useEventListener } from "~/composables/use-event-listener"
/**
* Whether the page has been scrolled down at all.
@@ -53,7 +53,7 @@ export function useWindowScroll({
? throttle(throttleMs, scrollHandler)
: scrollHandler
- useEventListener(window, 'scroll', handler, {
+ useEventListener(window, "scroll", handler, {
capture: false,
passive: true,
})
diff --git a/src/constants/audio.ts b/src/constants/audio.ts
index 43fff5058..7fcb13a8b 100644
--- a/src/constants/audio.ts
+++ b/src/constants/audio.ts
@@ -1,50 +1,50 @@
export type AudioLayout = typeof audioLayouts[number]
export const audioLayouts = Object.freeze([
- 'full',
- 'box',
- 'row',
- 'global',
+ "full",
+ "box",
+ "row",
+ "global",
] as const)
export type AudioSize = typeof audioSizes[number]
-export const audioSizes = Object.freeze(['s', 'm', 'l'] as const)
+export const audioSizes = Object.freeze(["s", "m", "l"] as const)
export type AudioStatus = typeof audioStatuses[number]
export const audioStatuses = Object.freeze([
- 'playing',
- 'paused',
- 'played',
- 'loading',
+ "playing",
+ "paused",
+ "played",
+ "loading",
] as const)
export type AudioFeature = typeof audioFeatures[number]
export const audioFeatures = Object.freeze([
- 'timestamps',
- 'duration',
- 'seek',
+ "timestamps",
+ "duration",
+ "seek",
] as const)
export const inactiveAudioStatus: readonly AudioStatus[] = Object.freeze([
- 'paused',
- 'played',
+ "paused",
+ "played",
])
export const activeAudioStatus: readonly AudioStatus[] = Object.freeze([
- 'playing',
- 'loading',
+ "playing",
+ "loading",
])
export const layoutMappings = Object.freeze({
- full: 'VFullLayout',
- row: 'VRowLayout',
- box: 'VBoxLayout',
- global: 'VGlobalLayout',
+ full: "VFullLayout",
+ row: "VRowLayout",
+ box: "VBoxLayout",
+ global: "VGlobalLayout",
})
export const statusVerbMap = Object.freeze({
- playing: 'pause',
- paused: 'play',
- played: 'replay',
- loading: 'loading',
+ playing: "pause",
+ paused: "play",
+ played: "replay",
+ loading: "loading",
} as const)
export const audioStatusVerbs = Object.values(statusVerbMap)
diff --git a/src/constants/content-report.ts b/src/constants/content-report.ts
index 2e32a3264..3d9efdf25 100644
--- a/src/constants/content-report.ts
+++ b/src/constants/content-report.ts
@@ -1,18 +1,18 @@
-export const DMCA = 'dmca'
-export const MATURE = 'mature'
-export const OTHER = 'other'
+export const DMCA = "dmca"
+export const MATURE = "mature"
+export const OTHER = "other"
export const reasons = [DMCA, MATURE, OTHER] as const
export type ReportReason = typeof reasons[number]
-export const SENT = 'sent'
-export const FAILED = 'failed'
-export const WIP = 'wip'
+export const SENT = "sent"
+export const FAILED = "failed"
+export const WIP = "wip"
export const statuses = [SENT, FAILED, WIP] as const
export type ReportStatus = typeof statuses[number]
export const DMCA_FORM_URL =
- 'https://docs.google.com/forms/d/e/1FAIpQLSd0I8GsEbGQLdaX4K_F6V2NbHZqN137WMZgnptUpzwd-kbDKA/viewform'
+ "https://docs.google.com/forms/d/e/1FAIpQLSd0I8GsEbGQLdaX4K_F6V2NbHZqN137WMZgnptUpzwd-kbDKA/viewform"
diff --git a/src/constants/deploy-env.ts b/src/constants/deploy-env.ts
index c90a9f43f..3b52c0a21 100644
--- a/src/constants/deploy-env.ts
+++ b/src/constants/deploy-env.ts
@@ -1,7 +1,7 @@
-export const LOCAL = 'local'
-export const DEVELOPMENT = 'development'
-export const STAGING = 'staging'
-export const PRODUCTION = 'production'
+export const LOCAL = "local"
+export const DEVELOPMENT = "development"
+export const STAGING = "staging"
+export const PRODUCTION = "production"
// The order of the environments is important. They should be arranged in
// increasing order of code-readiness, from local to production.
diff --git a/src/constants/errors.ts b/src/constants/errors.ts
index c28a8e0a1..766c9c41e 100644
--- a/src/constants/errors.ts
+++ b/src/constants/errors.ts
@@ -3,8 +3,8 @@
* that lead to the contents being replaced with an error message.
*/
-export const NO_RESULT = 'NO_RESULT'
-export const SERVER_TIMEOUT = 'SERVER_TIMEOUT'
+export const NO_RESULT = "NO_RESULT"
+export const SERVER_TIMEOUT = "SERVER_TIMEOUT"
export const errorCodes = [NO_RESULT, SERVER_TIMEOUT] as const
diff --git a/src/constants/feature-flag.ts b/src/constants/feature-flag.ts
index 67f7f0743..ec626b3cd 100644
--- a/src/constants/feature-flag.ts
+++ b/src/constants/feature-flag.ts
@@ -1,13 +1,13 @@
-export const ENABLED = 'enabled'
-export const DISABLED = 'disabled'
-export const SWITCHABLE = 'switchable'
+export const ENABLED = "enabled"
+export const DISABLED = "disabled"
+export const SWITCHABLE = "switchable"
export const FLAG_STATUSES = [ENABLED, DISABLED, SWITCHABLE] as const
export type FlagStatus = typeof FLAG_STATUSES[number]
-export const ON = 'on'
-export const OFF = 'off'
+export const ON = "on"
+export const OFF = "off"
export const FEATURE_STATES = [ON, OFF] as const
diff --git a/src/constants/filters.ts b/src/constants/filters.ts
index 54571f6ea..fa8db0dda 100644
--- a/src/constants/filters.ts
+++ b/src/constants/filters.ts
@@ -1,10 +1,10 @@
-import { kebab } from 'case'
+import { kebab } from "case"
-import { ALL_MEDIA, AUDIO, IMAGE, VIDEO, MODEL_3D } from '~/constants/media'
-import { ACTIVE_LICENSES } from '~/constants/license'
-import { deepFreeze } from '~/utils/deep-freeze'
+import { ALL_MEDIA, AUDIO, IMAGE, VIDEO, MODEL_3D } from "~/constants/media"
+import { ACTIVE_LICENSES } from "~/constants/license"
+import { deepFreeze } from "~/utils/deep-freeze"
-import type { SearchType } from '~/constants/media'
+import type { SearchType } from "~/constants/media"
export interface FilterItem {
code: string
@@ -28,7 +28,7 @@ export interface Filters {
mature: FilterItem[]
}
export type FilterCategory = keyof Filters
-export type NonMatureFilterCategory = Exclude<FilterCategory, 'mature'>
+export type NonMatureFilterCategory = Exclude<FilterCategory, "mature">
/**
* List of filters available for each search type. The order of the keys
@@ -37,29 +37,29 @@ export type NonMatureFilterCategory = Exclude<FilterCategory, 'mature'>
export const mediaFilterKeys = deepFreeze<Record<SearchType, FilterCategory[]>>(
{
[IMAGE]: [
- 'licenseTypes',
- 'licenses',
- 'imageCategories',
- 'imageExtensions',
- 'aspectRatios',
- 'sizes',
- 'imageProviders',
- 'searchBy',
- 'mature',
+ "licenseTypes",
+ "licenses",
+ "imageCategories",
+ "imageExtensions",
+ "aspectRatios",
+ "sizes",
+ "imageProviders",
+ "searchBy",
+ "mature",
],
[AUDIO]: [
- 'licenseTypes',
- 'licenses',
- 'audioCategories',
- 'audioExtensions',
- 'lengths',
- 'audioProviders',
- 'searchBy',
- 'mature',
+ "licenseTypes",
+ "licenses",
+ "audioCategories",
+ "audioExtensions",
+ "lengths",
+ "audioProviders",
+ "searchBy",
+ "mature",
],
[VIDEO]: [],
[MODEL_3D]: [],
- [ALL_MEDIA]: ['licenseTypes', 'licenses', 'searchBy', 'mature'],
+ [ALL_MEDIA]: ["licenseTypes", "licenses", "searchBy", "mature"],
}
)
@@ -72,38 +72,38 @@ export const mediaUniqueFilterKeys = deepFreeze<
>({
[ALL_MEDIA]: [],
[IMAGE]: [
- 'imageCategories',
- 'imageExtensions',
- 'aspectRatios',
- 'sizes',
- 'imageProviders',
+ "imageCategories",
+ "imageExtensions",
+ "aspectRatios",
+ "sizes",
+ "imageProviders",
],
- [AUDIO]: ['audioCategories', 'audioExtensions', 'lengths', 'audioProviders'],
+ [AUDIO]: ["audioCategories", "audioExtensions", "lengths", "audioProviders"],
[VIDEO]: [],
[MODEL_3D]: [],
})
const filterCodesPerCategory = deepFreeze<Record<FilterCategory, string[]>>({
licenses: [...ACTIVE_LICENSES],
- licenseTypes: ['commercial', 'modification'],
+ licenseTypes: ["commercial", "modification"],
audioCategories: [
- 'audiobook',
- 'music',
- 'news',
- 'podcast',
- 'pronunciation',
- 'sound_effect',
+ "audiobook",
+ "music",
+ "news",
+ "podcast",
+ "pronunciation",
+ "sound_effect",
],
- imageCategories: ['photograph', 'illustration', 'digitized_artwork'],
- audioExtensions: ['flac', 'mid', 'mp3', 'oga', 'ogg', 'opus', 'wav', 'webm'],
- imageExtensions: ['jpg', 'png', 'gif', 'svg'],
- aspectRatios: ['tall', 'wide', 'square'],
- lengths: ['shortest', 'short', 'medium', 'long'],
- sizes: ['small', 'medium', 'large'],
+ imageCategories: ["photograph", "illustration", "digitized_artwork"],
+ audioExtensions: ["flac", "mid", "mp3", "oga", "ogg", "opus", "wav", "webm"],
+ imageExtensions: ["jpg", "png", "gif", "svg"],
+ aspectRatios: ["tall", "wide", "square"],
+ lengths: ["shortest", "short", "medium", "long"],
+ sizes: ["small", "medium", "large"],
audioProviders: [],
imageProviders: [],
- searchBy: ['creator'],
- mature: ['mature'],
+ searchBy: ["creator"],
+ mature: ["mature"],
})
/**
* Converts the filterCodesPerCategory object into the format that's used by the filter store.
diff --git a/src/constants/key-codes.ts b/src/constants/key-codes.ts
index a5964bce8..91e0cf089 100644
--- a/src/constants/key-codes.ts
+++ b/src/constants/key-codes.ts
@@ -11,16 +11,16 @@
*/
export const keycodes = Object.freeze({
- Spacebar: ' ',
- Home: 'Home',
- End: 'End',
- ArrowUp: 'ArrowUp',
- ArrowDown: 'ArrowDown',
- ArrowLeft: 'ArrowLeft',
- ArrowRight: 'ArrowRight',
- Escape: 'Escape',
- PageUp: 'PageUp',
- PageDown: 'PageDown',
- Tab: 'Tab',
- Enter: 'Enter',
+ Spacebar: " ",
+ Home: "Home",
+ End: "End",
+ ArrowUp: "ArrowUp",
+ ArrowDown: "ArrowDown",
+ ArrowLeft: "ArrowLeft",
+ ArrowRight: "ArrowRight",
+ Escape: "Escape",
+ PageUp: "PageUp",
+ PageDown: "PageDown",
+ Tab: "Tab",
+ Enter: "Enter",
} as const)
diff --git a/src/constants/license.ts b/src/constants/license.ts
index 0d020f3ec..48ead5ab2 100644
--- a/src/constants/license.ts
+++ b/src/constants/license.ts
@@ -1,25 +1,25 @@
-import cc from '~/assets/licenses/cc.svg'
-import by from '~/assets/licenses/by.svg'
-import nc from '~/assets/licenses/nc.svg'
-import nd from '~/assets/licenses/nd.svg'
-import sa from '~/assets/licenses/sa.svg'
-import zero from '~/assets/licenses/zero.svg'
-import pd from '~/assets/licenses/pd.svg'
-import sampling from '~/assets/licenses/sampling.svg'
-import samplingPlus from '~/assets/licenses/sampling.plus.svg'
+import cc from "~/assets/licenses/cc.svg"
+import by from "~/assets/licenses/by.svg"
+import nc from "~/assets/licenses/nc.svg"
+import nd from "~/assets/licenses/nd.svg"
+import sa from "~/assets/licenses/sa.svg"
+import zero from "~/assets/licenses/zero.svg"
+import pd from "~/assets/licenses/pd.svg"
+import sampling from "~/assets/licenses/sampling.svg"
+import samplingPlus from "~/assets/licenses/sampling.plus.svg"
export const CC_LICENSES = [
- 'by',
- 'by-sa',
- 'by-nd',
- 'by-nc',
- 'by-nc-sa',
- 'by-nc-nd',
+ "by",
+ "by-sa",
+ "by-nd",
+ "by-nc",
+ "by-nc-sa",
+ "by-nc-nd",
] as const
-export const DEPRECATED_CC_LICENSES = ['nc-sampling+', 'sampling+'] as const
+export const DEPRECATED_CC_LICENSES = ["nc-sampling+", "sampling+"] as const
-export const PUBLIC_DOMAIN_MARKS = ['pdm', 'cc0'] as const
+export const PUBLIC_DOMAIN_MARKS = ["pdm", "cc0"] as const
export const ACTIVE_LICENSES = [...PUBLIC_DOMAIN_MARKS, ...CC_LICENSES] as const
@@ -30,7 +30,7 @@ export const ALL_LICENSES = [
export type License = typeof ALL_LICENSES[number]
-export const LICENSE_VERSIONS = ['', '1.0', '2.0', '2.5', '3.0', '4.0'] as const
+export const LICENSE_VERSIONS = ["", "1.0", "2.0", "2.5", "3.0", "4.0"] as const
export type LicenseVersion = typeof LICENSE_VERSIONS[number]
@@ -50,7 +50,7 @@ export const LICENSE_ICONS = Object.freeze({
pd,
zero,
sampling,
- 'sampling-plus': samplingPlus,
+ "sampling-plus": samplingPlus,
remix: undefined,
share: undefined,
} as const)
diff --git a/src/constants/media.ts b/src/constants/media.ts
index 7653db814..a19ee399e 100644
--- a/src/constants/media.ts
+++ b/src/constants/media.ts
@@ -1,10 +1,10 @@
/* Media types */
-export const IMAGE = 'image'
-export const AUDIO = 'audio'
-export const VIDEO = 'video'
-export const MODEL_3D = 'model-3d'
-export const ALL_MEDIA = 'all'
+export const IMAGE = "image"
+export const AUDIO = "audio"
+export const VIDEO = "video"
+export const MODEL_3D = "model-3d"
+export const ALL_MEDIA = "all"
/**
* all existing media types
@@ -50,9 +50,9 @@ export function isAdditionalSearchType(
/* Media support */
-export const SUPPORTED = 'supported' // Native search
-export const BETA = 'beta' // Native but incomplete search
-export const ADDITIONAL = 'additional' // Meta search
+export const SUPPORTED = "supported" // Native search
+export const BETA = "beta" // Native but incomplete search
+export const ADDITIONAL = "additional" // Meta search
export const contentStatus = Object.freeze({
[ALL_MEDIA]: SUPPORTED,
@@ -63,4 +63,4 @@ export const contentStatus = Object.freeze({
} as const)
export const searchPath = (type: SearchType) =>
- `/search/${type === ALL_MEDIA ? '' : type}`
+ `/search/${type === ALL_MEDIA ? "" : type}`
diff --git a/src/constants/screens.js b/src/constants/screens.js
index 0c1305226..81f3d1dff 100644
--- a/src/constants/screens.js
+++ b/src/constants/screens.js
@@ -14,7 +14,7 @@
*/
const SCREEN_SIZES = Object.freeze(
/** @type {const} */ ({
- '2xl': 1536,
+ "2xl": 1536,
xl: 1280,
lg: 1024,
md: 768,
@@ -48,12 +48,12 @@ const SCREENS = /** @type {Record<RealBreakpoint, string>} */ (
const VIEWPORTS = /** @type {Record<Breakpoint, Viewport>} */ (
Object.fromEntries(
/** @type {[Breakpoint, number][]} */ (Object.entries(SCREEN_SIZES))
- .concat([['xs', 340]])
+ .concat([["xs", 340]])
.map(([key, val]) => [
key,
{
name: `${key} (${val}px)`,
- styles: { width: `${val}px`, height: '768px' },
+ styles: { width: `${val}px`, height: "768px" },
},
])
)
diff --git a/src/constants/z-indices.js b/src/constants/z-indices.js
index fc0a3f5dc..87e1d6065 100644
--- a/src/constants/z-indices.js
+++ b/src/constants/z-indices.js
@@ -9,7 +9,7 @@
*/
const Z_INDICES = Object.freeze(
/** @type {const} */ ({
- auto: 'auto',
+ auto: "auto",
10: 10,
20: 20,
30: 30,
@@ -18,7 +18,7 @@ const Z_INDICES = Object.freeze(
// Named indices
popover: 50,
snackbar: 10,
- 'global-audio': 20,
+ "global-audio": 20,
})
)
diff --git a/src/data/api-service.ts b/src/data/api-service.ts
index 03b817034..8752b585b 100644
--- a/src/data/api-service.ts
+++ b/src/data/api-service.ts
@@ -1,7 +1,7 @@
-import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
+import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"
-import { warn } from '~/utils/console'
-import { AUDIO, IMAGE } from '~/constants/media'
+import { warn } from "~/utils/console"
+import { AUDIO, IMAGE } from "~/constants/media"
const DEFAULT_REQUEST_TIMEOUT = 30000
@@ -12,7 +12,7 @@ const DEFAULT_REQUEST_TIMEOUT = 30000
* @param resource - the first part of the request path
*/
export const getResourceSlug = (resource: string): string => {
- const slug = { [AUDIO]: 'audio', [IMAGE]: 'images' }[resource] ?? resource
+ const slug = { [AUDIO]: "audio", [IMAGE]: "images" }[resource] ?? resource
return `${slug}/`
}
@@ -62,14 +62,14 @@ export interface ApiService {
): Promise<AxiosResponse<T>>
post<T = unknown>(
resource: string,
- data: Parameters<AxiosInstance['post']>[1],
- headers?: AxiosRequestConfig['headers']
+ data: Parameters<AxiosInstance["post"]>[1],
+ headers?: AxiosRequestConfig["headers"]
): Promise<AxiosResponse<T>>
update<T = unknown>(
resource: string,
slug: string,
- data: Parameters<AxiosInstance['put']>[1],
- headers: AxiosRequestConfig['headers']
+ data: Parameters<AxiosInstance["put"]>[1],
+ headers: AxiosRequestConfig["headers"]
): Promise<AxiosResponse<T>>
put<T = unknown>(
resource: string,
@@ -78,7 +78,7 @@ export interface ApiService {
delete<T = unknown>(
resource: string,
slug: string,
- headers: AxiosRequestConfig['headers']
+ headers: AxiosRequestConfig["headers"]
): Promise<AxiosResponse<T>>
}
@@ -97,13 +97,13 @@ export const createApiService = ({
const client = axios.create(axiosParams)
client.interceptors.request.use(function (config) {
validateRequest(
- !config.url?.endsWith('/'),
- 'API request urls should have a trailing slash',
+ !config.url?.endsWith("/"),
+ "API request urls should have a trailing slash",
config
)
validateRequest(
- config.url?.includes('//') ?? false,
- 'API request urls should not have two slashes',
+ config.url?.includes("//") ?? false,
+ "API request urls should not have two slashes",
config
)
return config
@@ -111,7 +111,7 @@ export const createApiService = ({
client.interceptors.response.use(
(response) => response,
(error) => {
- if (error.code === 'ECONNABORTED') {
+ if (error.code === "ECONNABORTED") {
return Promise.reject({
message: `timeout of ${
DEFAULT_REQUEST_TIMEOUT / 1000
@@ -158,7 +158,7 @@ export const createApiService = ({
*/
post<T = unknown>(
resource: string,
- data: Parameters<typeof client['post']>[1]
+ data: Parameters<typeof client["post"]>[1]
): Promise<AxiosResponse<T>> {
return client.post(getResourceSlug(resource), data)
},
@@ -173,8 +173,8 @@ export const createApiService = ({
update<T = unknown>(
resource: string,
slug: string,
- data: Parameters<typeof client['put']>[1],
- headers: AxiosRequestConfig['headers']
+ data: Parameters<typeof client["put"]>[1],
+ headers: AxiosRequestConfig["headers"]
): Promise<AxiosResponse<T>> {
return client.put(`${getResourceSlug(resource)}${slug}`, data, {
headers,
@@ -202,7 +202,7 @@ export const createApiService = ({
delete<T = unknown>(
resource: string,
slug: string,
- headers: AxiosRequestConfig['headers']
+ headers: AxiosRequestConfig["headers"]
): Promise<AxiosResponse<T>> {
return client.delete(`${getResourceSlug(resource)}${slug}`, { headers })
},
diff --git a/src/data/media-provider-service.ts b/src/data/media-provider-service.ts
index 5e7960b7c..7e129c1fb 100644
--- a/src/data/media-provider-service.ts
+++ b/src/data/media-provider-service.ts
@@ -1,13 +1,13 @@
-import { AUDIO, IMAGE } from '~/constants/media'
-import type { AudioDetail, ImageDetail, Media } from '~/types/media'
-import { ApiService, createApiService } from '~/data/api-service'
-import type { MediaProvider } from '~/types/media-provider'
+import { AUDIO, IMAGE } from "~/constants/media"
+import type { AudioDetail, ImageDetail, Media } from "~/types/media"
+import { ApiService, createApiService } from "~/data/api-service"
+import type { MediaProvider } from "~/types/media-provider"
export class MediaProviderService<T extends Media> {
private readonly apiService: ApiService
- private readonly mediaType: T['frontendMediaType']
+ private readonly mediaType: T["frontendMediaType"]
- constructor(apiService: ApiService, mediaType: T['frontendMediaType']) {
+ constructor(apiService: ApiService, mediaType: T["frontendMediaType"]) {
this.apiService = apiService
this.mediaType = mediaType
}
@@ -17,7 +17,7 @@ export class MediaProviderService<T extends Media> {
* SSR-called
*/
async getProviderStats(): Promise<{ data: MediaProvider[] }> {
- return await this.apiService.get(this.mediaType, 'stats')
+ return await this.apiService.get(this.mediaType, "stats")
}
}
diff --git a/src/data/media-service.ts b/src/data/media-service.ts
index edb4713b0..75e26b115 100644
--- a/src/data/media-service.ts
+++ b/src/data/media-service.ts
@@ -1,10 +1,10 @@
-import { decodeMediaData } from '~/utils/decode-media-data'
-import type { ApiQueryParams } from '~/utils/search-query-transform'
-import type { ApiService } from '~/data/api-service'
-import type { DetailFromMediaType, Media } from '~/types/media'
-import { AUDIO, type SupportedMediaType } from '~/constants/media'
+import { decodeMediaData } from "~/utils/decode-media-data"
+import type { ApiQueryParams } from "~/utils/search-query-transform"
+import type { ApiService } from "~/data/api-service"
+import type { DetailFromMediaType, Media } from "~/types/media"
+import { AUDIO, type SupportedMediaType } from "~/constants/media"
-import type { AxiosResponse } from 'axios'
+import type { AxiosResponse } from "axios"
export interface MediaResult<
T extends Media | Media[] | Record<string, Media>
@@ -18,9 +18,9 @@ export interface MediaResult<
class MediaService<T extends Media> {
private readonly apiService: ApiService
- private readonly mediaType: T['frontendMediaType']
+ private readonly mediaType: T["frontendMediaType"]
- constructor(apiService: ApiService, mediaType: T['frontendMediaType']) {
+ constructor(apiService: ApiService, mediaType: T["frontendMediaType"]) {
this.apiService = apiService
this.mediaType = mediaType
}
@@ -51,7 +51,7 @@ class MediaService<T extends Media> {
): Promise<MediaResult<Record<string, Media>>> {
// Add the `peaks` param to all audio searches automatically
if (this.mediaType === AUDIO) {
- params.peaks = 'true'
+ params.peaks = "true"
}
const res = await this.apiService.query<MediaResult<T[]>>(
@@ -90,7 +90,7 @@ class MediaService<T extends Media> {
}
const params: ApiQueryParams = {}
if (this.mediaType === AUDIO) {
- params.peaks = 'true'
+ params.peaks = "true"
}
const res = (await this.apiService.get(
this.mediaType,
diff --git a/src/data/report-service.ts b/src/data/report-service.ts
index f2cd01d0b..23a923764 100644
--- a/src/data/report-service.ts
+++ b/src/data/report-service.ts
@@ -1,6 +1,6 @@
-import type { MediaType } from '~/constants/media'
-import type { ReportReason } from '~/constants/content-report'
-import { createApiService, getResourceSlug } from '~/data/api-service'
+import type { MediaType } from "~/constants/media"
+import type { ReportReason } from "~/constants/content-report"
+import { createApiService, getResourceSlug } from "~/data/api-service"
interface ReportParams {
mediaType: MediaType
diff --git a/src/layouts/blank.vue b/src/layouts/blank.vue
index f70cf6b3f..7e4bb5cc2 100644
--- a/src/layouts/blank.vue
+++ b/src/layouts/blank.vue
@@ -6,12 +6,12 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VBanners from '~/components/VBanner/VBanners.vue'
+import VBanners from "~/components/VBanner/VBanners.vue"
export default defineComponent({
- name: 'BlankLayout',
+ name: "BlankLayout",
components: { VBanners },
head() {
return this.$nuxtI18nHead({ addSeoAttributes: true, addDirAttribute: true })
diff --git a/src/layouts/default.vue b/src/layouts/default.vue
index 9185ca912..fdcfccda2 100644
--- a/src/layouts/default.vue
+++ b/src/layouts/default.vue
@@ -52,44 +52,44 @@ import {
provide,
ref,
watch,
-} from '@nuxtjs/composition-api'
-import { PortalTarget as VTeleportTarget } from 'portal-vue'
+} from "@nuxtjs/composition-api"
+import { PortalTarget as VTeleportTarget } from "portal-vue"
-import { useWindowScroll } from '~/composables/use-window-scroll'
+import { useWindowScroll } from "~/composables/use-window-scroll"
import {
useMatchSearchRoutes,
useMatchSingleResultRoutes,
-} from '~/composables/use-match-routes'
-import { useLayout } from '~/composables/use-layout'
+} from "~/composables/use-match-routes"
+import { useLayout } from "~/composables/use-layout"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { useUiStore } from '~/stores/ui'
-import { useSearchStore } from '~/stores/search'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { useUiStore } from "~/stores/ui"
+import { useSearchStore } from "~/stores/search"
-import { IsHeaderScrolledKey, IsSidebarVisibleKey } from '~/types/provides'
+import { IsHeaderScrolledKey, IsSidebarVisibleKey } from "~/types/provides"
-import VBanners from '~/components/VBanner/VBanners.vue'
-import VHeaderOld from '~/components/VHeaderOld/VHeaderOld.vue'
-import VModalTarget from '~/components/VModal/VModalTarget.vue'
-import VGlobalAudioSection from '~/components/VGlobalAudioSection/VGlobalAudioSection.vue'
-import VSearchGridFilter from '~/components/VFilters/VSearchGridFilter.vue'
+import VBanners from "~/components/VBanner/VBanners.vue"
+import VHeaderOld from "~/components/VHeaderOld/VHeaderOld.vue"
+import VModalTarget from "~/components/VModal/VModalTarget.vue"
+import VGlobalAudioSection from "~/components/VGlobalAudioSection/VGlobalAudioSection.vue"
+import VSearchGridFilter from "~/components/VFilters/VSearchGridFilter.vue"
const embeddedPage = {
- name: 'embedded',
+ name: "embedded",
components: {
VBanners,
- VHeaderDesktop: () => import('~/components/VHeader/VHeaderDesktop.vue'),
- VHeaderInternal: () => import('~/components/VHeader/VHeaderInternal.vue'),
+ VHeaderDesktop: () => import("~/components/VHeader/VHeaderDesktop.vue"),
+ VHeaderInternal: () => import("~/components/VHeader/VHeaderInternal.vue"),
VHeaderMobile: () =>
- import('~/components/VHeader/VHeaderMobile/VHeaderMobile.vue'),
- VFooter: () => import('~/components/VFooter/VFooter.vue'),
+ import("~/components/VHeader/VHeaderMobile/VHeaderMobile.vue"),
+ VFooter: () => import("~/components/VFooter/VFooter.vue"),
VHeaderOld,
VModalTarget,
VTeleportTarget,
VGlobalAudioSection,
VSearchGridFilter,
},
- layout: 'embedded',
+ layout: "embedded",
head() {
return this.$nuxtI18nHead({ addSeoAttributes: true, addDirAttribute: true })
},
@@ -99,7 +99,7 @@ const embeddedPage = {
const searchStore = useSearchStore()
const isNewHeaderEnabled = computed(() =>
- featureFlagStore.isOn('new_header')
+ featureFlagStore.isOn("new_header")
)
const { updateBreakpoint } = useLayout()
@@ -143,8 +143,8 @@ const embeddedPage = {
})
const showScrollButton = computed(() => scrollY.value > 70)
- provide('isHeaderScrolled', isHeaderScrolled)
- provide('showScrollButton', showScrollButton)
+ provide("isHeaderScrolled", isHeaderScrolled)
+ provide("showScrollButton", showScrollButton)
provide(IsHeaderScrolledKey, isHeaderScrolled)
provide(IsSidebarVisibleKey, isSidebarVisible)
@@ -153,7 +153,7 @@ const embeddedPage = {
() =>
isSearchRoute.value && !isHeaderScrolled.value && !isDesktopLayout.value
)
- provide('headerHasTwoRows', headerHasTwoRows)
+ provide("headerHasTwoRows", headerHasTwoRows)
return {
isHeaderScrolled,
diff --git a/src/layouts/error.vue b/src/layouts/error.vue
index a01293fb2..6d9f9b75d 100644
--- a/src/layouts/error.vue
+++ b/src/layouts/error.vue
@@ -3,14 +3,14 @@
</template>
<script>
-import { defineComponent } from '@nuxtjs/composition-api'
+import { defineComponent } from "@nuxtjs/composition-api"
-import VFourOhFour from '~/components/VFourOhFour.vue'
+import VFourOhFour from "~/components/VFourOhFour.vue"
export default defineComponent({
- name: 'ErrorPage',
+ name: "ErrorPage",
components: { VFourOhFour },
- layout: 'blank',
- props: ['error'],
+ layout: "blank",
+ props: ["error"],
})
</script>
diff --git a/src/locales/scripts/README.md b/src/locales/scripts/README.md
index 4b6d1f882..fbe3ecb8c 100644
--- a/src/locales/scripts/README.md
+++ b/src/locales/scripts/README.md
@@ -1,3 +1,4 @@
# Locale scripts
-Locale scripts should be run in the root of the repository using their respective pnpm commands, in the `i18n` namespace.
+Locale scripts should be run in the root of the repository using their
+respective pnpm commands, in the `i18n` namespace.
diff --git a/src/locales/scripts/axios.js b/src/locales/scripts/axios.js
index 78d8a8947..68e02d376 100644
--- a/src/locales/scripts/axios.js
+++ b/src/locales/scripts/axios.js
@@ -1,8 +1,8 @@
-const axios = require('axios')
+const axios = require("axios")
const userAgent =
- 'Openverse/0.1 (https://wordpress.org/openverse; [email protected])'
+ "Openverse/0.1 (https://wordpress.org/openverse; [email protected])"
module.exports = axios.create({
- headers: { 'User-Agent': userAgent },
+ headers: { "User-Agent": userAgent },
})
diff --git a/src/locales/scripts/create-wp-locale-list.js b/src/locales/scripts/create-wp-locale-list.js
index 83709d6ff..8feefb0c1 100644
--- a/src/locales/scripts/create-wp-locale-list.js
+++ b/src/locales/scripts/create-wp-locale-list.js
@@ -4,14 +4,14 @@ This script extracts data for locales available in GlotPress and translate.wp.or
and saves it to `wp-locales-list.json`.
**/
-const fs = require('fs')
+const fs = require("fs")
-const axios = require('./axios')
+const axios = require("./axios")
-const { addFetchedTranslationStatus } = require('./get-translations-status')
+const { addFetchedTranslationStatus } = require("./get-translations-status")
const base_url =
- 'https://raw.githubusercontent.com/GlotPress/GlotPress-WP/develop/locales/locales.php'
+ "https://raw.githubusercontent.com/GlotPress/GlotPress-WP/develop/locales/locales.php"
/**
* Fetches the data from GlotPress GitHub.
@@ -26,23 +26,23 @@ const snakeToCamel = (str) =>
str
.toLowerCase()
.replace(/([-_][a-z])/g, (group) =>
- group.toUpperCase().replace('-', '').replace('_', '')
+ group.toUpperCase().replace("-", "").replace("_", "")
)
const createPropertyRePatterns = ({
properties = [
- 'english_name',
- 'native_name',
- 'lang_code_iso_639_1',
- 'lang_code_iso_639_2',
- 'country_code',
- 'slug',
- 'nplurals',
- 'plural_expression',
- 'google_code',
- 'facebook_locale',
- 'text_direction',
- 'wp_locale',
+ "english_name",
+ "native_name",
+ "lang_code_iso_639_1",
+ "lang_code_iso_639_2",
+ "country_code",
+ "slug",
+ "nplurals",
+ "plural_expression",
+ "google_code",
+ "facebook_locale",
+ "text_direction",
+ "wp_locale",
],
} = {}) => {
const propertyRePatterns = {}
@@ -59,7 +59,7 @@ function parseLocaleData(rawData) {
// ugly check to exclude English from the locales list,
// so we don't overwrite `en.json` later. See `get-translations.js`
// to check how `en.json` file is created.
- if (wpLocaleMatch && wpLocaleMatch[1] !== 'en_US') {
+ if (wpLocaleMatch && wpLocaleMatch[1] !== "en_US") {
const wpLocale = wpLocaleMatch[1]
const data = {}
Object.keys(propertyRePatterns).forEach((key) => {
@@ -68,7 +68,7 @@ function parseLocaleData(rawData) {
if (value) {
// Convert locale property names to camelCase and replace `english_name` with `name`
const camelCasedPropName = snakeToCamel(
- key === 'english_name' ? 'name' : key
+ key === "english_name" ? "name" : key
)
data[camelCasedPropName] = value[1]
}
@@ -93,7 +93,7 @@ async function getWpLocaleData() {
const data = await getGpLocalesData()
const rawLocalesData = data
- .split('new GP_Locale();')
+ .split("new GP_Locale();")
.splice(1)
.map((item) => item.trim())
@@ -115,11 +115,11 @@ async function getWpLocaleData() {
getWpLocaleData()
.then((data) => {
try {
- const fileName = process.cwd() + '/src/locales/scripts/wp-locales.json'
- fs.writeFileSync(fileName, JSON.stringify(data, null, 2) + '\n')
+ const fileName = process.cwd() + "/src/locales/scripts/wp-locales.json"
+ fs.writeFileSync(fileName, JSON.stringify(data, null, 2) + "\n")
console.log(`Successfully wrote locales list file to ${fileName}`)
} catch (err) {
console.error(err)
}
})
- .catch((err) => console.log('Could not fetch data from ', base_url, err))
+ .catch((err) => console.log("Could not fetch data from ", base_url, err))
diff --git a/src/locales/scripts/en.json5 b/src/locales/scripts/en.json5
index f0b4a44c7..0f73e4c77 100644
--- a/src/locales/scripts/en.json5
+++ b/src/locales/scripts/en.json5
@@ -1,715 +1,715 @@
{
- '404': {
- title: 'The content you’re looking for seems to have disappeared.',
- main: 'Go to {link} or search for something similar from the field below.',
- 'search-placeholder': 'Search for content to reuse',
+ "404": {
+ title: "The content you’re looking for seems to have disappeared.",
+ main: "Go to {link} or search for something similar from the field below.",
+ "search-placeholder": "Search for content to reuse",
},
hero: {
- subtitle: 'Explore more than 600 million creative works',
- description: 'An extensive library of free stock photos, images, and audio, available for free use.',
+ subtitle: "Explore more than 600 million creative works",
+ description: "An extensive library of free stock photos, images, and audio, available for free use.",
search: {
- placeholder: 'Search for content',
+ placeholder: "Search for content",
},
disclaimer: {
- content: 'All {openverse} content is under a {license} or is in the public domain.',
- license: 'Creative Commons license',
+ content: "All {openverse} content is under a {license} or is in the public domain.",
+ license: "Creative Commons license",
},
- 'license-filter': {
- label: 'I want something I can',
+ "license-filter": {
+ label: "I want something I can",
},
aria: {
- search: 'search',
- 'search-type': 'search type',
+ search: "search",
+ "search-type": "search type",
},
},
notification: {
translation: {
- text: 'The translation for {locale} locale is incomplete. Help us get to 100 percent by {link}.',
- link: 'contributing a translation',
+ text: "The translation for {locale} locale is incomplete. Help us get to 100 percent by {link}.",
+ link: "contributing a translation",
},
},
header: {
- 'home-link': 'Home',
- 'about-nav-item': 'Our Story',
- 'source-nav-item': 'Sources',
- 'search-guide-nav-item': 'Search Guide',
- 'external-sources-nav-item': 'External Sources',
- 'privacy-nav-item': 'Privacy',
- 'feedback-nav-item': 'Feedback',
- 'support-nav-item': 'Support Us',
- placeholder: 'Search all content',
+ "home-link": "Home",
+ "about-nav-item": "Our Story",
+ "source-nav-item": "Sources",
+ "search-guide-nav-item": "Search Guide",
+ "external-sources-nav-item": "External Sources",
+ "privacy-nav-item": "Privacy",
+ "feedback-nav-item": "Feedback",
+ "support-nav-item": "Support Us",
+ placeholder: "Search all content",
aria: {
- primary: 'primary',
- menu: 'menu',
- search: 'search',
- 'sr-search': 'search button',
- },
- 'licenses-nav-item': 'The Licenses',
- 'about-tab': 'About',
- 'resources-tab': 'Resources',
- 'api-nav-item': 'API',
+ primary: "primary",
+ menu: "menu",
+ search: "search",
+ "sr-search": "search button",
+ },
+ "licenses-nav-item": "The Licenses",
+ "about-tab": "About",
+ "resources-tab": "Resources",
+ "api-nav-item": "API",
notification: {
- text: '{example_notification_text}',
- dismiss: 'Dismiss',
- okay: 'OK',
+ text: "{example_notification_text}",
+ dismiss: "Dismiss",
+ okay: "OK",
},
- loading: 'Loading...',
- 'filter-button': {
- simple: 'Filters',
- 'with-count': '{count} Filter|{count} Filters',
+ loading: "Loading...",
+ "filter-button": {
+ simple: "Filters",
+ "with-count": "{count} Filter|{count} Filters",
},
- 'see-results': 'See results',
- 'back-button': 'Go back',
- 'content-settings-button': {
- simple: 'Menu',
- 'with-count': 'Menu. {count} filter applied|Menu. {count} filters applied',
+ "see-results": "See results",
+ "back-button": "Go back",
+ "content-settings-button": {
+ simple: "Menu",
+ "with-count": "Menu. {count} filter applied|Menu. {count} filters applied",
},
},
navigation: {
- about: 'About',
- licenses: 'Licenses',
- 'get-involved': 'Get involved',
- api: 'API',
- privacy: 'Privacy',
- feedback: 'Feedback',
- sources: 'Sources',
- 'external-sources': 'External sources',
- 'search-help': 'Search help',
+ about: "About",
+ licenses: "Licenses",
+ "get-involved": "Get involved",
+ api: "API",
+ privacy: "Privacy",
+ feedback: "Feedback",
+ sources: "Sources",
+ "external-sources": "External sources",
+ "search-help": "Search help",
},
about: {
- title: 'About {openverse}',
+ title: "About {openverse}",
description: {
- content: '{openverse} is a tool that allows openly licensed and public domain works to be discovered and used by everyone.',
+ content: "{openverse} is a tool that allows openly licensed and public domain works to be discovered and used by everyone.",
},
collection: {
- content: '{openverse} searches across more than 300 million images from open APIs and the {common-crawl} dataset. It goes beyond simple search to aggregate results across multiple public repositories into a single catalog, and facilitates reuse through features like machine-generated tags and one-click attribution.',
+ content: "{openverse} searches across more than 300 million images from open APIs and the {common-crawl} dataset. It goes beyond simple search to aggregate results across multiple public repositories into a single catalog, and facilitates reuse through features like machine-generated tags and one-click attribution.",
},
planning: {
- content: 'Currently {openverse} only searches images and audio, with search for video provided through External Sources. But we plan to add additional media types such as open texts and 3D models, with the ultimate goal of providing access to all 1.4 billion CC licensed and public domain works on the web. All of our code is open source ({frontend}, {api}, {catalog}) and we {community}. You can see what {working}.',
- frontend: '{openverse} frontend',
- api: '{openverse} API',
- catalog: '{openverse} Catalog',
- community: 'welcome community contribution',
- working: 'we’re currently working on',
+ content: "Currently {openverse} only searches images and audio, with search for video provided through External Sources. But we plan to add additional media types such as open texts and 3D models, with the ultimate goal of providing access to all 1.4 billion CC licensed and public domain works on the web. All of our code is open source ({frontend}, {api}, {catalog}) and we {community}. You can see what {working}.",
+ frontend: "{openverse} frontend",
+ api: "{openverse} API",
+ catalog: "{openverse} Catalog",
+ community: "welcome community contribution",
+ working: "we’re currently working on",
},
transfer: {
- content: '{openverse} is the successor to CC Search which was launched by Creative Commons in 2019, after its migration to WordPress in 2021. You can read more about this transition in the official announcements from {creative-commons} and {wordpress}. We remain committed to our goal of tackling discoverability and accessibility of open access media.',
+ content: "{openverse} is the successor to CC Search which was launched by Creative Commons in 2019, after its migration to WordPress in 2021. You can read more about this transition in the official announcements from {creative-commons} and {wordpress}. We remain committed to our goal of tackling discoverability and accessibility of open access media.",
},
declaration: {
- content: 'Please note that {openverse} does not verify whether the images are properly CC licensed, or whether the attribution and other licensing information we have aggregated is accurate or complete. Please independently verify the licensing status and attribution information before reusing the content. For more details, read the {terms}.',
- terms: '{openverse} Terms of Use',
+ content: "Please note that {openverse} does not verify whether the images are properly CC licensed, or whether the attribution and other licensing information we have aggregated is accurate or complete. Please independently verify the licensing status and attribution information before reusing the content. For more details, read the {terms}.",
+ terms: "{openverse} Terms of Use",
},
},
sources: {
- title: 'Sources',
- detail: 'Clicking on a {single-name} allows you to browse and filter items within that source.',
- 'single-name': 'Source',
+ title: "Sources",
+ detail: "Clicking on a {single-name} allows you to browse and filter items within that source.",
+ "single-name": "Source",
providers: {
- source: 'Source',
- domain: 'Domain',
- item: 'Total items',
- },
- 'cc-content': {
- where: 'Where does the content on {openverse} come from?',
- content: 'There is openly licensed content hosted on millions of domains across the breadth of the internet. Our team systematically identifies providers hosting CC-licensed content. If it’s a good fit, we index that content and make it discoverable through {openverse}.',
- provider: 'Some providers have multiple different groupings of content within them. {flickr} has sources ranging from NASA to personal photography. The {smithsonian} comprises a dozen diverse collections. Wikimedia Commons runs the gamut in terms of content, and is used by several Galleries, Libraries, Archives, and Museums highlighting some or all of their digitized collections.',
- europeana: '{openverse} is especially grateful for the work of {link}, an organization that works to digitize and make discoverable cultural heritage works across Europe. {openverse} is able to index hundreds of valuable sources through a single integration with the {link-api}.',
- 'europeana-api': 'Europeana API',
- smithsonian: 'Smithsonian Institute',
- },
- 'new-content': {
- next: 'How do we decide what sources to add next?',
- integrate: 'We have a never ending list of possible sources to research prior to integration. We ask ourselves questions like:',
- impact: ' What is the impact or importance of this source to our users? If it exists within a provider like Wikimedia Commons, is it valuable for our users to be able to filter by this source directly?',
- reuse: 'Is licensing and attribution information clearly displayed to enable confident reuse?',
- 'total-items': 'How many new total items or new types of items can we bring to our users through this integration? Some sources are direct integrations, while others may be a source within a source.',
- },
- suggestions: 'We appreciate suggestions for new sources from our community of users.',
- 'issue-button': 'Suggest a new source',
+ source: "Source",
+ domain: "Domain",
+ item: "Total items",
+ },
+ "cc-content": {
+ where: "Where does the content on {openverse} come from?",
+ content: "There is openly licensed content hosted on millions of domains across the breadth of the internet. Our team systematically identifies providers hosting CC-licensed content. If it’s a good fit, we index that content and make it discoverable through {openverse}.",
+ provider: "Some providers have multiple different groupings of content within them. {flickr} has sources ranging from NASA to personal photography. The {smithsonian} comprises a dozen diverse collections. Wikimedia Commons runs the gamut in terms of content, and is used by several Galleries, Libraries, Archives, and Museums highlighting some or all of their digitized collections.",
+ europeana: "{openverse} is especially grateful for the work of {link}, an organization that works to digitize and make discoverable cultural heritage works across Europe. {openverse} is able to index hundreds of valuable sources through a single integration with the {link-api}.",
+ "europeana-api": "Europeana API",
+ smithsonian: "Smithsonian Institute",
+ },
+ "new-content": {
+ next: "How do we decide what sources to add next?",
+ integrate: "We have a never ending list of possible sources to research prior to integration. We ask ourselves questions like:",
+ impact: " What is the impact or importance of this source to our users? If it exists within a provider like Wikimedia Commons, is it valuable for our users to be able to filter by this source directly?",
+ reuse: "Is licensing and attribution information clearly displayed to enable confident reuse?",
+ "total-items": "How many new total items or new types of items can we bring to our users through this integration? Some sources are direct integrations, while others may be a source within a source.",
+ },
+ suggestions: "We appreciate suggestions for new sources from our community of users.",
+ "issue-button": "Suggest a new source",
aria: {
- table: 'sources table',
+ table: "sources table",
},
heading: {
- image: 'Image Sources',
- audio: 'Audio Sources',
+ image: "Image Sources",
+ audio: "Audio Sources",
},
},
- 'external-sources-page': {
- title: 'External Sources',
- intro: '{openverse} is built on top of a catalog that indexes CC-licensed and public domain content from selected sources. Learn more about our {link}.',
- link: 'sources here',
- license: 'However, there are many sources of CC-licensed and public domain media which we aren’t able to surface results from within the {openverse} interface yet. This might be because they do not offer a public API, or that our contributors have not yet had time to integrate them into Openverse. These are valued sources and we want to make sure that you are able to find the best openly licensed materials possible, regardless of where they are located.',
+ "external-sources-page": {
+ title: "External Sources",
+ intro: "{openverse} is built on top of a catalog that indexes CC-licensed and public domain content from selected sources. Learn more about our {link}.",
+ link: "sources here",
+ license: "However, there are many sources of CC-licensed and public domain media which we aren’t able to surface results from within the {openverse} interface yet. This might be because they do not offer a public API, or that our contributors have not yet had time to integrate them into Openverse. These are valued sources and we want to make sure that you are able to find the best openly licensed materials possible, regardless of where they are located.",
new: {
- title: 'Can I suggest new external sources?',
- content: 'Yes, please! Create an {issue} in our GitHub repository or send us an {email} and tell us about the new sources you’d like to see included.',
- issue: 'issue',
- email: 'email',
+ title: "Can I suggest new external sources?",
+ content: "Yes, please! Create an {issue} in our GitHub repository or send us an {email} and tell us about the new sources you’d like to see included.",
+ issue: "issue",
+ email: "email",
},
why: {
- title: 'Why did you build this?',
- content: 'For many years, Creative Commons has offered its users a dedicated search portal for searching platforms that have CC licensing filters built in. In fact, this is still maintained at {old}.',
- old: 'oldsearch.creativecommons.org',
+ title: "Why did you build this?",
+ content: "For many years, Creative Commons has offered its users a dedicated search portal for searching platforms that have CC licensing filters built in. In fact, this is still maintained at {old}.",
+ old: "oldsearch.creativecommons.org",
new: 'For users of the legacy CC Meta Search site, the "External Sources" feature on {openverse} will look familiar. The goal was to ensure that the functionality is not lost, but is updated and embedded within our new search engine for openly licensed content. In addition, the "External Sources" feature builds on this functionality, allowing us to quickly add new external sources as we discover them, and support new content types in the future, as we expand.',
- 'aria-label': 'feedback',
- 'feedback-suggestions': 'We hope you enjoy, and if you have suggestions for improvement, leave us {feedback}.',
- 'feedback-link': 'feedback',
+ "aria-label": "feedback",
+ "feedback-suggestions": "We hope you enjoy, and if you have suggestions for improvement, leave us {feedback}.",
+ "feedback-link": "feedback",
},
- relationships: 'This functionality also allows us to start conversations and build relationships with sources that may like to be included in {openverse} in the future. Finally, we can also offer external sources of media types we do not include in {openverse} yet, but plan to.',
- explanation: 'You can find links to external sources at the bottom of every {openverse} search results page; on pages for searches which return no results; and on pages for media types we do not yet support but intend to.',
+ relationships: "This functionality also allows us to start conversations and build relationships with sources that may like to be included in {openverse} in the future. Finally, we can also offer external sources of media types we do not include in {openverse} yet, but plan to.",
+ explanation: "You can find links to external sources at the bottom of every {openverse} search results page; on pages for searches which return no results; and on pages for media types we do not yet support but intend to.",
},
privacy: {
- title: 'Privacy',
+ title: "Privacy",
intro: {
- content: 'The {openverse} project seeks to make the privacy and safety of our users a priority. {openverse} adheres to the {link}. Please see that document for a full description of how {openverse} uses and protects any information that you give us.',
- link: 'privacy policy of all WordPress.org websites',
+ content: "The {openverse} project seeks to make the privacy and safety of our users a priority. {openverse} adheres to the {link}. Please see that document for a full description of how {openverse} uses and protects any information that you give us.",
+ link: "privacy policy of all WordPress.org websites",
},
cookies: {
- title: 'Cookies',
+ title: "Cookies",
content: '{openverse} uses cookies to store information about visitor\'s preferences and information about their web browsers. We use this information to improve the user experience of the site. These are considered "Necessary" or "Strictly necessary cookies" and you may disable these by changing your browser settings, but this may affect how {openverse} functions.',
},
contact: {
- title: 'Contact Us',
- content: 'Any questions about {openverse} and privacy can be sent to {email}, shared as a {issue}, or discussed with our community in the #openverse channel of the {chat}.',
- issue: 'GitHub issue',
- chat: 'Making WordPress Chat',
+ title: "Contact Us",
+ content: "Any questions about {openverse} and privacy can be sent to {email}, shared as a {issue}, or discussed with our community in the #openverse channel of the {chat}.",
+ issue: "GitHub issue",
+ chat: "Making WordPress Chat",
},
},
- 'search-guide': {
- title: '{openverse} Syntax Guide',
- intro: 'When you search, you can enter special symbols or words to your search term to make your search results more precise.',
+ "search-guide": {
+ title: "{openverse} Syntax Guide",
+ intro: "When you search, you can enter special symbols or words to your search term to make your search results more precise.",
exact: {
- title: 'Search for an exact match',
- 'aria-label': 'quote unquote Claude Monet',
- 'claude-monet': '"Claude Monet"',
- content: 'Put a word or phrase inside quotes. For example, {link}.',
+ title: "Search for an exact match",
+ "aria-label": "quote unquote Claude Monet",
+ "claude-monet": '"Claude Monet"',
+ content: "Put a word or phrase inside quotes. For example, {link}.",
},
combine: {
- title: 'Combining terms',
- description: 'If you want to combine terms, you can use the following operators to perform more complex queries',
- and: '{symbol} signifies AND operation',
- or: '{symbol} signifies OR operation',
- negate: '{symbol} negates a single token',
- prefix: '{symbol} at the end of a term signifies a prefix query',
- precedence: '{open} and {close} signify precedence',
- fuzziness: '{symbol} after a word signifies edit distance (fuzziness)',
- 'aria-labels': {
- fuzziness: 'tilde N',
- open: 'open parenthesis',
- close: 'close parenthesis',
- star: 'star symbol',
- minus: 'minus symbol',
- plus: 'plus symbol',
- 'vertical-bar': 'vertical bar symbol',
+ title: "Combining terms",
+ description: "If you want to combine terms, you can use the following operators to perform more complex queries",
+ and: "{symbol} signifies AND operation",
+ or: "{symbol} signifies OR operation",
+ negate: "{symbol} negates a single token",
+ prefix: "{symbol} at the end of a term signifies a prefix query",
+ precedence: "{open} and {close} signify precedence",
+ fuzziness: "{symbol} after a word signifies edit distance (fuzziness)",
+ "aria-labels": {
+ fuzziness: "tilde N",
+ open: "open parenthesis",
+ close: "close parenthesis",
+ star: "star symbol",
+ minus: "minus symbol",
+ plus: "plus symbol",
+ "vertical-bar": "vertical bar symbol",
},
},
example: {
and: {
- description: 'Example: {link}{br} This will search for images related to both dog and cat.',
- 'aria-label': 'dog plus cat',
- example: 'dog+cat',
+ description: "Example: {link}{br} This will search for images related to both dog and cat.",
+ "aria-label": "dog plus cat",
+ example: "dog+cat",
},
or: {
- description: 'Example: {link}{br} This will search for images related to dog or cat, but not necessarily both.',
- 'aria-label': 'dog vertical bar cat',
- example: 'dog|cat',
+ description: "Example: {link}{br} This will search for images related to dog or cat, but not necessarily both.",
+ "aria-label": "dog vertical bar cat",
+ example: "dog|cat",
},
negate: {
- description: 'You can use the {operator} to exclude a search term from the results.',
- 'operator-name': 'operator (signifies NOT)',
- 'operator-aria-label': 'minus operator (signifies NOT)',
- 'aria-label': 'dog minus pug',
- example: 'dog -pug',
+ description: "You can use the {operator} to exclude a search term from the results.",
+ "operator-name": "operator (signifies NOT)",
+ "operator-aria-label": "minus operator (signifies NOT)",
+ "aria-label": "dog minus pug",
+ example: "dog -pug",
content: "Example: {link}{br} This will search for images related to dog but won't include results related to 'pug'",
},
prefix: {
- description: 'You can use the {operator-name} to mark a prefix term. This will match anything after the *.',
- 'operator-name': 'operator (wildcard)',
- 'operator-aria-label': 'star operator (wildcard)',
- 'aria-label': 'net star symbol',
- example: 'net*',
+ description: "You can use the {operator-name} to mark a prefix term. This will match anything after the *.",
+ "operator-name": "operator (wildcard)",
+ "operator-aria-label": "star operator (wildcard)",
+ "aria-label": "net star symbol",
+ example: "net*",
content: "Example: {link}{br} This will search for images matching anything with 'net'. This might include 'network', 'Netflix', 'Netherlands', etc..",
},
precedence: {
- description: 'You can use parentheses {highlight} to specify precedence of terms or combine more complex queries.',
- 'aria-label': 'dogs plus open parenthesis corgis vertical bar labrador close parenthesis',
- example: 'dogs + (corgis | labrador)',
- content: 'Example: {link}{br} This will search for images that match dogs that are either corgis or labrador.',
+ description: "You can use parentheses {highlight} to specify precedence of terms or combine more complex queries.",
+ "aria-label": "dogs plus open parenthesis corgis vertical bar labrador close parenthesis",
+ example: "dogs + (corgis | labrador)",
+ content: "Example: {link}{br} This will search for images that match dogs that are either corgis or labrador.",
},
fuzziness: {
- description: 'You can use {highlight} to specify some fuzzy logic to the term according to the {link} — the number of one character changes that need to be made to one string to make it the same as another string.',
- 'link-text': 'Levenshtein Edit Distance',
- 'aria-label': 'theatre tilde 1',
- example: 'theatre~1',
+ description: "You can use {highlight} to specify some fuzzy logic to the term according to the {link} — the number of one character changes that need to be made to one string to make it the same as another string.",
+ "link-text": "Levenshtein Edit Distance",
+ "aria-label": "theatre tilde 1",
+ example: "theatre~1",
content: "Example: {link}{br} This will search for images that match strings close to the term 'theatre' with a difference of one character. Results might include terms with different spellings like 'theater'.",
},
},
},
feedback: {
- title: 'Feedback',
- intro: 'Thank you for using {openverse}! We welcome your ideas for improving the tool below. To provide regular feedback, join the {slack} channel in the {making-wordpress} Slack workspace.',
- improve: 'Help us Improve',
- report: 'Report a Bug',
- loading: 'Loading...',
+ title: "Feedback",
+ intro: "Thank you for using {openverse}! We welcome your ideas for improving the tool below. To provide regular feedback, join the {slack} channel in the {making-wordpress} Slack workspace.",
+ improve: "Help us Improve",
+ report: "Report a Bug",
+ loading: "Loading...",
aria: {
- 'cc-usability': 'slack cc-usability channel',
- improve: 'help us improve form',
- report: 'report a bug form',
+ "cc-usability": "slack cc-usability channel",
+ improve: "help us improve form",
+ report: "report a bug form",
},
},
error: {
- occurred: 'An error occurred',
- 'image-not-found': "Couldn't find image with id {id}",
- 'media-not-found': "Couldn't find {mediaType} with id {id}",
- image: 'image',
- audio: 'audio',
+ occurred: "An error occurred",
+ "image-not-found": "Couldn't find image with id {id}",
+ "media-not-found": "Couldn't find {mediaType} with id {id}",
+ image: "image",
+ audio: "audio",
},
filters: {
- title: 'Filters',
- 'filter-by': 'Filter By',
+ title: "Filters",
+ "filter-by": "Filter By",
licenses: {
- title: 'Licenses',
- cc0: 'CC0',
- pdm: 'Public Domain Mark',
- by: 'BY',
- 'by-sa': 'BY-SA',
- 'by-nc': 'BY-NC',
- 'by-nd': 'BY-ND',
- 'by-nc-sa': 'BY-NC-SA',
- 'by-nc-nd': 'BY-NC-ND',
- },
- 'license-types': {
- title: 'Use',
- commercial: 'Use commercially',
- modification: 'Modify or adapt',
- },
- 'image-providers': {
- title: 'Source',
- },
- 'audio-providers': {
- title: 'Source',
- },
- 'audio-categories': {
- title: 'Audio category',
- audiobook: 'Audiobook',
- music: 'Music',
- news: 'News',
- podcast: 'Podcast',
- pronunciation: 'Pronunciation',
- sound_effect: 'Sound effects',
- sound: 'Sound effects',
- },
- 'image-categories': {
- title: 'Image type',
- photograph: 'Photographs',
- illustration: 'Illustrations',
- digitized_artwork: 'Digitized Artworks',
- },
- 'audio-extensions': {
- title: 'Extension',
- flac: 'FLAC',
- mid: 'MID',
- mp3: 'MP3',
- oga: 'OGA',
- ogg: 'OGG',
- opus: 'OPUS',
- wav: 'WAV',
- webm: 'WEBM',
- },
- 'image-extensions': {
- title: 'Extension',
- jpg: 'JPEG',
- png: 'PNG',
- gif: 'GIF',
- svg: 'SVG',
- },
- 'aspect-ratios': {
- title: 'Aspect ratio',
- tall: 'Tall',
- wide: 'Wide',
- square: 'Square',
+ title: "Licenses",
+ cc0: "CC0",
+ pdm: "Public Domain Mark",
+ by: "BY",
+ "by-sa": "BY-SA",
+ "by-nc": "BY-NC",
+ "by-nd": "BY-ND",
+ "by-nc-sa": "BY-NC-SA",
+ "by-nc-nd": "BY-NC-ND",
+ },
+ "license-types": {
+ title: "Use",
+ commercial: "Use commercially",
+ modification: "Modify or adapt",
+ },
+ "image-providers": {
+ title: "Source",
+ },
+ "audio-providers": {
+ title: "Source",
+ },
+ "audio-categories": {
+ title: "Audio category",
+ audiobook: "Audiobook",
+ music: "Music",
+ news: "News",
+ podcast: "Podcast",
+ pronunciation: "Pronunciation",
+ sound_effect: "Sound effects",
+ sound: "Sound effects",
+ },
+ "image-categories": {
+ title: "Image type",
+ photograph: "Photographs",
+ illustration: "Illustrations",
+ digitized_artwork: "Digitized Artworks",
+ },
+ "audio-extensions": {
+ title: "Extension",
+ flac: "FLAC",
+ mid: "MID",
+ mp3: "MP3",
+ oga: "OGA",
+ ogg: "OGG",
+ opus: "OPUS",
+ wav: "WAV",
+ webm: "WEBM",
+ },
+ "image-extensions": {
+ title: "Extension",
+ jpg: "JPEG",
+ png: "PNG",
+ gif: "GIF",
+ svg: "SVG",
+ },
+ "aspect-ratios": {
+ title: "Aspect ratio",
+ tall: "Tall",
+ wide: "Wide",
+ square: "Square",
},
sizes: {
- title: 'Image size',
- small: 'Small',
- medium: 'Medium',
- large: 'Large',
+ title: "Image size",
+ small: "Small",
+ medium: "Medium",
+ large: "Large",
},
mature: {
- title: 'Search Settings',
- enable: 'Enable Mature Content',
+ title: "Search Settings",
+ enable: "Enable Mature Content",
},
lengths: {
- title: 'Duration',
- shortest: '< 30 sec',
- short: '30 sec-2 min',
- medium: '2-10 min',
- long: '> 10 min',
+ title: "Duration",
+ shortest: "< 30 sec",
+ short: "30 sec-2 min",
+ medium: "2-10 min",
+ long: "> 10 min",
},
creator: {
- title: 'Search by Creator',
+ title: "Search by Creator",
},
- 'search-by': {
- title: 'Search By',
- creator: 'Creator',
+ "search-by": {
+ title: "Search By",
+ creator: "Creator",
},
- 'license-explanation': {
- 'license-definition': 'License definition',
- 'mark-definition': '{mark} definition',
+ "license-explanation": {
+ "license-definition": "License definition",
+ "mark-definition": "{mark} definition",
more: {
- license: '{read-more} about this license.',
- mark: '{read-more} about {mark}.',
- 'read-more': 'Read more',
+ license: "{read-more} about this license.",
+ mark: "{read-more} about {mark}.",
+ "read-more": "Read more",
},
},
aria: {
- 'remove-filter': 'Remove {label} filter',
- },
- },
- 'filter-list': {
- 'filter-by': 'Filter by',
- hide: 'Hide filters',
- clear: 'Clear filters',
- 'clear-numbered': 'Clear filters ({number})',
- show: 'Show results',
- 'category-aria': 'filters list for {categoryName} category',
- },
- 'browse-page': {
- 'all-no-results': 'No results',
- 'all-result-count': '{localeCount} result|{localeCount} results',
- 'all-result-count-more': 'Over {localeCount} result|Over {localeCount} results',
- load: 'Load more results',
- loading: 'Loading...',
- 'fetching-error': 'Error fetching {type}:',
- 'search-rating': {
- content: 'Are these results relevant?',
- yes: 'Yes',
- no: 'No',
- 'feedback-thanks': 'Thank you for the feedback!',
- },
- 'search-form': {
- placeholder: 'Search all {type}',
- image: 'images',
- audio: 'audio',
- video: 'videos',
- 'model-3d': '3D Models',
- all: 'content',
- 'collection-placeholder': 'Search this collection',
- button: 'Search',
- clear: 'Clear',
- },
- 'license-description': {
- title: 'License CC',
- by: 'Credit the creator.',
- nc: 'Noncommercial uses only.',
- nd: 'No derivatives or adaptations permitted.',
- sa: 'Share adaptations under the same terms.',
- zero: 'This work has been marked as dedicated to the public domain.',
- pd: 'This work is marked as being in the public domain.',
- 'sampling-plus': 'Samples, mash-ups, creative transformations permitted.',
+ "remove-filter": "Remove {label} filter",
+ },
+ },
+ "filter-list": {
+ "filter-by": "Filter by",
+ hide: "Hide filters",
+ clear: "Clear filters",
+ "clear-numbered": "Clear filters ({number})",
+ show: "Show results",
+ "category-aria": "filters list for {categoryName} category",
+ },
+ "browse-page": {
+ "all-no-results": "No results",
+ "all-result-count": "{localeCount} result|{localeCount} results",
+ "all-result-count-more": "Over {localeCount} result|Over {localeCount} results",
+ load: "Load more results",
+ loading: "Loading...",
+ "fetching-error": "Error fetching {type}:",
+ "search-rating": {
+ content: "Are these results relevant?",
+ yes: "Yes",
+ no: "No",
+ "feedback-thanks": "Thank you for the feedback!",
+ },
+ "search-form": {
+ placeholder: "Search all {type}",
+ image: "images",
+ audio: "audio",
+ video: "videos",
+ "model-3d": "3D Models",
+ all: "content",
+ "collection-placeholder": "Search this collection",
+ button: "Search",
+ clear: "Clear",
+ },
+ "license-description": {
+ title: "License CC",
+ by: "Credit the creator.",
+ nc: "Noncommercial uses only.",
+ nd: "No derivatives or adaptations permitted.",
+ sa: "Share adaptations under the same terms.",
+ zero: "This work has been marked as dedicated to the public domain.",
+ pd: "This work is marked as being in the public domain.",
+ "sampling-plus": "Samples, mash-ups, creative transformations permitted.",
},
aria: {
- close: 'close',
- scroll: 'scroll to top',
- search: 'search',
+ close: "close",
+ scroll: "scroll to top",
+ search: "search",
relevance: {
- yes: 'relevant result? answer: yes',
- no: 'relevant result? answer: no',
+ yes: "relevant result? answer: yes",
+ no: "relevant result? answer: no",
},
- 'remove-filter': 'remove filter',
- 'license-explanation': 'license explanation',
- creator: 'search by creator',
+ "remove-filter": "remove filter",
+ "license-explanation": "license explanation",
+ creator: "search by creator",
},
},
- 'media-details': {
+ "media-details": {
reuse: {
- title: 'How to use',
+ title: "How to use",
description: "Visit the {media}'s website to download and use it. Make sure to credit the creator by showing the attribution information where you are sharing your work.",
- 'license-header': 'License',
- 'tool-header': 'Public Domain',
- audio: 'Audio',
- image: 'Image',
+ "license-header": "License",
+ "tool-header": "Public Domain",
+ audio: "Audio",
+ image: "Image",
tool: {
- content: 'Read more about the tool {link}.',
- link: 'here',
+ content: "Read more about the tool {link}.",
+ link: "here",
},
credit: {
- 'generic-title': 'This work',
- 'actual-title': '"{title}"',
- text: '{title} {creator} {marked-licensed} {license}. {view-legal}',
- 'creator-text': 'by {creator-name}',
- marked: 'is marked with',
- licensed: 'is licensed under',
- 'view-legal-text': 'To view {terms-copy}, visit {url}.',
- 'terms-text': 'the terms',
- 'copy-text': 'a copy of this license',
+ "generic-title": "This work",
+ "actual-title": '"{title}"',
+ text: "{title} {creator} {marked-licensed} {license}. {view-legal}",
+ "creator-text": "by {creator-name}",
+ marked: "is marked with",
+ licensed: "is licensed under",
+ "view-legal-text": "To view {terms-copy}, visit {url}.",
+ "terms-text": "the terms",
+ "copy-text": "a copy of this license",
},
- 'copy-license': {
- title: 'Credit the creator',
- rich: 'Rich Text',
- html: 'HTML',
- plain: 'Plain text',
- 'copy-text': 'Copy text',
- copied: 'Copied!',
+ "copy-license": {
+ title: "Credit the creator",
+ rich: "Rich Text",
+ html: "HTML",
+ plain: "Plain text",
+ "copy-text": "Copy text",
+ copied: "Copied!",
},
- attribution: 'This image was marked with a {link} license:',
+ attribution: "This image was marked with a {link} license:",
},
- 'provider-label': 'Provider',
- 'source-label': 'Source',
- loading: 'Loading...',
- 'related-error': 'Error fetching related media',
+ "provider-label": "Provider",
+ "source-label": "Source",
+ loading: "Loading...",
+ "related-error": "Error fetching related media",
aria: {
attribution: {
- license: 'read more about the license',
- tool: 'read more about the tool',
+ license: "read more about the license",
+ tool: "read more about the tool",
},
- 'creator-url': 'author {name}',
+ "creator-url": "author {name}",
},
- 'image-info': 'Image information',
- 'audio-info': 'Audio information',
- 'content-report': {
- short: 'Report',
- long: 'Report this content',
+ "image-info": "Image information",
+ "audio-info": "Audio information",
+ "content-report": {
+ short: "Report",
+ long: "Report this content",
form: {
- disclaimer: 'For security purposes, {openverse} collects and retains anonymized IP addresses of those who complete and submit this form.',
- question: 'What is the reason?',
+ disclaimer: "For security purposes, {openverse} collects and retains anonymized IP addresses of those who complete and submit this form.",
+ question: "What is the reason?",
dmca: {
- option: 'Infringes copyright',
- note: 'You must fill out this {form} to report copyright infringement. No action will be taken until this form is filled out and submitted. We recommend doing the same at the source, {source}.',
- form: 'DMCA form',
- open: 'Open form',
+ option: "Infringes copyright",
+ note: "You must fill out this {form} to report copyright infringement. No action will be taken until this form is filled out and submitted. We recommend doing the same at the source, {source}.",
+ form: "DMCA form",
+ open: "Open form",
},
mature: {
- option: 'Contains mature content',
- 'sub-label': 'Optional',
- placeholder: 'Optionally, provide a description.',
+ option: "Contains mature content",
+ "sub-label": "Optional",
+ placeholder: "Optionally, provide a description.",
},
other: {
- option: 'Other',
- note: 'Describe the issue.',
- 'sub-label': 'Required',
- placeholder: 'Please enter at least 20 characters.',
+ option: "Other",
+ note: "Describe the issue.",
+ "sub-label": "Required",
+ placeholder: "Please enter at least 20 characters.",
},
- submit: 'Report',
- cancel: 'Cancel',
+ submit: "Report",
+ cancel: "Cancel",
},
success: {
- title: 'Report submitted successfully',
- note: 'Thank you for reporting this content. We recommend doing the same at the source, {source}.',
+ title: "Report submitted successfully",
+ note: "Thank you for reporting this content. We recommend doing the same at the source, {source}.",
},
failure: {
- title: 'Report could not be submitted',
- note: 'Something went wrong, please try again after some time.',
+ title: "Report could not be submitted",
+ note: "Something went wrong, please try again after some time.",
},
},
},
- 'single-result': {
- back: 'Back to results',
+ "single-result": {
+ back: "Back to results",
},
- 'image-details': {
- creator: 'by {name}',
- weblink: 'Get this image',
+ "image-details": {
+ creator: "by {name}",
+ weblink: "Get this image",
information: {
- title: 'Image information',
- type: 'Type',
- provider: 'Provider',
- dimensions: 'Dimensions',
- source: 'Source',
- pixels: 'pixels',
- unknown: 'Unknown',
- },
- 'related-images': 'Related images',
+ title: "Image information",
+ type: "Type",
+ provider: "Provider",
+ dimensions: "Dimensions",
+ source: "Source",
+ pixels: "pixels",
+ unknown: "Unknown",
+ },
+ "related-images": "Related images",
aria: {
- 'creator-url': 'Author {creator}',
+ "creator-url": "Author {creator}",
},
},
- 'audio-details': {
- 'genre-label': 'Genre',
- 'related-audios': 'Related audio',
+ "audio-details": {
+ "genre-label": "Genre",
+ "related-audios": "Related audio",
table: {
- album: 'Album',
- category: 'Type',
- 'sample-rate': 'Sample Rate',
- filetype: 'Format',
- provider: 'Provider',
- source: 'Source',
- genre: 'Genre',
- },
- information: 'Audio information',
- weblink: 'Get this audio',
- },
- 'all-results': {
+ album: "Album",
+ category: "Type",
+ "sample-rate": "Sample Rate",
+ filetype: "Format",
+ provider: "Provider",
+ source: "Source",
+ genre: "Genre",
+ },
+ information: "Audio information",
+ weblink: "Get this audio",
+ },
+ "all-results": {
snackbar: {
- text: 'Press {spacebar} to play or pause the track.',
- spacebar: 'Spacebar',
+ text: "Press {spacebar} to play or pause the track.",
+ spacebar: "Spacebar",
},
},
- 'audio-results': {
+ "audio-results": {
snackbar: {
- text: 'Press {spacebar} to play or pause, and {left} & {right} to seek through the track.',
- spacebar: 'Spacebar',
- left: '←',
- right: '→',
+ text: "Press {spacebar} to play or pause, and {left} & {right} to seek through the track.",
+ spacebar: "Spacebar",
+ left: "←",
+ right: "→",
},
},
- 'external-sources': {
- caption: '{openverse} can not guarantee the accuracy of license information. Always verify that the work is actually under a CC license.',
- button: 'Source list',
- title: 'External sources',
+ "external-sources": {
+ caption: "{openverse} can not guarantee the accuracy of license information. Always verify that the work is actually under a CC license.",
+ button: "Source list",
+ title: "External sources",
card: {
search: "Not finding what you're looking for? Try external sources",
- caption: 'Click on a source below to directly search other collections of CC-licensed images.{break}Please note that Use filters are not supported for Open Clip Art Library or Nappy.',
+ caption: "Click on a source below to directly search other collections of CC-licensed images.{break}Please note that Use filters are not supported for Open Clip Art Library or Nappy.",
},
form: {
- 'unsupported-title': '{openverse} does not yet support built-in {type} search.',
- 'supported-title': "Not finding what you're looking for? Try an external source:",
- 'no-results-title': 'No {type} results for "{query}".',
- caption: 'Click on a source below to directly search other collections of CC-licensed {type}.',
+ "unsupported-title": "{openverse} does not yet support built-in {type} search.",
+ "supported-title": "Not finding what you're looking for? Try an external source:",
+ "no-results-title": 'No {type} results for "{query}".',
+ caption: "Click on a source below to directly search other collections of CC-licensed {type}.",
types: {
- image: 'image',
- audio: 'audio',
- video: 'video',
- 'model-3d': '3D model',
+ image: "image",
+ audio: "audio",
+ video: "video",
+ "model-3d": "3D model",
},
- 'types-plural': {
- image: 'images',
- audio: 'audios',
- video: 'videos',
- 'model-3d': '3D models',
+ "types-plural": {
+ image: "images",
+ audio: "audios",
+ video: "videos",
+ "model-3d": "3D models",
},
},
},
browsers: {
- chrome: 'Chrome',
- firefox: 'Firefox',
- opera: 'Opera',
- edge: 'Edge',
+ chrome: "Chrome",
+ firefox: "Firefox",
+ opera: "Opera",
+ edge: "Edge",
},
waveform: {
- label: 'Audio seek bar',
- 'current-time': '{time} second|{time} seconds',
+ label: "Audio seek bar",
+ "current-time": "{time} second|{time} seconds",
},
- 'audio-thumbnail': {
+ "audio-thumbnail": {
alt: 'Cover art for "{title}" by {creator}',
},
- 'audio-track': {
- 'aria-label': '{title} - Audio Player',
- 'aria-label-interactive': '{title} - audio player - press the spacebar to play and pause a preview of the audio',
- 'aria-label-interactive-seekable': '{title} - audio player - press the spacebar to play and pause a preview of the audio; use the left and right arrow keys to seek through the track.',
+ "audio-track": {
+ "aria-label": "{title} - Audio Player",
+ "aria-label-interactive": "{title} - audio player - press the spacebar to play and pause a preview of the audio",
+ "aria-label-interactive-seekable": "{title} - audio player - press the spacebar to play and pause a preview of the audio; use the left and right arrow keys to seek through the track.",
messages: {
- err_aborted: 'You aborted playback.',
- err_network: 'A network error occurred.',
- err_decode: 'Could not decode audio.',
- err_unallowed: 'Reproduction not allowed.',
- err_unknown: 'An unexpected error has occurred. Try again in a few minutes or report the item if the issue persists.',
- err_unsupported: 'This audio format is not supported by your browser.',
- loading: 'Loading...',
- },
- creator: 'by {creator}',
- },
- 'play-pause': {
- play: 'Play',
- pause: 'Pause',
- replay: 'Replay',
- loading: 'Loading',
+ err_aborted: "You aborted playback.",
+ err_network: "A network error occurred.",
+ err_decode: "Could not decode audio.",
+ err_unallowed: "Reproduction not allowed.",
+ err_unknown: "An unexpected error has occurred. Try again in a few minutes or report the item if the issue persists.",
+ err_unsupported: "This audio format is not supported by your browser.",
+ loading: "Loading...",
+ },
+ creator: "by {creator}",
+ },
+ "play-pause": {
+ play: "Play",
+ pause: "Pause",
+ replay: "Replay",
+ loading: "Loading",
},
search: {
- search: 'Search',
- 'search-bar-label': 'Search for content in {openverse}',
- },
- 'license-readable-names': {
- cc0: 'Zero',
- pdm: 'Public Domain Mark',
- by: 'Attribution',
- 'by-sa': 'Attribution-Share-Alike',
- 'by-nc': 'Attribution-NonCommercial',
- 'by-nd': 'Attribution-NoDerivatives',
- 'by-nc-sa': 'Attribution-NonCommercial-Share-Alike',
- 'by-nc-nd': 'Attribution-NonCommercial-NoDerivatives',
- 'sampling+': 'Sampling Plus',
- 'nc-sampling+': 'NonCommercial Sampling Plus',
- },
- 'dropdown-button': {
+ search: "Search",
+ "search-bar-label": "Search for content in {openverse}",
+ },
+ "license-readable-names": {
+ cc0: "Zero",
+ pdm: "Public Domain Mark",
+ by: "Attribution",
+ "by-sa": "Attribution-Share-Alike",
+ "by-nc": "Attribution-NonCommercial",
+ "by-nd": "Attribution-NoDerivatives",
+ "by-nc-sa": "Attribution-NonCommercial-Share-Alike",
+ "by-nc-nd": "Attribution-NonCommercial-NoDerivatives",
+ "sampling+": "Sampling Plus",
+ "nc-sampling+": "NonCommercial Sampling Plus",
+ },
+ "dropdown-button": {
aria: {
- 'arrow-label': 'Dropdown',
+ "arrow-label": "Dropdown",
},
},
- 'migration-notice': {
- intro: '{cc-search} is now called {openverse} and joins {wordpress} as an open source project.',
- more: '{read-more} about this announcement.',
- read: 'Read more',
+ "migration-notice": {
+ intro: "{cc-search} is now called {openverse} and joins {wordpress} as an open source project.",
+ more: "{read-more} about this announcement.",
+ read: "Read more",
},
- 'download-button': {
+ "download-button": {
aria: {
- 'dropdown-label': 'Select the download file format',
+ "dropdown-label": "Select the download file format",
},
- download: 'Download',
+ download: "Download",
},
- interpunct: '•',
+ interpunct: "•",
modal: {
- close: 'Close',
- 'aria-close': 'Close the modal',
- 'close-named': 'Close {name}',
+ close: "Close",
+ "aria-close": "Close the modal",
+ "close-named": "Close {name}",
},
- 'error-images': {
- 'depressed-musician': 'A depressed pianist rests their head in their hands.',
- 'waiting-for-a-bite': 'Three boys sit on a broken log while two of them fish.',
+ "error-images": {
+ "depressed-musician": "A depressed pianist rests their head in their hands.",
+ "waiting-for-a-bite": "Three boys sit on a broken log while two of them fish.",
},
- 'no-results': {
+ "no-results": {
heading: 'We couldn\'t find anything for "{query}".',
- alternatives: 'Try a different query or use one of the external sources to expand your search.',
- },
- 'server-timeout': {
- heading: 'Whoops, it looks like that request took too long to complete. Please try again.',
- },
- 'search-type': {
- image: 'Images',
- audio: 'Audio',
- all: 'All content',
- video: 'Videos',
- 'model-3d': '3D Models',
- label: 'Type of content to search',
- heading: 'Content types',
- additional: 'Coming soon',
- 'status-beta': 'Beta',
- 'see-image': 'See all images',
- 'see-audio': 'See all audio',
- },
- 'skip-to-content': 'Skip to content',
- 'pref-page': {
- title: 'Preferences',
- 'non-switchable': {
- title: 'Non-switchable features',
- desc: 'You cannot modify the status of these features.',
+ alternatives: "Try a different query or use one of the external sources to expand your search.",
+ },
+ "server-timeout": {
+ heading: "Whoops, it looks like that request took too long to complete. Please try again.",
+ },
+ "search-type": {
+ image: "Images",
+ audio: "Audio",
+ all: "All content",
+ video: "Videos",
+ "model-3d": "3D Models",
+ label: "Type of content to search",
+ heading: "Content types",
+ additional: "Coming soon",
+ "status-beta": "Beta",
+ "see-image": "See all images",
+ "see-audio": "See all audio",
+ },
+ "skip-to-content": "Skip to content",
+ "pref-page": {
+ title: "Preferences",
+ "non-switchable": {
+ title: "Non-switchable features",
+ desc: "You cannot modify the status of these features.",
},
switchable: {
- title: 'Switchable features',
- desc: 'You can toggle these features on or off as you like and your preferences will be saved in a cookie.',
+ title: "Switchable features",
+ desc: "You can toggle these features on or off as you like and your preferences will be saved in a cookie.",
},
- 'store-state': 'Store state',
- 'content-filtering': 'Content filtering',
- explanation: 'Shown because {feat-name} is {feat-state}',
+ "store-state": "Store state",
+ "content-filtering": "Content filtering",
+ explanation: "Shown because {feat-name} is {feat-state}",
},
- 'sketchfab-iframe-title': '{sketchfab} viewer',
- 'flag-status': {
- nonexistent: 'Nonexistent',
- on: 'On',
- off: 'Off',
+ "sketchfab-iframe-title": "{sketchfab} viewer",
+ "flag-status": {
+ nonexistent: "Nonexistent",
+ on: "On",
+ off: "Off",
},
footer: {
// Link back to WordPress, the word is replaced by the logo
- 'wordpress-affiliation': 'Part of the {wordpress} project',
- wip: '\uD83D\uDEA7',
+ "wordpress-affiliation": "Part of the {wordpress} project",
+ wip: "\uD83D\uDEA7",
},
language: {
- language: 'Language',
+ language: "Language",
},
- 'recent-searches': {
- heading: 'Recent searches',
+ "recent-searches": {
+ heading: "Recent searches",
clear: {
- text: 'Clear',
- label: 'Clear recent searches',
+ text: "Clear",
+ label: "Clear recent searches",
},
- none: 'No recent searches to show.',
- disclaimer: 'Openverse does not store your recent searches, this information is kept locally in your browser.',
+ none: "No recent searches to show.",
+ disclaimer: "Openverse does not store your recent searches, this information is kept locally in your browser.",
},
}
diff --git a/src/locales/scripts/get-translations-status.js b/src/locales/scripts/get-translations-status.js
index 7a81f1c51..b0f437962 100644
--- a/src/locales/scripts/get-translations-status.js
+++ b/src/locales/scripts/get-translations-status.js
@@ -4,22 +4,22 @@
* Update the GP locales object with this data, and removes any of the GP
* locales that are not available on translate.wordpress.org.
*/
-const parser = require('node-html-parser')
+const parser = require("node-html-parser")
-const axios = require('./axios')
+const axios = require("./axios")
-const baseUrl = 'https://translate.wordpress.org/projects/meta/openverse/'
+const baseUrl = "https://translate.wordpress.org/projects/meta/openverse/"
function parseRow(row, locales) {
- const cells = row.querySelectorAll('td')
- const langLink = cells[0].querySelector('a')
+ const cells = row.querySelectorAll("td")
+ const langLink = cells[0].querySelector("a")
const langName = langLink.text.trim()
const langObject = locales.find((locale) => {
return locale.name === langName
})
if (langObject) {
const percentTranslated = parseInt(
- cells[1].text.trim().replace('%', ''),
+ cells[1].text.trim().replace("%", ""),
10
)
langObject.code = langObject.slug
@@ -42,8 +42,8 @@ const addFetchedTranslationStatus = async (gpLocales) => {
const parsed = parser.parse(raw.data)
parsed
- .querySelector('tbody')
- .querySelectorAll('tr')
+ .querySelector("tbody")
+ .querySelectorAll("tr")
.forEach((row) => {
const locale = parseRow(row, locales)
if (locale) {
diff --git a/src/locales/scripts/get-translations.js b/src/locales/scripts/get-translations.js
index 6672675da..5f149b46c 100644
--- a/src/locales/scripts/get-translations.js
+++ b/src/locales/scripts/get-translations.js
@@ -2,16 +2,16 @@
* Fetch the NGX-Translate JSON file for each supported language,
* convert to our JSON format, and save in the correct folder.
*/
-const { writeFile } = require('fs/promises')
-const { writeFileSync } = require('fs')
-const os = require('os')
+const { writeFile } = require("fs/promises")
+const { writeFileSync } = require("fs")
+const os = require("os")
-const chokidar = require('chokidar')
+const chokidar = require("chokidar")
-const axios = require('./axios')
+const axios = require("./axios")
-const jed1xJsonToJson = require('./jed1x-json-to-json')
-const { parseJson } = require('./read-i18n')
+const jed1xJsonToJson = require("./jed1x-json-to-json")
+const { parseJson } = require("./read-i18n")
/**
*
@@ -32,8 +32,8 @@ const baseUrl = `https://translate.wordpress.org/projects/meta/openverse`
* @returns {(localeCode: string) => string}
*/
const makeTranslationUrl =
- (format = 'po') =>
- (localeCode = 'en-gb') =>
+ (format = "po") =>
+ (localeCode = "en-gb") =>
`${baseUrl}/${localeCode}/default/export-translations/?format=${format}`
/**
@@ -41,14 +41,14 @@ const makeTranslationUrl =
* @param {string} locale
*/
const fetchJed1xTranslation = (locale) =>
- axios.get(makeTranslationUrl('jed1x')(locale)).then((res) => res.data)
+ axios.get(makeTranslationUrl("jed1x")(locale)).then((res) => res.data)
const replacePlaceholders = (json) => {
if (json === null) {
return null
}
- if (typeof json === 'string') {
- return json.replace(/###([a-zA-Z-]*)###/g, '{$1}')
+ if (typeof json === "string") {
+ return json.replace(/###([a-zA-Z-]*)###/g, "{$1}")
}
let currentJson = { ...json }
@@ -96,7 +96,7 @@ const fetchAndConvertJed1xTranslations = (locales) => {
.then((res) => {
let successfulTranslations = []
res.forEach(({ status, value }, index) => {
- if (status === 'fulfilled' && !isEmpty(value)) {
+ if (status === "fulfilled" && !isEmpty(value)) {
successfulTranslations[locales[index]] = value
}
})
@@ -115,27 +115,27 @@ const fetchAndConvertJed1xTranslations = (locales) => {
* Write `en.json` from `en.json5`.
*/
const writeEnglish = () => {
- const rootEntry = parseJson('en.json5')
+ const rootEntry = parseJson("en.json5")
writeFileSync(
- process.cwd() + '/src/locales/en.json',
+ process.cwd() + "/src/locales/en.json",
JSON.stringify(rootEntry, null, 2) + os.EOL
)
- console.log('Successfully saved English translation to en.json.')
+ console.log("Successfully saved English translation to en.json.")
}
writeEnglish()
-if (process.argv.includes('--watch')) {
- console.log('Watching en.json5 for changes...')
+if (process.argv.includes("--watch")) {
+ console.log("Watching en.json5 for changes...")
chokidar
- .watch(process.cwd() + '/src/locales/scripts/en.json5')
- .on('all', (event, path) => {
+ .watch(process.cwd() + "/src/locales/scripts/en.json5")
+ .on("all", (event, path) => {
console.log(`Event '${event}' for file ${path}`)
writeEnglish()
})
}
-if (!process.argv.includes('--en-only')) {
- const localeJSON = require('./wp-locales.json')
+if (!process.argv.includes("--en-only")) {
+ const localeJSON = require("./wp-locales.json")
fetchAndConvertJed1xTranslations(Object.values(localeJSON).map((i) => i.slug))
.then((res) => {
diff --git a/src/locales/scripts/get-validated-locales.js b/src/locales/scripts/get-validated-locales.js
index b09616edc..de7ef21ae 100644
--- a/src/locales/scripts/get-validated-locales.js
+++ b/src/locales/scripts/get-validated-locales.js
@@ -3,10 +3,10 @@ Updates the translation status of locales list from wp-locales-list,
and saves lists of translated and untranslated locales with properties expected
by Vue i18n.
*/
-const fs = require('fs')
+const fs = require("fs")
-const localesList = require('./wp-locales.json')
-const { addFetchedTranslationStatus } = require('./get-translations-status')
+const localesList = require("./wp-locales.json")
+const { addFetchedTranslationStatus } = require("./get-translations-status")
/**
* Returns a list of locale objects with at least one translated string
@@ -27,7 +27,7 @@ const getValidatedLocales = async () => {
nativeName: locale.nativeName ?? locale.name,
iso: locale.langCodeIso_639_1,
wpLocale: locale.wpLocale,
- dir: locale.textDirection || 'ltr',
+ dir: locale.textDirection || "ltr",
translated: locale.translated,
file: `${locale.slug}.json`,
}))
@@ -44,15 +44,15 @@ const getValidatedLocales = async () => {
try {
getValidatedLocales().then((locales) => {
- const fileName = 'valid-locales.json'
+ const fileName = "valid-locales.json"
fs.writeFileSync(
process.cwd() + `/src/locales/scripts/` + fileName,
- JSON.stringify(locales.translated, null, 2) + '\n'
+ JSON.stringify(locales.translated, null, 2) + "\n"
)
- const untranslatedFileName = 'untranslated-locales.json'
+ const untranslatedFileName = "untranslated-locales.json"
fs.writeFileSync(
process.cwd() + `/src/locales/scripts/` + untranslatedFileName,
- JSON.stringify(locales.untranslated, null, 2) + '\n'
+ JSON.stringify(locales.untranslated, null, 2) + "\n"
)
console.log(`> Wrote locale metadata for @nuxt/i18n.`)
})
diff --git a/src/locales/scripts/jed1x-json-to-json.js b/src/locales/scripts/jed1x-json-to-json.js
index d621c6a25..495dc035d 100644
--- a/src/locales/scripts/jed1x-json-to-json.js
+++ b/src/locales/scripts/jed1x-json-to-json.js
@@ -1,4 +1,4 @@
-const { setToValue } = require('./utils')
+const { setToValue } = require("./utils")
/**
* Convert a Jed1x-Translate object to a nested JSON object.
@@ -36,7 +36,7 @@ function jed1xJsonToJson(jed1xObject) {
Object.entries(jed1xObject?.locale_data?.messages).forEach(([key, value]) => {
const cleanedKey = key.slice(0, key.indexOf(SPLIT_CHAR))
if (value.length > 0) {
- const cleanedValue = value.length === 1 ? value[0] : value.join('|')
+ const cleanedValue = value.length === 1 ? value[0] : value.join("|")
return setToValue(result, cleanedKey, cleanedValue)
}
})
diff --git a/src/locales/scripts/json-helpers.js b/src/locales/scripts/json-helpers.js
index 41a792db0..8ebec335c 100644
--- a/src/locales/scripts/json-helpers.js
+++ b/src/locales/scripts/json-helpers.js
@@ -1,7 +1,7 @@
// Copied from these two libraries:
// https://github.com/coderaiser/all-object-keys
// https://github.com/coderaiser/jessy
-const isObject = (a) => typeof a === 'object'
+const isObject = (a) => typeof a === "object"
const isEmptyObject = (a) => !Object.keys(a).length
const isSimple = (a) => !a || !isObject(a) || isEmptyObject(a)
const pop = (a) => a.pop() || []
@@ -25,8 +25,8 @@ function getAllPaths(obj) {
const { entries } = Object
-function readPaths(obj, path = '') {
- const divider = '.'
+function readPaths(obj, path = "") {
+ const divider = "."
const result = []
const stack = []
for (const [key, value] of entries(obj)) {
@@ -41,10 +41,10 @@ function readPaths(obj, path = '') {
return [result, stack]
}
const getKeyValue = (key, value) => {
- const selects = key.split('.')
+ const selects = key.split(".")
selects.some((name, i) => {
- const nestedName = selects.slice(i).join('.')
- if (typeof value[nestedName] !== 'undefined') {
+ const nestedName = selects.slice(i).join(".")
+ if (typeof value[nestedName] !== "undefined") {
value = value[nestedName]
return true
}
diff --git a/src/locales/scripts/json-pot-helpers.js b/src/locales/scripts/json-pot-helpers.js
index ab206774e..fc0f9517a 100644
--- a/src/locales/scripts/json-pot-helpers.js
+++ b/src/locales/scripts/json-pot-helpers.js
@@ -14,9 +14,9 @@
* ```
*/
-const { getParsedVueFiles } = require('./parse-vue-files')
+const { getParsedVueFiles } = require("./parse-vue-files")
-const PARSED_VUE_FILES = getParsedVueFiles('**/*.?(js|vue)')
+const PARSED_VUE_FILES = getParsedVueFiles("**/*.?(js|vue)")
/** @param str {string} */
const escapeQuotes = (str) => str.replace(/"/g, '\\"')
@@ -26,7 +26,7 @@ const containsCurlyWord = (str) => /\{[a-zA-Z-]*}/.test(str)
/** @param str {string} */
const checkStringForVars = (str) =>
- containsCurlyWord(str) ? '#. Do not translate words between ### ###.' : ''
+ containsCurlyWord(str) ? "#. Do not translate words between ### ###." : ""
/**
* For GlotPress to display warning when the translators miss the placeholders
@@ -64,7 +64,7 @@ const getRefComments = (keyPath) =>
)
const pot_creation_date = () =>
- `${new Date().toISOString().split('.')[0]}+00:00`
+ `${new Date().toISOString().split(".")[0]}+00:00`
const POT_FILE_META = `# Copyright (C) 2021
# This file is distributed under the same license as Openverse.
@@ -103,7 +103,7 @@ const getComment = (entry) => {
let refComments = getRefComments(entry.lineage)
if (refComments.length) comment.push(...refComments)
- return comment.map((item) => `${item}`).join('\n')
+ return comment.map((item) => `${item}`).join("\n")
}
/**
@@ -116,7 +116,7 @@ const getComment = (entry) => {
const toPot = (entry) => {
if (!entry.value) {
// string-object type mapping
- return entry.children.map((child) => toPot(child)).join('\n\n')
+ return entry.children.map((child) => toPot(child)).join("\n\n")
}
// string-string type mapping
@@ -124,8 +124,8 @@ const toPot = (entry) => {
let comment = getComment(entry)
if (comment) poEntry.push(comment)
poEntry.push(`msgctxt "${entry.lineage}"`)
- if (entry.value.includes('|') && /(count|time)/i.test(entry.value)) {
- const pluralizedValues = entry.value.split('|')
+ if (entry.value.includes("|") && /(count|time)/i.test(entry.value)) {
+ const pluralizedValues = entry.value.split("|")
if (pluralizedValues.length === 1) {
pluralizedValues.push(pluralizedValues[0])
}
@@ -138,7 +138,7 @@ const toPot = (entry) => {
} else {
poEntry.push(`msgid "${processValue(entry.value)}"`, 'msgstr ""')
}
- return poEntry.join('\n')
+ return poEntry.join("\n")
}
/**
@@ -148,6 +148,6 @@ const toPot = (entry) => {
* @param entry {import('./read-i18n').Entry} the root entry of the JSON file
* @return {string} the text content of the Openverse POT file
*/
-const makePot = (entry) => [POT_FILE_META, toPot(entry)].join('\n')
+const makePot = (entry) => [POT_FILE_META, toPot(entry)].join("\n")
module.exports = { replaceVarsPlaceholders, makePot }
diff --git a/src/locales/scripts/json-to-pot.js b/src/locales/scripts/json-to-pot.js
index 6329778b0..9f5a65339 100644
--- a/src/locales/scripts/json-to-pot.js
+++ b/src/locales/scripts/json-to-pot.js
@@ -1,14 +1,14 @@
-const fs = require('fs')
-const path = require('path')
+const fs = require("fs")
+const path = require("path")
-const { parseJson } = require('./read-i18n')
-const { makePot } = require('./json-pot-helpers')
+const { parseJson } = require("./read-i18n")
+const { makePot } = require("./json-pot-helpers")
try {
- const fileName = path.resolve(process.cwd(), 'openverse.pot')
+ const fileName = path.resolve(process.cwd(), "openverse.pot")
- const entries = parseJson('en.json5')
- fs.writeFileSync(fileName, makePot(entries), { flag: 'w' })
+ const entries = parseJson("en.json5")
+ fs.writeFileSync(fileName, makePot(entries), { flag: "w" })
console.log(`Successfully wrote pot file to ${fileName}`)
} catch (err) {
console.error(err)
diff --git a/src/locales/scripts/ngx-json-to-json.js b/src/locales/scripts/ngx-json-to-json.js
index af4e9bf56..d489d3d6e 100644
--- a/src/locales/scripts/ngx-json-to-json.js
+++ b/src/locales/scripts/ngx-json-to-json.js
@@ -1,4 +1,4 @@
-const { setToValue } = require('./utils')
+const { setToValue } = require("./utils")
/**
* Convert an NGX-Translate object to a nested JSON object
diff --git a/src/locales/scripts/parse-vue-files.js b/src/locales/scripts/parse-vue-files.js
index 13c2be6dd..a60246dd7 100644
--- a/src/locales/scripts/parse-vue-files.js
+++ b/src/locales/scripts/parse-vue-files.js
@@ -1,10 +1,10 @@
// This implementation is loosely copied from vue-i18n-extract
// https://github.com/pixari/vue-i18n-extract
-const fs = require('fs')
-const path = require('path')
+const fs = require("fs")
+const path = require("path")
-const glob = require('glob')
+const glob = require("glob")
const BASE_PATH = path.dirname(path.dirname(__dirname))
@@ -12,16 +12,16 @@ function readVueFiles(src) {
const targetFiles = glob.sync(src)
if (targetFiles.length === 0) {
- throw new Error('vueFiles glob has no files.')
+ throw new Error("vueFiles glob has no files.")
}
// Now that the script are inside `src/locales/scripts`,
// to get relative URL, the script needs to go up 3 levels
return targetFiles.map((f) => {
- const fileName = path.relative(process.cwd(), f.replace(BASE_PATH, 'src'))
+ const fileName = path.relative(process.cwd(), f.replace(BASE_PATH, "src"))
return {
fileName,
path: f,
- content: fs.readFileSync(f, 'utf8'),
+ content: fs.readFileSync(f, "utf8"),
}
})
}
diff --git a/src/locales/scripts/read-i18n.js b/src/locales/scripts/read-i18n.js
index 6379341ba..09d945fc3 100644
--- a/src/locales/scripts/read-i18n.js
+++ b/src/locales/scripts/read-i18n.js
@@ -10,10 +10,10 @@
* @typedef {{ [key: string]: string | SimJson }} SimJson
*/
-const fs = require('fs')
-const path = require('path')
+const fs = require("fs")
+const path = require("path")
-const babel = require('@babel/parser')
+const babel = require("@babel/parser")
/**
* An `Entry` refers to one i18n translation definition. It can be one of two
@@ -45,7 +45,7 @@ class Entry {
* @return {string} the dot separated path to this entry
*/
get lineage() {
- return [...this.ancestors.filter((item) => item), this.key].join('.')
+ return [...this.ancestors.filter((item) => item), this.key].join(".")
}
/**
@@ -87,11 +87,11 @@ class Entry {
* @return {string} the text content of the key
*/
const parseKey = (keyNode) => {
- if (keyNode === undefined) return ''
+ if (keyNode === undefined) return ""
switch (keyNode.type) {
- case 'StringLiteral':
+ case "StringLiteral":
return keyNode.value
- case 'Identifier':
+ case "Identifier":
return keyNode.name
}
}
@@ -105,12 +105,12 @@ const parseKey = (keyNode) => {
*/
const parseComment = (commentNode) => {
switch (commentNode.type) {
- case 'CommentLine':
+ case "CommentLine":
return commentNode.value.trim()
- case 'CommentBlock':
+ case "CommentBlock":
return commentNode.value
- .replace(/\n|\*+/g, '')
- .replace(/\s+/, ' ')
+ .replace(/\n|\*+/g, "")
+ .replace(/\s+/, " ")
.trim()
}
}
@@ -124,10 +124,10 @@ const parseComment = (commentNode) => {
*/
const parseValue = (entry, valueNode) => {
switch (valueNode.type) {
- case 'StringLiteral':
+ case "StringLiteral":
entry.value = valueNode.value
break
- case 'ObjectExpression':
+ case "ObjectExpression":
valueNode.properties.map(parseObjProperty).forEach((child) => {
entry.addChild(child)
})
@@ -143,7 +143,7 @@ const parseValue = (entry, valueNode) => {
*/
const parseObjProperty = (node) => {
let key = parseKey(node.key)
- let comments = node.leadingComments?.map(parseComment).join('')
+ let comments = node.leadingComments?.map(parseComment).join("")
let entry = new Entry(key, comments)
parseValue(entry, node.value)
return entry
@@ -157,7 +157,7 @@ const parseObjProperty = (node) => {
const parseJson = (filename) =>
parseObjProperty({
value: babel.parseExpression(
- fs.readFileSync(path.join(__dirname, filename), 'utf-8')
+ fs.readFileSync(path.join(__dirname, filename), "utf-8")
),
})
diff --git a/src/locales/scripts/utils.js b/src/locales/scripts/utils.js
index 839ebcf32..2efa74c86 100644
--- a/src/locales/scripts/utils.js
+++ b/src/locales/scripts/utils.js
@@ -10,7 +10,7 @@
* @param {unknown} value - The value to set at the path.
*/
exports.setToValue = function setValue(obj, path, value) {
- var a = path.split('.')
+ var a = path.split(".")
var o = obj
while (a.length - 1) {
var n = a.shift()
diff --git a/src/middleware/middleware.ts b/src/middleware/middleware.ts
index 078d797a7..6181936d3 100644
--- a/src/middleware/middleware.ts
+++ b/src/middleware/middleware.ts
@@ -1,13 +1,13 @@
-import { sendWindowMessage } from '~/utils/send-message'
+import { sendWindowMessage } from "~/utils/send-message"
-import { useNavigationStore } from '~/stores/navigation'
-import { useProviderStore } from '~/stores/provider'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { useUiStore } from '~/stores/ui'
+import { useNavigationStore } from "~/stores/navigation"
+import { useProviderStore } from "~/stores/provider"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { useUiStore } from "~/stores/ui"
-import { cookieOptions } from '~/utils/cookies'
+import { cookieOptions } from "~/utils/cookies"
-import type { Context, Middleware } from '@nuxt/types'
+import type { Context, Middleware } from "@nuxt/types"
/**
* In embedded mode, the app sends its url
@@ -33,12 +33,12 @@ const middleware: Middleware = async ({
const navigationStore = useNavigationStore($pinia)
- if ('embedded' in query) {
- navigationStore.setIsEmbedded(query.embedded === 'true')
+ if ("embedded" in query) {
+ navigationStore.setIsEmbedded(query.embedded === "true")
}
if (process.client) {
sendWindowMessage({
- type: 'urlChange',
+ type: "urlChange",
value: { path: route.fullPath, title: document.title },
})
}
@@ -54,18 +54,18 @@ const middleware: Middleware = async ({
/* Feature flag store */
const featureFlagStore = useFeatureFlagStore($pinia)
- featureFlagStore.initFromCookies($cookies.get('features') ?? {})
+ featureFlagStore.initFromCookies($cookies.get("features") ?? {})
featureFlagStore.initFromQuery(query)
/* UI store */
const uiStore = useUiStore($pinia)
const isMobileUa = $ua ? $ua.isMobile : false
- const sameSite = featureFlagStore.isOn('new_header')
+ const sameSite = featureFlagStore.isOn("new_header")
? cookieOptions.sameSite
- : 'none'
+ : "none"
- $cookies.set('uiIsMobileUa', isMobileUa, { ...cookieOptions, sameSite })
+ $cookies.set("uiIsMobileUa", isMobileUa, { ...cookieOptions, sameSite })
uiStore.initFromCookies($cookies.getAll() ?? {})
}
export default middleware
diff --git a/src/pages/about.vue b/src/pages/about.vue
index 7d172a210..85e0c618b 100644
--- a/src/pages/about.vue
+++ b/src/pages/about.vue
@@ -1,10 +1,10 @@
<template>
<VContentPage>
<h1>
- {{ $t('about.title', { openverse: 'Openverse' }) }}
+ {{ $t("about.title", { openverse: "Openverse" }) }}
</h1>
<p>
- {{ $t('about.description.content', { openverse: 'Openverse' }) }}
+ {{ $t("about.description.content", { openverse: "Openverse" }) }}
</p>
<i18n path="about.collection.content" tag="p">
@@ -18,27 +18,27 @@
<template #openverse>Openverse</template>
<template #frontend>
<VLink href="https://github.com/wordpress/openverse-frontend/">{{
- $t('about.planning.frontend', { openverse: 'Openverse' })
+ $t("about.planning.frontend", { openverse: "Openverse" })
}}</VLink>
</template>
<template #api>
<VLink href="https://github.com/wordpress/openverse-api/">{{
- $t('about.planning.api', { openverse: 'Openverse' })
+ $t("about.planning.api", { openverse: "Openverse" })
}}</VLink>
</template>
<template #catalog>
<VLink href="https://github.com/wordpress/openverse-catalog/">{{
- $t('about.planning.catalog', { openverse: 'Openverse' })
+ $t("about.planning.catalog", { openverse: "Openverse" })
}}</VLink>
</template>
<template #community>
<VLink href="https://make.wordpress.org/openverse/">{{
- $t('about.planning.community')
+ $t("about.planning.community")
}}</VLink>
</template>
<template #working>
<VLink href="https://github.com/orgs/WordPress/projects/3">{{
- $t('about.planning.working')
+ $t("about.planning.working")
}}</VLink>
</template>
</i18n>
@@ -62,71 +62,71 @@
<template #openverse>Openverse</template>
<template #terms>
<VLink href="https://creativecommons.org/terms/">{{
- $t('about.declaration.terms', { openverse: 'Openverse' })
+ $t("about.declaration.terms", { openverse: "Openverse" })
}}</VLink>
</template>
</i18n>
<h2 id="external-sources">
- {{ $t('external-sources-page.title') }}
+ {{ $t("external-sources-page.title") }}
</h2>
<i18n path="external-sources-page.intro" tag="p">
<template #openverse>Openverse</template>
<template #link>
- <VLink href="/sources">{{ $t('external-sources-page.link') }}</VLink>
+ <VLink href="/sources">{{ $t("external-sources-page.link") }}</VLink>
</template>
</i18n>
<p>
- {{ $t('external-sources-page.license', { openverse: 'Openverse' }) }}
+ {{ $t("external-sources-page.license", { openverse: "Openverse" }) }}
</p>
<p>
- {{ $t('external-sources-page.explanation', { openverse: 'Openverse' }) }}
+ {{ $t("external-sources-page.explanation", { openverse: "Openverse" }) }}
</p>
<p>
{{
- $t('external-sources-page.relationships', { openverse: 'Openverse' })
+ $t("external-sources-page.relationships", { openverse: "Openverse" })
}}
</p>
<h2>
- {{ $t('external-sources-page.new.title') }}
+ {{ $t("external-sources-page.new.title") }}
</h2>
<i18n path="external-sources-page.new.content" tag="p">
<template #issue>
<VLink
aria-label="issue"
href="https://github.com/WordPress/openverse-catalog/issues/new?assignees=&labels=%F0%9F%9A%A6+status%3A+awaiting+triage%2C%F0%9F%A7%B9+status%3A+ticket+work+required%2C%E2%98%81%EF%B8%8F+provider%3A+any&template=new_source_suggestion.yml&title=%3CSource+name+here%3E"
- >{{ $t('external-sources-page.new.issue') }}</VLink
+ >{{ $t("external-sources-page.new.issue") }}</VLink
>
</template>
<template #email>
<VLink aria-label="email" href="mailto:[email protected]">{{
- $t('external-sources-page.new.email')
+ $t("external-sources-page.new.email")
}}</VLink>
</template>
</i18n>
<h2>
- {{ $t('external-sources-page.why.title') }}
+ {{ $t("external-sources-page.why.title") }}
</h2>
<i18n path="external-sources-page.why.content" tag="p">
<template #old>
<VLink
aria-label="email"
href="https://oldsearch.creativecommons.org"
- >{{ $t('external-sources-page.why.old') }}</VLink
+ >{{ $t("external-sources-page.why.old") }}</VLink
>
</template>
</i18n>
<p>
- {{ $t('external-sources-page.why.new', { openverse: 'Openverse' }) }}
+ {{ $t("external-sources-page.why.new", { openverse: "Openverse" }) }}
</p>
<i18n path="external-sources-page.why.feedback-suggestions" tag="p">
<template #feedback>
<VLink
:aria-label="$t('external-sources-page.why.aria-label')"
href="/feedback"
- >{{ $t('external-sources-page.why.feedback-link') }}</VLink
+ >{{ $t("external-sources-page.why.feedback-link") }}</VLink
>
</template>
</i18n>
@@ -134,27 +134,27 @@
</template>
<script lang="ts">
-import { defineComponent, useMeta } from '@nuxtjs/composition-api'
+import { defineComponent, useMeta } from "@nuxtjs/composition-api"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { useI18n } from '~/composables/use-i18n'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { useI18n } from "~/composables/use-i18n"
-import VLink from '~/components/VLink.vue'
-import VContentPage from '~/components/VContentPage.vue'
+import VLink from "~/components/VLink.vue"
+import VContentPage from "~/components/VContentPage.vue"
export default defineComponent({
- name: 'AboutPage',
+ name: "AboutPage",
components: { VLink, VContentPage },
setup() {
const i18n = useI18n()
const featureFlagStore = useFeatureFlagStore()
useMeta({
- title: `${i18n.t('about.title', {
- openverse: 'Openverse',
+ title: `${i18n.t("about.title", {
+ openverse: "Openverse",
})} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
},
diff --git a/src/pages/audio/_id.vue b/src/pages/audio/_id.vue
index 255fa91fa..0842aeb1c 100644
--- a/src/pages/audio/_id.vue
+++ b/src/pages/audio/_id.vue
@@ -20,23 +20,23 @@
</template>
<script lang="ts">
-import { computed, defineComponent, useRoute } from '@nuxtjs/composition-api'
+import { computed, defineComponent, useRoute } from "@nuxtjs/composition-api"
-import { AUDIO } from '~/constants/media'
-import type { AudioDetail } from '~/types/media'
-import { useRelatedMediaStore } from '~/stores/media/related-media'
-import { useSingleResultStore } from '~/stores/media/single-result'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { createDetailPageMeta } from '~/utils/og'
+import { AUDIO } from "~/constants/media"
+import type { AudioDetail } from "~/types/media"
+import { useRelatedMediaStore } from "~/stores/media/related-media"
+import { useSingleResultStore } from "~/stores/media/single-result"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { createDetailPageMeta } from "~/utils/og"
-import VAudioDetails from '~/components/VAudioDetails/VAudioDetails.vue'
-import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
-import VBackToSearchResultsLink from '~/components/VBackToSearchResultsLink.vue'
-import VRelatedAudio from '~/components/VAudioDetails/VRelatedAudio.vue'
-import VMediaReuse from '~/components/VMediaInfo/VMediaReuse.vue'
+import VAudioDetails from "~/components/VAudioDetails/VAudioDetails.vue"
+import VAudioTrack from "~/components/VAudioTrack/VAudioTrack.vue"
+import VBackToSearchResultsLink from "~/components/VBackToSearchResultsLink.vue"
+import VRelatedAudio from "~/components/VAudioDetails/VRelatedAudio.vue"
+import VMediaReuse from "~/components/VMediaInfo/VMediaReuse.vue"
export default defineComponent({
- name: 'AudioDetailPage',
+ name: "AudioDetailPage",
components: {
VAudioDetails,
VAudioTrack,
@@ -45,7 +45,7 @@ export default defineComponent({
VRelatedAudio,
},
beforeRouteEnter(to, from, next) {
- if (from.path.includes('/search/')) {
+ if (from.path.includes("/search/")) {
to.meta.backToSearchPath = from.fullPath
}
next()
@@ -57,7 +57,7 @@ export default defineComponent({
const featureFlagStore = useFeatureFlagStore()
const isNewHeaderEnabled = computed(() =>
- featureFlagStore.isOn('new_header')
+ featureFlagStore.isOn("new_header")
)
const audio = computed(() =>
@@ -86,7 +86,7 @@ export default defineComponent({
} catch (err) {
error({
statusCode: 404,
- message: app.i18n.t('error.media-not-found', {
+ message: app.i18n.t("error.media-not-found", {
mediaType: AUDIO,
id: route.params.id,
}),
diff --git a/src/pages/external-sources.vue b/src/pages/external-sources.vue
index 265b740c6..860fa7dc9 100644
--- a/src/pages/external-sources.vue
+++ b/src/pages/external-sources.vue
@@ -1,89 +1,89 @@
<template>
<VContentPage>
<h1>
- {{ $t('external-sources-page.title') }}
+ {{ $t("external-sources-page.title") }}
</h1>
<i18n path="external-sources-page.intro" tag="p">
<template #openverse>Openverse</template>
<template #link>
- <VLink href="/sources">{{ $t('external-sources-page.link') }}</VLink>
+ <VLink href="/sources">{{ $t("external-sources-page.link") }}</VLink>
</template>
</i18n>
- <p>{{ $t('external-sources-page.license', { openverse: 'Openverse' }) }}</p>
+ <p>{{ $t("external-sources-page.license", { openverse: "Openverse" }) }}</p>
<p>
- {{ $t('external-sources-page.explanation', { openverse: 'Openverse' }) }}
+ {{ $t("external-sources-page.explanation", { openverse: "Openverse" }) }}
</p>
<p>
{{
- $t('external-sources-page.relationships', { openverse: 'Openverse' })
+ $t("external-sources-page.relationships", { openverse: "Openverse" })
}}
</p>
<h2>
- {{ $t('external-sources-page.new.title') }}
+ {{ $t("external-sources-page.new.title") }}
</h2>
<i18n path="external-sources-page.new.content" tag="p">
<template #issue>
<VLink
aria-label="issue"
href="https://github.com/WordPress/openverse-catalog/issues/new?assignees=&labels=%F0%9F%9A%A6+status%3A+awaiting+triage%2C%F0%9F%A7%B9+status%3A+ticket+work+required%2C%E2%98%81%EF%B8%8F+provider%3A+any&template=new_source_suggestion.yml&title=%3CSource+name+here%3E"
- >{{ $t('external-sources-page.new.issue') }}</VLink
+ >{{ $t("external-sources-page.new.issue") }}</VLink
>
</template>
<template #email>
<VLink aria-label="email" href="mailto:[email protected]">{{
- $t('external-sources-page.new.email')
+ $t("external-sources-page.new.email")
}}</VLink>
</template>
</i18n>
<h2>
- {{ $t('external-sources-page.why.title') }}
+ {{ $t("external-sources-page.why.title") }}
</h2>
<i18n path="external-sources-page.why.content" tag="p">
<template #old>
<VLink
aria-label="email"
href="https://oldsearch.creativecommons.org"
- >{{ $t('external-sources-page.why.old') }}</VLink
+ >{{ $t("external-sources-page.why.old") }}</VLink
>
</template>
</i18n>
<p>
- {{ $t('external-sources-page.why.new', { openverse: 'Openverse' }) }}
+ {{ $t("external-sources-page.why.new", { openverse: "Openverse" }) }}
</p>
<i18n path="external-sources-page.why.feedback-suggestions" tag="p">
<template #feedback>
<VLink
:aria-label="$t('external-sources-page.why.aria-label')"
href="/feedback"
- >{{ $t('external-sources-page.why.feedback-link') }}</VLink
+ >{{ $t("external-sources-page.why.feedback-link") }}</VLink
>
</template>
</i18n>
</VContentPage>
</template>
<script lang="ts">
-import { defineComponent, useMeta } from '@nuxtjs/composition-api'
+import { defineComponent, useMeta } from "@nuxtjs/composition-api"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import VContentPage from '~/components/VContentPage.vue'
-import VLink from '~/components/VLink.vue'
+import VContentPage from "~/components/VContentPage.vue"
+import VLink from "~/components/VLink.vue"
export default defineComponent({
- name: 'ExternalSourcesPage',
+ name: "ExternalSourcesPage",
components: { VContentPage, VLink },
setup() {
const i18n = useI18n()
const featureFlagStore = useFeatureFlagStore()
useMeta({
- title: `${i18n.t('external-sources-page.title')} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ title: `${i18n.t("external-sources-page.title")} | Openverse`,
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
},
diff --git a/src/pages/feedback.vue b/src/pages/feedback.vue
index f3d36a4d8..a457d91a4 100644
--- a/src/pages/feedback.vue
+++ b/src/pages/feedback.vue
@@ -1,7 +1,7 @@
<template>
<VContentPage>
<h1 id="feedback">
- {{ $t('feedback.title') }}
+ {{ $t("feedback.title") }}
</h1>
<i18n path="feedback.intro" tag="p">
<!-- eslint-disable @intlify/vue-i18n/no-raw-text -->
@@ -30,7 +30,7 @@
:aria-label="$t(`feedback.aria.${tab}`).toString()"
:title="$t(`feedback.aria.${tab}`).toString()"
>
- {{ $t('feedback.loading') }}
+ {{ $t("feedback.loading") }}
</iframe>
</VTabPanel>
</VTabs>
@@ -39,21 +39,21 @@
</template>
<script lang="ts">
-import { defineComponent, useMeta } from '@nuxtjs/composition-api'
+import { defineComponent, useMeta } from "@nuxtjs/composition-api"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { useI18n } from '~/composables/use-i18n'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { useI18n } from "~/composables/use-i18n"
-import VLink from '~/components/VLink.vue'
-import VContentPage from '~/components/VContentPage.vue'
-import VTabs from '~/components/VTabs/VTabs.vue'
-import VTab from '~/components/VTabs/VTab.vue'
-import VTabPanel from '~/components/VTabs/VTabPanel.vue'
+import VLink from "~/components/VLink.vue"
+import VContentPage from "~/components/VContentPage.vue"
+import VTabs from "~/components/VTabs/VTabs.vue"
+import VTab from "~/components/VTabs/VTab.vue"
+import VTabPanel from "~/components/VTabs/VTabPanel.vue"
const bugForm =
- 'https://docs.google.com/forms/d/e/1FAIpQLSenCn-3HoZlCz4vlL2621wjezfu1sPZDaWGe_FtQ1R5-5qR4Q/viewform'
+ "https://docs.google.com/forms/d/e/1FAIpQLSenCn-3HoZlCz4vlL2621wjezfu1sPZDaWGe_FtQ1R5-5qR4Q/viewform"
const suggestionForm =
- 'https://docs.google.com/forms/d/e/1FAIpQLSfGC7JWbNjGs-_pUNe3B2nzBW-YrIrmRd92t-7u0y7s8jMjzQ/viewform'
+ "https://docs.google.com/forms/d/e/1FAIpQLSfGC7JWbNjGs-_pUNe3B2nzBW-YrIrmRd92t-7u0y7s8jMjzQ/viewform"
const forms = {
report: `${bugForm}?embedded=true`,
@@ -62,16 +62,16 @@ const forms = {
const tabs = Object.keys(forms) as (keyof typeof forms)[]
export default defineComponent({
- name: 'FeedbackPage',
+ name: "FeedbackPage",
components: { VLink, VContentPage, VTabs, VTab, VTabPanel },
setup() {
const i18n = useI18n()
const featureFlagStore = useFeatureFlagStore()
useMeta({
- title: `${i18n.t('feedback.title')} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ title: `${i18n.t("feedback.title")} | Openverse`,
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
diff --git a/src/pages/image/_id.vue b/src/pages/image/_id.vue
index 5ae8e810e..23d0176fa 100644
--- a/src/pages/image/_id.vue
+++ b/src/pages/image/_id.vue
@@ -45,7 +45,7 @@
class="description-bold md:heading-6 mb-4 w-full flex-initial self-center md:mb-0 md:w-max"
size="large"
>
- {{ $t('image-details.weblink') }}
+ {{ $t("image-details.weblink") }}
<VIcon
:icon-path="externalIcon"
:rtl-flip="true"
@@ -91,36 +91,36 @@
</template>
<script lang="ts">
-import axios from 'axios'
+import axios from "axios"
import {
computed,
defineComponent,
ref,
useRoute,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { IMAGE } from '~/constants/media'
-import type { ImageDetail } from '~/types/media'
-import { useSingleResultStore } from '~/stores/media/single-result'
-import { useRelatedMediaStore } from '~/stores/media/related-media'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { createDetailPageMeta } from '~/utils/og'
+import { IMAGE } from "~/constants/media"
+import type { ImageDetail } from "~/types/media"
+import { useSingleResultStore } from "~/stores/media/single-result"
+import { useRelatedMediaStore } from "~/stores/media/related-media"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { createDetailPageMeta } from "~/utils/og"
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VLink from '~/components/VLink.vue'
-import VImageDetails from '~/components/VImageDetails/VImageDetails.vue'
-import VMediaReuse from '~/components/VMediaInfo/VMediaReuse.vue'
-import VRelatedImages from '~/components/VImageDetails/VRelatedImages.vue'
-import VSketchFabViewer from '~/components/VSketchFabViewer.vue'
-import VBackToSearchResultsLink from '~/components/VBackToSearchResultsLink.vue'
+import VButton from "~/components/VButton.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VLink from "~/components/VLink.vue"
+import VImageDetails from "~/components/VImageDetails/VImageDetails.vue"
+import VMediaReuse from "~/components/VMediaInfo/VMediaReuse.vue"
+import VRelatedImages from "~/components/VImageDetails/VRelatedImages.vue"
+import VSketchFabViewer from "~/components/VSketchFabViewer.vue"
+import VBackToSearchResultsLink from "~/components/VBackToSearchResultsLink.vue"
-import errorImage from '~/assets/image_not_available_placeholder.png'
-import externalIcon from '~/assets/icons/external-link.svg'
+import errorImage from "~/assets/image_not_available_placeholder.png"
+import externalIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
- name: 'VImageDetailsPage',
+ name: "VImageDetailsPage",
components: {
VButton,
VIcon,
@@ -132,7 +132,7 @@ export default defineComponent({
VBackToSearchResultsLink,
},
beforeRouteEnter(to, from, next) {
- if (from.path.includes('/search/')) {
+ if (from.path.includes("/search/")) {
to.meta.backToSearchPath = from.fullPath
}
next()
@@ -150,7 +150,7 @@ export default defineComponent({
const featureFlagStore = useFeatureFlagStore()
const isNewHeaderEnabled = computed(() =>
- featureFlagStore.isOn('new_header')
+ featureFlagStore.isOn("new_header")
)
const backToSearchPath = computed(() => route.value.meta?.backToSearchPath)
@@ -160,7 +160,7 @@ export default defineComponent({
const imageWidth = ref(0)
const imageHeight = ref(0)
- const imageType = ref('Unknown')
+ const imageType = ref("Unknown")
/**
* To make sure that image is loaded fast, we `src` to `image.thumbnail`,
* and then replace it with the provider image once it is loaded.
@@ -170,12 +170,12 @@ export default defineComponent({
const sketchFabfailure = ref(false)
const sketchFabUid = computed(() => {
- if (image.value?.source !== 'sketchfab' || sketchFabfailure.value) {
+ if (image.value?.source !== "sketchfab" || sketchFabfailure.value) {
return null
}
return image.value.url
- .split('https://media.sketchfab.com/models/')[1]
- .split('/')[0]
+ .split("https://media.sketchfab.com/models/")[1]
+ .split("/")[0]
})
/**
@@ -211,7 +211,7 @@ export default defineComponent({
axios
.head(event.target.src)
.then((res) => {
- imageType.value = res.headers['content-type']
+ imageType.value = res.headers["content-type"]
})
.catch(() => {
/**
@@ -249,7 +249,7 @@ export default defineComponent({
await singleResultStore.fetch(IMAGE, imageId)
} catch (err) {
const errorMessage = app.i18n
- .t('error.image-not-found', {
+ .t("error.image-not-found", {
id: imageId,
})
.toString()
diff --git a/src/pages/index.vue b/src/pages/index.vue
index aa3e1ce2c..88139a5c4 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -21,9 +21,9 @@
<h2
class="mt-auto mb-2 max-w-[80%] text-[27px] font-normal leading-[35px] md:mt-16 md:mb-4 md:text-[46px] md:leading-[60px]"
>
- {{ $t('hero.subtitle') }}
+ {{ $t("hero.subtitle") }}
</h2>
- <p class="text-base md:text-3xl">{{ $t('hero.description') }}</p>
+ <p class="text-base md:text-3xl">{{ $t("hero.description") }}</p>
<div
class="mt-8 flex justify-start gap-4"
:class="isNewHeaderEnabled ? 'lg:hidden' : 'md:hidden'"
@@ -61,7 +61,7 @@
<VLink
href="https://creativecommons.org/licenses/"
class="text-dark-charcoal underline hover:text-dark-charcoal"
- >{{ $t('hero.disclaimer.license') }}</VLink
+ >{{ $t("hero.disclaimer.license") }}</VLink
>
</template>
</i18n>
@@ -117,7 +117,7 @@
<VLink
href="https://creativecommons.org/licenses/"
class="text-dark-charcoal underline hover:text-dark-charcoal"
- >{{ $t('hero.disclaimer.license') }}</VLink
+ >{{ $t("hero.disclaimer.license") }}</VLink
>
</template>
</i18n>
@@ -133,34 +133,34 @@ import {
useContext,
useMeta,
useRouter,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
import {
ALL_MEDIA,
searchPath,
SupportedSearchType,
supportedSearchTypes,
-} from '~/constants/media'
-import { useLayout } from '~/composables/use-layout'
+} from "~/constants/media"
+import { useLayout } from "~/composables/use-layout"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { useMediaStore } from '~/stores/media'
-import { useSearchStore } from '~/stores/search'
-import { useUiStore } from '~/stores/ui'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { useMediaStore } from "~/stores/media"
+import { useSearchStore } from "~/stores/search"
+import { useUiStore } from "~/stores/ui"
-import VLink from '~/components/VLink.vue'
-import VLogoButtonOld from '~/components/VHeaderOld/VLogoButtonOld.vue'
-import VStandaloneSearchBar from '~/components/VHeader/VSearchBar/VStandaloneSearchBar.vue'
-import VSearchTypeRadio from '~/components/VContentSwitcher/VSearchTypeRadio.vue'
-import VSearchTypePopoverOld from '~/components/VContentSwitcherOld/VSearchTypePopoverOld.vue'
-import VBrand from '~/components/VBrand/VBrand.vue'
+import VLink from "~/components/VLink.vue"
+import VLogoButtonOld from "~/components/VHeaderOld/VLogoButtonOld.vue"
+import VStandaloneSearchBar from "~/components/VHeader/VSearchBar/VStandaloneSearchBar.vue"
+import VSearchTypeRadio from "~/components/VContentSwitcher/VSearchTypeRadio.vue"
+import VSearchTypePopoverOld from "~/components/VContentSwitcherOld/VSearchTypePopoverOld.vue"
+import VBrand from "~/components/VBrand/VBrand.vue"
-import type { Dictionary } from 'vue-router/types/router'
+import type { Dictionary } from "vue-router/types/router"
-import imageInfo from '~/assets/homepage_images/image_info.json'
+import imageInfo from "~/assets/homepage_images/image_info.json"
export default defineComponent({
- name: 'HomePage',
+ name: "HomePage",
components: {
VBrand,
VSearchTypePopoverOld,
@@ -169,7 +169,7 @@ export default defineComponent({
VLink,
VLogoButtonOld,
},
- layout: 'blank',
+ layout: "blank",
setup() {
const { app } = useContext()
const router = useRouter()
@@ -180,14 +180,14 @@ export default defineComponent({
const featureFlagStore = useFeatureFlagStore()
const isNewHeaderEnabled = computed(() =>
- featureFlagStore.isOn('new_header')
+ featureFlagStore.isOn("new_header")
)
const themeColorMeta = [
- { hid: 'theme-color', name: 'theme-color', content: '#ffe033' },
+ { hid: "theme-color", name: "theme-color", content: "#ffe033" },
]
useMeta({
meta: isNewHeaderEnabled.value
- ? [...themeColorMeta, { hid: 'robots', name: 'robots', content: 'all' }]
+ ? [...themeColorMeta, { hid: "robots", name: "robots", content: "all" }]
: themeColorMeta,
})
@@ -210,7 +210,7 @@ export default defineComponent({
src: require(`~/assets/homepage_images/${setItem.prefix}-${imageItem.index}.jpg`),
url: router.resolve(
app.localePath({
- name: 'image-id',
+ name: "image-id",
params: { id: imageItem.identifier },
})
).href,
@@ -262,9 +262,9 @@ export default defineComponent({
head: {
meta: [
{
- hid: 'theme-color',
- name: 'theme-color',
- content: '#ffe033',
+ hid: "theme-color",
+ name: "theme-color",
+ content: "#ffe033",
},
],
},
diff --git a/src/pages/preferences.vue b/src/pages/preferences.vue
index 1acb1dc1d..a5f90e553 100644
--- a/src/pages/preferences.vue
+++ b/src/pages/preferences.vue
@@ -1,13 +1,13 @@
<template>
<VContentPage>
- <h1>{{ $t('pref-page.title') }}</h1>
+ <h1>{{ $t("pref-page.title") }}</h1>
<div v-for="isSwitchable in [false, true]" :key="isSwitchable">
<h2>
- {{ $t(`pref-page.${isSwitchable ? '' : 'non-'}switchable.title`) }}
+ {{ $t(`pref-page.${isSwitchable ? "" : "non-"}switchable.title`) }}
</h2>
<p>
- {{ $t(`pref-page.${isSwitchable ? '' : 'non-'}switchable.desc`) }}
+ {{ $t(`pref-page.${isSwitchable ? "" : "non-"}switchable.desc`) }}
</p>
<ul class="!ps-0">
<template v-for="(feature, name) in flags">
@@ -34,10 +34,10 @@
</ul>
</div>
- <h2>{{ $t('pref-page.store-state') }}</h2>
+ <h2>{{ $t("pref-page.store-state") }}</h2>
<pre><code>{{ flags }}</code></pre>
- <h2>{{ $t('pref-page.content-filtering') }}</h2>
+ <h2>{{ $t("pref-page.content-filtering") }}</h2>
<ul>
<template v-for="(_, featName) in flags">
<template v-for="featState in FEATURE_STATES">
@@ -73,16 +73,16 @@
</template>
<script lang="ts">
-import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'
+import { computed, defineComponent, useContext } from "@nuxtjs/composition-api"
-import { useFeatureFlagStore, getFlagStatus } from '~/stores/feature-flag'
-import { SWITCHABLE, ON, OFF, FEATURE_STATES } from '~/constants/feature-flag'
+import { useFeatureFlagStore, getFlagStatus } from "~/stores/feature-flag"
+import { SWITCHABLE, ON, OFF, FEATURE_STATES } from "~/constants/feature-flag"
-import VContentPage from '~/components/VContentPage.vue'
-import VCheckbox from '~/components/VCheckbox/VCheckbox.vue'
+import VContentPage from "~/components/VContentPage.vue"
+import VCheckbox from "~/components/VCheckbox/VCheckbox.vue"
export default defineComponent({
- name: 'VPreferences',
+ name: "VPreferences",
components: {
VContentPage,
VCheckbox,
@@ -106,7 +106,7 @@ export default defineComponent({
checked: boolean
}) => {
featureFlagStore.toggleFeature(name, checked ? ON : OFF)
- $cookies.set('features', featureFlagStore.flagStateMap)
+ $cookies.set("features", featureFlagStore.flagStateMap)
}
return {
diff --git a/src/pages/privacy.vue b/src/pages/privacy.vue
index 763c61d97..0dea8f2bc 100644
--- a/src/pages/privacy.vue
+++ b/src/pages/privacy.vue
@@ -1,26 +1,26 @@
<template>
<VContentPage>
<h1>
- {{ $t('privacy.title', { openverse: 'Openverse' }) }}
+ {{ $t("privacy.title", { openverse: "Openverse" }) }}
</h1>
<i18n path="privacy.intro.content" tag="p">
<template #link>
<VLink href="https://wordpress.org/about/privacy/">{{
- $t('privacy.intro.link')
+ $t("privacy.intro.link")
}}</VLink>
</template>
<template #openverse>Openverse</template>
</i18n>
<h2>
- {{ $t('privacy.cookies.title') }}
+ {{ $t("privacy.cookies.title") }}
</h2>
<i18n path="privacy.cookies.content" tag="p">
<template #openverse>Openverse</template>
</i18n>
<h2>
- {{ $t('privacy.contact.title') }}
+ {{ $t("privacy.contact.title") }}
</h2>
<i18n path="privacy.contact.content" tag="p">
@@ -32,12 +32,12 @@
</template>
<template #issue>
<VLink href="https://github.com/WordPress/openverse/issues/new/choose">
- {{ $t('privacy.contact.issue') }}</VLink
+ {{ $t("privacy.contact.issue") }}</VLink
>
</template>
<template #chat>
<VLink href="https://make.wordpress.org/chat/">
- {{ $t('privacy.contact.chat') }}</VLink
+ {{ $t("privacy.contact.chat") }}</VLink
>
</template>
</i18n>
@@ -45,27 +45,27 @@
</template>
<script lang="ts">
-import { defineComponent, useMeta } from '@nuxtjs/composition-api'
+import { defineComponent, useMeta } from "@nuxtjs/composition-api"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { useI18n } from '~/composables/use-i18n'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { useI18n } from "~/composables/use-i18n"
-import VLink from '~/components/VLink.vue'
-import VContentPage from '~/components/VContentPage.vue'
+import VLink from "~/components/VLink.vue"
+import VContentPage from "~/components/VContentPage.vue"
export default defineComponent({
- name: 'VPrivacyPage',
+ name: "VPrivacyPage",
components: { VLink, VContentPage },
setup() {
const i18n = useI18n()
const featureFlagStore = useFeatureFlagStore()
useMeta({
- title: `${i18n.t('privacy.title', {
- openverse: 'Openverse',
+ title: `${i18n.t("privacy.title", {
+ openverse: "Openverse",
})} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
},
diff --git a/src/pages/search-help.vue b/src/pages/search-help.vue
index aef477ad4..c3da04792 100644
--- a/src/pages/search-help.vue
+++ b/src/pages/search-help.vue
@@ -1,14 +1,14 @@
<template>
<VContentPage>
<h1>
- {{ $t('search-guide.title', { openverse: 'Openverse' }) }}
+ {{ $t("search-guide.title", { openverse: "Openverse" }) }}
</h1>
<p>
- {{ $t('search-guide.intro') }}
+ {{ $t("search-guide.intro") }}
</p>
<h2>
- {{ $t('search-guide.exact.title') }}
+ {{ $t("search-guide.exact.title") }}
</h2>
<i18n path="search-guide.exact.content" tag="p">
<template #link>
@@ -17,18 +17,18 @@
:aria-label="$t('search-guide.exact.aria-label')"
:href="pathFromQuery('Claude Monet', true)"
>
- <em>{{ $t('search-guide.exact.claude-monet') }}</em>
+ <em>{{ $t("search-guide.exact.claude-monet") }}</em>
</VLink>
<!-- eslint-enable -->
</template>
</i18n>
<h2>
- {{ $t('search-guide.combine.title') }}
+ {{ $t("search-guide.combine.title") }}
</h2>
<p>
- {{ $t('search-guide.combine.description') }}
+ {{ $t("search-guide.combine.description") }}
</p>
<ul>
<i18n path="search-guide.combine.and" tag="li">
@@ -102,7 +102,7 @@
:aria-label="$t('search-guide.example.and.aria-label').toString()"
:href="pathFromQuery('dog%2Bcat')"
>
- <em>{{ $t('search-guide.example.and.example') }}</em>
+ <em>{{ $t("search-guide.example.and.example") }}</em>
</VLink>
</template>
<template #br>
@@ -116,7 +116,7 @@
:aria-label="$t('search-guide.example.or.aria-label')"
:href="pathFromQuery('dog%7Ccat')"
>
- <em>{{ $t('search-guide.example.or.example').toString() }}</em>
+ <em>{{ $t("search-guide.example.or.example").toString() }}</em>
</VLink>
</template>
<template #br>
@@ -131,7 +131,7 @@
$t('search-guide.example.negate.operator-aria-label').toString()
"
>-
- {{ $t('search-guide.example.negate.operator-name').toString() }}</em
+ {{ $t("search-guide.example.negate.operator-name").toString() }}</em
>
</template>
</i18n>
@@ -142,7 +142,7 @@
:aria-label="$t('search-guide.example.negate.aria-label')"
:href="pathFromQuery('dog%20-pug')"
>
- <em>{{ $t('search-guide.example.negate.example') }}</em>
+ <em>{{ $t("search-guide.example.negate.example") }}</em>
</VLink>
</template>
<template #br>
@@ -155,7 +155,7 @@
<em
:aria-label="$t('search-guide.example.prefix.aria-label').toString()"
>*
- {{ $t('search-guide.example.prefix.operator-name').toString() }}</em
+ {{ $t("search-guide.example.prefix.operator-name").toString() }}</em
>
</template>
</i18n>
@@ -166,7 +166,7 @@
:aria-label="$t('search-guide.example.prefix.aria-label')"
:href="pathFromQuery('net%2a')"
>
- <em>{{ $t('search-guide.example.prefix.example') }}</em>
+ <em>{{ $t("search-guide.example.prefix.example") }}</em>
</VLink>
</template>
<template #br>
@@ -186,7 +186,7 @@
:aria-label="$t('search-guide.example.precedence.aria-label')"
:href="pathFromQuery('dogs%20%2B%20%28corgis%20%7C%20labrador%29')"
>
- <em>{{ $t('search-guide.example.precedence.example') }}</em>
+ <em>{{ $t("search-guide.example.precedence.example") }}</em>
</VLink>
</template>
<template #br>
@@ -200,7 +200,7 @@
</template>
<template #link>
<VLink href="https://en.wikipedia.org/wiki/Levenshtein_distance">
- {{ $t('search-guide.example.fuzziness.link-text') }}
+ {{ $t("search-guide.example.fuzziness.link-text") }}
</VLink>
</template>
</i18n>
@@ -211,7 +211,7 @@
:aria-label="$t('search-guide.example.fuzziness.aria-label')"
:href="pathFromQuery('theatre~1')"
>
- <em>{{ $t('search-guide.example.fuzziness.example') }}</em>
+ <em>{{ $t("search-guide.example.fuzziness.example") }}</em>
</VLink>
</template>
<template #br>
@@ -223,16 +223,16 @@
</template>
<script lang="ts">
-import { defineComponent, useContext, useMeta } from '@nuxtjs/composition-api'
+import { defineComponent, useContext, useMeta } from "@nuxtjs/composition-api"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { useI18n } from '~/composables/use-i18n'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { useI18n } from "~/composables/use-i18n"
-import VLink from '~/components/VLink.vue'
-import VContentPage from '~/components/VContentPage.vue'
+import VLink from "~/components/VLink.vue"
+import VContentPage from "~/components/VContentPage.vue"
export default defineComponent({
- name: 'VSearchHelpPage',
+ name: "VSearchHelpPage",
components: { VLink, VContentPage },
setup() {
const { app } = useContext()
@@ -241,17 +241,17 @@ export default defineComponent({
const featureFlagStore = useFeatureFlagStore()
useMeta({
- title: `${i18n.t('search-guide.title', {
- openverse: 'Openverse',
+ title: `${i18n.t("search-guide.title", {
+ openverse: "Openverse",
})} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
const pathFromQuery = (queryString: string, quote = false) => {
return app.localePath({
- path: 'search',
+ path: "search",
query: {
q: quote ? `"${queryString}"` : queryString,
},
diff --git a/src/pages/search.vue b/src/pages/search.vue
index 86c6dc868..1b0c3bcf5 100644
--- a/src/pages/search.vue
+++ b/src/pages/search.vue
@@ -33,22 +33,22 @@
</template>
<script lang="ts">
-import { isShallowEqualObjects } from '@wordpress/is-shallow-equal'
-import { computed, defineComponent, inject, ref } from '@nuxtjs/composition-api'
+import { isShallowEqualObjects } from "@wordpress/is-shallow-equal"
+import { computed, defineComponent, inject, ref } from "@nuxtjs/composition-api"
-import { Focus, focusIn } from '~/utils/focus-management'
-import { useMediaStore } from '~/stores/media'
-import { useSearchStore } from '~/stores/search'
-import { IsSidebarVisibleKey } from '~/types/provides'
+import { Focus, focusIn } from "~/utils/focus-management"
+import { useMediaStore } from "~/stores/media"
+import { useSearchStore } from "~/stores/search"
+import { IsSidebarVisibleKey } from "~/types/provides"
-import VSearchGrid from '~/components/VSearchGrid.vue'
-import VSkipToContentContainer from '~/components/VSkipToContentContainer.vue'
-import VScrollButton from '~/components/VScrollButton.vue'
+import VSearchGrid from "~/components/VSearchGrid.vue"
+import VSkipToContentContainer from "~/components/VSkipToContentContainer.vue"
+import VScrollButton from "~/components/VScrollButton.vue"
-import type { Context } from '@nuxt/types'
+import type { Context } from "@nuxt/types"
export default defineComponent({
- name: 'BrowsePage',
+ name: "BrowsePage",
components: {
VScrollButton,
VSearchGrid,
@@ -61,13 +61,13 @@ export default defineComponent({
* an exception for the 'creator' filter. The creator filter doesn't send
* the search query to the API.
*/
- if (!route.query.q && !route.query.searchBy) return redirect('/')
+ if (!route.query.q && !route.query.searchBy) return redirect("/")
},
scrollToTop: false,
setup() {
const searchGridRef = ref<InstanceType<typeof VSearchGrid> | null>(null)
- const showScrollButton = inject('showScrollButton')
+ const showScrollButton = inject("showScrollButton")
const isSidebarVisible = inject(IsSidebarVisibleKey)
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
@@ -91,7 +91,7 @@ export default defineComponent({
Boolean(
searchStore.searchTypeIsSupported &&
!mediaStore.resultCount &&
- searchStore.searchTerm.trim() !== ''
+ searchStore.searchTerm.trim() !== ""
)
)
@@ -134,7 +134,7 @@ export default defineComponent({
/**
* Updates the search type only if the route's path changes.
*/
- async $route(newRoute: Context['route'], oldRoute: Context['route']) {
+ async $route(newRoute: Context["route"], oldRoute: Context["route"]) {
if (
newRoute.path !== oldRoute.path ||
!isShallowEqualObjects(newRoute.query, oldRoute.query)
@@ -148,10 +148,10 @@ export default defineComponent({
},
methods: {
handleTab(event: KeyboardEvent, element: string) {
- if (this.showScrollButton.value && element !== 'scroll-button') {
+ if (this.showScrollButton.value && element !== "scroll-button") {
return
}
- focusIn(document.getElementById('__layout'), Focus.First)
+ focusIn(document.getElementById("__layout"), Focus.First)
},
fetchMedia(payload: { shouldPersistMedia?: boolean } = {}) {
const mediaStore = useMediaStore(this.$pinia)
diff --git a/src/pages/search/audio.vue b/src/pages/search/audio.vue
index 7ecc9cdb9..6f65b375d 100644
--- a/src/pages/search/audio.vue
+++ b/src/pages/search/audio.vue
@@ -40,26 +40,26 @@ import {
useMeta,
ref,
inject,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
-import { useFocusFilters } from '~/composables/use-focus-filters'
-import { Focus } from '~/utils/focus-management'
+import { useFocusFilters } from "~/composables/use-focus-filters"
+import { Focus } from "~/utils/focus-management"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
-import { IsSidebarVisibleKey } from '~/types/provides'
+import { IsSidebarVisibleKey } from "~/types/provides"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import VSnackbar from '~/components/VSnackbar.vue'
-import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
-import VLoadMore from '~/components/VLoadMore.vue'
-import VGridSkeleton from '~/components/VSkeleton/VGridSkeleton.vue'
+import VSnackbar from "~/components/VSnackbar.vue"
+import VAudioTrack from "~/components/VAudioTrack/VAudioTrack.vue"
+import VLoadMore from "~/components/VLoadMore.vue"
+import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue"
-import { propTypes } from './search-page.types'
+import { propTypes } from "./search-page.types"
export default defineComponent({
- name: 'AudioSearch',
+ name: "AudioSearch",
components: {
VSnackbar,
VAudioTrack,
@@ -72,8 +72,8 @@ export default defineComponent({
useMeta({
title: `${props.searchTerm} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
@@ -85,7 +85,7 @@ export default defineComponent({
const filterVisibleRef = inject(IsSidebarVisibleKey)
const audioTrackSize = computed(() =>
- !isDesktopLayout.value ? 's' : filterVisibleRef.value ? 'l' : 'm'
+ !isDesktopLayout.value ? "s" : filterVisibleRef.value ? "l" : "m"
)
const focusFilters = useFocusFilters()
diff --git a/src/pages/search/image.vue b/src/pages/search/image.vue
index d53c13249..447278cd2 100644
--- a/src/pages/search/image.vue
+++ b/src/pages/search/image.vue
@@ -8,16 +8,16 @@
</template>
<script lang="ts">
-import { computed, defineComponent, useMeta } from '@nuxtjs/composition-api'
+import { computed, defineComponent, useMeta } from "@nuxtjs/composition-api"
-import { propTypes } from '~/pages/search/search-page.types'
-import { useFocusFilters } from '~/composables/use-focus-filters'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { propTypes } from "~/pages/search/search-page.types"
+import { useFocusFilters } from "~/composables/use-focus-filters"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import VImageGrid from '~/components/VImageGrid/VImageGrid.vue'
+import VImageGrid from "~/components/VImageGrid/VImageGrid.vue"
export default defineComponent({
- name: 'ImageSearch',
+ name: "ImageSearch",
components: { VImageGrid },
props: propTypes,
setup(props) {
@@ -25,8 +25,8 @@ export default defineComponent({
useMeta({
title: `${props.searchTerm} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
diff --git a/src/pages/search/index.vue b/src/pages/search/index.vue
index 613fb7848..3d8d2b81d 100644
--- a/src/pages/search/index.vue
+++ b/src/pages/search/index.vue
@@ -3,15 +3,15 @@
</template>
<script lang="ts">
-import { defineComponent, useMeta } from '@nuxtjs/composition-api'
+import { defineComponent, useMeta } from "@nuxtjs/composition-api"
-import { propTypes } from '~/pages/search/search-page.types'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { propTypes } from "~/pages/search/search-page.types"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import VAllResultsGrid from '~/components/VAllResultsGrid/VAllResultsGrid.vue'
+import VAllResultsGrid from "~/components/VAllResultsGrid/VAllResultsGrid.vue"
export default defineComponent({
- name: 'SearchIndex',
+ name: "SearchIndex",
components: { VAllResultsGrid },
props: propTypes,
setup(props) {
@@ -19,8 +19,8 @@ export default defineComponent({
useMeta({
title: `${props.searchTerm} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
},
diff --git a/src/pages/search/model-3d.vue b/src/pages/search/model-3d.vue
index 7409dd8fb..7850ca61d 100644
--- a/src/pages/search/model-3d.vue
+++ b/src/pages/search/model-3d.vue
@@ -4,6 +4,6 @@
<script>
export default {
- name: 'Model3dPage',
+ name: "Model3dPage",
}
</script>
diff --git a/src/pages/search/search-page.types.ts b/src/pages/search/search-page.types.ts
index 5f902e23e..aa58a5f15 100644
--- a/src/pages/search/search-page.types.ts
+++ b/src/pages/search/search-page.types.ts
@@ -1,8 +1,8 @@
-import type { SupportedMediaType } from '~/constants/media'
-import type { Media } from '~/types/media'
-import type { FetchState } from '~/types/fetch-state'
+import type { SupportedMediaType } from "~/constants/media"
+import type { Media } from "~/types/media"
+import type { FetchState } from "~/types/fetch-state"
-import type { ExtractPropTypes, PropType } from '@nuxtjs/composition-api'
+import type { ExtractPropTypes, PropType } from "@nuxtjs/composition-api"
export const propTypes = {
resultItems: {
diff --git a/src/pages/search/video.vue b/src/pages/search/video.vue
index 488d73818..adcba64d8 100644
--- a/src/pages/search/video.vue
+++ b/src/pages/search/video.vue
@@ -4,6 +4,6 @@
<script>
export default {
- name: 'VideoSearch',
+ name: "VideoSearch",
}
</script>
diff --git a/src/pages/sources.vue b/src/pages/sources.vue
index dfc2e62b3..3f7a3c721 100644
--- a/src/pages/sources.vue
+++ b/src/pages/sources.vue
@@ -1,14 +1,14 @@
<template>
<VContentPage>
<h1>
- {{ $t('sources.title') }}
+ {{ $t("sources.title") }}
</h1>
<h2>
- {{ $t('sources.cc-content.where', { openverse: 'Openverse' }) }}
+ {{ $t("sources.cc-content.where", { openverse: "Openverse" }) }}
</h2>
<p>
- {{ $t('sources.cc-content.content', { openverse: 'Openverse' }) }}
+ {{ $t("sources.cc-content.content", { openverse: "Openverse" }) }}
</p>
<i18n path="sources.cc-content.provider" tag="p">
<template #flickr>
@@ -16,7 +16,7 @@
</template>
<template #smithsonian>
<VLink href="https://www.si.edu/">{{
- $t('sources.cc-content.smithsonian')
+ $t("sources.cc-content.smithsonian")
}}</VLink>
</template>
</i18n>
@@ -27,31 +27,31 @@
</template>
<template #link-api>
<VLink href="https://pro.europeana.eu/page/apis">{{
- $t('sources.cc-content.europeana-api')
+ $t("sources.cc-content.europeana-api")
}}</VLink>
</template>
</i18n>
<h2>
- {{ $t('sources.new-content.next') }}
+ {{ $t("sources.new-content.next") }}
</h2>
<p>
- {{ $t('sources.new-content.integrate') }}
+ {{ $t("sources.new-content.integrate") }}
</p>
<ul>
<li>
- {{ $t('sources.new-content.impact') }}
+ {{ $t("sources.new-content.impact") }}
</li>
<li>
- {{ $t('sources.new-content.reuse') }}
+ {{ $t("sources.new-content.reuse") }}
</li>
<li>
- {{ $t('sources.new-content.total-items') }}
+ {{ $t("sources.new-content.total-items") }}
</li>
</ul>
<h2>
- {{ $t('sources.suggestions') }}
+ {{ $t("sources.suggestions") }}
</h2>
<p class="inline-block">
@@ -62,7 +62,7 @@
class="not-prose mt-5 px-6 py-4 font-semibold"
href="https://github.com/WordPress/openverse-catalog/issues/new?assignees=&labels=%F0%9F%9A%A6+status%3A+awaiting+triage%2C+%F0%9F%A7%B9+status%3A+ticket+work+required%2C+%E2%98%81%EF%B8%8F+provider%3A+any&template=new-source-suggestion.md&title=%5BSource+Suggestion%5D+Insert+source+name+here"
>
- {{ $t('sources.issue-button') }}
+ {{ $t("sources.issue-button") }}
<VIcon :icon-path="externalLinkIcon" :rtl-flip="true" class="mx-2" />
</VButton>
</p>
@@ -70,7 +70,7 @@
<i18n path="sources.detail" tag="p">
<template #single-name>
<strong>
- {{ $t('sources.single-name') }}
+ {{ $t("sources.single-name") }}
</strong>
</template>
</i18n>
@@ -82,31 +82,31 @@
</template>
<script lang="ts">
-import { defineComponent, useMeta } from '@nuxtjs/composition-api'
+import { defineComponent, useMeta } from "@nuxtjs/composition-api"
-import { supportedMediaTypes } from '~/constants/media'
-import { useI18n } from '~/composables/use-i18n'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { supportedMediaTypes } from "~/constants/media"
+import { useI18n } from "~/composables/use-i18n"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import VButton from '~/components/VButton.vue'
-import VLink from '~/components/VLink.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VContentPage from '~/components/VContentPage.vue'
-import VSourcesTable from '~/components/VSourcesTable.vue'
+import VButton from "~/components/VButton.vue"
+import VLink from "~/components/VLink.vue"
+import VIcon from "~/components/VIcon/VIcon.vue"
+import VContentPage from "~/components/VContentPage.vue"
+import VSourcesTable from "~/components/VSourcesTable.vue"
-import externalLinkIcon from '~/assets/icons/external-link.svg'
+import externalLinkIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
- name: 'SourcePage',
+ name: "SourcePage",
components: { VButton, VContentPage, VIcon, VLink, VSourcesTable },
setup() {
const i18n = useI18n()
const featureFlagStore = useFeatureFlagStore()
useMeta({
- title: `${i18n.t('sources.title')} | Openverse`,
- meta: featureFlagStore.isOn('new_header')
- ? [{ hid: 'robots', name: 'robots', content: 'all' }]
+ title: `${i18n.t("sources.title")} | Openverse`,
+ meta: featureFlagStore.isOn("new_header")
+ ? [{ hid: "robots", name: "robots", content: "all" }]
: undefined,
})
diff --git a/src/plugins/api-token.server.ts b/src/plugins/api-token.server.ts
index 5defdaabd..1093b5196 100644
--- a/src/plugins/api-token.server.ts
+++ b/src/plugins/api-token.server.ts
@@ -1,11 +1,11 @@
-import { Mutex, MutexInterface } from 'async-mutex'
+import { Mutex, MutexInterface } from "async-mutex"
-import { createApiService } from '~/data/api-service'
-import { error, log } from '~/utils/console'
+import { createApiService } from "~/data/api-service"
+import { error, log } from "~/utils/console"
-import type { AxiosError } from 'axios'
+import type { AxiosError } from "axios"
-import type { Context, Plugin } from '@nuxt/types'
+import type { Context, Plugin } from "@nuxt/types"
/* Process level state */
@@ -28,7 +28,7 @@ export declare let process: NodeJS.Process & Process
* is mysteriously reloaded (cache-busted) for each request.
*/
process.tokenData = process.tokenData || {
- accessToken: '', // '' denotes non-existent key
+ accessToken: "", // '' denotes non-existent key
accessTokenExpiry: 0, // 0 denotes non-existent key
}
@@ -73,14 +73,14 @@ const refreshApiAccessToken = async (
clientSecret: string
) => {
const formData = new URLSearchParams()
- formData.append('client_id', clientId)
- formData.append('client_secret', clientSecret)
- formData.append('grant_type', 'client_credentials')
+ formData.append("client_id", clientId)
+ formData.append("client_secret", clientSecret)
+ formData.append("grant_type", "client_credentials")
const apiService = createApiService()
try {
const res = await apiService.post<TokenResponse>(
- 'auth_tokens/token',
+ "auth_tokens/token",
formData
)
process.tokenData.accessToken = res.data.access_token
@@ -91,8 +91,8 @@ const refreshApiAccessToken = async (
* anonymously and hope it works. By setting the expiry to 0 we queue
* up another token fetch attempt for the next request.
*/
- error('Unable to retrieve API token, clearing existing token', e)
- process.tokenData.accessToken = ''
+ error("Unable to retrieve API token, clearing existing token", e)
+ process.tokenData.accessToken = ""
process.tokenData.accessTokenExpiry = 0
;(e as AxiosError).message = `Unable to retrieve API token. ${
(e as AxiosError).message
@@ -128,16 +128,16 @@ const getApiAccessToken = async (
// not already another request making the request (represented
// by the locked mutex).
if (isNewTokenNeeded() && !process.fetchingMutex.isLocked()) {
- log('acquiring mutex lock')
+ log("acquiring mutex lock")
release = await process.fetchingMutex.acquire()
- log('mutex lock acquired, preparing token refresh request')
+ log("mutex lock acquired, preparing token refresh request")
process.tokenFetching = refreshApiAccessToken(apiClientId, apiClientSecret)
}
try {
- log('awaiting the fetching of the api token to resolve')
+ log("awaiting the fetching of the api token to resolve")
await process.tokenFetching
- log('done waiting for the token, moving on now...')
+ log("done waiting for the token, moving on now...")
} finally {
/**
* Releasing must be in a `finally` block otherwise if the
@@ -146,9 +146,9 @@ const getApiAccessToken = async (
* refresh.
*/
if (release) {
- log('releasing mutex')
+ log("releasing mutex")
release()
- log('mutex released')
+ log("mutex released")
}
}
@@ -157,7 +157,7 @@ const getApiAccessToken = async (
/* Plugin */
-declare module '@nuxt/types' {
+declare module "@nuxt/types" {
interface Context {
$openverseApiToken: string
}
@@ -171,7 +171,7 @@ const apiToken: Plugin = async (context, inject) => {
// capture the exception but allow the request to continue with anonymous API requests
context.$sentry.captureException(e)
} finally {
- inject('openverseApiToken', openverseApiToken || '')
+ inject("openverseApiToken", openverseApiToken || "")
}
}
diff --git a/src/plugins/focus-visible.client.ts b/src/plugins/focus-visible.client.ts
index 5ac75a536..bca5d8c07 100644
--- a/src/plugins/focus-visible.client.ts
+++ b/src/plugins/focus-visible.client.ts
@@ -1 +1 @@
-import 'focus-visible'
+import "focus-visible"
diff --git a/src/plugins/migration-notice.ts b/src/plugins/migration-notice.ts
index 441de60eb..eda56957b 100644
--- a/src/plugins/migration-notice.ts
+++ b/src/plugins/migration-notice.ts
@@ -1,6 +1,6 @@
-import { useNavigationStore } from '~/stores/navigation'
+import { useNavigationStore } from "~/stores/navigation"
-import type { Plugin } from '@nuxt/types'
+import type { Plugin } from "@nuxt/types"
/**
* If the URL contains a referral parameter pointing containing
@@ -10,7 +10,7 @@ import type { Plugin } from '@nuxt/types'
const migrationNoticePlugin: Plugin = ({ query }) => {
if (query.referrer) {
useNavigationStore().setIsReferredFromCc(
- query.referrer.includes('creativecommons.org')
+ query.referrer.includes("creativecommons.org")
)
}
}
diff --git a/src/plugins/sentry.ts b/src/plugins/sentry.ts
index 07b9e09e1..c5665fe6c 100644
--- a/src/plugins/sentry.ts
+++ b/src/plugins/sentry.ts
@@ -1,9 +1,9 @@
-import * as Sentry from '@sentry/browser'
+import * as Sentry from "@sentry/browser"
/**
* adds render context to the error event that is sent to sentry
*/
-Sentry.setContext('render context', {
- platform: process.client ? 'client' : 'server',
+Sentry.setContext("render context", {
+ platform: process.client ? "client" : "server",
})
diff --git a/src/plugins/ua-parse.ts b/src/plugins/ua-parse.ts
index cbe231725..44b71ef77 100644
--- a/src/plugins/ua-parse.ts
+++ b/src/plugins/ua-parse.ts
@@ -1,24 +1,24 @@
-import useragent, { Details as UADetails } from 'express-useragent'
+import useragent, { Details as UADetails } from "express-useragent"
-import type { Plugin } from '@nuxt/types'
+import type { Plugin } from "@nuxt/types"
const uaParsePlugin: Plugin = (context, inject) => {
let userAgent
- if (typeof context.req !== 'undefined') {
- userAgent = context.req.headers['user-agent']
- } else if (typeof navigator !== 'undefined') {
+ if (typeof context.req !== "undefined") {
+ userAgent = context.req.headers["user-agent"]
+ } else if (typeof navigator !== "undefined") {
userAgent = navigator.userAgent
}
let ua: UADetails | null
- if (typeof userAgent == 'string') {
+ if (typeof userAgent == "string") {
ua = useragent.parse(userAgent)
} else {
ua = null
}
context.$ua = ua
- inject('ua', ua)
+ inject("ua", ua)
}
export default uaParsePlugin
diff --git a/src/plugins/url-change.ts b/src/plugins/url-change.ts
index 0232eb566..40f9fddbe 100644
--- a/src/plugins/url-change.ts
+++ b/src/plugins/url-change.ts
@@ -1,7 +1,7 @@
-import { sendWindowMessage } from '~/utils/send-message'
-import { useNavigationStore } from '~/stores/navigation'
+import { sendWindowMessage } from "~/utils/send-message"
+import { useNavigationStore } from "~/stores/navigation"
-import type { Plugin } from '@nuxt/types'
+import type { Plugin } from "@nuxt/types"
/**
* In embedded mode, we need to notify the outer window of the current URL.
@@ -14,7 +14,7 @@ const urlChangePlugin: Plugin = ({ app, $pinia }): void => {
const isEmbedded = useNavigationStore($pinia).isEmbedded
if (process.client && isEmbedded && app.router) {
sendWindowMessage({
- type: 'urlChange',
+ type: "urlChange",
value: {
path: app.router.currentRoute.fullPath,
title: document.title,
diff --git a/src/plugins/vue-i18n.ts b/src/plugins/vue-i18n.ts
index e2965a349..e39d9ed17 100644
--- a/src/plugins/vue-i18n.ts
+++ b/src/plugins/vue-i18n.ts
@@ -1,6 +1,6 @@
export default () => {
return {
- fallbackLocale: 'en',
+ fallbackLocale: "en",
silentFallbackWarn: true,
pluralizationRules: {
/**
diff --git a/src/server-middleware/healthcheck.js b/src/server-middleware/healthcheck.js
index b7d208bb6..6e3927593 100644
--- a/src/server-middleware/healthcheck.js
+++ b/src/server-middleware/healthcheck.js
@@ -6,6 +6,6 @@
* @type {import('@nuxt/types').ServerMiddleware}
*/
export default function healthcheck(_, res) {
- res.setHeader('Content-Type', 'text/plain')
- res.end('OK')
+ res.setHeader("Content-Type", "text/plain")
+ res.end("OK")
}
diff --git a/src/static/static/img/.DO_NOT_MOVE_THIS_DIRECTORY_OR_ITS_CONTENTS.md b/src/static/static/img/.DO_NOT_MOVE_THIS_DIRECTORY_OR_ITS_CONTENTS.md
index 2d49cab38..6fe11d0c8 100644
--- a/src/static/static/img/.DO_NOT_MOVE_THIS_DIRECTORY_OR_ITS_CONTENTS.md
+++ b/src/static/static/img/.DO_NOT_MOVE_THIS_DIRECTORY_OR_ITS_CONTENTS.md
@@ -2,8 +2,15 @@
As the title says, don't do it 😁
-For historical reasons (pre-Openverse, back in the CC Search days) we need to serve these files at `/static/img/*.svg`. Nuxt serves static files at the top level, so anything immediately inside the `src/static` directory will just be served directly at `/` (like `/favicon.ico`). The nested `static` directories are absolutely necessary to maintain existing static assets being served at the root _and_ these historical static assets that need to be served at `/static`.
+For historical reasons (pre-Openverse, back in the CC Search days) we need to
+serve these files at `/static/img/*.svg`. Nuxt serves static files at the top
+level, so anything immediately inside the `src/static` directory will just be
+served directly at `/` (like `/favicon.ico`). The nested `static` directories
+are absolutely necessary to maintain existing static assets being served at the
+root _and_ these historical static assets that need to be served at `/static`.
-If you do happen to move these files you will break the references to these glyphs in the attribution HTML copied users from single result pages throughout the entire history of CC Search and Openverse.
+If you do happen to move these files you will break the references to these
+glyphs in the attribution HTML copied users from single result pages throughout
+the entire history of CC Search and Openverse.
Thank you for not moving or renaming these files ❤️
diff --git a/src/stores/active-media.ts b/src/stores/active-media.ts
index af105e666..e7b6a71b7 100644
--- a/src/stores/active-media.ts
+++ b/src/stores/active-media.ts
@@ -1,18 +1,18 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
-import type { SupportedMediaType } from '~/constants/media'
-import type { Media } from '~/types/media'
+import type { SupportedMediaType } from "~/constants/media"
+import type { Media } from "~/types/media"
-export type MediaStatus = 'ejected' | 'playing' | 'paused' // 'ejected' means player is closed
+export type MediaStatus = "ejected" | "playing" | "paused" // 'ejected' means player is closed
export interface ActiveMediaState {
type: SupportedMediaType | null
- id: Media['id'] | null
+ id: Media["id"] | null
status: MediaStatus
message: string | null
}
-const ACTIVE_MEDIA = 'active-media'
+const ACTIVE_MEDIA = "active-media"
/**
* Store information about the active media item.
@@ -23,7 +23,7 @@ export const useActiveMediaStore = defineStore(ACTIVE_MEDIA, {
state: (): ActiveMediaState => ({
type: null,
id: null,
- status: 'ejected',
+ status: "ejected",
message: null,
}),
@@ -38,10 +38,10 @@ export const useActiveMediaStore = defineStore(ACTIVE_MEDIA, {
setActiveMediaItem({
type,
id,
- status = 'playing',
+ status = "playing",
}: {
type: SupportedMediaType
- id: Media['id']
+ id: Media["id"]
status?: MediaStatus
}) {
this.type = type
@@ -50,11 +50,11 @@ export const useActiveMediaStore = defineStore(ACTIVE_MEDIA, {
},
pauseActiveMediaItem() {
- this.status = 'paused'
+ this.status = "paused"
},
ejectActiveMediaItem() {
- this.status = 'ejected'
+ this.status = "ejected"
this.id = null
this.type = null
},
diff --git a/src/stores/feature-flag.ts b/src/stores/feature-flag.ts
index 0ccc12153..d8afbd645 100644
--- a/src/stores/feature-flag.ts
+++ b/src/stores/feature-flag.ts
@@ -1,10 +1,10 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
-import featureData from '~~/feat/feature-flags.json'
+import featureData from "~~/feat/feature-flags.json"
-import { warn } from '~/utils/console'
+import { warn } from "~/utils/console"
-import type { FeatureFlag } from '~/types/feature-flag'
+import type { FeatureFlag } from "~/types/feature-flag"
import {
FeatureState,
FlagStatus,
@@ -13,17 +13,17 @@ import {
ON,
OFF,
DISABLED,
-} from '~/constants/feature-flag'
-import { LOCAL, DEPLOY_ENVS, DeployEnv } from '~/constants/deploy-env'
+} from "~/constants/feature-flag"
+import { LOCAL, DEPLOY_ENVS, DeployEnv } from "~/constants/deploy-env"
-import type { Dictionary } from 'vue-router/types/router'
+import type { Dictionary } from "vue-router/types/router"
-type FlagName = keyof typeof featureData['features']
+type FlagName = keyof typeof featureData["features"]
export interface FeatureFlagState {
flags: Record<FlagName, FeatureFlag>
}
-const FEATURE_FLAG = 'feature_flag'
+const FEATURE_FLAG = "feature_flag"
/**
* Get the status of the flag. If the flag status is environment dependent, this
@@ -34,7 +34,7 @@ const FEATURE_FLAG = 'feature_flag'
*/
export const getFlagStatus = (flag: FeatureFlag): FlagStatus => {
const deployEnv = (process.env.DEPLOYMENT_ENV ?? LOCAL) as DeployEnv
- if (typeof flag.status === 'string') return flag.status
+ if (typeof flag.status === "string") return flag.status
else {
const envIndex = DEPLOY_ENVS.indexOf(deployEnv)
for (let i = envIndex; i < DEPLOY_ENVS.length; i += 1) {
@@ -127,11 +127,11 @@ export const useFeatureFlagStore = defineStore(FEATURE_FLAG, {
*/
initFromQuery(query: Dictionary<string | (string | null)[]>) {
const isValidName = (name: string): name is `ff_${FlagName}` =>
- name.startsWith('ff_') && name.replace('ff_', '') in this.flags
+ name.startsWith("ff_") && name.replace("ff_", "") in this.flags
const isValidValue = (
value: string | (string | null)[]
): value is FeatureState =>
- typeof value === 'string' && ['on', 'off'].includes(value)
+ typeof value === "string" && ["on", "off"].includes(value)
const isValidEntry = (
entry: [string, string | (string | null)[]]
): entry is [`ff_${FlagName}`, FeatureState] =>
diff --git a/src/stores/media/index.ts b/src/stores/media/index.ts
index ece5746ad..8502a7da1 100644
--- a/src/stores/media/index.ts
+++ b/src/stores/media/index.ts
@@ -1,12 +1,12 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
-import axios from 'axios'
+import axios from "axios"
-import { warn } from '~/utils/console'
-import { hash, rand as prng } from '~/utils/prng'
-import prepareSearchQueryParams from '~/utils/prepare-search-query-params'
-import type { DetailFromMediaType, Media } from '~/types/media'
-import type { FetchState } from '~/types/fetch-state'
+import { warn } from "~/utils/console"
+import { hash, rand as prng } from "~/utils/prng"
+import prepareSearchQueryParams from "~/utils/prepare-search-query-params"
+import type { DetailFromMediaType, Media } from "~/types/media"
+import type { FetchState } from "~/types/fetch-state"
import {
ALL_MEDIA,
AUDIO,
@@ -14,11 +14,11 @@ import {
SupportedMediaType,
supportedMediaTypes,
isAdditionalSearchType,
-} from '~/constants/media'
-import { initServices } from '~/stores/media/services'
-import { isSearchTypeSupported, useSearchStore } from '~/stores/search'
-import { useRelatedMediaStore } from '~/stores/media/related-media'
-import { deepFreeze } from '~/utils/deep-freeze'
+} from "~/constants/media"
+import { initServices } from "~/stores/media/services"
+import { isSearchTypeSupported, useSearchStore } from "~/stores/search"
+import { useRelatedMediaStore } from "~/stores/media/related-media"
+import { deepFreeze } from "~/utils/deep-freeze"
export type MediaStoreResult = {
count: number
@@ -45,7 +45,7 @@ export const initialResults = deepFreeze({
items: {},
}) as MediaStoreResult
-export const useMediaStore = defineStore('media', {
+export const useMediaStore = defineStore("media", {
state: (): MediaState => ({
results: {
[AUDIO]: { ...initialResults },
@@ -154,13 +154,13 @@ export const useMediaStore = defineStore('media', {
}
return {
- isFetching: atLeastOne('isFetching'),
+ isFetching: atLeastOne("isFetching"),
fetchingError: supportedMediaTypes.every(
(type) => this.mediaFetchState[type].fetchingError !== null
)
? allMediaError()
: null,
- hasStarted: atLeastOne('hasStarted'),
+ hasStarted: atLeastOne("hasStarted"),
isFinished: supportedMediaTypes.every(
(type) => this.mediaFetchState[type].isFinished
),
@@ -196,12 +196,12 @@ export const useMediaStore = defineStore('media', {
// distribution is the same on repeated searches
const seedString = media[IMAGE][0]?.id
let seed: number
- if (typeof seedString === 'string') {
+ if (typeof seedString === "string") {
seed = hash(seedString)
} else {
- let otherTypeId = 'string'
+ let otherTypeId = "string"
for (const type of supportedMediaTypes.slice(1)) {
- if (typeof media[type][0]?.id === 'string') {
+ if (typeof media[type][0]?.id === "string") {
otherTypeId = media[type][0].id
break
}
@@ -286,20 +286,20 @@ export const useMediaStore = defineStore('media', {
_updateFetchState(
mediaType: SupportedMediaType,
- action: 'reset' | 'start' | 'end' | 'finish',
+ action: "reset" | "start" | "end" | "finish",
option?: string
) {
switch (action) {
- case 'reset':
+ case "reset":
this._resetFetchState()
break
- case 'start':
+ case "start":
this._startFetching(mediaType)
break
- case 'end':
+ case "end":
this._endFetching(mediaType, option)
break
- case 'finish':
+ case "finish":
this._finishFetchingForQuery(mediaType)
break
}
@@ -336,7 +336,7 @@ export const useMediaStore = defineStore('media', {
this.results[mediaType].page = mediaCount === 0 ? undefined : mediaPage
this.results[mediaType].pageCount = pageCount
if (mediaPage >= pageCount) {
- this._updateFetchState(mediaType, 'finish')
+ this._updateFetchState(mediaType, "finish")
}
},
@@ -415,7 +415,7 @@ export const useMediaStore = defineStore('media', {
page = (this.results[mediaType].page ?? 0) + 1
queryParams.page = `${page}`
}
- this._updateFetchState(mediaType, 'start')
+ this._updateFetchState(mediaType, "start")
try {
const accessToken = this.$nuxt.$openverseApiToken
const service = initServices[mediaType](accessToken)
@@ -425,7 +425,7 @@ export const useMediaStore = defineStore('media', {
if (!mediaCount) {
page = undefined
}
- this._updateFetchState(mediaType, 'end', errorMessage)
+ this._updateFetchState(mediaType, "end", errorMessage)
this.setMedia({
mediaType,
media: data.results,
@@ -475,7 +475,7 @@ export const useMediaStore = defineStore('media', {
},
})
- this._updateFetchState(mediaType, 'end', errorMessage)
+ this._updateFetchState(mediaType, "end", errorMessage)
if (!axios.isAxiosError(error)) {
throw new Error(errorMessage)
}
diff --git a/src/stores/media/related-media.ts b/src/stores/media/related-media.ts
index a8fb4950b..88be1ef71 100644
--- a/src/stores/media/related-media.ts
+++ b/src/stores/media/related-media.ts
@@ -1,9 +1,9 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
-import type { FetchState } from '~/types/fetch-state'
-import { initServices } from '~/stores/media/services'
-import type { Media } from '~/types/media'
-import type { SupportedMediaType } from '~/constants/media'
+import type { FetchState } from "~/types/fetch-state"
+import { initServices } from "~/stores/media/services"
+import type { Media } from "~/types/media"
+import type { SupportedMediaType } from "~/constants/media"
interface RelatedMediaState {
mainMediaId: null | string
@@ -11,7 +11,7 @@ interface RelatedMediaState {
fetchState: FetchState
}
-export const useRelatedMediaStore = defineStore('related-media', {
+export const useRelatedMediaStore = defineStore("related-media", {
state: (): RelatedMediaState => ({
mainMediaId: null,
fetchState: { isFetching: false, hasStarted: false, fetchingError: null },
diff --git a/src/stores/media/services.ts b/src/stores/media/services.ts
index 341dd4af3..55341aa7c 100644
--- a/src/stores/media/services.ts
+++ b/src/stores/media/services.ts
@@ -1,7 +1,7 @@
-import { AUDIO, IMAGE } from '~/constants/media'
-import MediaService from '~/data/media-service'
-import type { AudioDetail, ImageDetail } from '~/types/media'
-import { createApiService } from '~/data/api-service'
+import { AUDIO, IMAGE } from "~/constants/media"
+import MediaService from "~/data/media-service"
+import type { AudioDetail, ImageDetail } from "~/types/media"
+import { createApiService } from "~/data/api-service"
export const initServices = {
[AUDIO]: (accessToken?: string) =>
diff --git a/src/stores/media/single-result.ts b/src/stores/media/single-result.ts
index 4b5504501..2599e2dcf 100644
--- a/src/stores/media/single-result.ts
+++ b/src/stores/media/single-result.ts
@@ -1,23 +1,23 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
-import axios from 'axios'
+import axios from "axios"
-import type { AudioDetail, ImageDetail, Media } from '~/types/media'
-import type { SupportedMediaType } from '~/constants/media'
-import type { FetchState } from '~/types/fetch-state'
-import { initServices } from '~/stores/media/services'
-import { useMediaStore } from '~/stores/media/index'
-import { useRelatedMediaStore } from '~/stores/media/related-media'
-import { useProviderStore } from '~/stores/provider'
+import type { AudioDetail, ImageDetail, Media } from "~/types/media"
+import type { SupportedMediaType } from "~/constants/media"
+import type { FetchState } from "~/types/fetch-state"
+import { initServices } from "~/stores/media/services"
+import { useMediaStore } from "~/stores/media/index"
+import { useRelatedMediaStore } from "~/stores/media/related-media"
+import { useProviderStore } from "~/stores/provider"
export type MediaItemState =
| {
- mediaType: 'audio'
+ mediaType: "audio"
mediaItem: AudioDetail
fetchState: FetchState
}
| {
- mediaType: 'image'
+ mediaType: "image"
mediaItem: ImageDetail
fetchState: FetchState
}
@@ -27,7 +27,7 @@ export type MediaItemState =
fetchState: FetchState
}
-export const useSingleResultStore = defineStore('single-result', {
+export const useSingleResultStore = defineStore("single-result", {
state: (): MediaItemState => ({
mediaItem: null,
mediaType: null,
@@ -45,8 +45,8 @@ export const useSingleResultStore = defineStore('single-result', {
this.fetchState.fetchingError = null
},
- _updateFetchState(action: 'start' | 'end', option?: string) {
- action === 'start' ? this._startFetching() : this._endFetching(option)
+ _updateFetchState(action: "start" | "end", option?: string) {
+ action === "start" ? this._startFetching() : this._endFetching(option)
},
_addProviderName(mediaItem: Media) {
@@ -94,13 +94,13 @@ export const useSingleResultStore = defineStore('single-result', {
try {
await useRelatedMediaStore().fetchMedia(type, id)
} catch (error) {
- console.warn('Could not load related media: ', error)
+ console.warn("Could not load related media: ", error)
}
} else {
useRelatedMediaStore()
.fetchMedia(type, id)
.catch((error) =>
- console.warn('Could not load related media: ', error)
+ console.warn("Could not load related media: ", error)
)
}
},
@@ -112,13 +112,13 @@ export const useSingleResultStore = defineStore('single-result', {
*/
async fetchMediaItem(type: SupportedMediaType, id: string) {
try {
- this._updateFetchState('start')
+ this._updateFetchState("start")
const accessToken = this.$nuxt.$openverseApiToken
const service = initServices[type](accessToken)
this.mediaItem = this._addProviderName(await service.getMediaDetail(id))
this.mediaType = type
- this._updateFetchState('end')
+ this._updateFetchState("end")
} catch (error: unknown) {
this.mediaItem = null
this.mediaType = type
@@ -138,16 +138,16 @@ export const useSingleResultStore = defineStore('single-result', {
if (axios.isAxiosError(error)) {
errorMessage =
error.response?.status === 500
- ? 'There was a problem with our servers'
+ ? "There was a problem with our servers"
: `Request failed with status ${
- error.response?.status ?? 'unknown'
+ error.response?.status ?? "unknown"
}`
} else {
errorMessage =
- error instanceof Error ? error.message : 'Oops! Something went wrong'
+ error instanceof Error ? error.message : "Oops! Something went wrong"
}
- this._updateFetchState('end', errorMessage)
+ this._updateFetchState("end", errorMessage)
throw new Error(errorMessage)
},
},
diff --git a/src/stores/navigation.ts b/src/stores/navigation.ts
index 9fbaf8ea6..c4798bf10 100644
--- a/src/stores/navigation.ts
+++ b/src/stores/navigation.ts
@@ -1,4 +1,4 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
export interface NavigationState {
isEmbedded: boolean
@@ -8,7 +8,7 @@ export interface NavigationState {
/**
* Store information about navigation.
*/
-export const useNavigationStore = defineStore('navigation', {
+export const useNavigationStore = defineStore("navigation", {
state: (): NavigationState => ({
isEmbedded: true,
isReferredFromCc: false,
diff --git a/src/stores/provider.ts b/src/stores/provider.ts
index 6f63500b6..8164be1ab 100644
--- a/src/stores/provider.ts
+++ b/src/stores/provider.ts
@@ -1,19 +1,19 @@
-import { capital } from 'case'
-import { defineStore } from 'pinia'
-import { Ref, ssrRef } from '@nuxtjs/composition-api'
-import axios from 'axios'
+import { capital } from "case"
+import { defineStore } from "pinia"
+import { Ref, ssrRef } from "@nuxtjs/composition-api"
+import axios from "axios"
-import { env } from '~/utils/env'
+import { env } from "~/utils/env"
import {
AUDIO,
IMAGE,
SupportedMediaType,
supportedMediaTypes,
-} from '~/constants/media'
-import { warn } from '~/utils/console'
-import { initProviderServices } from '~/data/media-provider-service'
-import type { MediaProvider } from '~/types/media-provider'
-import type { FetchState } from '~/types/fetch-state'
+} from "~/constants/media"
+import { warn } from "~/utils/console"
+import { initProviderServices } from "~/data/media-provider-service"
+import type { MediaProvider } from "~/types/media-provider"
+import type { FetchState } from "~/types/fetch-state"
export interface ProviderState {
providers: {
@@ -44,7 +44,7 @@ const lastUpdated: Ref<Date | null> = ssrRef(null)
const updateFrequency = parseInt(env.providerUpdateFrequency, 10)
-export const useProviderStore = defineStore('provider', {
+export const useProviderStore = defineStore("provider", {
state: (): ProviderState => ({
providers: {
[AUDIO]: [],
@@ -74,10 +74,10 @@ export const useProviderStore = defineStore('provider', {
_updateFetchState(
mediaType: SupportedMediaType,
- action: 'start' | 'end',
+ action: "start" | "end",
option?: string
) {
- action === 'start'
+ action === "start"
? this._startFetching(mediaType)
: this._endFetching(mediaType, option)
},
@@ -121,7 +121,7 @@ export const useProviderStore = defineStore('provider', {
async fetchMediaTypeProviders(
mediaType: SupportedMediaType
): Promise<void> {
- this._updateFetchState(mediaType, 'start')
+ this._updateFetchState(mediaType, "start")
let sortedProviders = [] as MediaProvider[]
try {
const service = initProviderServices[mediaType](
@@ -129,19 +129,19 @@ export const useProviderStore = defineStore('provider', {
)
const res = await service.getProviderStats()
sortedProviders = sortProviders(res.data)
- this._updateFetchState(mediaType, 'end')
+ this._updateFetchState(mediaType, "end")
} catch (error: unknown) {
let errorMessage = `There was an error fetching media providers for ${mediaType}`
if (error instanceof Error) {
errorMessage =
- axios.isAxiosError(error) && 'response' in error
+ axios.isAxiosError(error) && "response" in error
? `${errorMessage}: ${error.code}`
: `${errorMessage}: ${error?.message}`
}
warn(errorMessage)
// Fallback on existing providers if there was an error
sortedProviders = this.providers[mediaType]
- this._updateFetchState(mediaType, 'end', errorMessage)
+ this._updateFetchState(mediaType, "end", errorMessage)
} finally {
this.providers[mediaType] = sortedProviders
}
diff --git a/src/stores/search.ts b/src/stores/search.ts
index 06ca74dba..4223e96e6 100644
--- a/src/stores/search.ts
+++ b/src/stores/search.ts
@@ -1,10 +1,10 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
-import { useStorage } from '@vueuse/core'
+import { useStorage } from "@vueuse/core"
-import { env } from '~/utils/env'
-import { deepClone } from '~/utils/clone'
-import type { DeepWriteable } from '~/types/utils'
+import { env } from "~/utils/env"
+import { deepClone } from "~/utils/clone"
+import type { DeepWriteable } from "~/types/utils"
import {
ALL_MEDIA,
@@ -16,13 +16,13 @@ import {
SupportedSearchType,
supportedSearchTypes,
isAdditionalSearchType,
-} from '~/constants/media'
+} from "~/constants/media"
import {
ApiQueryParams,
filtersToQueryData,
queryStringToSearchType,
queryToFilterData,
-} from '~/utils/search-query-transform'
+} from "~/utils/search-query-transform"
import {
FilterCategory,
FilterItem,
@@ -30,14 +30,14 @@ import {
filterData,
mediaFilterKeys,
mediaUniqueFilterKeys,
-} from '~/constants/filters'
-import { useProviderStore } from '~/stores/provider'
+} from "~/constants/filters"
+import { useProviderStore } from "~/stores/provider"
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-import type { Ref } from '@nuxtjs/composition-api'
+import type { Ref } from "@nuxtjs/composition-api"
-import type { Dictionary } from 'vue-router/types/router'
+import type { Dictionary } from "vue-router/types/router"
export const isSearchTypeSupported = (
st: SearchType
@@ -63,7 +63,7 @@ function computeQueryParams(
return queryKeys.reduce(
(obj, key) => {
- if (key !== 'q' && query[key]?.length) {
+ if (key !== "q" && query[key]?.length) {
obj[key] = query[key]
}
return obj
@@ -73,16 +73,16 @@ function computeQueryParams(
)
}
-export const useSearchStore = defineStore('search', {
+export const useSearchStore = defineStore("search", {
state: (): SearchState => ({
searchType: ALL_MEDIA,
- searchTerm: '',
- recentSearches: useStorage<string[]>('recent-searches', []),
+ searchTerm: "",
+ recentSearches: useStorage<string[]>("recent-searches", []),
filters: deepClone(filterData as DeepWriteable<typeof filterData>),
}),
hydrate(state) {
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/43826
- state.recentSearches = useStorage<string[]>('recent-searches', [])
+ state.recentSearches = useStorage<string[]>("recent-searches", [])
},
getters: {
filterCategories(state) {
@@ -110,7 +110,7 @@ export const useSearchStore = defineStore('search', {
*/
appliedFilterCount(state) {
const filterKeys = mediaFilterKeys[state.searchType].filter(
- (f) => f !== 'mature'
+ (f) => f !== "mature"
)
return filterKeys.reduce((count, filterCategory) => {
return (
@@ -124,7 +124,7 @@ export const useSearchStore = defineStore('search', {
*/
searchFilters(state) {
return mediaFilterKeys[state.searchType]
- .filter((filterKey) => filterKey !== 'mature')
+ .filter((filterKey) => filterKey !== "mature")
.reduce((obj, filterKey) => {
obj[filterKey] = this.filters[filterKey]
return obj
@@ -141,7 +141,7 @@ export const useSearchStore = defineStore('search', {
][]
return filterEntries.some(
([filterKey, filterItems]) =>
- filterKey !== 'mature' && filterItems.some((filter) => filter.checked)
+ filterKey !== "mature" && filterItems.some((filter) => filter.checked)
)
},
/**
@@ -155,7 +155,7 @@ export const useSearchStore = defineStore('search', {
setSearchType(type: SearchType) {
const featureFlagStore = useFeatureFlagStore()
if (
- !featureFlagStore.isOn('external_sources') &&
+ !featureFlagStore.isOn("external_sources") &&
isAdditionalSearchType(type)
) {
throw new Error(
@@ -178,7 +178,7 @@ export const useSearchStore = defineStore('search', {
*/
refreshRecentSearches() {
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/43826
- this.recentSearches = useStorage<string[]>('recent-searches', [])
+ this.recentSearches = useStorage<string[]>("recent-searches", [])
},
/** Add a new term to the list of recent search terms */
addRecentSearch(
@@ -186,7 +186,7 @@ export const useSearchStore = defineStore('search', {
) {
// No-op if feature isn't enabled
const featureFlagStore = useFeatureFlagStore()
- const saveRecentSearches = featureFlagStore.isOn('new_header')
+ const saveRecentSearches = featureFlagStore.isOn("new_header")
if (!saveRecentSearches) {
return
}
@@ -281,7 +281,7 @@ export const useSearchStore = defineStore('search', {
codeIdx?: number
code?: string
}) {
- if (typeof codeIdx === 'undefined' && typeof code === 'undefined') {
+ if (typeof codeIdx === "undefined" && typeof code === "undefined") {
throw new Error(
`Cannot toggle filter of type ${filterType}. Use code or codeIdx parameter`
)
@@ -344,7 +344,7 @@ export const useSearchStore = defineStore('search', {
path: string
urlQuery: Dictionary<string | (string | null)[]>
}) {
- if (urlQuery.q && typeof urlQuery.q === 'string') {
+ if (urlQuery.q && typeof urlQuery.q === "string") {
this.setSearchTerm(urlQuery.q.trim())
}
this.searchType = queryStringToSearchType(path)
@@ -352,8 +352,8 @@ export const useSearchStore = defineStore('search', {
// When setting filters from URL query, 'mature' has a value of 'true',
// but we need the 'mature' code. Creating a local shallow copy to prevent mutation.
const query = { ...urlQuery }
- if (query.mature === 'true') {
- query.mature = 'mature'
+ if (query.mature === "true") {
+ query.mature = "mature"
} else {
delete query.mature
}
@@ -376,24 +376,24 @@ export const useSearchStore = defineStore('search', {
item: FilterItem,
filterCategory: FilterCategory
): boolean | undefined {
- if (!['licenseTypes', 'licenses'].includes(filterCategory)) {
+ if (!["licenseTypes", "licenses"].includes(filterCategory)) {
return
}
- if (item.code === 'commercial' || item.code === 'modification') {
+ if (item.code === "commercial" || item.code === "modification") {
const targetCode = {
- commercial: 'nc',
- modification: 'nd',
+ commercial: "nc",
+ modification: "nd",
}[item.code]
return this.filters.licenses.some(
(item: FilterItem) => item.code.includes(targetCode) && item.checked
)
} else {
const dependentFilters: string[] = []
- if (item.code.includes('nc')) {
- dependentFilters.push('commercial')
+ if (item.code.includes("nc")) {
+ dependentFilters.push("commercial")
}
- if (item.code.includes('nd')) {
- dependentFilters.push('modification')
+ if (item.code.includes("nd")) {
+ dependentFilters.push("modification")
}
return this.filters.licenseTypes.some(
(item: FilterItem) =>
diff --git a/src/stores/ui.ts b/src/stores/ui.ts
index 178c3400b..584517aee 100644
--- a/src/stores/ui.ts
+++ b/src/stores/ui.ts
@@ -1,21 +1,21 @@
-import { defineStore } from 'pinia'
+import { defineStore } from "pinia"
-import { computed } from '@nuxtjs/composition-api'
+import { computed } from "@nuxtjs/composition-api"
-import { useNavigationStore } from '~/stores/navigation'
+import { useNavigationStore } from "~/stores/navigation"
-import type { OpenverseCookieState, SnackbarState } from '~/types/cookies'
-import type { BannerId, TranslationBannerId } from '~/types/banners'
+import type { OpenverseCookieState, SnackbarState } from "~/types/cookies"
+import type { BannerId, TranslationBannerId } from "~/types/banners"
-import type { Breakpoint } from '~/constants/screens'
-import { ALL_SCREEN_SIZES } from '~/constants/screens'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { cookieOptions } from '~/utils/cookies'
-import { needsTranslationBanner } from '~/utils/translation-banner'
+import type { Breakpoint } from "~/constants/screens"
+import { ALL_SCREEN_SIZES } from "~/constants/screens"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
+import { cookieOptions } from "~/utils/cookies"
+import { needsTranslationBanner } from "~/utils/translation-banner"
-import type { LocaleObject } from '@nuxtjs/i18n'
+import type { LocaleObject } from "@nuxtjs/i18n"
-const desktopBreakpoints: Breakpoint[] = ['2xl', 'xl', 'lg']
+const desktopBreakpoints: Breakpoint[] = ["2xl", "xl", "lg"]
export interface UiState {
/**
@@ -49,30 +49,30 @@ export interface UiState {
export const breakpoints = Object.keys(ALL_SCREEN_SIZES)
-export const useUiStore = defineStore('ui', {
+export const useUiStore = defineStore("ui", {
state: (): UiState => ({
- instructionsSnackbarState: 'not_shown',
+ instructionsSnackbarState: "not_shown",
innerFilterVisible: false,
isFilterDismissed: false,
isDesktopLayout: false,
- breakpoint: 'sm',
+ breakpoint: "sm",
isMobileUa: true,
dismissedBanners: [],
}),
getters: {
areInstructionsVisible(state): boolean {
- return state.instructionsSnackbarState === 'visible'
+ return state.instructionsSnackbarState === "visible"
},
desktopBreakpoints(): Breakpoint[] {
const featureFlagStore = useFeatureFlagStore()
const isNewHeaderEnabled = computed(() =>
- featureFlagStore.isOn('new_header')
+ featureFlagStore.isOn("new_header")
)
return isNewHeaderEnabled.value
? desktopBreakpoints
- : [...desktopBreakpoints, 'md']
+ : [...desktopBreakpoints, "md"]
},
/**
* On desktop, we only hide the filters sidebar if it was
@@ -105,7 +105,7 @@ export const useUiStore = defineStore('ui', {
* @example 'translation-ru'
*/
translationBannerId(): TranslationBannerId {
- return `translation-${this.currentLocale.code as LocaleObject['code']}`
+ return `translation-${this.currentLocale.code as LocaleObject["code"]}`
},
/**
* The translation banner is shown if the translated percentage is below 90%,
@@ -124,7 +124,7 @@ export const useUiStore = defineStore('ui', {
shouldShowMigrationBanner(): boolean {
const navigationStore = useNavigationStore()
return (
- !this.dismissedBanners.includes('cc-referral') &&
+ !this.dismissedBanners.includes("cc-referral") &&
navigationStore.isReferredFromCc
)
},
@@ -132,13 +132,13 @@ export const useUiStore = defineStore('ui', {
actions: {
showInstructionsSnackbar() {
- if (this.instructionsSnackbarState === 'not_shown') {
- this.instructionsSnackbarState = 'visible'
+ if (this.instructionsSnackbarState === "not_shown") {
+ this.instructionsSnackbarState = "visible"
}
},
hideInstructionsSnackbar() {
- this.instructionsSnackbarState = 'dismissed'
+ this.instructionsSnackbarState = "dismissed"
},
/**
@@ -160,20 +160,20 @@ export const useUiStore = defineStore('ui', {
updateCookies() {
const opts = { ...cookieOptions }
- if (!useFeatureFlagStore().isOn('new_header')) {
- opts.sameSite = 'none'
+ if (!useFeatureFlagStore().isOn("new_header")) {
+ opts.sameSite = "none"
}
this.$nuxt.$cookies.setAll([
{
- name: 'uiInstructionsSnackbarState',
+ name: "uiInstructionsSnackbarState",
value: this.instructionsSnackbarState,
opts,
},
- { name: 'uiIsFilterDismissed', value: this.isFilterDismissed, opts },
- { name: 'uiBreakpoint', value: this.breakpoint, opts },
- { name: 'uiIsMobileUa', value: this.isMobileUa, opts },
- { name: 'uiDismissedBanners', value: this.dismissedBanners, opts },
+ { name: "uiIsFilterDismissed", value: this.isFilterDismissed, opts },
+ { name: "uiBreakpoint", value: this.breakpoint, opts },
+ { name: "uiIsMobileUa", value: this.isMobileUa, opts },
+ { name: "uiDismissedBanners", value: this.dismissedBanners, opts },
])
},
@@ -188,11 +188,11 @@ export const useUiStore = defineStore('ui', {
}
this.breakpoint = breakpoint
- const sameSite = useFeatureFlagStore().isOn('new_header')
+ const sameSite = useFeatureFlagStore().isOn("new_header")
? cookieOptions.sameSite
- : 'none'
+ : "none"
- this.$nuxt.$cookies.set('uiBreakpoint', this.breakpoint, {
+ this.$nuxt.$cookies.set("uiBreakpoint", this.breakpoint, {
...cookieOptions,
sameSite,
})
@@ -210,11 +210,11 @@ export const useUiStore = defineStore('ui', {
this.innerFilterVisible = visible
if (this.isDesktopLayout) {
this.isFilterDismissed = !visible
- const sameSite = useFeatureFlagStore().isOn('new_header')
+ const sameSite = useFeatureFlagStore().isOn("new_header")
? cookieOptions.sameSite
- : 'none'
+ : "none"
- this.$nuxt.$cookies.set('uiIsFilterDismissed', this.isFilterDismissed, {
+ this.$nuxt.$cookies.set("uiIsFilterDismissed", this.isFilterDismissed, {
...cookieOptions,
sameSite,
})
@@ -237,11 +237,11 @@ export const useUiStore = defineStore('ui', {
}
this.dismissedBanners.push(bannerId)
- const sameSite = useFeatureFlagStore().isOn('new_header')
+ const sameSite = useFeatureFlagStore().isOn("new_header")
? cookieOptions.sameSite
- : 'none'
+ : "none"
- this.$nuxt.$cookies.set('uiDismissedBanners', this.dismissedBanners, {
+ this.$nuxt.$cookies.set("uiDismissedBanners", this.dismissedBanners, {
...cookieOptions,
sameSite,
})
diff --git a/src/stories/Introduction.stories.mdx b/src/stories/Introduction.stories.mdx
index 87784c86a..416365175 100644
--- a/src/stories/Introduction.stories.mdx
+++ b/src/stories/Introduction.stories.mdx
@@ -1,4 +1,4 @@
-import { Meta } from '@storybook/addon-docs'
+import { Meta } from "@storybook/addon-docs"
<Meta title="Introduction/Openverse UI" />
diff --git a/src/styles/accent.css b/src/styles/accent.css
index 7d8e940ac..6dbf8d4bb 100644
--- a/src/styles/accent.css
+++ b/src/styles/accent.css
@@ -1,10 +1,10 @@
:root {
/* Accent color tints checkbox, radio, range and progress. */
- accent-color: theme('colors.pink');
+ accent-color: theme("colors.pink");
}
:focus-visible {
- outline-color: theme('colors.pink');
+ outline-color: theme("colors.pink");
}
::selection {
diff --git a/src/styles/tailwind.css b/src/styles/tailwind.css
index ecacfff6c..db1ba088b 100644
--- a/src/styles/tailwind.css
+++ b/src/styles/tailwind.css
@@ -28,10 +28,10 @@
}
/* Removes the cross icon to clear the field */
- input[type='search']::-webkit-search-decoration,
- input[type='search']::-webkit-search-cancel-button,
- input[type='search']::-webkit-search-results-button,
- input[type='search']::-webkit-search-results-decoration {
+ input[type="search"]::-webkit-search-decoration,
+ input[type="search"]::-webkit-search-cancel-button,
+ input[type="search"]::-webkit-search-results-button,
+ input[type="search"]::-webkit-search-results-decoration {
-webkit-appearance: none;
}
}
diff --git a/src/types/banners.ts b/src/types/banners.ts
index 91bb1a884..eed51c7d9 100644
--- a/src/types/banners.ts
+++ b/src/types/banners.ts
@@ -1,4 +1,4 @@
-import type { LocaleObject } from '@nuxtjs/i18n'
+import type { LocaleObject } from "@nuxtjs/i18n"
-export type TranslationBannerId = `translation-${LocaleObject['code']}`
-export type BannerId = TranslationBannerId | 'cc-referral'
+export type TranslationBannerId = `translation-${LocaleObject["code"]}`
+export type BannerId = TranslationBannerId | "cc-referral"
diff --git a/src/types/button.ts b/src/types/button.ts
index e6b410776..e4aaf7d4d 100644
--- a/src/types/button.ts
+++ b/src/types/button.ts
@@ -1,30 +1,30 @@
-export const buttonForms = ['VLink', 'button'] as const
+export const buttonForms = ["VLink", "button"] as const
export type ButtonForm = typeof buttonForms[number]
export const buttonVariants = [
- 'primary',
- 'secondary',
- 'secondary-bordered',
- 'secondary-filled',
- 'menu',
- 'text',
- 'action-menu',
- 'action-menu-bordered',
- 'action-menu-bordered-pressed',
- 'action-menu-muted',
- 'action-menu-muted-pressed',
- 'plain',
- 'plain--avoid',
- 'full',
+ "primary",
+ "secondary",
+ "secondary-bordered",
+ "secondary-filled",
+ "menu",
+ "text",
+ "action-menu",
+ "action-menu-bordered",
+ "action-menu-bordered-pressed",
+ "action-menu-muted",
+ "action-menu-muted-pressed",
+ "plain",
+ "plain--avoid",
+ "full",
] as const
export type ButtonVariant = typeof buttonVariants[number]
-export const buttonSizes = ['large', 'medium', 'small', 'disabled'] as const
+export const buttonSizes = ["large", "medium", "small", "disabled"] as const
export type ButtonSize = typeof buttonSizes[number]
-export const buttonTypes = ['button', 'submit', 'reset'] as const
+export const buttonTypes = ["button", "submit", "reset"] as const
export type ButtonType = typeof buttonTypes[number]
-export const buttonConnections = ['start', 'end', 'none', 'all'] as const
+export const buttonConnections = ["start", "end", "none", "all"] as const
export type ButtonConnections = typeof buttonConnections[number]
diff --git a/src/types/cookies.ts b/src/types/cookies.ts
index b5751f9c9..af6d452ba 100644
--- a/src/types/cookies.ts
+++ b/src/types/cookies.ts
@@ -1,16 +1,16 @@
-import type { FeatureState } from '~/constants/feature-flag'
-import { isProd } from '~/utils/node-env'
+import type { FeatureState } from "~/constants/feature-flag"
+import { isProd } from "~/utils/node-env"
-import type { BannerId } from '~/types/banners'
-import type { Breakpoint } from '~/constants/screens'
+import type { BannerId } from "~/types/banners"
+import type { Breakpoint } from "~/constants/screens"
-import type { CookieSerializeOptions } from 'cookie'
+import type { CookieSerializeOptions } from "cookie"
-export type SnackbarState = 'not_shown' | 'visible' | 'dismissed'
+export type SnackbarState = "not_shown" | "visible" | "dismissed"
export const cookieOptions: CookieSerializeOptions = {
- path: '/',
- sameSite: 'strict',
+ path: "/",
+ sameSite: "strict",
maxAge: 60 * 60 * 24 * 60, // 60 days
secure: isProd,
}
diff --git a/src/types/feature-flag.ts b/src/types/feature-flag.ts
index 211cbeaa4..f45736d9d 100644
--- a/src/types/feature-flag.ts
+++ b/src/types/feature-flag.ts
@@ -1,5 +1,5 @@
-import type { FeatureState, FlagStatus } from '~/constants/feature-flag'
-import type { DeployEnv } from '~/constants/deploy-env'
+import type { FeatureState, FlagStatus } from "~/constants/feature-flag"
+import type { DeployEnv } from "~/constants/deploy-env"
export interface FeatureFlag {
status: FlagStatus | Record<DeployEnv, FlagStatus>
diff --git a/src/types/item-group.ts b/src/types/item-group.ts
index ac5fae608..b553cba06 100644
--- a/src/types/item-group.ts
+++ b/src/types/item-group.ts
@@ -1,16 +1,16 @@
-import type { InjectionKey, Ref } from '@nuxtjs/composition-api'
+import type { InjectionKey, Ref } from "@nuxtjs/composition-api"
export const itemGroupDirections = [
- 'vertical',
- 'horizontal',
- 'columns',
+ "vertical",
+ "horizontal",
+ "columns",
] as const
export type ItemGroupDirection = typeof itemGroupDirections[number]
-export const itemGroupTypes = ['list', 'menu', 'radiogroup'] as const
+export const itemGroupTypes = ["list", "menu", "radiogroup"] as const
export type ItemGroupType = typeof itemGroupTypes[number]
-export const itemGroupSizes = ['small', 'medium'] as const
+export const itemGroupSizes = ["small", "medium"] as const
export type ItemGroupSize = typeof itemGroupSizes[number]
export type VIemGroupContext = {
@@ -21,7 +21,7 @@ export type VIemGroupContext = {
}
export const VItemGroupContextKey = Symbol(
- 'VItemGroupContext'
+ "VItemGroupContext"
) as InjectionKey<VIemGroupContext>
export type VIemGroupFocusContext = {
@@ -32,5 +32,5 @@ export type VIemGroupFocusContext = {
}
export const VItemGroupFocusContextKey = Symbol(
- 'VItemGroupFocusContext'
+ "VItemGroupFocusContext"
) as InjectionKey<VIemGroupFocusContext>
diff --git a/src/types/media.ts b/src/types/media.ts
index 1e31ce512..84dc139d0 100644
--- a/src/types/media.ts
+++ b/src/types/media.ts
@@ -1,5 +1,5 @@
-import type { SupportedMediaType } from '~/constants/media'
-import type { License, LicenseVersion } from '~/constants/license'
+import type { SupportedMediaType } from "~/constants/media"
+import type { License, LicenseVersion } from "~/constants/license"
export interface Tag {
name: string
@@ -47,7 +47,7 @@ export interface Media {
}
export interface ImageDetail extends Media {
- frontendMediaType: 'image'
+ frontendMediaType: "image"
height?: number
width?: number
@@ -64,7 +64,7 @@ export interface AudioSet {
}
export interface AudioDetail extends Media {
- frontendMediaType: 'audio'
+ frontendMediaType: "audio"
audio_set?: AudioSet
genres?: string[]
@@ -81,14 +81,14 @@ export interface AudioDetail extends Media {
}
export type DetailFromMediaType<T extends SupportedMediaType> =
- T extends 'audio' ? AudioDetail : ImageDetail
+ T extends "audio" ? AudioDetail : ImageDetail
/**
* This interface is a subset of `Media` that types dictionaries sent by the API
* being decoded in the `decodeMediaData` function.
*/
export interface ApiMedia
- extends Omit<Media, 'frontendMediaType' | 'title' | 'originalTitle'> {
+ extends Omit<Media, "frontendMediaType" | "title" | "originalTitle"> {
title?: string
originalTitle?: string
}
diff --git a/src/types/modal.ts b/src/types/modal.ts
index 06c8beb5d..0e8507dfa 100644
--- a/src/types/modal.ts
+++ b/src/types/modal.ts
@@ -1,2 +1,2 @@
-export type ModalVariant = 'default' | 'full' | 'two-thirds'
-export type ModalColorMode = 'dark' | 'light'
+export type ModalVariant = "default" | "full" | "two-thirds"
+export type ModalColorMode = "dark" | "light"
diff --git a/src/types/prop-extraction.ts b/src/types/prop-extraction.ts
index 547395ab1..3ef0a0978 100644
--- a/src/types/prop-extraction.ts
+++ b/src/types/prop-extraction.ts
@@ -1,7 +1,7 @@
import type {
ExtractPropTypes,
ExtractDefaultPropTypes,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
/**
* Correctly extracts optional prop types.
diff --git a/src/types/provides.ts b/src/types/provides.ts
index 835c9c139..360cc2079 100644
--- a/src/types/provides.ts
+++ b/src/types/provides.ts
@@ -1,4 +1,4 @@
-import type { InjectionKey, Ref } from '@nuxtjs/composition-api'
+import type { InjectionKey, Ref } from "@nuxtjs/composition-api"
export const IsHeaderScrolledKey = Symbol() as InjectionKey<Ref<boolean>>
export const IsSidebarVisibleKey = Symbol() as InjectionKey<Ref<boolean>>
diff --git a/src/types/tabs.ts b/src/types/tabs.ts
index 5bb065cec..15ce76520 100644
--- a/src/types/tabs.ts
+++ b/src/types/tabs.ts
@@ -1,8 +1,8 @@
-import type { ComputedRef, InjectionKey, Ref } from '@nuxtjs/composition-api'
-import type { ComponentPublicInstance } from '@vue/runtime-dom'
+import type { ComputedRef, InjectionKey, Ref } from "@nuxtjs/composition-api"
+import type { ComponentPublicInstance } from "@vue/runtime-dom"
-export type TabActivation = 'manual' | 'auto'
-export type TabVariant = 'bordered' | 'plain'
+export type TabActivation = "manual" | "auto"
+export type TabVariant = "bordered" | "plain"
export type TabsState = {
// State
selectedId: Ref<string>
diff --git a/src/utils/a11y/supports-disabled-attribute.ts b/src/utils/a11y/supports-disabled-attribute.ts
index 6b21668b3..cf67cc1e3 100644
--- a/src/utils/a11y/supports-disabled-attribute.ts
+++ b/src/utils/a11y/supports-disabled-attribute.ts
@@ -2,5 +2,5 @@
* @see https://github.com/reakit/reakit/blob/f05d36daa6fbcc52c70cf2c71baea69025aa2402/packages/reakit/src/Tabbable/Tabbable.ts#L50
*/
export function supportsDisabledAttribute(element: Element) {
- return ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'].includes(element.tagName)
+ return ["BUTTON", "INPUT", "SELECT", "TEXTAREA"].includes(element.tagName)
}
diff --git a/src/utils/attribution-html.ts b/src/utils/attribution-html.ts
index 5c79c941e..6e24451cf 100644
--- a/src/utils/attribution-html.ts
+++ b/src/utils/attribution-html.ts
@@ -4,17 +4,17 @@
* backend, or open an issue to track it.
*/
-import type { Media } from '~/types/media'
+import type { Media } from "~/types/media"
import {
getElements,
getFullLicenseName,
isPublicDomain,
-} from '~/utils/license'
-import type { LicenseElement } from '~/constants/license'
+} from "~/utils/license"
+import type { LicenseElement } from "~/constants/license"
-import enJson from '~/locales/en.json'
+import enJson from "~/locales/en.json"
-import type VueI18n from 'vue-i18n'
+import type VueI18n from "vue-i18n"
/* Helper functions */
@@ -33,10 +33,10 @@ const h = (
): string => {
const map = Object.entries(attrs)
.map(([key, value]) => `${key}="${value}"`)
- .join(' ')
+ .join(" ")
const opening = map ? `<${name} ${map}>` : `<${name}>`
const closing = `</${name}>`
- return `${opening}${(children ?? []).join('\n')}${closing}`
+ return `${opening}${(children ?? []).join("\n")}${closing}`
}
/**
@@ -70,15 +70,15 @@ const fakeT = (
[key: string]: string | NestedRecord
}
- const segments = path.split('.')
- let fraction: NestedRecord = enJson['media-details'].reuse.credit
+ const segments = path.split(".")
+ let fraction: NestedRecord = enJson["media-details"].reuse.credit
let text: string | undefined = undefined
segments.forEach((segment) => {
const piece = fraction[segment]
- if (typeof piece === 'string') text = piece
+ if (typeof piece === "string") text = piece
else fraction = piece
})
- return text ? fmt(text, replacements) : ''
+ return text ? fmt(text, replacements) : ""
}
/**
@@ -88,11 +88,11 @@ const fakeT = (
* @returns the HTML markup of the `<img>` tag
*/
const licenseElementImg = (licenseElement: LicenseElement): string => {
- const filename = licenseElement.replace('-', '.')
+ const filename = licenseElement.replace("-", ".")
const src = `https://mirrors.creativecommons.org/presskit/icons/${filename}.svg`
- return h('img', {
+ return h("img", {
src,
- style: 'height: 1em; margin-right: 0.125em; display: inline;',
+ style: "height: 1em; margin-right: 0.125em; display: inline;",
})
}
@@ -104,7 +104,7 @@ const licenseElementImg = (licenseElement: LicenseElement): string => {
* @returns the HTML markup of the `<a>` tag
*/
const extLink = (href: string, text: string) =>
- h('a', { target: '_blank', rel: 'noopener noreferrer', href }, [text])
+ h("a", { target: "_blank", rel: "noopener noreferrer", href }, [text])
/* Interfaces */
@@ -114,13 +114,13 @@ const extLink = (href: string, text: string) =>
*/
export type AttributableMedia = Pick<
Media,
- | 'originalTitle'
- | 'foreign_landing_url'
- | 'creator'
- | 'creator_url'
- | 'license'
- | 'license_version'
- | 'license_url'
+ | "originalTitle"
+ | "foreign_landing_url"
+ | "creator"
+ | "creator_url"
+ | "license"
+ | "license_version"
+ | "license_url"
>
/**
@@ -150,11 +150,11 @@ export const getAttribution = (
includeIcons: true,
}
): string => {
- if (!mediaItem) return ''
+ if (!mediaItem) return ""
const isPd = isPublicDomain(mediaItem.license)
- const i18nBase = 'media-details.reuse.credit'
+ const i18nBase = "media-details.reuse.credit"
const tFn = i18n
? (key: string, values?: VueI18n.Values) =>
i18n.t(`${i18nBase}.${key}`, values).toString()
@@ -162,10 +162,10 @@ export const getAttribution = (
/* Title */
- let title = mediaItem.originalTitle || tFn('generic-title')
+ let title = mediaItem.originalTitle || tFn("generic-title")
if (!isPlaintext && mediaItem.foreign_landing_url)
title = extLink(mediaItem.foreign_landing_url, title)
- if (mediaItem.originalTitle) title = tFn('actual-title', { title })
+ if (mediaItem.originalTitle) title = tFn("actual-title", { title })
/* License */
@@ -174,12 +174,12 @@ export const getAttribution = (
mediaItem.license_version,
i18n
)
- let licenseIcons = ''
+ let licenseIcons = ""
if (includeIcons && mediaItem.license) {
const elements = getElements(mediaItem.license)
const icons = elements.map((element) => licenseElementImg(element))
// Icons are only rendered if present for every element
- if (!icons.includes('')) licenseIcons = icons.join('')
+ if (!icons.includes("")) licenseIcons = icons.join("")
}
let license = `${fullLicenseName} ${licenseIcons}`.trim()
if (!isPlaintext && mediaItem.license_url)
@@ -189,15 +189,15 @@ export const getAttribution = (
const attributionParts: Record<string, string> = {
title,
- 'marked-licensed': tFn(isPd ? 'marked' : 'licensed'),
+ "marked-licensed": tFn(isPd ? "marked" : "licensed"),
license: license,
- 'view-legal': '',
- creator: '',
+ "view-legal": "",
+ creator: "",
}
if (isPlaintext && mediaItem.license_url) {
- attributionParts['view-legal'] = tFn('view-legal-text', {
- 'terms-copy': tFn(isPd ? 'terms-text' : 'copy-text'),
+ attributionParts["view-legal"] = tFn("view-legal-text", {
+ "terms-copy": tFn(isPd ? "terms-text" : "copy-text"),
url: `${mediaItem.license_url}?ref=openverse`,
})
}
@@ -206,14 +206,14 @@ export const getAttribution = (
let creator = mediaItem.creator
if (!isPlaintext && mediaItem.creator_url)
creator = extLink(mediaItem.creator_url, creator)
- attributionParts.creator = tFn('creator-text', {
- 'creator-name': creator,
+ attributionParts.creator = tFn("creator-text", {
+ "creator-name": creator,
})
}
- const attribution = tFn('text', attributionParts).replace(/\s{2}/g, ' ')
+ const attribution = tFn("text", attributionParts).replace(/\s{2}/g, " ")
return isPlaintext
? attribution
- : h('p', { class: 'attribution' }, [attribution])
+ : h("p", { class: "attribution" }, [attribution])
}
diff --git a/src/utils/clone.ts b/src/utils/clone.ts
index 48a0c0cb2..c6cb0b20f 100644
--- a/src/utils/clone.ts
+++ b/src/utils/clone.ts
@@ -1,3 +1,3 @@
-import rfdc from 'rfdc'
+import rfdc from "rfdc"
export const deepClone = rfdc()
diff --git a/src/utils/console.ts b/src/utils/console.ts
index 165b63dce..b6cf475a7 100644
--- a/src/utils/console.ts
+++ b/src/utils/console.ts
@@ -1,12 +1,12 @@
-import { isProd, isClient } from '~/utils/node-env'
+import { isProd, isClient } from "~/utils/node-env"
-export const getLogger = (level: 'log' | 'warn' | 'error') =>
+export const getLogger = (level: "log" | "warn" | "error") =>
isProd && isClient
? () => {
// do nothing
}
: console[level]
-export const warn = getLogger('warn')
-export const log = getLogger('log')
-export const error = getLogger('error')
+export const warn = getLogger("warn")
+export const log = getLogger("log")
+export const error = getLogger("error")
diff --git a/src/utils/cookies.ts b/src/utils/cookies.ts
index b4e2e2c78..7c0a8869b 100644
--- a/src/utils/cookies.ts
+++ b/src/utils/cookies.ts
@@ -1,10 +1,10 @@
-import { isProd } from '~/utils/node-env'
+import { isProd } from "~/utils/node-env"
-import type { CookieSerializeOptions } from 'cookie'
+import type { CookieSerializeOptions } from "cookie"
export const cookieOptions: CookieSerializeOptions = {
- path: '/',
- sameSite: 'strict',
+ path: "/",
+ sameSite: "strict",
maxAge: 60 * 60 * 24 * 60, // 60 days
secure: isProd,
}
diff --git a/src/utils/decode-data.ts b/src/utils/decode-data.ts
index 121c6a8ea..02bf31d81 100644
--- a/src/utils/decode-data.ts
+++ b/src/utils/decode-data.ts
@@ -5,8 +5,8 @@
*
* @param data - the string to unescape so that it can be rendered
*/
-export const decodeData = (data = ''): string => {
- if (!data) return ''
+export const decodeData = (data = ""): string => {
+ if (!data) return ""
try {
const regexes = [/\\x([\d\w]{2})/gi, /\\u([\d\w]{4})/gi]
diff --git a/src/utils/decode-media-data.ts b/src/utils/decode-media-data.ts
index 51609c167..4bd6624bb 100644
--- a/src/utils/decode-media-data.ts
+++ b/src/utils/decode-media-data.ts
@@ -1,15 +1,15 @@
-import { title as titleCase } from 'case'
+import { title as titleCase } from "case"
-import { decodeData as decodeString } from '~/utils/decode-data'
-import type { ApiMedia, Media, Tag } from '~/types/media'
-import type { MediaType } from '~/constants/media'
-import { AUDIO, IMAGE, MODEL_3D, VIDEO } from '~/constants/media'
+import { decodeData as decodeString } from "~/utils/decode-data"
+import type { ApiMedia, Media, Tag } from "~/types/media"
+import type { MediaType } from "~/constants/media"
+import { AUDIO, IMAGE, MODEL_3D, VIDEO } from "~/constants/media"
const mediaTypeExtensions: Record<MediaType, string[]> = {
- [IMAGE]: ['jpg', 'jpeg', 'png', 'gif', 'svg'],
- [AUDIO]: ['mp3', 'wav', 'ogg', 'flac', 'aac', 'aiff', 'mp32'],
- [VIDEO]: ['mp4', 'webm', 'mkv', 'avi', 'mov', 'wmv', 'flv', 'mpg', 'mpeg'],
- [MODEL_3D]: ['fbx', 'obj', 'stl', 'dae', '3ds', 'blend', 'max', 'obj', 'ply'],
+ [IMAGE]: ["jpg", "jpeg", "png", "gif", "svg"],
+ [AUDIO]: ["mp3", "wav", "ogg", "flac", "aac", "aiff", "mp32"],
+ [VIDEO]: ["mp4", "webm", "mkv", "avi", "mov", "wmv", "flv", "mpg", "mpeg"],
+ [MODEL_3D]: ["fbx", "obj", "stl", "dae", "3ds", "blend", "max", "obj", "ply"],
}
const matchers = [/jpe?g$/i, /tiff?$/i, /mp32?$/i]
@@ -31,10 +31,10 @@ const isFiletypeMatching = (extension: string, filetype?: string) => {
}
const extractPartAfterLastDot = (str?: string) => {
if (!str) {
- return ''
+ return ""
}
- const parts = str.split('.')
- return parts.length ? parts[parts.length - 1].toLowerCase() : ''
+ const parts = str.split(".")
+ return parts.length ? parts[parts.length - 1].toLowerCase() : ""
}
/**
@@ -48,14 +48,14 @@ const stripExtension = (
media: ApiMedia
) => {
const filetype = media.filetype ?? extractPartAfterLastDot(media.url)
- const titleParts = title.split('.')
+ const titleParts = title.split(".")
if (
mediaTypeExtensions[mediaType].includes(filetype) &&
isFiletypeMatching(extractPartAfterLastDot(title), filetype)
) {
titleParts.pop()
}
- return titleParts.join('.')
+ return titleParts.join(".")
}
/**
* Corrects the encoding of the media title, or uses the media type as the title.
@@ -82,7 +82,7 @@ const mediaTitle = (
*/
export const decodeMediaData = <T extends Media>(
media: ApiMedia,
- mediaType: T['frontendMediaType']
+ mediaType: T["frontendMediaType"]
): T =>
({
...media,
diff --git a/src/utils/deep-freeze.ts b/src/utils/deep-freeze.ts
index e4189d447..244c9c334 100644
--- a/src/utils/deep-freeze.ts
+++ b/src/utils/deep-freeze.ts
@@ -1,4 +1,4 @@
-import type { DeepReadonly } from '@nuxtjs/composition-api'
+import type { DeepReadonly } from "@nuxtjs/composition-api"
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#examples
@@ -14,7 +14,7 @@ export function deepFreeze<T>(object: T): DeepReadonly<T> {
// @ts-ignore We got the property name from getOwnPropertyNames so this is safe
const value = object[name]
- if (value && typeof value === 'object') {
+ if (value && typeof value === "object") {
deepFreeze(value)
}
}
diff --git a/src/utils/dom.ts b/src/utils/dom.ts
index 8a57d7fd9..39a46859b 100644
--- a/src/utils/dom.ts
+++ b/src/utils/dom.ts
@@ -1,6 +1,6 @@
// Credit: https://github.com/tailwindlabs/headlessui/
-import type { ComponentPublicInstance } from '@vue/runtime-dom'
-import type { Ref } from '@nuxtjs/composition-api'
+import type { ComponentPublicInstance } from "@vue/runtime-dom"
+import type { Ref } from "@nuxtjs/composition-api"
export function getDomElement<T extends Element | ComponentPublicInstance>(
ref?: Ref<T | null>
@@ -8,5 +8,5 @@ export function getDomElement<T extends Element | ComponentPublicInstance>(
if (ref == null) return null
if (ref.value == null) return null
- return '$el' in ref.value ? (ref.value.$el as T | null) : ref.value
+ return "$el" in ref.value ? (ref.value.$el as T | null) : ref.value
}
diff --git a/src/utils/env.ts b/src/utils/env.ts
index 7f3e995f6..8d089ce14 100644
--- a/src/utils/env.ts
+++ b/src/utils/env.ts
@@ -1,4 +1,4 @@
-const apiUrl = process.env.API_URL ?? 'https://api.openverse.engineering/'
+const apiUrl = process.env.API_URL ?? "https://api.openverse.engineering/"
/**
* Default environment variables are set on this key. Defaults are fallbacks to existing env vars.
@@ -6,8 +6,8 @@ const apiUrl = process.env.API_URL ?? 'https://api.openverse.engineering/'
* providerUpdateFrequency - how often we should re-fetch provider statistics.
*/
export const env = {
- apiUrl: apiUrl.endsWith('/') ? apiUrl : `${apiUrl}/`,
- filterStorageKey: 'openverse-filter-visibility',
- savedSearchCount: '4',
+ apiUrl: apiUrl.endsWith("/") ? apiUrl : `${apiUrl}/`,
+ filterStorageKey: "openverse-filter-visibility",
+ savedSearchCount: "4",
providerUpdateFrequency: `${60 * 60 * 1000}`, // 1 hour
} as const
diff --git a/src/utils/focus-management.ts b/src/utils/focus-management.ts
index c68c40efe..4056a9a18 100644
--- a/src/utils/focus-management.ts
+++ b/src/utils/focus-management.ts
@@ -1,14 +1,14 @@
// Credit: https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-vue/src/utils/focus-management.ts
-import { getDomElement } from '~/utils/dom'
+import { getDomElement } from "~/utils/dom"
-import type { Ref } from '@nuxtjs/composition-api'
+import type { Ref } from "@nuxtjs/composition-api"
function getOwnerDocument<T extends Element | Ref<Element | null>>(
element: T | null | undefined
) {
- if (typeof window === 'undefined') return null
+ if (typeof window === "undefined") return null
if (element instanceof Node) return element.ownerDocument
- if (element && Object.prototype.hasOwnProperty.call(element, 'value')) {
+ if (element && Object.prototype.hasOwnProperty.call(element, "value")) {
const domElement = getDomElement(element)
if (domElement) return domElement.ownerDocument
}
@@ -19,18 +19,18 @@ function getOwnerDocument<T extends Element | Ref<Element | null>>(
// Credit:
// - https://stackoverflow.com/a/30753870
const focusableSelector = [
- '[contentEditable=true]',
- '[tabindex]',
- 'a[href]',
- 'area[href]',
- 'button:not([disabled])',
- 'iframe',
- 'input:not([disabled])',
- 'select:not([disabled])',
- 'textarea:not([disabled])',
+ "[contentEditable=true]",
+ "[tabindex]",
+ "a[href]",
+ "area[href]",
+ "button:not([disabled])",
+ "iframe",
+ "input:not([disabled])",
+ "select:not([disabled])",
+ "textarea:not([disabled])",
]
.map(
- process.env.NODE_ENV === 'test'
+ process.env.NODE_ENV === "test"
? // TODO: Remove this once JSDOM fixes the issue where an element that is
// "hidden" can be the document.activeElement, because this is not possible
// in real browsers.
@@ -38,7 +38,7 @@ const focusableSelector = [
`${selector}:not([tabindex='-1']):not([style*='display: none'])`
: (selector) => `${selector}:not([tabindex='-1'])`
)
- .join(',')
+ .join(",")
export const Focus = Object.freeze({
/** Focus the first non-disabled element */
@@ -58,10 +58,10 @@ export const Focus = Object.freeze({
})
export const FocusResult = Object.freeze({
- Error: 'Error' as const,
- Overflow: 'Overflow' as const,
- Success: 'Success' as const,
- Underflow: 'Underflow' as const,
+ Error: "Error" as const,
+ Overflow: "Overflow" as const,
+ Success: "Success" as const,
+ Underflow: "Underflow" as const,
})
export const Direction = Object.freeze({ Next: 1, Previous: -1 })
@@ -83,7 +83,7 @@ export function focusElement(element: HTMLElement | null) {
}
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select
-const selectableSelector = ['textarea', 'input'].join(',')
+const selectableSelector = ["textarea", "input"].join(",")
function isSelectableElement(
element: Element | null
): element is HTMLInputElement | HTMLTextAreaElement {
@@ -127,7 +127,7 @@ export function focusIn(container: HTMLElement | HTMLElement[], focus: number) {
if (focus & (Focus.Previous | Focus.Last)) return Direction.Previous
throw new Error(
- 'Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last'
+ "Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last"
)
})()
@@ -138,7 +138,7 @@ export function focusIn(container: HTMLElement | HTMLElement[], focus: number) {
if (focus & Focus.Last) return elements.length - 1
throw new Error(
- 'Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last'
+ "Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last"
)
})()
@@ -165,10 +165,10 @@ export function focusIn(container: HTMLElement | HTMLElement[], focus: number) {
offset += direction
} while (next !== ownerDocument.activeElement)
if (
- !next.hasAttribute('tabindex') ||
- next.getAttribute('tabindex') === '-1'
+ !next.hasAttribute("tabindex") ||
+ next.getAttribute("tabindex") === "-1"
) {
- next.setAttribute('tabindex', '0')
+ next.setAttribute("tabindex", "0")
}
if (focus & (Focus.Next | Focus.Previous) && isSelectableElement(next)) {
diff --git a/src/utils/get-additional-sources.ts b/src/utils/get-additional-sources.ts
index d5a9d2984..2e42c17a3 100644
--- a/src/utils/get-additional-sources.ts
+++ b/src/utils/get-additional-sources.ts
@@ -1,11 +1,11 @@
-import buildUrl from 'build-url'
+import buildUrl from "build-url"
-import type { MediaType } from '~/constants/media'
-import type { ApiQueryParams } from '~/utils/search-query-transform'
+import type { MediaType } from "~/constants/media"
+import type { ApiQueryParams } from "~/utils/search-query-transform"
-import { MODEL_3D } from '~/constants/media'
+import { MODEL_3D } from "~/constants/media"
-import type { BuildUrlOptions } from 'build-url'
+import type { BuildUrlOptions } from "build-url"
/**
* Describes the query format used by the URL builder functions of additional
@@ -25,7 +25,7 @@ interface AdditionalSearchQuery {
const transformSearchQuery = (
query: ApiQueryParams
): AdditionalSearchQuery => ({
- q: query.q ?? '',
+ q: query.q ?? "",
})
type SearchFunctions = {
@@ -60,101 +60,101 @@ interface AdditionalSource {
*/
const additionalSourceBuilders: AdditionalSourceBuilder[] = [
{
- name: 'Centre For Ageing Better',
+ name: "Centre For Ageing Better",
image: (search) => ({
- url: 'https://ageingbetter.resourcespace.com/pages/search.php',
+ url: "https://ageingbetter.resourcespace.com/pages/search.php",
queryParams: {
search: search.q,
},
}),
},
{
- name: 'EDU images',
+ name: "EDU images",
image: (search) => ({
- url: 'https://images.all4ed.org',
+ url: "https://images.all4ed.org",
queryParams: {
s: search.q,
},
}),
},
{
- name: 'Google Images',
+ name: "Google Images",
image: (search) => ({
- url: 'https://www.google.com/search',
+ url: "https://www.google.com/search",
queryParams: {
q: search.q,
- tbm: 'isch', // this means 'search images'
- tbs: 'il:cl',
+ tbm: "isch", // this means 'search images'
+ tbs: "il:cl",
},
}),
},
{
- name: 'Images of Empowerment',
+ name: "Images of Empowerment",
image: (search) => ({
- url: 'https://www.imagesofempowerment.org/',
+ url: "https://www.imagesofempowerment.org/",
queryParams: {
s: search.q,
},
}),
},
{
- name: 'Open Clip Art Library',
+ name: "Open Clip Art Library",
image: (search) => ({
- url: 'http://www.openclipart.org/search/',
+ url: "http://www.openclipart.org/search/",
queryParams: {
query: search.q,
},
}),
},
{
- name: 'Nappy',
+ name: "Nappy",
image: (search) => ({
- url: 'https://www.nappy.co/',
+ url: "https://www.nappy.co/",
queryParams: {
s: search.q,
},
}),
},
{
- name: 'The Greats',
+ name: "The Greats",
image: (search) => ({
- url: 'https://www.thegreats.co/artworks/',
+ url: "https://www.thegreats.co/artworks/",
queryParams: {
- theme: '0',
+ theme: "0",
search: search.q,
},
}),
},
{
- name: 'ccMixter',
+ name: "ccMixter",
audio: (search) => ({
// no https :(
- url: 'http://dig.ccmixter.org/search',
+ url: "http://dig.ccmixter.org/search",
queryParams: {
- lic: 'open',
+ lic: "open",
searchp: search.q,
},
}),
},
{
- name: 'SoundCloud',
+ name: "SoundCloud",
audio: (search) => {
return {
- url: 'https://soundcloud.com/search/sounds',
+ url: "https://soundcloud.com/search/sounds",
queryParams: {
q: search.q,
- 'filter.license': 'to_share', // @todo: choose which type from the search object
+ "filter.license": "to_share", // @todo: choose which type from the search object
},
}
},
},
{
- name: 'Europeana',
+ name: "Europeana",
audio: (search) => {
return {
- url: 'https://www.europeana.eu/en/search',
+ url: "https://www.europeana.eu/en/search",
queryParams: {
- page: '1',
+ page: "1",
qf: 'TYPE:"SOUND"',
// search cc licensed works
query: `${search.q} AND RIGHTS:*creative*`,
@@ -163,9 +163,9 @@ const additionalSourceBuilders: AdditionalSourceBuilder[] = [
},
video(search) {
return {
- url: 'https://www.europeana.eu/en/search',
+ url: "https://www.europeana.eu/en/search",
queryParams: {
- page: '1',
+ page: "1",
qf: 'TYPE:"VIDEO"',
// search cc licensed works
query: `${search.q} AND RIGHTS:*creative*`,
@@ -174,51 +174,51 @@ const additionalSourceBuilders: AdditionalSourceBuilder[] = [
},
},
{
- name: 'Vimeo',
+ name: "Vimeo",
video: (search) => ({
- url: 'https://vimeo.com/search',
+ url: "https://vimeo.com/search",
queryParams: {
- license: 'by',
+ license: "by",
q: search.q,
},
}),
},
{
- name: 'Wikimedia Commons',
+ name: "Wikimedia Commons",
video: (search) => ({
- url: 'https://commons.wikimedia.org/w/index.php',
+ url: "https://commons.wikimedia.org/w/index.php",
queryParams: {
search: `${search.q}`,
- title: 'Special:MediaSearch',
- type: 'video',
+ title: "Special:MediaSearch",
+ type: "video",
},
}),
},
{
- name: 'YouTube',
+ name: "YouTube",
video: (search) => ({
- url: 'https://www.youtube.com/results',
+ url: "https://www.youtube.com/results",
queryParams: {
search_query: search.q,
- sp: 'EgIwAQ%3D%3D', // this interesting line filters by cc license
+ sp: "EgIwAQ%3D%3D", // this interesting line filters by cc license
},
}),
},
{
- name: 'Sketchfab',
+ name: "Sketchfab",
[MODEL_3D](search) {
// TODO: Use actual license from filters
const licenseCodes: string[] = [
- '322a749bcfa841b29dff1e8a1bb74b0b', // CC BY
- 'b9ddc40b93e34cdca1fc152f39b9f375', // CC BY-SA
- '72360ff1740d419791934298b8b6d270', // CC BY-ND
- 'bbfe3f7dbcdd4122b966b85b9786a989', // CC BY-NC
- '2628dbe5140a4e9592126c8df566c0b7', // CC BY-NC-SA
- '34b725081a6a4184957efaec2cb84ed3', // CC BY-NC-ND
- '7c23a1ba438d4306920229c12afcb5f9', // CC0
+ "322a749bcfa841b29dff1e8a1bb74b0b", // CC BY
+ "b9ddc40b93e34cdca1fc152f39b9f375", // CC BY-SA
+ "72360ff1740d419791934298b8b6d270", // CC BY-ND
+ "bbfe3f7dbcdd4122b966b85b9786a989", // CC BY-NC
+ "2628dbe5140a4e9592126c8df566c0b7", // CC BY-NC-SA
+ "34b725081a6a4184957efaec2cb84ed3", // CC BY-NC-ND
+ "7c23a1ba438d4306920229c12afcb5f9", // CC0
]
return {
- url: 'https://sketchfab.com/search',
+ url: "https://sketchfab.com/search",
queryParams: {
q: search.q,
licenses: licenseCodes,
@@ -228,12 +228,12 @@ const additionalSourceBuilders: AdditionalSourceBuilder[] = [
},
},
{
- name: 'Thingiverse',
+ name: "Thingiverse",
[MODEL_3D](search) {
return {
- url: 'https://www.thingiverse.com/search',
+ url: "https://www.thingiverse.com/search",
queryParams: {
- type: 'things',
+ type: "things",
q: search.q,
},
}
diff --git a/src/utils/license.ts b/src/utils/license.ts
index 3ccd9322a..a534d2d4b 100644
--- a/src/utils/license.ts
+++ b/src/utils/license.ts
@@ -8,14 +8,14 @@ import type {
License,
LicenseVersion,
LicenseElement,
-} from '~/constants/license'
+} from "~/constants/license"
import {
CC_LICENSES,
DEPRECATED_CC_LICENSES,
PUBLIC_DOMAIN_MARKS,
-} from '~/constants/license'
+} from "~/constants/license"
-import type VueI18n from 'vue-i18n'
+import type VueI18n from "vue-i18n"
/**
* Get the full name of the license in a displayable format from the license
@@ -28,16 +28,16 @@ import type VueI18n from 'vue-i18n'
*/
export const getFullLicenseName = (
license: License,
- licenseVersion: LicenseVersion = '', // unknown version
+ licenseVersion: LicenseVersion = "", // unknown version
i18n: VueI18n | null = null
): string => {
let licenseName
// PDM has no abbreviation
- if (license === 'pdm' && i18n) {
+ if (license === "pdm" && i18n) {
licenseName = i18n.t(`license-readable-names.${license}`).toString()
} else {
- licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling')
+ licenseName = license.toUpperCase().replace("SAMPLING", "Sampling")
}
// If version is known, append version to the name
@@ -61,17 +61,17 @@ export const getFullLicenseName = (
*/
export const getLicenseUrl = (
license: License,
- licenseVersion: LicenseVersion = ''
+ licenseVersion: LicenseVersion = ""
) => {
let fragment
- if (license === 'cc0') {
- fragment = 'publicdomain/zero/1.0'
- } else if (license === 'pdm') {
- fragment = 'publicdomain/mark/1.0'
+ if (license === "cc0") {
+ fragment = "publicdomain/zero/1.0"
+ } else if (license === "pdm") {
+ fragment = "publicdomain/mark/1.0"
} else if (isDeprecated(license)) {
fragment = `licenses/${license}/1.0`
} else {
- fragment = `licenses/${license}/${licenseVersion || '4.0'}`
+ fragment = `licenses/${license}/${licenseVersion || "4.0"}`
}
return `https://creativecommons.org/${fragment}/?ref=openverse`
}
@@ -117,7 +117,7 @@ export const isDeprecated = (license: License): boolean =>
* @returns `true` if the license is a CC license, `false` otherwise
*/
export const isCc = (license: License): boolean =>
- license == 'cc0' ||
+ license == "cc0" ||
(CC_LICENSES as ReadonlyArray<License>).includes(license) ||
(DEPRECATED_CC_LICENSES as ReadonlyArray<License>).includes(license)
@@ -127,19 +127,19 @@ export const isCc = (license: License): boolean =>
* @param license - the license for which to get the elements
*/
export const getElements = (license: License): LicenseElement[] => {
- if (license === 'pdm') {
- return ['pd']
+ if (license === "pdm") {
+ return ["pd"]
}
- const icons: LicenseElement[] = ['cc']
- if (license === 'cc0') {
- icons.push('zero')
+ const icons: LicenseElement[] = ["cc"]
+ if (license === "cc0") {
+ icons.push("zero")
} else {
const replacements: Record<string, LicenseElement> = {
- 'sampling+': 'sampling-plus',
+ "sampling+": "sampling-plus",
}
const elements = license
- .split('-')
+ .split("-")
.map((element) =>
element in replacements
? replacements[element]
diff --git a/src/utils/load-script.ts b/src/utils/load-script.ts
index 1caff9fdd..224fcf36a 100644
--- a/src/utils/load-script.ts
+++ b/src/utils/load-script.ts
@@ -5,17 +5,17 @@
* @param url - the URL of the script to load
* @returns the `load` event emitted by the script tag upon successful load
*/
-export const loadScript = (url = ''): Promise<Event> => {
+export const loadScript = (url = ""): Promise<Event> => {
return new Promise((resolve, reject) => {
- if (typeof document === 'undefined') {
+ if (typeof document === "undefined") {
reject()
}
- const el = document.createElement('script')
+ const el = document.createElement("script")
el.src = url
el.defer = true
- el.addEventListener('load', resolve)
- el.addEventListener('error', reject)
+ el.addEventListener("load", resolve)
+ el.addEventListener("error", reject)
document.head.appendChild(el)
})
}
diff --git a/src/utils/local.ts b/src/utils/local.ts
index b8ec697ce..8a19a0c69 100644
--- a/src/utils/local.ts
+++ b/src/utils/local.ts
@@ -2,7 +2,7 @@
* Small wrapper for localstorage to protect against SSR and permissions
*/
-import { warn } from '~/utils/console'
+import { warn } from "~/utils/console"
const localStorageExists = () => process.client && window.localStorage !== null
@@ -10,7 +10,7 @@ const tryUse = <R>(fn: () => R, def: R) => {
try {
return localStorageExists() ? fn() : def
} catch (e) {
- warn('`localStorage` access denied', e)
+ warn("`localStorage` access denied", e)
return def
}
}
diff --git a/src/utils/node-env.ts b/src/utils/node-env.ts
index 4c4e429ae..611deb55a 100644
--- a/src/utils/node-env.ts
+++ b/src/utils/node-env.ts
@@ -1,5 +1,5 @@
-export const isDev: boolean = process.env.NODE_ENV === 'development'
-export const isTest: boolean = process.env.NODE_ENV === 'test'
-export const isProd: boolean = process.env.NODE_ENV === 'production'
+export const isDev: boolean = process.env.NODE_ENV === "development"
+export const isTest: boolean = process.env.NODE_ENV === "test"
+export const isProd: boolean = process.env.NODE_ENV === "production"
export const isServer: boolean = process.server
export const isClient: boolean = process.client
diff --git a/src/utils/og.ts b/src/utils/og.ts
index f5053ddf9..2aad00266 100644
--- a/src/utils/og.ts
+++ b/src/utils/og.ts
@@ -1,27 +1,27 @@
-import type { MetaInfo } from 'vue-meta'
-import type { MetaPropertyName } from 'vue-meta/types/vue-meta'
+import type { MetaInfo } from "vue-meta"
+import type { MetaPropertyName } from "vue-meta/types/vue-meta"
export const createDetailPageMeta = (title?: string, thumbnail?: string) => {
const head = {} as MetaInfo
const meta = [
{
- hid: 'robots',
- name: 'robots',
- content: 'noindex',
+ hid: "robots",
+ name: "robots",
+ content: "noindex",
},
] as MetaPropertyName[]
if (title) {
head.title = `${title} | Openverse`
meta.push({
- hid: 'og:title',
- name: 'og:title',
+ hid: "og:title",
+ name: "og:title",
content: title,
})
}
if (thumbnail) {
meta.push({
- hid: 'og:image',
- name: 'og:image',
+ hid: "og:image",
+ name: "og:image",
content: thumbnail,
})
}
diff --git a/src/utils/pinia-state.ts b/src/utils/pinia-state.ts
index 4ee3882a9..bae247f1f 100644
--- a/src/utils/pinia-state.ts
+++ b/src/utils/pinia-state.ts
@@ -1,6 +1,6 @@
-import { isClient } from '~/constants/window'
+import { isClient } from "~/constants/window"
-import type { StateTree } from 'pinia'
+import type { StateTree } from "pinia"
/**
* On the server, set the state to `initialState`.
diff --git a/src/utils/prepare-search-query-params.ts b/src/utils/prepare-search-query-params.ts
index ba0411b6b..5ea44b8b7 100644
--- a/src/utils/prepare-search-query-params.ts
+++ b/src/utils/prepare-search-query-params.ts
@@ -1,6 +1,6 @@
-import type { ApiQueryParams } from '~/utils/search-query-transform'
+import type { ApiQueryParams } from "~/utils/search-query-transform"
-const NON_API_PARAMS = ['shouldPersistMedia']
+const NON_API_PARAMS = ["shouldPersistMedia"]
export default function prepareSearchQueryParams(
searchParams: Record<string, string>
@@ -24,7 +24,7 @@ export default function prepareSearchQueryParams(
delete params.q
}
Object.keys(params).forEach((key) => {
- if (params[key] === '') {
+ if (params[key] === "") {
delete params[key]
}
})
diff --git a/src/utils/prop-validators.ts b/src/utils/prop-validators.ts
index eaae7b4c4..e907fe549 100644
--- a/src/utils/prop-validators.ts
+++ b/src/utils/prop-validators.ts
@@ -1,4 +1,4 @@
-import { SupportedSearchType, supportedSearchTypes } from '~/constants/media'
+import { SupportedSearchType, supportedSearchTypes } from "~/constants/media"
/**
* Validates the search types that have supported API endpoints.
diff --git a/src/utils/reakit-utils/README.md b/src/utils/reakit-utils/README.md
index 36417d9ee..8d6018b3f 100644
--- a/src/utils/reakit-utils/README.md
+++ b/src/utils/reakit-utils/README.md
@@ -1,5 +1,9 @@
# Contents
-This directory contains utilities from [`reakit-utils` version 0.15.2](https://github.com/ariakit/ariakit/tree/f05d36daa6fbcc52c70cf2c71baea69025aa2402/packages/reakit-utils) .
+This directory contains utilities from
+[`reakit-utils` version 0.15.2](https://github.com/ariakit/ariakit/tree/f05d36daa6fbcc52c70cf2c71baea69025aa2402/packages/reakit-utils)
+.
-We cannot use Reakit/Ariakit directly as it imports React's JSX types (`@types/react`) which conflict with Vue's own JSX types (`@vue/runtime-dom`). [Ariakit has essentially the same issue as Storybook, for the moment](https://github.com/storybookjs/storybook/issues/12505).
+We cannot use Reakit/Ariakit directly as it imports React's JSX types
+(`@types/react`) which conflict with Vue's own JSX types (`@vue/runtime-dom`).
+[Ariakit has essentially the same issue as Storybook, for the moment](https://github.com/storybookjs/storybook/issues/12505).
diff --git a/src/utils/reakit-utils/dom.ts b/src/utils/reakit-utils/dom.ts
index 75ad1492e..42adda214 100644
--- a/src/utils/reakit-utils/dom.ts
+++ b/src/utils/reakit-utils/dom.ts
@@ -25,7 +25,7 @@ export function getActiveElement(
)
}
if (activeDescendant) {
- const id = activeElement.getAttribute('aria-activedescendant')
+ const id = activeElement.getAttribute("aria-activedescendant")
if (id) {
const element = getDocument(activeElement).getElementById(id)
if (element) {
@@ -50,7 +50,7 @@ export function contains(parent: Node, child: Node): boolean {
* Checks whether `element` is a frame element.
*/
export function isFrame(element: Element): element is HTMLIFrameElement {
- return element.tagName === 'IFRAME'
+ return element.tagName === "IFRAME"
}
/**
@@ -67,6 +67,6 @@ export function isVisible(element: Element) {
export function isInDocument(target: Element) {
const document = getDocument(target)
- if (target.tagName === 'HTML') return true
+ if (target.tagName === "HTML") return true
return contains(document.body, target)
}
diff --git a/src/utils/reakit-utils/focus.ts b/src/utils/reakit-utils/focus.ts
index 8f002e063..c5a104f7a 100644
--- a/src/utils/reakit-utils/focus.ts
+++ b/src/utils/reakit-utils/focus.ts
@@ -1,13 +1,13 @@
-import { contains, getActiveElement, isFrame, isVisible } from './dom'
+import { contains, getActiveElement, isFrame, isVisible } from "./dom"
const selector =
"input:not([type='hidden']):not([disabled]), select:not([disabled]), " +
- 'textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], ' +
- 'iframe, object, embed, area[href], audio[controls], video[controls], ' +
+ "textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], " +
+ "iframe, object, embed, area[href], audio[controls], video[controls], " +
"[contenteditable]:not([contenteditable='false'])"
function hasNegativeTabIndex(element: Element) {
- const tabIndex = parseInt(element.getAttribute('tabindex') || '0', 10)
+ const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10)
return tabIndex < 0
}
@@ -126,7 +126,7 @@ export function hasFocus(element: Element) {
const activeElement = getActiveElement(element)
if (!activeElement) return false
if (activeElement === element) return true
- const activeDescendant = activeElement.getAttribute('aria-activedescendant')
+ const activeDescendant = activeElement.getAttribute("aria-activedescendant")
if (!activeDescendant) return false
return activeDescendant === element.id
}
@@ -141,9 +141,9 @@ export function hasFocusWithin(element: Node | Element) {
const activeElement = getActiveElement(element)
if (!activeElement) return false
if (contains(element, activeElement)) return true
- const activeDescendant = activeElement.getAttribute('aria-activedescendant')
+ const activeDescendant = activeElement.getAttribute("aria-activedescendant")
if (!activeDescendant) return false
- if (!('id' in element)) return false
+ if (!("id" in element)) return false
if (activeDescendant === element.id) return true
return !!element.querySelector(`#${CSS.escape(activeDescendant)}`)
}
diff --git a/src/utils/search-query-transform.ts b/src/utils/search-query-transform.ts
index b4ddf3408..05302fa93 100644
--- a/src/utils/search-query-transform.ts
+++ b/src/utils/search-query-transform.ts
@@ -3,16 +3,16 @@ import {
FilterItem,
Filters,
mediaFilterKeys,
-} from '~/constants/filters'
+} from "~/constants/filters"
import {
ALL_MEDIA,
mediaTypes,
SearchType,
SupportedSearchType,
supportedSearchTypes,
-} from '~/constants/media'
-import { getParameterByName } from '~/utils/url-params'
-import { deepClone } from '~/utils/clone'
+} from "~/constants/media"
+import { getParameterByName } from "~/utils/url-params"
+import { deepClone } from "~/utils/clone"
export interface ApiQueryParams {
q?: string
@@ -34,7 +34,7 @@ export interface ApiQueryParams {
peaks?: string
}
-export type ApiQueryFilters = Omit<ApiQueryParams, 'q'>
+export type ApiQueryFilters = Omit<ApiQueryParams, "q">
export type ApiQueryKeys = keyof ApiQueryFilters
/**
@@ -43,19 +43,19 @@ export type ApiQueryKeys = keyof ApiQueryFilters
* parameters are singular.
*/
const filterPropertyMappings: Record<FilterCategory, ApiQueryKeys> = {
- licenses: 'license',
- licenseTypes: 'license_type',
- audioCategories: 'category',
- imageCategories: 'category',
- audioExtensions: 'extension',
- imageExtensions: 'extension',
- lengths: 'length',
- aspectRatios: 'aspect_ratio',
- sizes: 'size',
- audioProviders: 'source',
- imageProviders: 'source',
- searchBy: 'searchBy',
- mature: 'mature',
+ licenses: "license",
+ licenseTypes: "license_type",
+ audioCategories: "category",
+ imageCategories: "category",
+ audioExtensions: "extension",
+ imageExtensions: "extension",
+ lengths: "length",
+ aspectRatios: "aspect_ratio",
+ sizes: "size",
+ audioProviders: "source",
+ imageProviders: "source",
+ searchBy: "searchBy",
+ mature: "mature",
}
const getMediaFilterTypes = (searchType: SearchType) => {
@@ -73,8 +73,8 @@ const filterToString = (filterItem: FilterItem[]) => {
const filterString = filterItem
.filter((f) => f.checked)
.map((filterItem) => filterItem.code)
- .join(',')
- return filterString === 'mature' ? 'true' : filterString
+ .join(",")
+ return filterString === "mature" ? "true" : filterString
}
/**
@@ -110,7 +110,7 @@ export const filtersToQueryData = (
* @param queryString - the query path string from the url
*/
export const queryStringToSearchType = (queryString: string): SearchType => {
- const searchTypePattern = new RegExp(`/search/(${mediaTypes.join('|')})`)
+ const searchTypePattern = new RegExp(`/search/(${mediaTypes.join("|")})`)
const matchedType = queryString.match(searchTypePattern)
return matchedType === null ? ALL_MEDIA : (matchedType[1] as SearchType)
}
@@ -132,8 +132,8 @@ const getMediaTypeApiFilters = (
filterParameter: string,
parameterFilters: FilterItem[]
): FilterItem[] => {
- if (filterParameter !== '') {
- const parameterValues = filterParameter.split(',')
+ if (filterParameter !== "") {
+ const parameterValues = filterParameter.split(",")
parameterValues.forEach((parameter) => {
const existingParameterIdx = parameterFilters.findIndex(
(p) => p.code === parameter
@@ -163,7 +163,7 @@ const getMediaTypeApiFilters = (
*/
export const queryToFilterData = ({
query,
- searchType = 'image',
+ searchType = "image",
defaultFilters,
}: {
query: Record<string, string>
@@ -175,12 +175,12 @@ export const queryToFilterData = ({
const filters = deepClone(defaultFilters) as Filters
const filterTypes = getMediaFilterTypes(searchType)
const differentFiltersWithSameApiParams = [
- 'audioProviders',
- 'imageProviders',
- 'audioExtensions',
- 'imageExtensions',
- 'audioCategories',
- 'imageCategories',
+ "audioProviders",
+ "imageProviders",
+ "audioExtensions",
+ "imageExtensions",
+ "audioCategories",
+ "imageCategories",
]
filterTypes.forEach((filterDataKey) => {
if (differentFiltersWithSameApiParams.includes(filterDataKey)) {
@@ -196,10 +196,10 @@ export const queryToFilterData = ({
} else {
const queryDataKey = filterPropertyMappings[filterDataKey]
if (query[queryDataKey]) {
- if (queryDataKey === 'mature' && query[queryDataKey].length > 0) {
+ if (queryDataKey === "mature" && query[queryDataKey].length > 0) {
filters[filterDataKey][0].checked = true
} else {
- const filterValues = query[queryDataKey].split(',')
+ const filterValues = query[queryDataKey].split(",")
filterValues.forEach((val: string) => {
const idx = filters[filterDataKey].findIndex((f) => f.code === val)
if (idx >= 0) {
@@ -235,7 +235,7 @@ export const queryStringToQueryData = (queryString: string) => {
)
})
- queryDataObject.q = getParameterByName('q', queryString)
+ queryDataObject.q = getParameterByName("q", queryString)
return queryDataObject
}
@@ -248,7 +248,7 @@ export const areQueriesEqual = (
oldQuery: ApiQueryParams
): boolean => {
const queryKeys = (query: ApiQueryParams) =>
- Object.keys(query).filter((k) => k !== 'q') as (keyof ApiQueryParams)[]
+ Object.keys(query).filter((k) => k !== "q") as (keyof ApiQueryParams)[]
const oldQueryKeys = queryKeys(oldQuery)
const newQueryKeys = queryKeys(newQuery)
if (oldQueryKeys.length !== newQueryKeys.length) return false
diff --git a/src/utils/send-message.ts b/src/utils/send-message.ts
index 41d9b18c6..c0cc536f5 100644
--- a/src/utils/send-message.ts
+++ b/src/utils/send-message.ts
@@ -1,10 +1,10 @@
-import { isProd } from '~/utils/node-env'
+import { isProd } from "~/utils/node-env"
// TODO: set correct targetOrigin of the parent window
-const TARGET_ORIGIN = '*'
+const TARGET_ORIGIN = "*"
interface Message<T extends ResizeValue | UrlChangeValue> {
- type: 'resize' | 'urlChange'
+ type: "resize" | "urlChange"
value: T
}
diff --git a/src/utils/sentry-config.ts b/src/utils/sentry-config.ts
index adf393ac7..4092efd61 100644
--- a/src/utils/sentry-config.ts
+++ b/src/utils/sentry-config.ts
@@ -1,6 +1,6 @@
-import { isProd } from './node-env'
+import { isProd } from "./node-env"
-import type { ModuleConfiguration } from '@nuxtjs/sentry'
+import type { ModuleConfiguration } from "@nuxtjs/sentry"
/**
* Get the Sentry configuration based on the current environment.
diff --git a/src/utils/string-to-boolean.ts b/src/utils/string-to-boolean.ts
index 1fdf26853..d6f7e61a7 100644
--- a/src/utils/string-to-boolean.ts
+++ b/src/utils/string-to-boolean.ts
@@ -12,19 +12,19 @@
export const stringToBoolean = (value: string | boolean): boolean => {
// In case the string is already a boolean, return as-is.
// If `.env` vars are auto-cast to booleans, this will catch that.
- if (typeof value === 'boolean') return value
+ if (typeof value === "boolean") return value
if (!value) return false
value = value.toLowerCase().trim()
switch (value) {
- case 'true':
- case 'yes':
- case '1':
+ case "true":
+ case "yes":
+ case "1":
return true
- case 'false':
- case 'no':
- case '0':
+ case "false":
+ case "no":
+ case "0":
return false
default:
return Boolean(value)
diff --git a/src/utils/time-fmt.ts b/src/utils/time-fmt.ts
index bf22bda02..764ad68d5 100644
--- a/src/utils/time-fmt.ts
+++ b/src/utils/time-fmt.ts
@@ -11,13 +11,13 @@ export const timeFmt = (duration: number, isMs = false): string => {
const hrs = ~~(seconds / 3600)
let mins = (~~((seconds % 3600) / 60)).toString()
- const secs = (~~seconds % 60).toString().padStart(2, '0') // always padded
+ const secs = (~~seconds % 60).toString().padStart(2, "0") // always padded
const parts = []
if (hrs > 0) {
parts.push(hrs)
- mins = mins.padStart(2, '0') // padded only if hours present
+ mins = mins.padStart(2, "0") // padded only if hours present
}
parts.push(mins, secs)
- return parts.join(':')
+ return parts.join(":")
}
diff --git a/src/utils/translation-banner.ts b/src/utils/translation-banner.ts
index 671e63fd7..ae6272ac0 100644
--- a/src/utils/translation-banner.ts
+++ b/src/utils/translation-banner.ts
@@ -1,14 +1,14 @@
-import type { LocaleObject } from '@nuxtjs/i18n'
+import type { LocaleObject } from "@nuxtjs/i18n"
-const BASE_URL = 'https://translate.wordpress.org/projects/meta/openverse/'
+const BASE_URL = "https://translate.wordpress.org/projects/meta/openverse/"
// We show the banner if the translation is less than this percentage
const MINIMUM_TRANSLATION_PERCENTAGE = 90
export const needsTranslationBanner = (locale: LocaleObject) => {
- if (!locale || locale.code === 'en') return false
+ if (!locale || locale.code === "en") return false
return (locale.translated ?? 100) <= MINIMUM_TRANSLATION_PERCENTAGE
}
export const createTranslationLink = (locale: LocaleObject) =>
- `${BASE_URL}${locale.code || 'en'}/default/`
+ `${BASE_URL}${locale.code || "en"}/default/`
diff --git a/src/utils/try-on-mounted.ts b/src/utils/try-on-mounted.ts
index 4130ec176..3c10368fc 100644
--- a/src/utils/try-on-mounted.ts
+++ b/src/utils/try-on-mounted.ts
@@ -2,7 +2,7 @@ import {
getCurrentInstance,
nextTick,
onMounted,
-} from '@nuxtjs/composition-api'
+} from "@nuxtjs/composition-api"
export function tryOnMounted(fn: () => void, sync = true) {
if (getCurrentInstance()) {
diff --git a/src/utils/try-on-scope-dispose.ts b/src/utils/try-on-scope-dispose.ts
index bb8727842..217de6db3 100644
--- a/src/utils/try-on-scope-dispose.ts
+++ b/src/utils/try-on-scope-dispose.ts
@@ -1,4 +1,4 @@
-import { getCurrentScope, onScopeDispose } from '@nuxtjs/composition-api'
+import { getCurrentScope, onScopeDispose } from "@nuxtjs/composition-api"
export function tryOnScopeDispose(fn: () => void) {
if (getCurrentScope()) {
diff --git a/src/utils/url-params.ts b/src/utils/url-params.ts
index 58a117415..71de36fa2 100644
--- a/src/utils/url-params.ts
+++ b/src/utils/url-params.ts
@@ -6,18 +6,18 @@
* @param url - the URL containing query parameters
*/
export const getParameterByName = (key: string, url: string): string => {
- const name = key.replace(/[[\]]/g, '\\$&')
- const regex = new RegExp(`(${name})=([^&]*)+&*`, 'g')
+ const name = key.replace(/[[\]]/g, "\\$&")
+ const regex = new RegExp(`(${name})=([^&]*)+&*`, "g")
const parameterValues = []
let regexResults = regex.exec(url)
while (regexResults) {
- const value = decodeURIComponent(regexResults[2].replace(/\+/g, ' '))
+ const value = decodeURIComponent(regexResults[2].replace(/\+/g, " "))
parameterValues.push(value)
regexResults = regex.exec(url)
}
- return parameterValues.join(',')
+ return parameterValues.join(",")
}
diff --git a/tailwind.config.js b/tailwind.config.js
index 33d08ac69..1b00d0ec4 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,179 +1,179 @@
-const defaultTheme = require('tailwindcss/defaultTheme')
+const defaultTheme = require("tailwindcss/defaultTheme")
-const { SCREENS } = require('./src/constants/screens')
-const { Z_INDICES } = require('./src/constants/z-indices')
+const { SCREENS } = require("./src/constants/screens")
+const { Z_INDICES } = require("./src/constants/z-indices")
module.exports = {
content: [
- 'src/**/*.{vue,js,jsx,ts,tsx,mdx}',
- './nuxt.config.js',
- './tailwind.safelist.txt',
+ "src/**/*.{vue,js,jsx,ts,tsx,mdx}",
+ "./nuxt.config.js",
+ "./tailwind.safelist.txt",
],
theme: {
screens: SCREENS,
zIndex: Z_INDICES,
colors: {
// Accents
- tomato: '#e23600',
- gold: '#efbe00',
- 'forest-green': '#008300',
- 'dark-turquoise': '#05b5da',
- 'dark-slate-blue': '#3c5c99',
- 'trans-blue': '#3e58e1',
- 'trans-blue-action': '#5067e4',
- 'dark-blue': '#23282d',
+ tomato: "#e23600",
+ gold: "#efbe00",
+ "forest-green": "#008300",
+ "dark-turquoise": "#05b5da",
+ "dark-slate-blue": "#3c5c99",
+ "trans-blue": "#3e58e1",
+ "trans-blue-action": "#5067e4",
+ "dark-blue": "#23282d",
// Brand
- yellow: '#ffe033',
- pink: '#c52b9b',
+ yellow: "#ffe033",
+ pink: "#c52b9b",
// Active
- 'dark-pink': '#7c2264',
+ "dark-pink": "#7c2264",
// Grayscale
- black: '#000000',
- 'dark-gray': '#767676', // rgb(118, 118, 188)
- gray: '#b0b0b0', // rgb(176, 176, 176)
- 'light-gray': '#d8d8d8', // rgb(216, 216, 216)
- white: 'white',
+ black: "#000000",
+ "dark-gray": "#767676", // rgb(118, 118, 188)
+ gray: "#b0b0b0", // rgb(176, 176, 176)
+ "light-gray": "#d8d8d8", // rgb(216, 216, 216)
+ white: "white",
// WordPress
- 'admin-gray': '#dcdcde',
+ "admin-gray": "#dcdcde",
// Dark Charcoal
- 'dark-charcoal': {
- DEFAULT: '#30272e',
- '06': '#f3f2f2', // rgb(243, 242, 242)
- 10: '#eae9ea', // rgb(234, 233, 234)
- 20: '#d6d4d5',
- 30: '#c1bec0',
- 40: '#aca9ab',
- 50: '#989397',
- 60: '#837d82',
- 70: '#6e686d',
- 80: '#595258',
- 90: '#453D43',
+ "dark-charcoal": {
+ DEFAULT: "#30272e",
+ "06": "#f3f2f2", // rgb(243, 242, 242)
+ 10: "#eae9ea", // rgb(234, 233, 234)
+ 20: "#d6d4d5",
+ 30: "#c1bec0",
+ 40: "#aca9ab",
+ 50: "#989397",
+ 60: "#837d82",
+ 70: "#6e686d",
+ 80: "#595258",
+ 90: "#453D43",
},
// Special keywords
- tx: 'transparent',
- curr: 'currentColor',
- current: 'currentColor',
+ tx: "transparent",
+ curr: "currentColor",
+ current: "currentColor",
},
spacing: {
// Constants
- '0.5px': '0.5px',
- px: '1px',
- '1.5px': '1.5px',
- ch: '1ch',
- ex: '1ex',
- half: '50%',
- full: '100%',
+ "0.5px": "0.5px",
+ px: "1px",
+ "1.5px": "1.5px",
+ ch: "1ch",
+ ex: "1ex",
+ half: "50%",
+ full: "100%",
// Indexed by multiples of baseline (~ `0.25rem`)
- 0: '0',
- 0.5: '0.125rem',
- 1: '0.25rem',
- 2: '0.50rem',
- 3: '0.75rem',
- 4: '1.00rem',
- 5: '1.25rem',
- 6: '1.50rem',
- 7: '1.75rem',
- 8: '2.00rem',
- 10: '2.50rem',
- 12: '3.00rem',
- 14: '3.50rem',
- 15: '3.75rem',
- 16: '4.00rem',
- 20: '5.00rem',
- 24: '6.00rem',
- 30: '7.50rem',
- 40: '10.00rem',
- 50: '12.50rem',
- 64: '16.00rem',
- 70: '17.50rem',
- 80: '20.00rem',
- 120: '30.00rem',
+ 0: "0",
+ 0.5: "0.125rem",
+ 1: "0.25rem",
+ 2: "0.50rem",
+ 3: "0.75rem",
+ 4: "1.00rem",
+ 5: "1.25rem",
+ 6: "1.50rem",
+ 7: "1.75rem",
+ 8: "2.00rem",
+ 10: "2.50rem",
+ 12: "3.00rem",
+ 14: "3.50rem",
+ 15: "3.75rem",
+ 16: "4.00rem",
+ 20: "5.00rem",
+ 24: "6.00rem",
+ 30: "7.50rem",
+ 40: "10.00rem",
+ 50: "12.50rem",
+ 64: "16.00rem",
+ 70: "17.50rem",
+ 80: "20.00rem",
+ 120: "30.00rem",
},
ringWidth: {
- DEFAULT: '1.5px',
+ DEFAULT: "1.5px",
0: 0,
},
borderWidth: {
- 0: '0px',
- DEFAULT: '1px',
- 1.5: '1.5px',
- 2: '2px',
- 3: '3px',
+ 0: "0px",
+ DEFAULT: "1px",
+ 1.5: "1.5px",
+ 2: "2px",
+ 3: "3px",
},
ringOffsetWidth: {
- 0: '0px',
- 1: '1px',
- 2: '2px',
+ 0: "0px",
+ 1: "1px",
+ 2: "2px",
},
fontSize: {
// Deprecated
- lg: '1.12rem',
- lgr: '1.43rem',
- '7xl': [
+ lg: "1.12rem",
+ lgr: "1.43rem",
+ "7xl": [
// Heading 1
- '5.625rem', // 90px
- '1.3', // 130%
+ "5.625rem", // 90px
+ "1.3", // 130%
],
- '6xl': [
+ "6xl": [
// Heading 2
- '2.0000rem', // 32px
- '1.3', // 130%
+ "2.0000rem", // 32px
+ "1.3", // 130%
],
- '5xl': [
+ "5xl": [
// Heading 3
- '1.7500rem', // 28px
- '1.3', // 130%
+ "1.7500rem", // 28px
+ "1.3", // 130%
],
- '4xl': [
+ "4xl": [
// Heading 4
- '1.5000rem', // 24px
- '1.3', // 130%
+ "1.5000rem", // 24px
+ "1.3", // 130%
],
- '3xl': [
+ "3xl": [
// Heading 5
- '1.1875rem', // 19px
- '1.3', // 130%
+ "1.1875rem", // 19px
+ "1.3", // 130%
],
- '2xl': [
+ "2xl": [
// Heading 6
- '1.0000rem', // 16px
- '1.3', // 130%
+ "1.0000rem", // 16px
+ "1.3", // 130%
],
// Content
base: [
- '0.8750rem', // 14px
- '1.5', // 150%
+ "0.8750rem", // 14px
+ "1.5", // 150%
],
sm: [
// small, eg. label
- '0.8125rem', // 13px
- '1.3', // 130%
+ "0.8125rem", // 13px
+ "1.3", // 130%
],
sr: [
// smaller, eg. caption, category
- '0.7500rem', // 12px
- '1.3', // 130%
+ "0.7500rem", // 12px
+ "1.3", // 130%
],
xs: [
// extra small, eg. time
- '0.6875rem', // 11px
- '1.2', // 120%
+ "0.6875rem", // 11px
+ "1.2", // 120%
],
},
lineHeights: {
- larger: '1.9',
- large: '1.7',
- normal: '1.5',
- snug: '1.3',
- tight: '1.2',
- none: '1.0',
+ larger: "1.9",
+ large: "1.7",
+ normal: "1.5",
+ snug: "1.3",
+ tight: "1.2",
+ none: "1.0",
},
flexGrow: {
0: 0,
@@ -181,29 +181,29 @@ module.exports = {
2: 2,
},
fontFamily: {
- mono: ['"JetBrains Mono"', 'monospace'],
- sans: ['Inter', ...defaultTheme.fontFamily.sans],
+ mono: ['"JetBrains Mono"', "monospace"],
+ sans: ["Inter", ...defaultTheme.fontFamily.sans],
serif: [...defaultTheme.fontFamily.serif],
},
extend: {
scale: {
- '-100': '-1',
+ "-100": "-1",
},
boxShadow: {
- ring: 'inset 0 0 0 1px white',
- 'ring-1.5': 'inset 0 0 0 1.5px white',
- 'el-2': '0 0.125rem 0.25rem rgba(0, 0, 0, 0.1)',
+ ring: "inset 0 0 0 1px white",
+ "ring-1.5": "inset 0 0 0 1.5px white",
+ "el-2": "0 0.125rem 0.25rem rgba(0, 0, 0, 0.1)",
},
typography: (theme) => ({
DEFAULT: {
css: {
- '--tw-prose-body': theme('colors.dark-charcoal'),
- '--tw-prose-headings': theme('colors.dark-charcoal'),
- '--tw-prose-links': theme('colors.pink'),
+ "--tw-prose-body": theme("colors.dark-charcoal"),
+ "--tw-prose-headings": theme("colors.dark-charcoal"),
+ "--tw-prose-links": theme("colors.pink"),
a: {
- textDecoration: 'none',
- '&:hover': {
- 'text-decoration': 'underline',
+ textDecoration: "none",
+ "&:hover": {
+ "text-decoration": "underline",
},
},
},
@@ -212,9 +212,9 @@ module.exports = {
},
},
plugins: [
- require('tailwindcss-rtl'),
- require('@tailwindcss/line-clamp'),
- require('@tailwindcss/typography'),
- require('tailwindcss-labeled-groups')(['waveform']),
+ require("tailwindcss-rtl"),
+ require("@tailwindcss/line-clamp"),
+ require("@tailwindcss/typography"),
+ require("tailwindcss-labeled-groups")(["waveform"]),
],
}
diff --git a/test/README.md b/test/README.md
index 7c05c7624..4bd4d0aa6 100644
--- a/test/README.md
+++ b/test/README.md
@@ -1,8 +1,16 @@
# /locales/ directory
-Normally when you build Openverse, you download the updated information about locales and translation files to `src/locales` folder. To prevent too many requests during CI, we save the locale files that are necessary to run the app during Playwright tests.
+Normally when you build Openverse, you download the updated information about
+locales and translation files to `src/locales` folder. To prevent too many
+requests during CI, we save the locale files that are necessary to run the app
+during Playwright tests.
-1. `scripts/valid-locales.json` contains a list of valid locales with properties including their translation status (the percentage of strings that are translated).
-2. `es.json` is the `es` locale file used for search navigation tests (`../playwright/e2e/search-navigation-old.spec.ts`).
-3. `ru.json` is the `ru` locale file used for testing the translation banner because the current translated percentage is ~40%, which is below the banner threshold of 90%.
+1. `scripts/valid-locales.json` contains a list of valid locales with properties
+ including their translation status (the percentage of strings that are
+ translated).
+2. `es.json` is the `es` locale file used for search navigation tests
+ (`../playwright/e2e/search-navigation-old.spec.ts`).
+3. `ru.json` is the `ru` locale file used for testing the translation banner
+ because the current translated percentage is ~40%, which is below the banner
+ threshold of 90%.
4. `ar.json` is the machine-translated `ar` locale file used for RTL testing.
diff --git a/test/iframe-test.html b/test/iframe-test.html
index ea15b1eda..fd377613f 100644
--- a/test/iframe-test.html
+++ b/test/iframe-test.html
@@ -30,7 +30,7 @@
></iframe>
<!-- Scripts stolen from: https://github.com/WordPress/wordpress.org/blob/master/wordpress.org/public_html/wp-content/themes/pub/wporg-openverse/js -->
<script>
- const openverseSubpath = 'http://localhost:8443/'
+ const openverseSubpath = "http://localhost:8443/"
/**
* Update the height of the nested `iframe` to match the height of the nested
@@ -45,10 +45,10 @@
if (height) {
heightProp = `${height}px`
} else {
- heightProp = '100vh'
+ heightProp = "100vh"
}
document.documentElement.style.setProperty(
- '--openverse-embed-height',
+ "--openverse-embed-height",
heightProp
)
}
@@ -69,7 +69,7 @@
const url = `${openverseSubpath}${path}` // openverseSubpath defined in `index.php`
console.log(`Replacing state URL: ${url}`)
- history.replaceState(value.state, value.title ?? 'Openverse', url)
+ history.replaceState(value.state, value.title ?? "Openverse", url)
if (value.title) {
console.log(`Setting document title: ${value.title}`)
@@ -82,7 +82,7 @@
* not have a handler configured for them.
*/
function logUnhandled() {
- console.error('No handler configured for event received')
+ console.error("No handler configured for event received")
}
/**
@@ -103,7 +103,7 @@
let handler
switch (data.type) {
- case 'urlChange':
+ case "urlChange":
handler = updatePath
break
default:
@@ -112,7 +112,7 @@
handler(data.value)
}
- window.addEventListener('message', handleIframeMessages)
+ window.addEventListener("message", handleIframeMessages)
</script>
</body>
</html>
diff --git a/test/playwright/README.md b/test/playwright/README.md
index d9fafd07b..e467177ab 100644
--- a/test/playwright/README.md
+++ b/test/playwright/README.md
@@ -2,24 +2,51 @@
## Visual regression and end-to-end tests
-We run the Playwright test suite on each PR to test that the front end works correctly and there are no visual regressions.
-
-The **end-to-end** tests make sure that functionality works as expected and are located in `test/playwright/e2e`. They test, for instance, that we can open the filters by clicking on the Filters button in the header, or select the filters and execute the relevant search by clicking on the filter checkboxes.
-
-There are also **visual regression** tests that make sure that the pages display correct components, and components are rendered correctly.
-The components can be tested in isolation to make sure that the states are correctly rendered. For more on which states should be tested, see [`TESTING_GUIDELINES.md`](./TESTING_GUIDELINES.md). These tests should use Storybook to render the component in isolation, and be placed in `test/storybook/visual-regression`.
-
-The component tests that test that the component state is correctly rendered based on the page interaction should be placed in `test/visual-regression/components`. For example, the header elements are tested this way because their appearance depends on the page scroll position.
+We run the Playwright test suite on each PR to test that the front end works
+correctly and there are no visual regressions.
+
+The **end-to-end** tests make sure that functionality works as expected and are
+located in `test/playwright/e2e`. They test, for instance, that we can open the
+filters by clicking on the Filters button in the header, or select the filters
+and execute the relevant search by clicking on the filter checkboxes.
+
+There are also **visual regression** tests that make sure that the pages display
+correct components, and components are rendered correctly. The components can be
+tested in isolation to make sure that the states are correctly rendered. For
+more on which states should be tested, see
+[`TESTING_GUIDELINES.md`](./TESTING_GUIDELINES.md). These tests should use
+Storybook to render the component in isolation, and be placed in
+`test/storybook/visual-regression`.
+
+The component tests that test that the component state is correctly rendered
+based on the page interaction should be placed in
+`test/visual-regression/components`. For example, the header elements are tested
+this way because their appearance depends on the page scroll position.
## Dockerization
-Our Playwright test suite runs inside a docker container in order to prevent cross-platform browser differences from creating flaky test behavior. We run both end-to-end and visual-regression tests in the same container to save from having to run the Nuxt production build twice.
-
-Having docker and docker-compose is a pre-requisite to running the playwright tests locally. Please follow [the relevant instructions for your operating system for how to install docker and docker-compose](https://docs.docker.com/get-docker/). If you're on Windows 10 Home Edition, please note that you'll need to [install and run docker inside WSL2](https://www.freecodecamp.org/news/how-to-run-docker-on-windows-10-home-edition/). We strongly recommend (and only plan to support) Windows users run everything inside of WSL.
-
-If it's not possible for you to run docker locally, don't fret! Our CI will run it on every pull request and another contributor who is able to run the tests locally can help you develop new or update existing tests for your changes.
-
-The Playwright docker container runs everything needed for the end-to-end and visual-regression tests, including the Nuxt server and a [Talkback proxy](https://github.com/ijpiantanida/talkback) for the API. It will also generate and match against the existing visual-regression snapshots in the codebase.
+Our Playwright test suite runs inside a docker container in order to prevent
+cross-platform browser differences from creating flaky test behavior. We run
+both end-to-end and visual-regression tests in the same container to save from
+having to run the Nuxt production build twice.
+
+Having docker and docker-compose is a pre-requisite to running the playwright
+tests locally. Please follow
+[the relevant instructions for your operating system for how to install docker and docker-compose](https://docs.docker.com/get-docker/).
+If you're on Windows 10 Home Edition, please note that you'll need to
+[install and run docker inside WSL2](https://www.freecodecamp.org/news/how-to-run-docker-on-windows-10-home-edition/).
+We strongly recommend (and only plan to support) Windows users run everything
+inside of WSL.
+
+If it's not possible for you to run docker locally, don't fret! Our CI will run
+it on every pull request and another contributor who is able to run the tests
+locally can help you develop new or update existing tests for your changes.
+
+The Playwright docker container runs everything needed for the end-to-end and
+visual-regression tests, including the Nuxt server and a
+[Talkback proxy](https://github.com/ijpiantanida/talkback) for the API. It will
+also generate and match against the existing visual-regression snapshots in the
+codebase.
## Running the tests
@@ -29,68 +56,132 @@ To run the end-to-end tests, after having installed docker, run the following:
pnpm test:playwright
```
-You may pass arguments to playwright directly, for example `-u` to update snapshots or a filter.
+You may pass arguments to playwright directly, for example `-u` to update
+snapshots or a filter.
```bash
pnpm test:playwright visual-regression -u
```
-The above will run only test files with `visual-regression` in the path and will update any snapshot tests due to the `-u` flag.
+The above will run only test files with `visual-regression` in the path and will
+update any snapshot tests due to the `-u` flag.
## Visual Regression tests
-When writing visual regression tests, it is good practice to write tests for each relevant breakpoint. There is a series of helpers in [`./utils/breakpoints.ts`](./utils/breakpoints.ts) for this. The most common usage for this module is to run a test or set of tests for every breakpoint our app knows about or a subset of them. Occasionally you will need to separate tests by breakpoint or by range for which there are also helpers.
-
-Each of the following methods expects a describe block callback function accepting some useful helpers.
-
-- `breakpoints.describeEvery`: Generates a describe block for every breakpoint our app is concerned with.
-- `breakpoints.describeEachDesktop`: Generates a describe block for every breakpoint that roughly correlates with desktop and tablet width devices.
-- `breakpoints.describeEachMobile`: Generates a describe block for every breakpoint that roughly correlates with smartphone sized mobile devices.
-- `breakpoints.describeEachBreakpoint`: Accepts a list of breakpoints to generate describe blocks for, with similar syntax to `jest`'s `test.each` helper. Used like `breakpoints.describeEachBreakpoint(['xs', '2xl'])(<block>)`. `describeEvery` and the two `describeEach*` methods are aliases for pre-configured `describeEachBreakpoint`. It is unlikely that you will need to use this helper directly.
-
-Additionally there are describe blocks for individual breakpoints, each following the pattern `` `describe${Capitalize<Breakpoint>}` ``, for example `breakpoints.describeXs`.
+When writing visual regression tests, it is good practice to write tests for
+each relevant breakpoint. There is a series of helpers in
+[`./utils/breakpoints.ts`](./utils/breakpoints.ts) for this. The most common
+usage for this module is to run a test or set of tests for every breakpoint our
+app knows about or a subset of them. Occasionally you will need to separate
+tests by breakpoint or by range for which there are also helpers.
+
+Each of the following methods expects a describe block callback function
+accepting some useful helpers.
+
+- `breakpoints.describeEvery`: Generates a describe block for every breakpoint
+ our app is concerned with.
+- `breakpoints.describeEachDesktop`: Generates a describe block for every
+ breakpoint that roughly correlates with desktop and tablet width devices.
+- `breakpoints.describeEachMobile`: Generates a describe block for every
+ breakpoint that roughly correlates with smartphone sized mobile devices.
+- `breakpoints.describeEachBreakpoint`: Accepts a list of breakpoints to
+ generate describe blocks for, with similar syntax to `jest`'s `test.each`
+ helper. Used like
+ `breakpoints.describeEachBreakpoint(['xs', '2xl'])(<block>)`. `describeEvery`
+ and the two `describeEach*` methods are aliases for pre-configured
+ `describeEachBreakpoint`. It is unlikely that you will need to use this helper
+ directly.
+
+Additionally there are describe blocks for individual breakpoints, each
+following the pattern `` `describe${Capitalize<Breakpoint>}` ``, for example
+`breakpoints.describeXs`.
The describe blocks are passed the following helpers:
- `breakpoint`: The name of the breakpoint for the current describe block.
-- `getConfigValues`: Returns useful configuration values if running a snapshot test manually.
-- `expectSnapshot`: A function accepting an identifier and a screenshot-able object. This will generate the screenshot and match it against a snapshot matching the name passed. Remember to `await` this function or else the `expect` will not be fired within the context of the test (you'll get a nasty error in this case).
-
-Optionally, you may pass a configuration object as the first argument to the `breakpoints.describe*` functions. If you do this, then the describe block is the second argument.
+- `getConfigValues`: Returns useful configuration values if running a snapshot
+ test manually.
+- `expectSnapshot`: A function accepting an identifier and a screenshot-able
+ object. This will generate the screenshot and match it against a snapshot
+ matching the name passed. Remember to `await` this function or else the
+ `expect` will not be fired within the context of the test (you'll get a nasty
+ error in this case).
+
+Optionally, you may pass a configuration object as the first argument to the
+`breakpoints.describe*` functions. If you do this, then the describe block is
+the second argument.
The configuration object currently supports the following options:
-- `uaMocking`: This `boolean` option defaults to `true`. When enabled, it will use a mock mobile browser user agent string for narrow viewports. Setting it to `false` for viewport widths above `md` (inclusive) is a no-op.
+- `uaMocking`: This `boolean` option defaults to `true`. When enabled, it will
+ use a mock mobile browser user agent string for narrow viewports. Setting it
+ to `false` for viewport widths above `md` (inclusive) is a no-op.
-Please see the [`homepage.spec.ts` visual-regression tests](visual-regression/pages/homepage.spec.ts) as an example of how to use these helpers.
+Please see the
+[`homepage.spec.ts` visual-regression tests](visual-regression/pages/homepage.spec.ts)
+as an example of how to use these helpers.
### What to test for visual regression
-Visual regression tests can match entire pages or on individual elements in specific states. They're useful, for example, to test the various focus, hover, and active states of interactive elements. Use [`page.locator`](https://playwright.dev/docs/api/class-page#page-locator) to select specific elements to pass to `expectSnapshot`.
+Visual regression tests can match entire pages or on individual elements in
+specific states. They're useful, for example, to test the various focus, hover,
+and active states of interactive elements. Use
+[`page.locator`](https://playwright.dev/docs/api/class-page#page-locator) to
+select specific elements to pass to `expectSnapshot`.
## API proxy
-The Playwright test container also runs an API proxy using [Talkback](https://github.com/ijpiantanida/talkback) to prevent network requests from hitting the live API during end-to-end and visual-regression tests. This significantly speeds up the tests and makes the data being tested against consistent across test runs and eliminates variations that the API may include after data refreshes happen.
+The Playwright test container also runs an API proxy using
+[Talkback](https://github.com/ijpiantanida/talkback) to prevent network requests
+from hitting the live API during end-to-end and visual-regression tests. This
+significantly speeds up the tests and makes the data being tested against
+consistent across test runs and eliminates variations that the API may include
+after data refreshes happen.
-The configuration for the Talkback proxy is in the [`proxy.js`](../proxy.js) module and is run using `pnpm talkback`. It is rare and unlikely that you will need to run it directly as running it is handled by the Playwright `webServer` configuration.
+The configuration for the Talkback proxy is in the [`proxy.js`](../proxy.js)
+module and is run using `pnpm talkback`. It is rare and unlikely that you will
+need to run it directly as running it is handled by the Playwright `webServer`
+configuration.
-If you've added new tests or updated existing ones, you may get errors about API responses not being found. To remedy this, you'll need to update the tapes:
+If you've added new tests or updated existing ones, you may get errors about API
+responses not being found. To remedy this, you'll need to update the tapes:
```bash
pnpm test:playwright:update-tapes
```
-If for some reason you find yourself needing to completely recreate the tapes, you may do so using the `test:playwright:recreate-tapes` script. Please use this sparingly as it creates massive diffs in PRs (tens of thousands of lines across over literally hundreds of JSON files). Note that you may be rate-limited by the upstream production API if you do this. There is no official workaround for this at the moment.
+If for some reason you find yourself needing to completely recreate the tapes,
+you may do so using the `test:playwright:recreate-tapes` script. Please use this
+sparingly as it creates massive diffs in PRs (tens of thousands of lines across
+over literally hundreds of JSON files). Note that you may be rate-limited by the
+upstream production API if you do this. There is no official workaround for this
+at the moment.
## Debugging
-Additional debugging may be accomplished in two ways. You may inspect the trace output of failed tests by finding the `trace.zip` for the relevant test in the `test-results` folder. Traces are only saved for failed tests. You can use the [Playwright Trace Viewer](https://playwright.dev/docs/trace-viewer) to inspect these (or open the zip yourself and poke around the files on your own).
-
-For Playwright tests failing in CI, a GitHub comment will appear with a link to download an artifact of the `test-results` folder.
-
-Visual regression tests that fail to match the existing snapshots will also have `expected`, `actual` and `diff` files generated that are helpful for understanding why intermittent failures are happening. These are generated automatically by Playwright and will be placed in the `test-results` folder under the fully qualified name of the test that failed (with every parent describe block included).
-
-Additionally, you can run run the tests in debug mode. This will run the tests with a headed browser as opposed to a headless (invisible) one and allow you to watch the test happen in real time. It's not possible for a headed browser to run inside the docker container, however, so be aware that when debugging the environment will be slightly different. For example, if you're on any OS other than Linux, the browser you're running will have small differences in how it renders the page compared to the docker container.
+Additional debugging may be accomplished in two ways. You may inspect the trace
+output of failed tests by finding the `trace.zip` for the relevant test in the
+`test-results` folder. Traces are only saved for failed tests. You can use the
+[Playwright Trace Viewer](https://playwright.dev/docs/trace-viewer) to inspect
+these (or open the zip yourself and poke around the files on your own).
+
+For Playwright tests failing in CI, a GitHub comment will appear with a link to
+download an artifact of the `test-results` folder.
+
+Visual regression tests that fail to match the existing snapshots will also have
+`expected`, `actual` and `diff` files generated that are helpful for
+understanding why intermittent failures are happening. These are generated
+automatically by Playwright and will be placed in the `test-results` folder
+under the fully qualified name of the test that failed (with every parent
+describe block included).
+
+Additionally, you can run run the tests in debug mode. This will run the tests
+with a headed browser as opposed to a headless (invisible) one and allow you to
+watch the test happen in real time. It's not possible for a headed browser to
+run inside the docker container, however, so be aware that when debugging the
+environment will be slightly different. For example, if you're on any OS other
+than Linux, the browser you're running will have small differences in how it
+renders the page compared to the docker container.
To run the debug tests:
@@ -98,7 +189,10 @@ To run the debug tests:
pnpm test:playwright:debug
```
-Note that this still runs the talkback proxy and the Nuxt server for you. If you'd like to avoid this, simply run the Nuxt server before you run the `test:playwright:debug` script and Playwright will automatically prefer your previously running Nuxt server.
+Note that this still runs the talkback proxy and the Nuxt server for you. If
+you'd like to avoid this, simply run the Nuxt server before you run the
+`test:playwright:debug` script and Playwright will automatically prefer your
+previously running Nuxt server.
<aside>
For some reason the following two tests are consistently flaky when updating tapes but appear to be stable when running the e2e tapes with pre-existing tapes.
@@ -114,12 +208,16 @@ Don't be alarmed if you notice this.
## Generating new tests
-When writing end-to-end tests, it can be helpful to use Playwright [codegen](https://playwright.dev/docs/cli#generate-code) to generate the tests by performing actions in the browser:
+When writing end-to-end tests, it can be helpful to use Playwright
+[codegen](https://playwright.dev/docs/cli#generate-code) to generate the tests
+by performing actions in the browser:
```
pnpm run test:playwright:gen
```
-This will open the app in a new browser window, and record any actions you take in a format that can be used in end-to-end tests.
+This will open the app in a new browser window, and record any actions you take
+in a format that can be used in end-to-end tests.
-Note that this does _not_ run the server for you; you must run the Nuxt server using `pnpm start` or `pnpm dev` separately before running the codegen script.
+Note that this does _not_ run the server for you; you must run the Nuxt server
+using `pnpm start` or `pnpm dev` separately before running the codegen script.
diff --git a/test/playwright/e2e/all-results-keyboard.spec.ts b/test/playwright/e2e/all-results-keyboard.spec.ts
index bf8fcd005..4eae6f7e2 100644
--- a/test/playwright/e2e/all-results-keyboard.spec.ts
+++ b/test/playwright/e2e/all-results-keyboard.spec.ts
@@ -1,18 +1,18 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
-import audio from '~~/test/playwright/utils/audio'
+import audio from "~~/test/playwright/utils/audio"
-import { keycodes } from '~/constants/key-codes'
+import { keycodes } from "~/constants/key-codes"
-const walkToNextOfType = async (type: 'image' | 'audio', page: Page) => {
+const walkToNextOfType = async (type: "image" | "audio", page: Page) => {
const isActiveElementOfType = () => {
return page.evaluate(
([contextType]) =>
new RegExp(
`/${contextType}/[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$`,
- 'i'
+ "i"
).test(
- (document.activeElement as HTMLAnchorElement | null)?.href ?? ''
+ (document.activeElement as HTMLAnchorElement | null)?.href ?? ""
),
[type]
)
@@ -23,7 +23,7 @@ const walkToNextOfType = async (type: 'image' | 'audio', page: Page) => {
}
}
-const walkToType = async (type: 'image' | 'audio', page: Page) => {
+const walkToType = async (type: "image" | "audio", page: Page) => {
// Go to skip to content button
await page.keyboard.press(keycodes.Tab)
// Skip to content
@@ -37,50 +37,50 @@ const locateFocusedResult = async (page: Page) => {
() => (document.activeElement as HTMLAnchorElement | null)?.href
)
expect(href).toBeDefined()
- const url = new URL(href ?? '')
+ const url = new URL(href ?? "")
return page.locator(`[href="${url.pathname}"]`)
}
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('all results grid keyboard accessibility test', () => {
+test.describe("all results grid keyboard accessibility test", () => {
test.beforeEach(async ({ page }) => {
- await page.goto('/search?q=birds')
+ await page.goto("/search?q=birds")
})
- test('should open image results as links', async ({ page }) => {
- await walkToType('image', page)
- await page.keyboard.press('Enter')
+ test("should open image results as links", async ({ page }) => {
+ await walkToType("image", page)
+ await page.keyboard.press("Enter")
await page.waitForURL(
new RegExp(
`/image/[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$`,
- 'i'
+ "i"
)
)
})
- test('should open audio results as links', async ({ page }) => {
- await walkToType('audio', page)
- await page.keyboard.press('Enter')
+ test("should open audio results as links", async ({ page }) => {
+ await walkToType("audio", page)
+ await page.keyboard.press("Enter")
await page.waitForURL(
new RegExp(
`/audio/[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$`,
- 'i'
+ "i"
)
)
expect(page.url()).toMatch(
new RegExp(
`/audio/[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$`,
- 'i'
+ "i"
)
)
})
- test('should allow toggling audio playback via play/pause click', async ({
+ test("should allow toggling audio playback via play/pause click", async ({
page,
}) => {
- await walkToType('audio', page)
+ await walkToType("audio", page)
const focusedResult = await locateFocusedResult(page)
const playButton = await audio.getInactive(focusedResult)
await playButton.click()
@@ -92,10 +92,10 @@ test.describe('all results grid keyboard accessibility test', () => {
await expect(playButton).toBeVisible()
})
- test('should allow toggling audio playback via spacebar', async ({
+ test("should allow toggling audio playback via spacebar", async ({
page,
}) => {
- await walkToType('audio', page)
+ await walkToType("audio", page)
await page.keyboard.press(keycodes.Spacebar)
const focusedResult = await locateFocusedResult(page)
await expect(await audio.getActive(focusedResult)).toBeVisible()
@@ -103,15 +103,15 @@ test.describe('all results grid keyboard accessibility test', () => {
await expect(await audio.getInactive(focusedResult)).toBeVisible()
})
- test('should pause audio after playing another', async ({ page }) => {
- await walkToType('audio', page)
+ test("should pause audio after playing another", async ({ page }) => {
+ await walkToType("audio", page)
const focusedResult = await locateFocusedResult(page)
const playButton = await audio.getInactive(focusedResult)
await playButton.click()
const pauseButton = await audio.getActive(focusedResult)
await page.keyboard.press(keycodes.Tab)
- await walkToNextOfType('audio', page)
+ await walkToNextOfType("audio", page)
const nextFocusedResult = await locateFocusedResult(page)
const nextPlayButton = await audio.getInactive(nextFocusedResult)
diff --git a/test/playwright/e2e/attribution.spec.ts b/test/playwright/e2e/attribution.spec.ts
index 0217f9387..60caab613 100644
--- a/test/playwright/e2e/attribution.spec.ts
+++ b/test/playwright/e2e/attribution.spec.ts
@@ -1,13 +1,13 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
- await context.grantPermissions(['clipboard-read', 'clipboard-write'])
+ await context.grantPermissions(["clipboard-read", "clipboard-write"])
})
-test('can copy rich text attribution', async ({ page }) => {
- await page.goto('image/e9d97a98-621b-4ec2-bf70-f47a74380452')
+test("can copy rich text attribution", async ({ page }) => {
+ await page.goto("image/e9d97a98-621b-4ec2-bf70-f47a74380452")
await page.click('[aria-controls="panel-rich"]')
await page.click('[id="copyattr-rich"]')
const clippedText = await page.evaluate(async () => {
@@ -17,8 +17,8 @@ test('can copy rich text attribution', async ({ page }) => {
expect(clippedText).toContain('"bubbles in honey" by mutednarayan')
})
-test('can copy HTML attribution', async ({ page }) => {
- await page.goto('image/e9d97a98-621b-4ec2-bf70-f47a74380452')
+test("can copy HTML attribution", async ({ page }) => {
+ await page.goto("image/e9d97a98-621b-4ec2-bf70-f47a74380452")
await page.click('[aria-controls="panel-html"]')
await page.click('[id="copyattr-html"]')
const clippedText = await page.evaluate(async () => {
@@ -26,21 +26,21 @@ test('can copy HTML attribution', async ({ page }) => {
})
const snippets = [
'<p class="attribution">',
- '>bubbles in honey</a>',
- '>mutednarayan</a>',
+ ">bubbles in honey</a>",
+ ">mutednarayan</a>",
]
snippets.forEach((snippet) => {
expect(clippedText).toContain(snippet)
})
})
-test('can copy plain text attribution', async ({ page }) => {
- await page.goto('image/e9d97a98-621b-4ec2-bf70-f47a74380452')
+test("can copy plain text attribution", async ({ page }) => {
+ await page.goto("image/e9d97a98-621b-4ec2-bf70-f47a74380452")
await page.click('[aria-controls="panel-plain"]')
await page.click('[id="copyattr-plain"]')
const clippedText = await page.evaluate(async () => {
return navigator.clipboard.readText()
})
// Only the plain-text license contains the "To view" bit.
- expect(clippedText).toContain('To view a copy of this license')
+ expect(clippedText).toContain("To view a copy of this license")
})
diff --git a/test/playwright/e2e/audio-detail.spec.ts b/test/playwright/e2e/audio-detail.spec.ts
index 4c813ee57..a9ff89b56 100644
--- a/test/playwright/e2e/audio-detail.spec.ts
+++ b/test/playwright/e2e/audio-detail.spec.ts
@@ -1,25 +1,25 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+import { mockProviderApis } from "~~/test/playwright/utils/route"
const goToCustomAudioPage = async (page: Page) => {
// Test in a custom audio detail page, it should apply the same for any audio.
- await page.goto('audio/7e063ee6-343f-48e4-a4a5-f436393730f6')
+ await page.goto("audio/7e063ee6-343f-48e4-a4a5-f436393730f6")
}
const showsErrorPage = async (page: Page) => {
- await expect(page.locator('h1')).toHaveText(
+ await expect(page.locator("h1")).toHaveText(
/The content you’re looking for seems to have disappeared/
)
}
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
-test('shows the data that is only available in single result, not search response', async ({
+test("shows the data that is only available in single result, not search response", async ({
page,
}) => {
await goToCustomAudioPage(page)
@@ -28,12 +28,12 @@ test('shows the data that is only available in single result, not search respons
).toBeVisible()
})
-test('shows the 404 error page when no valid id', async ({ page }) => {
- await page.goto('audio/foo')
+test("shows the 404 error page when no valid id", async ({ page }) => {
+ await page.goto("audio/foo")
await showsErrorPage(page)
})
-test('shows the 404 error page when no id', async ({ page }) => {
- await page.goto('audio/')
+test("shows the 404 error page when no id", async ({ page }) => {
+ await page.goto("audio/")
await showsErrorPage(page)
})
diff --git a/test/playwright/e2e/filters-old.spec.ts b/test/playwright/e2e/filters-old.spec.ts
index 95f4166bf..b3549bacd 100644
--- a/test/playwright/e2e/filters-old.spec.ts
+++ b/test/playwright/e2e/filters-old.spec.ts
@@ -1,4 +1,4 @@
-import { expect, Page, test } from '@playwright/test'
+import { expect, Page, test } from "@playwright/test"
import {
assertCheckboxStatus,
@@ -6,18 +6,18 @@ import {
goToSearchTerm,
OLD_HEADER,
openFilters,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+import { mockProviderApis } from "~~/test/playwright/utils/route"
import {
ALL_MEDIA,
AUDIO,
IMAGE,
supportedSearchTypes,
-} from '~/constants/media'
+} from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
@@ -25,13 +25,13 @@ test.beforeEach(async ({ context }) => {
const assertCheckboxCount = async (
page: Page,
- checked: 'checked' | 'notChecked' | 'total',
+ checked: "checked" | "notChecked" | "total",
count: number
) => {
const checkedString = {
- checked: ':checked',
- notChecked: ':not(:checked)',
- total: '',
+ checked: ":checked",
+ notChecked: ":not(:checked)",
+ total: "",
}[checked]
const locatorString = `input[type="checkbox"]${checkedString}`
await expect(page.locator(locatorString)).toHaveCount(count, { timeout: 200 })
@@ -47,90 +47,90 @@ for (const searchType of supportedSearchTypes) {
test(`correct total number of filters is displayed for ${searchType}`, async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType })
+ await goToSearchTerm(page, "cat", { searchType })
await openFilters(page, OLD_HEADER)
- await assertCheckboxCount(page, 'total', FILTER_COUNTS[searchType])
+ await assertCheckboxCount(page, "total", FILTER_COUNTS[searchType])
})
}
-test('initial filters are applied based on the url', async ({ page }) => {
+test("initial filters are applied based on the url", async ({ page }) => {
await page.goto(
- '/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page, OLD_HEADER)
- const expectedFilters = ['cc0', 'commercial', 'creator']
+ const expectedFilters = ["cc0", "commercial", "creator"]
for (const checkbox of expectedFilters) {
await assertCheckboxStatus(page, checkbox)
}
})
-test('common filters are retained when media type changes from all media to single type', async ({
+test("common filters are retained when media type changes from all media to single type", async ({
page,
}) => {
await page.goto(
- '/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page, OLD_HEADER)
- const expectedFilters = ['cc0', 'commercial', 'creator']
+ const expectedFilters = ["cc0", "commercial", "creator"]
for (const checkbox of expectedFilters) {
await assertCheckboxStatus(page, checkbox)
}
- await changeContentType(page, 'Images', OLD_HEADER)
+ await changeContentType(page, "Images", OLD_HEADER)
await expect(page).toHaveURL(
- '/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
for (const checkbox of expectedFilters) {
await assertCheckboxStatus(page, checkbox)
}
})
-test('common filters are retained when media type changes from single type to all media', async ({
+test("common filters are retained when media type changes from single type to all media", async ({
page,
}) => {
await page.goto(
- '/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page, OLD_HEADER)
- for (const checkbox of ['cc0', 'commercial', 'creator']) {
+ for (const checkbox of ["cc0", "commercial", "creator"]) {
await assertCheckboxStatus(page, checkbox)
}
- await changeContentType(page, 'All content', OLD_HEADER)
+ await changeContentType(page, "All content", OLD_HEADER)
- for (const checkbox of ['cc0', 'commercial', 'creator']) {
+ for (const checkbox of ["cc0", "commercial", "creator"]) {
await assertCheckboxStatus(page, checkbox)
}
await expect(page).toHaveURL(
- '/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
})
-test('selecting some filters can disable dependent filters', async ({
+test("selecting some filters can disable dependent filters", async ({
page,
}) => {
- await page.goto('/search/audio?q=cat&license_type=commercial')
+ await page.goto("/search/audio?q=cat&license_type=commercial")
await openFilters(page, OLD_HEADER)
// by-nc is special because we normally test for fuzzy match, and by-nc matches 3 labels.
const byNc = page.locator('input[value="by-nc"]')
await expect(byNc).toBeDisabled()
- for (const checkbox of ['by-nc-sa', 'by-nc-nd']) {
- await assertCheckboxStatus(page, checkbox, '', 'disabled')
+ for (const checkbox of ["by-nc-sa", "by-nc-nd"]) {
+ await assertCheckboxStatus(page, checkbox, "", "disabled")
}
- await assertCheckboxStatus(page, 'commercial')
+ await assertCheckboxStatus(page, "commercial")
await page.click('label:has-text("commercial")')
- await assertCheckboxStatus(page, 'commercial', '', 'unchecked')
+ await assertCheckboxStatus(page, "commercial", "", "unchecked")
await expect(byNc).not.toBeDisabled()
- for (const checkbox of ['commercial', 'by-nc-sa', 'by-nc-nd']) {
- await assertCheckboxStatus(page, checkbox, '', 'unchecked')
+ for (const checkbox of ["commercial", "by-nc-sa", "by-nc-nd"]) {
+ await assertCheckboxStatus(page, checkbox, "", "unchecked")
}
})
@@ -143,47 +143,47 @@ test('selecting some filters can disable dependent filters', async ({
* Tests for the missing checkbox with `toHaveCount` are flaky, so we use filter button
* text and the URL instead.
*/
-test('filters are updated when media type changes', async ({ page }) => {
- await page.goto('/search/image?q=cat&aspect_ratio=tall&license=cc0')
+test("filters are updated when media type changes", async ({ page }) => {
+ await page.goto("/search/image?q=cat&aspect_ratio=tall&license=cc0")
await openFilters(page, OLD_HEADER)
- await assertCheckboxStatus(page, 'tall')
- await assertCheckboxStatus(page, 'cc0')
+ await assertCheckboxStatus(page, "tall")
+ await assertCheckboxStatus(page, "cc0")
- await changeContentType(page, 'Audio', OLD_HEADER)
+ await changeContentType(page, "Audio", OLD_HEADER)
// Only CC0 checkbox is checked, and the filter button label is '1 Filter'
- await assertCheckboxStatus(page, 'cc0')
+ await assertCheckboxStatus(page, "cc0")
await expect(
page.locator('[aria-controls="filters"] span:visible')
- ).toHaveText('1 Filter')
+ ).toHaveText("1 Filter")
- await expect(page).toHaveURL('/search/audio?q=cat&license=cc0')
+ await expect(page).toHaveURL("/search/audio?q=cat&license=cc0")
})
-test('new media request is sent when a filter is selected', async ({
+test("new media request is sent when a filter is selected", async ({
page,
}) => {
- await page.goto('/search/image?q=cat')
+ await page.goto("/search/image?q=cat")
await openFilters(page, OLD_HEADER)
- await assertCheckboxStatus(page, 'cc0', '', 'unchecked')
+ await assertCheckboxStatus(page, "cc0", "", "unchecked")
const [response] = await Promise.all([
- page.waitForResponse((response) => response.url().includes('cc0')),
+ page.waitForResponse((response) => response.url().includes("cc0")),
page.click('label:has-text("CC0")'),
])
- await assertCheckboxStatus(page, 'cc0')
+ await assertCheckboxStatus(page, "cc0")
// Remove the host url and path because when proxied, the 'http://localhost:49153' is used instead of the
// real API url
- const queryString = response.url().split('/images/')[1]
- expect(queryString).toEqual('?q=cat&license=cc0')
+ const queryString = response.url().split("/images/")[1]
+ expect(queryString).toEqual("?q=cat&license=cc0")
})
for (const [searchType, source] of [
- ['audio', 'Freesound'],
- ['image', 'Flickr'],
+ ["audio", "Freesound"],
+ ["image", "Flickr"],
]) {
test(`Provider filters are correctly initialized from the URL: ${source} - ${searchType}`, async ({
page,
@@ -193,6 +193,6 @@ for (const [searchType, source] of [
)
await openFilters(page, OLD_HEADER)
- await assertCheckboxStatus(page, source, '', 'checked')
+ await assertCheckboxStatus(page, source, "", "checked")
})
}
diff --git a/test/playwright/e2e/filters.spec.ts b/test/playwright/e2e/filters.spec.ts
index 8b59a2418..bd872556e 100644
--- a/test/playwright/e2e/filters.spec.ts
+++ b/test/playwright/e2e/filters.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
import {
assertCheckboxStatus,
@@ -8,30 +8,30 @@ import {
enableNewHeader,
closeFilters,
isPageDesktop,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+import { mockProviderApis } from "~~/test/playwright/utils/route"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
import {
supportedSearchTypes,
ALL_MEDIA,
IMAGE,
AUDIO,
-} from '~/constants/media'
+} from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
const assertCheckboxCount = async (
page: Page,
- checked: 'checked' | 'notChecked' | 'total',
+ checked: "checked" | "notChecked" | "total",
count: number
) => {
const checkedString = {
- checked: ':checked',
- notChecked: ':not(:checked)',
- total: '',
+ checked: ":checked",
+ notChecked: ":not(:checked)",
+ total: "",
}[checked]
const locatorString = `input[type="checkbox"]${checkedString}`
await expect(page.locator(locatorString)).toHaveCount(count, { timeout: 200 })
@@ -52,42 +52,42 @@ breakpoints.describeMobileAndDesktop(() => {
test(`correct total number of filters is displayed for ${searchType}`, async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType })
+ await goToSearchTerm(page, "cat", { searchType })
await openFilters(page)
- await assertCheckboxCount(page, 'total', FILTER_COUNTS[searchType])
+ await assertCheckboxCount(page, "total", FILTER_COUNTS[searchType])
})
}
- test('initial filters are applied based on the url', async ({ page }) => {
+ test("initial filters are applied based on the url", async ({ page }) => {
await page.goto(
- '/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page)
- const expectedFilters = ['cc0', 'commercial', 'creator']
+ const expectedFilters = ["cc0", "commercial", "creator"]
for (const checkbox of expectedFilters) {
await assertCheckboxStatus(page, checkbox)
}
})
- test('common filters are retained when media type changes from all media to single type', async ({
+ test("common filters are retained when media type changes from all media to single type", async ({
page,
}) => {
await page.goto(
- '/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page)
- const expectedFilters = ['cc0', 'commercial', 'creator']
+ const expectedFilters = ["cc0", "commercial", "creator"]
for (const checkbox of expectedFilters) {
await assertCheckboxStatus(page, checkbox)
}
- await changeContentType(page, 'Images')
+ await changeContentType(page, "Images")
await expect(page).toHaveURL(
- '/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page)
for (const checkbox of expectedFilters) {
@@ -95,48 +95,48 @@ breakpoints.describeMobileAndDesktop(() => {
}
})
- test('common filters are retained when media type changes from single type to all media', async ({
+ test("common filters are retained when media type changes from single type to all media", async ({
page,
}) => {
await page.goto(
- '/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/image?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page)
- for (const checkbox of ['cc0', 'commercial', 'creator']) {
+ for (const checkbox of ["cc0", "commercial", "creator"]) {
await assertCheckboxStatus(page, checkbox)
}
- await changeContentType(page, 'All content')
+ await changeContentType(page, "All content")
await openFilters(page)
await expect(page.locator('input[type="checkbox"]:checked')).toHaveCount(3)
await expect(page).toHaveURL(
- '/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator'
+ "/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
})
- test('selecting some filters can disable dependent filters', async ({
+ test("selecting some filters can disable dependent filters", async ({
page,
}) => {
- await page.goto('/search/audio?q=cat&license_type=commercial')
+ await page.goto("/search/audio?q=cat&license_type=commercial")
await openFilters(page)
// by-nc is special because we normally test for fuzzy match, and by-nc matches 3 labels.
const byNc = page.locator('input[value="by-nc"]')
await expect(byNc).toBeDisabled()
- for (const checkbox of ['by-nc-sa', 'by-nc-nd']) {
- await assertCheckboxStatus(page, checkbox, '', 'disabled')
+ for (const checkbox of ["by-nc-sa", "by-nc-nd"]) {
+ await assertCheckboxStatus(page, checkbox, "", "disabled")
}
- await assertCheckboxStatus(page, 'commercial')
+ await assertCheckboxStatus(page, "commercial")
await page.click('label:has-text("commercial")')
- await assertCheckboxStatus(page, 'commercial', '', 'unchecked')
+ await assertCheckboxStatus(page, "commercial", "", "unchecked")
await expect(byNc).not.toBeDisabled()
- for (const checkbox of ['commercial', 'by-nc-sa', 'by-nc-nd']) {
- await assertCheckboxStatus(page, checkbox, '', 'unchecked')
+ for (const checkbox of ["commercial", "by-nc-sa", "by-nc-nd"]) {
+ await assertCheckboxStatus(page, checkbox, "", "unchecked")
}
})
@@ -149,59 +149,59 @@ breakpoints.describeMobileAndDesktop(() => {
* Tests for the missing checkbox with `toHaveCount` are flaky, so we use filter button
* text and the URL instead.
*/
- test('filters are updated when media type changes', async ({ page }) => {
- await page.goto('/search/image?q=cat&aspect_ratio=tall&license=cc0')
+ test("filters are updated when media type changes", async ({ page }) => {
+ await page.goto("/search/image?q=cat&aspect_ratio=tall&license=cc0")
await openFilters(page)
- await assertCheckboxStatus(page, 'tall')
- await assertCheckboxStatus(page, 'cc0')
+ await assertCheckboxStatus(page, "tall")
+ await assertCheckboxStatus(page, "cc0")
- await changeContentType(page, 'Audio')
+ await changeContentType(page, "Audio")
await openFilters(page)
// Only CC0 checkbox is checked, and the filter button label is
// '1 Filter' on `xl` or '1' on `lg` screens
- await assertCheckboxStatus(page, 'cc0')
+ await assertCheckboxStatus(page, "cc0")
await closeFilters(page)
if (isPageDesktop(page)) {
const filterButtonText = await page
.locator('[aria-controls="filters"] span:visible')
.textContent()
- expect(filterButtonText).toContain('1')
+ expect(filterButtonText).toContain("1")
} else {
const filtersAriaLabel =
(await page
.locator('[aria-controls="content-settings-modal"]')
- .getAttribute('aria-label')) ?? ''
- expect(filtersAriaLabel.trim()).toEqual('Menu. 1 filter applied')
+ .getAttribute("aria-label")) ?? ""
+ expect(filtersAriaLabel.trim()).toEqual("Menu. 1 filter applied")
}
- await expect(page).toHaveURL('/search/audio?q=cat&license=cc0')
+ await expect(page).toHaveURL("/search/audio?q=cat&license=cc0")
})
- test('new media request is sent when a filter is selected', async ({
+ test("new media request is sent when a filter is selected", async ({
page,
}) => {
- await page.goto('/search/image?q=cat')
+ await page.goto("/search/image?q=cat")
await openFilters(page)
- await assertCheckboxStatus(page, 'cc0', '', 'unchecked')
+ await assertCheckboxStatus(page, "cc0", "", "unchecked")
const [response] = await Promise.all([
- page.waitForResponse((response) => response.url().includes('cc0')),
+ page.waitForResponse((response) => response.url().includes("cc0")),
page.click('label:has-text("CC0")'),
])
- await assertCheckboxStatus(page, 'cc0')
+ await assertCheckboxStatus(page, "cc0")
// Remove the host url and path because when proxied, the 'http://localhost:49153' is used instead of the
// real API url
- const queryString = response.url().split('/images/')[1]
- expect(queryString).toEqual('?q=cat&license=cc0')
+ const queryString = response.url().split("/images/")[1]
+ expect(queryString).toEqual("?q=cat&license=cc0")
})
for (const [searchType, source] of [
- ['audio', 'Freesound'],
- ['image', 'Flickr'],
+ ["audio", "Freesound"],
+ ["image", "Flickr"],
]) {
test(`Provider filters are correctly initialized from the URL: ${source} - ${searchType}`, async ({
page,
@@ -211,7 +211,7 @@ breakpoints.describeMobileAndDesktop(() => {
)
await openFilters(page)
- await assertCheckboxStatus(page, source, '', 'checked')
+ await assertCheckboxStatus(page, source, "", "checked")
})
}
})
diff --git a/test/playwright/e2e/global-audio.spec.ts b/test/playwright/e2e/global-audio.spec.ts
index a3a1ec236..9480e13a9 100644
--- a/test/playwright/e2e/global-audio.spec.ts
+++ b/test/playwright/e2e/global-audio.spec.ts
@@ -1,50 +1,50 @@
-import { test, expect, Page, Locator } from '@playwright/test'
+import { test, expect, Page, Locator } from "@playwright/test"
-import { sleep } from '~~/test/playwright/utils/navigation'
+import { sleep } from "~~/test/playwright/utils/navigation"
const getNthAudioRow = async (page: Page, num: number) => {
const rowSelector = `[aria-label*="Audio Player"] >> nth=${num}`
- const nthAudioRow = await page.locator(rowSelector).locator('article')
- expect(nthAudioRow).toHaveAttribute('status', 'paused')
+ const nthAudioRow = await page.locator(rowSelector).locator("article")
+ expect(nthAudioRow).toHaveAttribute("status", "paused")
return nthAudioRow
}
const play = async (audioRow: Locator) => {
await audioRow.locator('button[aria-label="Play"] >> visible=true').click()
- await expect(audioRow).toHaveAttribute('status', /(loading|playing)/)
+ await expect(audioRow).toHaveAttribute("status", /(loading|playing)/)
}
-test.describe('global audio', () => {
- test.skip('track continues playing when navigating from audio search to its details page', async ({
+test.describe("global audio", () => {
+ test.skip("track continues playing when navigating from audio search to its details page", async ({
page,
}) => {
- await page.goto('/search/audio?q=honey')
+ await page.goto("/search/audio?q=honey")
// Find and play the first audio result
const firstAudioRow = await getNthAudioRow(page, 0)
await play(firstAudioRow)
// Navigate to the details page of the playing audio track
- await firstAudioRow.locator('a').click()
+ await firstAudioRow.locator("a").click()
// and confirm is still playing (or loading to play)
- const mainPlayerButton = await page.locator('.main-track >> button')
+ const mainPlayerButton = await page.locator(".main-track >> button")
await sleep(600) // Doesn't seem to make a difference for the status
await expect(mainPlayerButton).toHaveAttribute(
- 'aria-label',
+ "aria-label",
/(Loading|Pause)/
)
})
- test.skip('player does not reproduce an audio different that the current audio in the details page', async ({
+ test.skip("player does not reproduce an audio different that the current audio in the details page", async ({
page,
}) => {
- await page.goto('/search/audio?q=honey')
+ await page.goto("/search/audio?q=honey")
// Find and play the first audio result
const firstAudioRow = await getNthAudioRow(page, 0)
await play(firstAudioRow)
// Navigate to the details page of the second audio track
const secondAudioRow = await getNthAudioRow(page, 1)
- await secondAudioRow.locator('a').click()
+ await secondAudioRow.locator("a").click()
// and confirm is not playing
- const mainPlayerButton = page.locator('.main-track >> button')
- await expect(mainPlayerButton).toHaveAttribute('aria-label', 'Play')
+ const mainPlayerButton = page.locator(".main-track >> button")
+ await expect(mainPlayerButton).toHaveAttribute("aria-label", "Play")
})
})
diff --git a/test/playwright/e2e/header-internal.spec.ts b/test/playwright/e2e/header-internal.spec.ts
index d58ef7628..722009ec3 100644
--- a/test/playwright/e2e/header-internal.spec.ts
+++ b/test/playwright/e2e/header-internal.spec.ts
@@ -1,38 +1,38 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
import {
enableNewHeader,
isMobileMenuOpen,
scrollToBottom,
t,
-} from '~~/test/playwright/utils/navigation'
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+} from "~~/test/playwright/utils/navigation"
+import breakpoints from "~~/test/playwright/utils/breakpoints"
const modalCloseButton = 'div[role="dialog"] >> [aria-label="Close"]'
const currentPageLink = 'div[role="dialog"] >> [aria-current="page"]'
-const menuButton = `[aria-label="${t('header.aria.menu')}"]`
+const menuButton = `[aria-label="${t("header.aria.menu")}"]`
const openMenu = async (page: Page) => await page.click(menuButton)
const closeMenu = async (page: Page) => await page.click(modalCloseButton)
-test.describe('Header internal', () => {
+test.describe("Header internal", () => {
breakpoints.describeSm(() => {
test.beforeEach(async ({ page }) => {
await enableNewHeader(page)
- await page.goto('/about')
+ await page.goto("/about")
})
- test('can open and close the modal on md breakpoint', async ({ page }) => {
+ test("can open and close the modal on md breakpoint", async ({ page }) => {
await openMenu(page)
expect(await isMobileMenuOpen(page)).toBe(true)
await expect(page.locator(currentPageLink)).toBeVisible()
- await expect(page.locator(currentPageLink)).toHaveText('About')
+ await expect(page.locator(currentPageLink)).toHaveText("About")
await closeMenu(page)
expect(await isMobileMenuOpen(page)).toBe(false)
await expect(page.locator(menuButton)).toBeVisible()
})
- test('the modal locks the scroll on md breakpoint', async ({ page }) => {
+ test("the modal locks the scroll on md breakpoint", async ({ page }) => {
await scrollToBottom(page)
await openMenu(page)
@@ -50,7 +50,7 @@ test.describe('Header internal', () => {
// Open the external link in a new tab, close the tab
const [popup] = await Promise.all([
- page.waitForEvent('popup'),
+ page.waitForEvent("popup"),
page.locator('div[role="dialog"] >> text=API').click(),
])
await popup.close()
diff --git a/test/playwright/e2e/homepage.spec.ts b/test/playwright/e2e/homepage.spec.ts
index 4c4523c20..a2b8e19bf 100644
--- a/test/playwright/e2e/homepage.spec.ts
+++ b/test/playwright/e2e/homepage.spec.ts
@@ -1,14 +1,14 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+import { mockProviderApis } from "~~/test/playwright/utils/route"
import {
goToSearchTerm,
searchTypePath,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-import { supportedSearchTypes } from '~/constants/media'
+import { supportedSearchTypes } from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
@@ -18,7 +18,7 @@ for (const searchType of supportedSearchTypes) {
test(`can change type and search for ${searchType} from homepage`, async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType, mode: 'CSR' })
+ await goToSearchTerm(page, "cat", { searchType, mode: "CSR" })
const expectedUrl = `/search/${searchTypePath(searchType)}?q=cat`
await expect(page).toHaveURL(expectedUrl)
@@ -26,16 +26,16 @@ for (const searchType of supportedSearchTypes) {
}
const popoverIsVisible = async (page: Page) =>
- await expect(page.locator('.popover-content')).toBeVisible()
+ await expect(page.locator(".popover-content")).toBeVisible()
const popoverIsNotVisible = async (page: Page) =>
- await expect(page.locator('.popover-content')).not.toBeVisible()
+ await expect(page.locator(".popover-content")).not.toBeVisible()
const clickPopoverButton = async (page: Page) =>
await page.click('button[aria-label="All content"]')
-test('can close the search type popover by clicking outside', async ({
+test("can close the search type popover by clicking outside", async ({
page,
}) => {
- await page.goto('/')
+ await page.goto("/")
await clickPopoverButton(page)
await popoverIsVisible(page)
@@ -43,14 +43,14 @@ test('can close the search type popover by clicking outside', async ({
await popoverIsNotVisible(page)
})
-test('can close the search type popover by pressing Escape', async ({
+test("can close the search type popover by pressing Escape", async ({
page,
}) => {
- await page.goto('/')
+ await page.goto("/")
await clickPopoverButton(page)
await popoverIsVisible(page)
- await page.keyboard.press('Escape')
+ await page.keyboard.press("Escape")
await popoverIsNotVisible(page)
})
diff --git a/test/playwright/e2e/image-detail.spec.ts b/test/playwright/e2e/image-detail.spec.ts
index c23932e53..f1605aa27 100644
--- a/test/playwright/e2e/image-detail.spec.ts
+++ b/test/playwright/e2e/image-detail.spec.ts
@@ -1,62 +1,62 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
-import { mockProviderApis } from '~~/test/playwright/utils/route'
-import { t } from '~~/test/playwright/utils/navigation'
+import { mockProviderApis } from "~~/test/playwright/utils/route"
+import { t } from "~~/test/playwright/utils/navigation"
const goToCustomImagePage = async (page: Page) => {
// Test in a custom image detail page, it should apply the same for any image.
- await page.goto('image/e9d97a98-621b-4ec2-bf70-f47a74380452')
+ await page.goto("image/e9d97a98-621b-4ec2-bf70-f47a74380452")
}
const showsErrorPage = async (page: Page) => {
- await expect(page.locator('h1')).toHaveText(
+ await expect(page.locator("h1")).toHaveText(
/The content you’re looking for seems to have disappeared/
)
}
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
-test('shows the author and title of the image', async ({ page }) => {
+test("shows the author and title of the image", async ({ page }) => {
await goToCustomImagePage(page)
const author = page.locator('a[aria-label^="author"]')
await expect(author).toBeVisible()
- const imgTitle = page.locator('h1')
+ const imgTitle = page.locator("h1")
await expect(imgTitle).toBeVisible()
})
-test('shows the main image with its title as alt text', async ({ page }) => {
+test("shows the main image with its title as alt text", async ({ page }) => {
await goToCustomImagePage(page)
- const imgTitle = await page.locator('h1').innerText()
- const img = page.locator('id=main-image')
+ const imgTitle = await page.locator("h1").innerText()
+ const img = page.locator("id=main-image")
await expect(img).toBeVisible()
- await expect(img).toHaveAttribute('alt', imgTitle)
+ await expect(img).toHaveAttribute("alt", imgTitle)
})
-test('does not show back to search results breadcrumb', async ({ page }) => {
+test("does not show back to search results breadcrumb", async ({ page }) => {
await goToCustomImagePage(page)
await expect(
- page.locator(`text="${t('single-result.back')}"`)
+ page.locator(`text="${t("single-result.back")}"`)
).not.toBeVisible({
timeout: 300,
})
})
-test('redirects from old /photos/:id route to /image/:id', async ({ page }) => {
- const uuid = 'e9d97a98-621b-4ec2-bf70-f47a74380452'
- await page.goto('photos/' + uuid)
- await expect(page).toHaveURL('image/' + uuid)
+test("redirects from old /photos/:id route to /image/:id", async ({ page }) => {
+ const uuid = "e9d97a98-621b-4ec2-bf70-f47a74380452"
+ await page.goto("photos/" + uuid)
+ await expect(page).toHaveURL("image/" + uuid)
})
-test('shows the 404 error page when no valid id', async ({ page }) => {
- await page.goto('image/foo')
+test("shows the 404 error page when no valid id", async ({ page }) => {
+ await page.goto("image/foo")
await showsErrorPage(page)
})
-test('shows the 404 error page when no id', async ({ page }) => {
- await page.goto('image/')
+test("shows the 404 error page when no id", async ({ page }) => {
+ await page.goto("image/")
await showsErrorPage(page)
})
diff --git a/test/playwright/e2e/load-more.spec.ts b/test/playwright/e2e/load-more.spec.ts
index 1b7f46794..9aac9d4c3 100644
--- a/test/playwright/e2e/load-more.spec.ts
+++ b/test/playwright/e2e/load-more.spec.ts
@@ -1,28 +1,28 @@
-import { expect, Page, test } from '@playwright/test'
+import { expect, Page, test } from "@playwright/test"
import {
goToSearchTerm,
renderModes,
t,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
-import { AUDIO, IMAGE, SupportedMediaType } from '~/constants/media'
+import { AUDIO, IMAGE, SupportedMediaType } from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
-const loadMoreButton = `button:has-text("${t('browse-page.load', 'ltr')}")`
+const loadMoreButton = `button:has-text("${t("browse-page.load", "ltr")}")`
const openSingleMediaView = async (
page: Page,
mediaType: SupportedMediaType
) => {
const contentLinkSelector =
- mediaType === IMAGE ? 'See all images' : 'See all audio'
+ mediaType === IMAGE ? "See all images" : "See all audio"
return await Promise.all([
page.waitForNavigation(),
page.click(`text=${contentLinkSelector}`),
@@ -44,22 +44,22 @@ const openSingleMediaView = async (
* - image view should have a Load more button.
*/
-test.describe('Load more button', () => {
- test('Clicking sends 2 requests on All view with enough results', async ({
+test.describe("Load more button", () => {
+ test("Clicking sends 2 requests on All view with enough results", async ({
page,
}) => {
const additionalRequests = [] as SupportedMediaType[]
- page.on('request', (re) => {
+ page.on("request", (re) => {
const url = re.url()
- if (url.includes('page=2')) {
- if (url.includes('/audio/')) {
+ if (url.includes("page=2")) {
+ if (url.includes("/audio/")) {
additionalRequests.push(AUDIO)
- } else if (url.includes('/images/')) {
+ } else if (url.includes("/images/")) {
additionalRequests.push(IMAGE)
}
}
})
- await goToSearchTerm(page, 'cat')
+ await goToSearchTerm(page, "cat")
await expect(page.locator(loadMoreButton)).toBeVisible()
await page.click(loadMoreButton)
@@ -72,7 +72,7 @@ test.describe('Load more button', () => {
for (const mode of renderModes) {
test.describe(mode, () => {
test(`Rendered on All view if enough results`, async ({ page }) => {
- await goToSearchTerm(page, 'cat', { mode })
+ await goToSearchTerm(page, "cat", { mode })
await expect(page.locator(loadMoreButton)).toBeVisible()
// Load more button is also available on single media type views.
@@ -88,7 +88,7 @@ test.describe('Load more button', () => {
test(`Renders on All view when images have results but audio does not`, async ({
page,
}) => {
- await goToSearchTerm(page, 'ecommerce', { mode })
+ await goToSearchTerm(page, "ecommerce", { mode })
await expect(page.locator(loadMoreButton)).toBeVisible()
})
@@ -97,17 +97,17 @@ test.describe('Load more button', () => {
page,
}) => {
const additionalRequests = [] as SupportedMediaType[]
- page.on('request', (req) => {
+ page.on("request", (req) => {
const url = req.url()
- if (url.includes('page=2')) {
- if (url.includes('/audio/')) {
+ if (url.includes("page=2")) {
+ if (url.includes("/audio/")) {
additionalRequests.push(AUDIO)
- } else if (url.includes('/images/')) {
+ } else if (url.includes("/images/")) {
additionalRequests.push(IMAGE)
}
}
})
- await goToSearchTerm(page, 'horses snort', { mode })
+ await goToSearchTerm(page, "horses snort", { mode })
await page.click(loadMoreButton)
expect(additionalRequests.length).toEqual(1)
@@ -117,11 +117,11 @@ test.describe('Load more button', () => {
test(`Rendered on All view but not on the audio view when audio has only 1 page of results`, async ({
page,
}) => {
- await goToSearchTerm(page, 'horses snort', { mode })
+ await goToSearchTerm(page, "horses snort", { mode })
await expect(page.locator(loadMoreButton)).toBeVisible()
// Cannot go to the audio view because the link is disabled.
- await goToSearchTerm(page, 'horses snort', { mode, searchType: AUDIO })
+ await goToSearchTerm(page, "horses snort", { mode, searchType: AUDIO })
await expect(page.locator(loadMoreButton)).not.toBeVisible()
})
})
diff --git a/test/playwright/e2e/migration-banner.spec.ts b/test/playwright/e2e/migration-banner.spec.ts
index 6b785c464..12a3c77fa 100644
--- a/test/playwright/e2e/migration-banner.spec.ts
+++ b/test/playwright/e2e/migration-banner.spec.ts
@@ -1,54 +1,54 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('migration banner', () => {
- test('shows migration banner on homepage', async ({ page }) => {
- await page.goto('/?referrer=creativecommons.org')
+test.describe("migration banner", () => {
+ test("shows migration banner on homepage", async ({ page }) => {
+ await page.goto("/?referrer=creativecommons.org")
const migrationNotice = page.locator('[data-testid="banner-cc-referral"]')
- const message = 'CC Search is now called Openverse'
+ const message = "CC Search is now called Openverse"
await expect(migrationNotice).toContainText(message)
await expect(migrationNotice).toBeVisible()
})
- test('does not show migration banner if cookie dismissed value is saved', async ({
+ test("does not show migration banner if cookie dismissed value is saved", async ({
context,
page,
}) => {
await context.addCookies([
{
- name: 'uiDismissedBanners',
+ name: "uiDismissedBanners",
value: '["cc-referral"]',
- domain: 'localhost',
- path: '/',
+ domain: "localhost",
+ path: "/",
},
])
- await page.goto('/?referrer=creativecommons.org')
+ await page.goto("/?referrer=creativecommons.org")
const migrationNotice = page.locator('[data-testid="banner-cc-referral"]')
await expect(migrationNotice).toBeHidden()
})
- test('migration banner goes away on navigation', async ({ page }) => {
- await page.goto('/?referrer=creativecommons.org')
+ test("migration banner goes away on navigation", async ({ page }) => {
+ await page.goto("/?referrer=creativecommons.org")
const migrationNotice = page.locator('[data-testid="banner-cc-referral"]')
await expect(migrationNotice).toBeVisible()
// Navigate away from the page
await Promise.all([
- page.locator('a.homepage-image').first().click(),
- page.waitForLoadState('domcontentloaded'),
+ page.locator("a.homepage-image").first().click(),
+ page.waitForLoadState("domcontentloaded"),
])
await expect(migrationNotice).toBeHidden()
})
- test('migration banner is dismissable and stays dismissed', async ({
+ test("migration banner is dismissable and stays dismissed", async ({
page,
}) => {
- await page.goto('/?referrer=creativecommons.org')
+ await page.goto("/?referrer=creativecommons.org")
const migrationNotice = page.locator('[data-testid="banner-cc-referral"]')
await expect(migrationNotice).toBeVisible({ timeout: 500 })
diff --git a/test/playwright/e2e/mobile-menu-old.spec.ts b/test/playwright/e2e/mobile-menu-old.spec.ts
index fe398b6e4..202298130 100644
--- a/test/playwright/e2e/mobile-menu-old.spec.ts
+++ b/test/playwright/e2e/mobile-menu-old.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
import {
closeMobileMenu,
@@ -6,20 +6,20 @@ import {
OLD_HEADER,
openContentTypes,
openFilters,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
const mockUaString =
- 'Mozilla/5.0 (Android 7.0; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0'
+ "Mozilla/5.0 (Android 7.0; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0"
const mobileFixture = {
viewport: { width: 640, height: 700 },
userAgent: mockUaString,
}
test.use(mobileFixture)
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test('Can open filters menu on mobile at least twice', async ({ page }) => {
- await page.goto('/search/?q=cat')
+test("Can open filters menu on mobile at least twice", async ({ page }) => {
+ await page.goto("/search/?q=cat")
await openFilters(page, OLD_HEADER)
await expect(page.locator(`input[type="checkbox"]`)).toHaveCount(11, {
@@ -36,21 +36,21 @@ test('Can open filters menu on mobile at least twice', async ({ page }) => {
})
})
-test('Can open mobile menu at least twice', async ({ page }) => {
- await goToSearchTerm(page, 'cat')
+test("Can open mobile menu at least twice", async ({ page }) => {
+ await goToSearchTerm(page, "cat")
await openContentTypes(page, OLD_HEADER)
- await expect(page.locator('button', { hasText: 'Close' })).toBeVisible()
+ await expect(page.locator("button", { hasText: "Close" })).toBeVisible()
await closeMobileMenu(page, OLD_HEADER)
- await expect(page.locator('button', { hasText: 'Close' })).not.toBeVisible()
+ await expect(page.locator("button", { hasText: "Close" })).not.toBeVisible()
await openContentTypes(page, OLD_HEADER)
- await expect(page.locator('button', { hasText: 'Close' })).toBeVisible()
+ await expect(page.locator("button", { hasText: "Close" })).toBeVisible()
})
-test('Selecting a search type closes the modal', async ({ page }) => {
- await goToSearchTerm(page, 'cat')
+test("Selecting a search type closes the modal", async ({ page }) => {
+ await goToSearchTerm(page, "cat")
await openContentTypes(page, OLD_HEADER)
- await expect(page.locator('button', { hasText: 'Close' })).toBeVisible()
+ await expect(page.locator("button", { hasText: "Close" })).toBeVisible()
await page.locator('a[role="radio"]:has-text("Audio")').click()
- await expect(page.locator('button', { hasText: 'Close' })).not.toBeVisible()
+ await expect(page.locator("button", { hasText: "Close" })).not.toBeVisible()
})
diff --git a/test/playwright/e2e/mobile-menu.spec.ts b/test/playwright/e2e/mobile-menu.spec.ts
index 08e52ac76..b40d524d2 100644
--- a/test/playwright/e2e/mobile-menu.spec.ts
+++ b/test/playwright/e2e/mobile-menu.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
import {
closeFilters,
@@ -8,19 +8,19 @@ import {
isMobileMenuOpen,
openContentTypes,
openFilters,
-} from '~~/test/playwright/utils/navigation'
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+} from "~~/test/playwright/utils/navigation"
+import breakpoints from "~~/test/playwright/utils/breakpoints"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('mobile menu', () => {
+test.describe("mobile menu", () => {
breakpoints.describeSm(() => {
test.beforeEach(async ({ page }) => {
await enableNewHeader(page)
})
- test('Can open filters menu on mobile at least twice', async ({ page }) => {
- await page.goto('/search/?q=cat')
+ test("Can open filters menu on mobile at least twice", async ({ page }) => {
+ await page.goto("/search/?q=cat")
await openFilters(page)
expect(await isMobileMenuOpen(page)).toBe(true)
@@ -32,8 +32,8 @@ test.describe('mobile menu', () => {
expect(await isMobileMenuOpen(page)).toBe(false)
})
- test('Can open mobile menu at least twice', async ({ page }) => {
- await goToSearchTerm(page, 'cat')
+ test("Can open mobile menu at least twice", async ({ page }) => {
+ await goToSearchTerm(page, "cat")
await openContentTypes(page)
expect(await isMobileMenuOpen(page)).toBe(true)
await closeMobileMenu(page)
diff --git a/test/playwright/e2e/recent-searches.spec.ts b/test/playwright/e2e/recent-searches.spec.ts
index a2dd57a58..0237f6aed 100644
--- a/test/playwright/e2e/recent-searches.spec.ts
+++ b/test/playwright/e2e/recent-searches.spec.ts
@@ -1,27 +1,27 @@
-import { expect, test, type Page } from '@playwright/test'
+import { expect, test, type Page } from "@playwright/test"
import {
enableNewHeader,
searchFromHeader,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ page }) => {
await enableNewHeader(page)
// We are first navigating to search because the recent searches feature has
// not yet been implemented on the homepage.
- await page.goto('/search?q=galah')
+ await page.goto("/search?q=galah")
})
const executeSearches = async (page: Page) => {
- const searches = ['honey', 'galah'] // in that order
+ const searches = ["honey", "galah"] // in that order
for (const term of searches) await searchFromHeader(page, term)
return searches
}
-test('shows recent searches in reverse chronological order', async ({
+test("shows recent searches in reverse chronological order", async ({
page,
}) => {
const searches = await executeSearches(page)
@@ -34,29 +34,29 @@ test('shows recent searches in reverse chronological order', async ({
})
})
-test('clicking takes user to that search', async ({ page }) => {
+test("clicking takes user to that search", async ({ page }) => {
await executeSearches(page)
- expect(page.url()).toContain('?q=galah')
+ expect(page.url()).toContain("?q=galah")
// Click on the input to open the Recent searches
await page.locator('input[type="search"]').click()
await page
.locator(`[aria-label="Recent searches"]`)
.locator('[id="option-1"]')
.click()
- expect(page.url()).toContain('?q=honey')
+ expect(page.url()).toContain("?q=honey")
})
-test('recent searches shows message when blank', async ({ page }) => {
+test("recent searches shows message when blank", async ({ page }) => {
// Click on the input to open the Recent searches
await page.locator('input[type="search"]').click()
const recentSearchesText = await page
.locator('[data-testid="recent-searches"]')
.textContent()
- expect(recentSearchesText).toContain('No recent searches to show.')
+ expect(recentSearchesText).toContain("No recent searches to show.")
})
-test('clicking Clear clears the recent searches', async ({ page }) => {
+test("clicking Clear clears the recent searches", async ({ page }) => {
await executeSearches(page)
// Click on the input to open the Recent searches
await page.locator('input[type="search"]').click()
@@ -64,5 +64,5 @@ test('clicking Clear clears the recent searches', async ({ page }) => {
const recentSearchesText = await page
.locator('[data-testid="recent-searches"]')
.textContent()
- expect(recentSearchesText).toContain('No recent searches to show.')
+ expect(recentSearchesText).toContain("No recent searches to show.")
})
diff --git a/test/playwright/e2e/redirect-queryless-searches.spec.ts b/test/playwright/e2e/redirect-queryless-searches.spec.ts
index 1dea4f9f9..a6fc32281 100644
--- a/test/playwright/e2e/redirect-queryless-searches.spec.ts
+++ b/test/playwright/e2e/redirect-queryless-searches.spec.ts
@@ -3,11 +3,11 @@
* redirect to the homepage.
*/
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
-import { searchTypes, searchPath } from '~/constants/media'
+import { searchTypes, searchPath } from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
searchTypes.forEach((type) => {
test(`Queryless ${type} search redirects to homepage`, async ({ page }) => {
@@ -15,7 +15,7 @@ searchTypes.forEach((type) => {
expect(response?.request().redirectedFrom()?.url()).toBeDefined()
})
test(`${type} search with query doesn't redirect`, async ({ page }) => {
- const response = await page.goto(searchPath(type) + '?q=dog')
+ const response = await page.goto(searchPath(type) + "?q=dog")
expect(response?.request().redirectedFrom()?.url()).toBeUndefined()
})
})
diff --git a/test/playwright/e2e/report-media.spec.ts b/test/playwright/e2e/report-media.spec.ts
index e4e321493..eb2393a7c 100644
--- a/test/playwright/e2e/report-media.spec.ts
+++ b/test/playwright/e2e/report-media.spec.ts
@@ -1,20 +1,20 @@
-import { test, expect, Page, BrowserContext } from '@playwright/test'
+import { test, expect, Page, BrowserContext } from "@playwright/test"
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+import { mockProviderApis } from "~~/test/playwright/utils/route"
import {
goToSearchTerm,
openFirstResult,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-import { supportedMediaTypes } from '~/constants/media'
+import { supportedMediaTypes } from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
/**
* Some helpers for repeated actions.
*/
-const reportingEndpoint = '**/report/'
+const reportingEndpoint = "**/report/"
export const openReportModal = (page: Page) =>
page.click('text="Report this content"')
@@ -24,8 +24,8 @@ export const mockReportingEndpoint = (context: BrowserContext) =>
context.route(reportingEndpoint, (route) =>
route.fulfill({
status: 200,
- contentType: 'text/json',
- headers: { 'access-control-allow-origin': '*' },
+ contentType: "text/json",
+ headers: { "access-control-allow-origin": "*" },
})
)
@@ -42,20 +42,20 @@ export const submitApiReport = (page: Page) =>
const submitDmcaReport = async (page: Page, context: BrowserContext) => {
// Mock the Google Form to return a successful html document
- await context.route('https://docs.google.com/forms/**', (route) => {
+ await context.route("https://docs.google.com/forms/**", (route) => {
route.fulfill({
status: 200,
- contentType: 'text/html',
- body: '<div>Fake form!</div>',
+ contentType: "text/html",
+ body: "<div>Fake form!</div>",
})
})
await page.click('text="Infringes copyright"')
const [newPage] = await Promise.all([
- context.waitForEvent('page'),
+ context.waitForEvent("page"),
await page.click('text="Open form"'), // Opens a new tab
])
await newPage.waitForLoadState()
- return expect(await newPage.url()).toContain('https://docs.google.com/forms')
+ return expect(await newPage.url()).toContain("https://docs.google.com/forms")
}
// todo: Test a mature report with the optional description field
@@ -73,7 +73,7 @@ const submitOtherReport = async (page: Page, context: BrowserContext) => {
await mockReportingEndpoint(context)
await page.click('text="Other"')
await page.fill(
- 'text=Describe the issue',
+ "text=Describe the issue",
'This is an example "Other" report submit by Playwright, our automated e2e test tool.'
)
const response = await submitApiReport(page)
@@ -100,7 +100,7 @@ supportedMediaTypes.forEach((mediaType) => {
page,
context,
}) => {
- await goToSearchTerm(page, 'cat', { searchType: mediaType })
+ await goToSearchTerm(page, "cat", { searchType: mediaType })
await openFirstResult(page, mediaType)
await openReportModal(page)
await reportAssertion(page, context)
diff --git a/test/playwright/e2e/search-navigation-old.spec.ts b/test/playwright/e2e/search-navigation-old.spec.ts
index f9ab2c94a..22c75dacc 100644
--- a/test/playwright/e2e/search-navigation-old.spec.ts
+++ b/test/playwright/e2e/search-navigation-old.spec.ts
@@ -1,99 +1,99 @@
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
import {
goToSearchTerm,
OLD_HEADER,
openFilters,
t,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
-test.describe('search history navigation', () => {
- test('should update search results when back navigation changes filters', async ({
+test.describe("search history navigation", () => {
+ test("should update search results when back navigation changes filters", async ({
page,
}) => {
- await goToSearchTerm(page, 'galah')
+ await goToSearchTerm(page, "galah")
// Open filter sidebar
await openFilters(page, OLD_HEADER)
// Apply a filter
- await page.click('#modification')
+ await page.click("#modification")
// Verify the filter is applied to the URL and the checkbox is checked
// Note: Need to add that a search was actually executed with the new
// filters and that the page results have been updated for the new filters
// @todo(sarayourfriend): ^?
- expect(page.url()).toContain('license_type=modification')
- expect(await page.isChecked('#modification')).toBe(true)
+ expect(page.url()).toContain("license_type=modification")
+ expect(await page.isChecked("#modification")).toBe(true)
// Navigate backwards and verify URL is updated and the filter is unapplied
await page.goBack()
// Ditto here about the note above, need to verify a new search actually happened with new results
- expect(page.url()).not.toContain('license_type=modification')
- expect(await page.isChecked('#modification')).toBe(false)
+ expect(page.url()).not.toContain("license_type=modification")
+ expect(await page.isChecked("#modification")).toBe(false)
})
- test('should update search results when back button updates search type', async ({
+ test("should update search results when back button updates search type", async ({
page,
}) => {
- await goToSearchTerm(page, 'galah')
- await page.click('text=See all images')
- await page.waitForSelector('text=See all images', { state: 'hidden' })
- expect(page.url()).toContain('/search/image')
+ await goToSearchTerm(page, "galah")
+ await page.click("text=See all images")
+ await page.waitForSelector("text=See all images", { state: "hidden" })
+ expect(page.url()).toContain("/search/image")
await page.goBack()
- await page.waitForSelector('text=See all images')
- expect(await page.locator('text=See all images').isVisible()).toBe(true)
- expect(await page.locator('text=See all audio').isVisible()).toBe(true)
+ await page.waitForSelector("text=See all images")
+ expect(await page.locator("text=See all images").isVisible()).toBe(true)
+ expect(await page.locator("text=See all audio").isVisible()).toBe(true)
})
})
-test('navigates to the image detail page correctly', async ({ page }) => {
- await goToSearchTerm(page, 'honey')
- const figure = page.locator('figure').first()
- const imgTitle = await figure.locator('img').getAttribute('alt')
+test("navigates to the image detail page correctly", async ({ page }) => {
+ await goToSearchTerm(page, "honey")
+ const figure = page.locator("figure").first()
+ const imgTitle = await figure.locator("img").getAttribute("alt")
await page.locator('a[href^="/image"]').first().click()
// Until the image is loaded, the heading is 'Image' instead of the actual title
- await page.locator('#main-image').waitFor()
+ await page.locator("#main-image").waitFor()
- const headingText = await page.locator('h1').textContent()
+ const headingText = await page.locator("h1").textContent()
expect(headingText?.trim().toLowerCase()).toEqual(imgTitle?.toLowerCase())
})
-test.describe('back to search results link', () => {
- test('is visible in breadcrumb when navigating to image details page and returns to the search page', async ({
+test.describe("back to search results link", () => {
+ test("is visible in breadcrumb when navigating to image details page and returns to the search page", async ({
page,
}) => {
- const url = '/search/?q=galah'
+ const url = "/search/?q=galah"
await page.goto(url)
await page.locator('a[href^="/image"]').first().click()
- const link = page.locator(`text="${t('single-result.back')}"`)
+ const link = page.locator(`text="${t("single-result.back")}"`)
await expect(link).toBeVisible()
await link.click()
await expect(page).toHaveURL(url)
})
- test('is visible in breadcrumb when navigating to localized image details page', async ({
+ test("is visible in breadcrumb when navigating to localized image details page", async ({
page,
}) => {
- await page.goto('/es/search/?q=galah')
+ await page.goto("/es/search/?q=galah")
await page.locator('a[href^="/es/image"]').first().click()
await expect(
page.locator('text="Volver a los resultados de búsqueda"')
).toBeVisible()
})
- test('is visible in breadcrumb when navigating to localized audio details page', async ({
+ test("is visible in breadcrumb when navigating to localized audio details page", async ({
page,
}) => {
- await page.goto('/es/search/?q=galah')
+ await page.goto("/es/search/?q=galah")
await page.locator('a[href^="/es/audio"]').first().click()
await expect(
page.locator('text="Volver a los resultados de búsqueda"')
diff --git a/test/playwright/e2e/search-navigation.spec.ts b/test/playwright/e2e/search-navigation.spec.ts
index 709188a39..9b5bb1593 100644
--- a/test/playwright/e2e/search-navigation.spec.ts
+++ b/test/playwright/e2e/search-navigation.spec.ts
@@ -1,58 +1,58 @@
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
import {
enableNewHeader,
goToSearchTerm,
openFilters,
t,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
+import breakpoints from "~~/test/playwright/utils/breakpoints"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('search history navigation', () => {
+test.describe("search history navigation", () => {
breakpoints.describeMobileAndDesktop(() => {
test.beforeEach(async ({ context, page }) => {
await mockProviderApis(context)
await enableNewHeader(page)
})
- test('should update search results when back navigation changes filters', async ({
+ test("should update search results when back navigation changes filters", async ({
page,
}) => {
- await goToSearchTerm(page, 'galah')
+ await goToSearchTerm(page, "galah")
// Open filter sidebar
await openFilters(page)
// Apply a filter
- await page.click('#modification')
+ await page.click("#modification")
// Verify the filter is applied to the URL and the checkbox is checked
// Note: Need to add that a search was actually executed with the new
// filters and that the page results have been updated for the new filters
// @todo(sarayourfriend): ^?
- expect(page.url()).toContain('license_type=modification')
- expect(await page.isChecked('#modification')).toBe(true)
+ expect(page.url()).toContain("license_type=modification")
+ expect(await page.isChecked("#modification")).toBe(true)
// Navigate backwards and verify URL is updated and the filter is unapplied
await page.goBack()
// Ditto here about the note above, need to verify a new search actually happened with new results
- expect(page.url()).not.toContain('license_type=modification')
- expect(await page.isChecked('#modification')).toBe(false)
+ expect(page.url()).not.toContain("license_type=modification")
+ expect(await page.isChecked("#modification")).toBe(false)
})
- test('should update search results when back button updates search type', async ({
+ test("should update search results when back button updates search type", async ({
page,
}) => {
- await goToSearchTerm(page, 'galah')
+ await goToSearchTerm(page, "galah")
await page.click('a:has-text("See all images")')
await page.waitForSelector('p:has-text("See all images")', {
- state: 'hidden',
+ state: "hidden",
})
- expect(page.url()).toContain('/search/image')
+ expect(page.url()).toContain("/search/image")
await page.goBack()
await page.waitForSelector('a:has-text("See all images")')
expect(
@@ -63,46 +63,46 @@ test.describe('search history navigation', () => {
).toBe(true)
})
- test('navigates to the image detail page correctly', async ({ page }) => {
- await goToSearchTerm(page, 'honey')
- const figure = page.locator('figure').first()
- const imgTitle = await figure.locator('img').getAttribute('alt')
+ test("navigates to the image detail page correctly", async ({ page }) => {
+ await goToSearchTerm(page, "honey")
+ const figure = page.locator("figure").first()
+ const imgTitle = await figure.locator("img").getAttribute("alt")
await page.locator('a[href^="/image"]').first().click()
// Until the image is loaded, the heading is 'Image' instead of the actual title
- await page.locator('#main-image').waitFor()
+ await page.locator("#main-image").waitFor()
- const headingText = await page.locator('h1').textContent()
+ const headingText = await page.locator("h1").textContent()
expect(headingText?.trim().toLowerCase()).toEqual(imgTitle?.toLowerCase())
})
- test.describe('back to search results link', () => {
- test('is visible in breadcrumb when navigating to image details page and returns to the search page', async ({
+ test.describe("back to search results link", () => {
+ test("is visible in breadcrumb when navigating to image details page and returns to the search page", async ({
page,
}) => {
- const url = '/search/?q=galah'
+ const url = "/search/?q=galah"
await page.goto(url)
await page.locator('a[href^="/image"]').first().click()
- const link = page.locator(`text="${t('single-result.back')}"`)
+ const link = page.locator(`text="${t("single-result.back")}"`)
await expect(link).toBeVisible()
await link.click()
await expect(page).toHaveURL(url)
})
- test('is visible in breadcrumb when navigating to localized image details page', async ({
+ test("is visible in breadcrumb when navigating to localized image details page", async ({
page,
}) => {
- await page.goto('/es/search/?q=galah')
+ await page.goto("/es/search/?q=galah")
await page.locator('a[href^="/es/image"]').first().click()
await expect(
page.locator('text="Volver a los resultados de búsqueda"')
).toBeVisible()
})
- test('is visible in breadcrumb when navigating to localized audio details page', async ({
+ test("is visible in breadcrumb when navigating to localized audio details page", async ({
page,
}) => {
- await page.goto('/es/search/?q=galah')
+ await page.goto("/es/search/?q=galah")
await page.locator('a[href^="/es/audio"]').first().click()
await expect(
page.locator('text="Volver a los resultados de búsqueda"')
diff --git a/test/playwright/e2e/search-query-client-old.spec.ts b/test/playwright/e2e/search-query-client-old.spec.ts
index c8e68c7bc..115f17d61 100644
--- a/test/playwright/e2e/search-query-client-old.spec.ts
+++ b/test/playwright/e2e/search-query-client-old.spec.ts
@@ -1,13 +1,13 @@
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
import {
changeContentType,
goToSearchTerm,
OLD_HEADER,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
-import { AUDIO, IMAGE } from '~/constants/media'
+import { AUDIO, IMAGE } from "~/constants/media"
/**
* When navigating to the search page on the client side:
@@ -21,66 +21,66 @@ import { AUDIO, IMAGE } from '~/constants/media'
* All of these tests test search page on the client
*/
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
-test('q query parameter is set as the search term', async ({ page }) => {
- await goToSearchTerm(page, 'cat', { mode: 'CSR' })
+test("q query parameter is set as the search term", async ({ page }) => {
+ await goToSearchTerm(page, "cat", { mode: "CSR" })
- await expect(page.locator('header input[type="search"]')).toHaveValue('cat')
- await expect(page).toHaveURL('search/?q=cat')
+ await expect(page.locator('header input[type="search"]')).toHaveValue("cat")
+ await expect(page).toHaveURL("search/?q=cat")
})
-test('selecting `audio` on homepage, you can search for audio', async ({
+test("selecting `audio` on homepage, you can search for audio", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType: AUDIO, mode: 'CSR' })
+ await goToSearchTerm(page, "cat", { searchType: AUDIO, mode: "CSR" })
- await expect(page.locator('header input[type="search"]')).toHaveValue('cat')
+ await expect(page.locator('header input[type="search"]')).toHaveValue("cat")
- await expect(page).toHaveURL('search/audio?q=cat')
+ await expect(page).toHaveURL("search/audio?q=cat")
})
-test('url filter parameters not used by current mediaType are discarded', async ({
+test("url filter parameters not used by current mediaType are discarded", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'category=photograph',
+ query: "category=photograph",
})
- await changeContentType(page, 'Audio', OLD_HEADER)
- await expect(page).toHaveURL('/search/audio?q=cat')
+ await changeContentType(page, "Audio", OLD_HEADER)
+ await expect(page).toHaveURL("/search/audio?q=cat")
})
-test('url filter types not used by current mediaType are discarded', async ({
+test("url filter types not used by current mediaType are discarded", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'aspect_ratio=tall',
+ query: "aspect_ratio=tall",
})
- await changeContentType(page, 'Audio', OLD_HEADER)
- await expect(page).toHaveURL('/search/audio?q=cat')
+ await changeContentType(page, "Audio", OLD_HEADER)
+ await expect(page).toHaveURL("/search/audio?q=cat")
})
-test('can search for a different term', async ({ page }) => {
- await goToSearchTerm(page, 'cat', { searchType: IMAGE })
- await page.fill('header input[type="search"]', 'dog')
- await page.keyboard.press('Enter')
- await expect(page).toHaveURL('/search/image?q=dog')
+test("can search for a different term", async ({ page }) => {
+ await goToSearchTerm(page, "cat", { searchType: IMAGE })
+ await page.fill('header input[type="search"]', "dog")
+ await page.keyboard.press("Enter")
+ await expect(page).toHaveURL("/search/image?q=dog")
})
-test('search for a different term keeps query parameters', async ({ page }) => {
- await goToSearchTerm(page, 'cat', {
+test("search for a different term keeps query parameters", async ({ page }) => {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'license=by&extension=jpg',
+ query: "license=by&extension=jpg",
})
- await page.fill('header input[type="search"]', 'dog')
- await page.keyboard.press('Enter')
- await expect(page).toHaveURL('/search/image?q=dog&license=by&extension=jpg')
+ await page.fill('header input[type="search"]', "dog")
+ await page.keyboard.press("Enter")
+ await expect(page).toHaveURL("/search/image?q=dog&license=by&extension=jpg")
})
diff --git a/test/playwright/e2e/search-query-client.spec.ts b/test/playwright/e2e/search-query-client.spec.ts
index 8ecf679f8..366d14523 100644
--- a/test/playwright/e2e/search-query-client.spec.ts
+++ b/test/playwright/e2e/search-query-client.spec.ts
@@ -1,16 +1,16 @@
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
import {
changeContentType,
enableNewHeader,
goToSearchTerm,
searchFromHeader,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
-import { AUDIO, IMAGE } from '~/constants/media'
+import { AUDIO, IMAGE } from "~/constants/media"
/**
* When navigating to the search page on the client side:
@@ -24,79 +24,79 @@ import { AUDIO, IMAGE } from '~/constants/media'
* All of these tests test search page on the client
*/
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('search query on CSR', () => {
+test.describe("search query on CSR", () => {
breakpoints.describeMobileAndDesktop(() => {
test.beforeEach(async ({ context, page }) => {
await mockProviderApis(context)
await enableNewHeader(page)
})
- test('q query parameter is set as the search term', async ({ page }) => {
- await goToSearchTerm(page, 'cat', { mode: 'CSR' })
+ test("q query parameter is set as the search term", async ({ page }) => {
+ await goToSearchTerm(page, "cat", { mode: "CSR" })
await expect(page.locator('header input[type="search"]')).toHaveValue(
- 'cat'
+ "cat"
)
- await expect(page).toHaveURL('search/?q=cat')
+ await expect(page).toHaveURL("search/?q=cat")
})
- test('selecting `audio` on homepage, you can search for audio', async ({
+ test("selecting `audio` on homepage, you can search for audio", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType: AUDIO, mode: 'CSR' })
+ await goToSearchTerm(page, "cat", { searchType: AUDIO, mode: "CSR" })
await expect(page.locator('header input[type="search"]')).toHaveValue(
- 'cat'
+ "cat"
)
- await expect(page).toHaveURL('search/audio?q=cat')
+ await expect(page).toHaveURL("search/audio?q=cat")
})
- test('url filter parameters not used by current mediaType are discarded', async ({
+ test("url filter parameters not used by current mediaType are discarded", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'category=photograph',
+ query: "category=photograph",
})
- await changeContentType(page, 'Audio')
- await expect(page).toHaveURL('/search/audio?q=cat')
+ await changeContentType(page, "Audio")
+ await expect(page).toHaveURL("/search/audio?q=cat")
})
- test('url filter types not used by current mediaType are discarded', async ({
+ test("url filter types not used by current mediaType are discarded", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'aspect_ratio=tall',
+ query: "aspect_ratio=tall",
})
- await changeContentType(page, 'Audio')
- await expect(page).toHaveURL('/search/audio?q=cat')
+ await changeContentType(page, "Audio")
+ await expect(page).toHaveURL("/search/audio?q=cat")
})
- test('can search for a different term', async ({ page }) => {
- await goToSearchTerm(page, 'cat', { searchType: IMAGE })
+ test("can search for a different term", async ({ page }) => {
+ await goToSearchTerm(page, "cat", { searchType: IMAGE })
- await searchFromHeader(page, 'dog')
+ await searchFromHeader(page, "dog")
- await expect(page).toHaveURL('/search/image?q=dog')
+ await expect(page).toHaveURL("/search/image?q=dog")
})
- test('search for a different term keeps query parameters', async ({
+ test("search for a different term keeps query parameters", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'license=by&extension=jpg',
+ query: "license=by&extension=jpg",
})
- await searchFromHeader(page, 'dog')
+ await searchFromHeader(page, "dog")
await expect(page).toHaveURL(
- '/search/image?q=dog&license=by&extension=jpg'
+ "/search/image?q=dog&license=by&extension=jpg"
)
})
})
diff --git a/test/playwright/e2e/search-query-server-old.spec.ts b/test/playwright/e2e/search-query-server-old.spec.ts
index e0b151cbb..10df5f04a 100644
--- a/test/playwright/e2e/search-query-server-old.spec.ts
+++ b/test/playwright/e2e/search-query-server-old.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
import {
assertCheckboxStatus,
@@ -6,10 +6,10 @@ import {
goToSearchTerm,
OLD_HEADER,
openFilters,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
-import { AUDIO, IMAGE } from '~/constants/media'
+import { AUDIO, IMAGE } from "~/constants/media"
/**
* URL is correctly converted into search state:
@@ -23,79 +23,79 @@ import { AUDIO, IMAGE } from '~/constants/media'
* All of these tests test server-generated search page, not the one generated on the client
*/
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
-test('q query parameter is set as the search term', async ({ page }) => {
- await goToSearchTerm(page, 'cat', {
- query: 'license=cc0&license_type=commercial&searchBy=creator',
+test("q query parameter is set as the search term", async ({ page }) => {
+ await goToSearchTerm(page, "cat", {
+ query: "license=cc0&license_type=commercial&searchBy=creator",
})
const searchInput = page.locator('input[type="search"]')
- await expect(searchInput).toHaveValue('cat')
+ await expect(searchInput).toHaveValue("cat")
// Todo: focus the input?
// await expect(searchInput).toBeFocused()
})
-test('url path /search/ is used to select `all` search tab', async ({
+test("url path /search/ is used to select `all` search tab", async ({
page,
}) => {
- await page.goto('/search/?q=cat')
+ await page.goto("/search/?q=cat")
const contentType = await currentContentType(page, OLD_HEADER)
- expect(contentType?.trim()).toEqual('All content')
+ expect(contentType?.trim()).toEqual("All content")
})
-test('url path /search/audio is used to select `audio` search tab', async ({
+test("url path /search/audio is used to select `audio` search tab", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType: AUDIO })
+ await goToSearchTerm(page, "cat", { searchType: AUDIO })
const contentType = await currentContentType(page, OLD_HEADER)
- expect(contentType?.trim()).toEqual('Audio')
+ expect(contentType?.trim()).toEqual("Audio")
})
-test('url query to filter, all tab, one parameter per filter type', async ({
+test("url query to filter, all tab, one parameter per filter type", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
- query: 'license=cc0&license_type=commercial&searchBy=creator',
+ await goToSearchTerm(page, "cat", {
+ query: "license=cc0&license_type=commercial&searchBy=creator",
})
await openFilters(page, OLD_HEADER)
- for (const checkbox of ['cc0', 'commercial', 'creator']) {
+ for (const checkbox of ["cc0", "commercial", "creator"]) {
await assertCheckboxStatus(page, checkbox)
}
})
-test('url query to filter, image tab, several filters for one filter type selected', async ({
+test("url query to filter, image tab, several filters for one filter type selected", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'searchBy=creator&extension=jpg,png,gif,svg',
+ query: "searchBy=creator&extension=jpg,png,gif,svg",
})
await openFilters(page, OLD_HEADER)
- const checkboxes = ['jpeg', 'png', 'gif', 'svg']
+ const checkboxes = ["jpeg", "png", "gif", "svg"]
for (const checkbox of checkboxes) {
- const forValue = checkbox === 'jpeg' ? 'jpg' : checkbox
+ const forValue = checkbox === "jpeg" ? "jpg" : checkbox
await assertCheckboxStatus(page, checkbox, forValue)
}
})
-test.skip('url mature query is set, and can be unchecked using the Safer Browsing popup', async ({
+test.skip("url mature query is set, and can be unchecked using the Safer Browsing popup", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType: IMAGE, query: 'mature=true' })
+ await goToSearchTerm(page, "cat", { searchType: IMAGE, query: "mature=true" })
await page.click('button:has-text("Safer Browsing")')
- const matureCheckbox = await page.locator('text=Show Mature Content')
+ const matureCheckbox = await page.locator("text=Show Mature Content")
await expect(matureCheckbox).toBeChecked()
- await page.click('text=Show Mature Content')
- await expect(page).toHaveURL('/search/image?q=cat')
+ await page.click("text=Show Mature Content")
+ await expect(page).toHaveURL("/search/image?q=cat")
})
diff --git a/test/playwright/e2e/search-query-server.spec.ts b/test/playwright/e2e/search-query-server.spec.ts
index 2f7fd3a7a..798ccbf3f 100644
--- a/test/playwright/e2e/search-query-server.spec.ts
+++ b/test/playwright/e2e/search-query-server.spec.ts
@@ -1,4 +1,4 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
import {
assertCheckboxStatus,
@@ -6,12 +6,12 @@ import {
enableNewHeader,
goToSearchTerm,
openFilters,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
-import { AUDIO, IMAGE } from '~/constants/media'
+import { AUDIO, IMAGE } from "~/constants/media"
/**
* URL is correctly converted into search state:
@@ -25,87 +25,87 @@ import { AUDIO, IMAGE } from '~/constants/media'
* All of these tests test server-generated search page, not the one generated on the client
*/
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('search query on SSR', () => {
+test.describe("search query on SSR", () => {
breakpoints.describeMobileAndDesktop(() => {
test.beforeEach(async ({ context, page }) => {
await mockProviderApis(context)
await enableNewHeader(page)
})
- test('q query parameter is set as the search term', async ({ page }) => {
- await goToSearchTerm(page, 'cat', {
- query: 'license=cc0&license_type=commercial&searchBy=creator',
+ test("q query parameter is set as the search term", async ({ page }) => {
+ await goToSearchTerm(page, "cat", {
+ query: "license=cc0&license_type=commercial&searchBy=creator",
})
const searchInput = page.locator('input[type="search"]')
- await expect(searchInput).toHaveValue('cat')
+ await expect(searchInput).toHaveValue("cat")
// Todo: focus the input?
// await expect(searchInput).toBeFocused()
})
- test('url path /search/ is used to select `all` search tab', async ({
+ test("url path /search/ is used to select `all` search tab", async ({
page,
}) => {
- await page.goto('/search/?q=cat')
+ await page.goto("/search/?q=cat")
const contentType = await currentContentType(page)
- expect(contentType?.trim()).toEqual('All content')
+ expect(contentType?.trim()).toEqual("All content")
})
- test('url path /search/audio is used to select `audio` search tab', async ({
+ test("url path /search/audio is used to select `audio` search tab", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', { searchType: AUDIO })
+ await goToSearchTerm(page, "cat", { searchType: AUDIO })
const contentType = await currentContentType(page)
- expect(contentType?.trim()).toEqual('Audio')
+ expect(contentType?.trim()).toEqual("Audio")
})
- test('url query to filter, all tab, one parameter per filter type', async ({
+ test("url query to filter, all tab, one parameter per filter type", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
- query: 'license=cc0&license_type=commercial&searchBy=creator',
+ await goToSearchTerm(page, "cat", {
+ query: "license=cc0&license_type=commercial&searchBy=creator",
})
await openFilters(page)
- for (const checkbox of ['cc0', 'commercial', 'creator']) {
+ for (const checkbox of ["cc0", "commercial", "creator"]) {
await assertCheckboxStatus(page, checkbox)
}
})
- test('url query to filter, image tab, several filters for one filter type selected', async ({
+ test("url query to filter, image tab, several filters for one filter type selected", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'searchBy=creator&extension=jpg,png,gif,svg',
+ query: "searchBy=creator&extension=jpg,png,gif,svg",
})
await openFilters(page)
- const checkboxes = ['jpeg', 'png', 'gif', 'svg']
+ const checkboxes = ["jpeg", "png", "gif", "svg"]
for (const checkbox of checkboxes) {
- const forValue = checkbox === 'jpeg' ? 'jpg' : checkbox
+ const forValue = checkbox === "jpeg" ? "jpg" : checkbox
await assertCheckboxStatus(page, checkbox, forValue)
}
})
- test.skip('url mature query is set, and can be unchecked using the Safer Browsing popup', async ({
+ test.skip("url mature query is set, and can be unchecked using the Safer Browsing popup", async ({
page,
}) => {
- await goToSearchTerm(page, 'cat', {
+ await goToSearchTerm(page, "cat", {
searchType: IMAGE,
- query: 'mature=true',
+ query: "mature=true",
})
await page.click('button:has-text("Safer Browsing")')
- const matureCheckbox = await page.locator('text=Show Mature Content')
+ const matureCheckbox = await page.locator("text=Show Mature Content")
await expect(matureCheckbox).toBeChecked()
- await page.click('text=Show Mature Content')
- await expect(page).toHaveURL('/search/image?q=cat')
+ await page.click("text=Show Mature Content")
+ await expect(page).toHaveURL("/search/image?q=cat")
})
})
})
diff --git a/test/playwright/e2e/search-types-old.spec.ts b/test/playwright/e2e/search-types-old.spec.ts
index 70966f937..4d447a616 100644
--- a/test/playwright/e2e/search-types-old.spec.ts
+++ b/test/playwright/e2e/search-types-old.spec.ts
@@ -1,12 +1,12 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
import {
changeContentType,
goToSearchTerm,
OLD_HEADER,
searchTypePath,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
/**
* Using SSR:
@@ -24,33 +24,33 @@ import { mockProviderApis } from '~~/test/playwright/utils/route'
* Results include search meta information, media grid and Meta search form, can load more media if there are more media items.
*/
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
const allContentConfig = {
- id: 'all',
- name: 'All content',
- url: '/search/?q=birds',
+ id: "all",
+ name: "All content",
+ url: "/search/?q=birds",
canLoadMore: true,
metaSourceCount: 7,
} as const
const imageConfig = {
- id: 'image',
- name: 'Images',
- url: '/search/image?q=birds',
+ id: "image",
+ name: "Images",
+ url: "/search/image?q=birds",
canLoadMore: true,
metaSourceCount: 7,
results: /Over 10,000 results/,
} as const
const audioConfig = {
- id: 'audio',
- name: 'Audio',
- url: '/search/audio?q=birds',
+ id: "audio",
+ name: "Audio",
+ url: "/search/audio?q=birds",
canLoadMore: true,
metaSourceCount: 3,
results: /764 results/,
@@ -68,7 +68,7 @@ async function checkLoadMore(page: Page, searchType: SearchTypeConfig) {
await expect(loadMoreSection).toHaveCount(0, { timeout: 300 })
} else {
await expect(loadMoreSection).toHaveCount(1)
- await expect(loadMoreSection).toContainText('Load more')
+ await expect(loadMoreSection).toContainText("Load more")
}
}
async function checkMetasearchForm(page: Page, searchType: SearchTypeConfig) {
@@ -77,7 +77,7 @@ async function checkMetasearchForm(page: Page, searchType: SearchTypeConfig) {
)
await expect(metaSearchForm).toHaveCount(1)
- const sourceButtons = await page.locator('.external-sources a')
+ const sourceButtons = await page.locator(".external-sources a")
await expect(sourceButtons).toHaveCount(searchType.metaSourceCount)
}
@@ -107,28 +107,28 @@ async function checkSearchResult(page: Page, searchType: SearchTypeConfig) {
for (const searchType of searchTypes) {
test(`Can open ${searchType.name} search page on SSR`, async ({ page }) => {
- await goToSearchTerm(page, 'birds', { searchType: searchType.id })
+ await goToSearchTerm(page, "birds", { searchType: searchType.id })
await checkSearchResult(page, searchType)
})
test(`Can open ${searchType.name} page client-side`, async ({ page }) => {
// Audio is loading a lot of files, so we do not use it for the first SSR page
- const pageToOpen = searchType.id === 'all' ? searchTypes[1] : searchTypes[0]
+ const pageToOpen = searchType.id === "all" ? searchTypes[1] : searchTypes[0]
await page.goto(pageToOpen.url)
await changeContentType(page, searchType.name, OLD_HEADER)
await checkSearchResult(page, searchType)
})
}
-for (const searchTypeName of ['audio', 'image'] as const) {
+for (const searchTypeName of ["audio", "image"] as const) {
const searchType = searchTypes.find((type) => type.id === searchTypeName) as
| typeof audioConfig
| typeof imageConfig
test(`Can open ${searchTypeName} page from the all view`, async ({
page,
}) => {
- await page.goto('/search/?q=birds')
+ await page.goto("/search/?q=birds")
const contentLink = await page.locator(
`a:not([role="radio"])[href*="/search/${searchTypeName}"][href$="q=birds"]`
)
diff --git a/test/playwright/e2e/search-types.spec.ts b/test/playwright/e2e/search-types.spec.ts
index 194ab4b1a..a540bbdef 100644
--- a/test/playwright/e2e/search-types.spec.ts
+++ b/test/playwright/e2e/search-types.spec.ts
@@ -1,13 +1,13 @@
-import { test, expect, Page } from '@playwright/test'
+import { test, expect, Page } from "@playwright/test"
import {
changeContentType,
enableNewHeader,
goToSearchTerm,
searchTypePath,
-} from '~~/test/playwright/utils/navigation'
-import { mockProviderApis } from '~~/test/playwright/utils/route'
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+} from "~~/test/playwright/utils/navigation"
+import { mockProviderApis } from "~~/test/playwright/utils/route"
+import breakpoints from "~~/test/playwright/utils/breakpoints"
/**
* Using SSR:
@@ -25,29 +25,29 @@ import breakpoints from '~~/test/playwright/utils/breakpoints'
* Results include search meta information, media grid and Meta search form, can load more media if there are more media items.
*/
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
const allContentConfig = {
- id: 'all',
- name: 'All content',
- url: '/search/?q=birds',
+ id: "all",
+ name: "All content",
+ url: "/search/?q=birds",
canLoadMore: true,
metaSourceCount: 7,
} as const
const imageConfig = {
- id: 'image',
- name: 'Images',
- url: '/search/image?q=birds',
+ id: "image",
+ name: "Images",
+ url: "/search/image?q=birds",
canLoadMore: true,
metaSourceCount: 7,
results: /Over 10,000 results/,
} as const
const audioConfig = {
- id: 'audio',
- name: 'Audio',
- url: '/search/audio?q=birds',
+ id: "audio",
+ name: "Audio",
+ url: "/search/audio?q=birds",
canLoadMore: true,
metaSourceCount: 3,
results: /764 results/,
@@ -65,7 +65,7 @@ async function checkLoadMore(page: Page, searchType: SearchTypeConfig) {
await expect(loadMoreSection).toHaveCount(0, { timeout: 300 })
} else {
await expect(loadMoreSection).toHaveCount(1)
- await expect(loadMoreSection).toContainText('Load more')
+ await expect(loadMoreSection).toContainText("Load more")
}
}
async function checkMetasearchForm(page: Page, searchType: SearchTypeConfig) {
@@ -74,7 +74,7 @@ async function checkMetasearchForm(page: Page, searchType: SearchTypeConfig) {
)
await expect(metaSearchForm).toHaveCount(1)
- const sourceButtons = await page.locator('.external-sources a')
+ const sourceButtons = await page.locator(".external-sources a")
await expect(sourceButtons).toHaveCount(searchType.metaSourceCount)
}
@@ -102,7 +102,7 @@ async function checkSearchResult(page: Page, searchType: SearchTypeConfig) {
await checkPageMeta(page, searchType)
}
-test.describe('search types', () => {
+test.describe("search types", () => {
breakpoints.describeMobileAndDesktop(() => {
test.beforeEach(async ({ context, page }) => {
await mockProviderApis(context)
@@ -113,7 +113,7 @@ test.describe('search types', () => {
test(`Can open ${searchType.name} search page on SSR`, async ({
page,
}) => {
- await goToSearchTerm(page, 'birds', { searchType: searchType.id })
+ await goToSearchTerm(page, "birds", { searchType: searchType.id })
await checkSearchResult(page, searchType)
})
@@ -121,21 +121,21 @@ test.describe('search types', () => {
test(`Can open ${searchType.name} page client-side`, async ({ page }) => {
// Audio is loading a lot of files, so we do not use it for the first SSR page
const pageToOpen =
- searchType.id === 'all' ? searchTypes[1] : searchTypes[0]
+ searchType.id === "all" ? searchTypes[1] : searchTypes[0]
await page.goto(pageToOpen.url)
await changeContentType(page, searchType.name)
await checkSearchResult(page, searchType)
})
}
- for (const searchTypeName of ['audio', 'image'] as const) {
+ for (const searchTypeName of ["audio", "image"] as const) {
const searchType = searchTypes.find(
(type) => type.id === searchTypeName
) as typeof audioConfig | typeof imageConfig
test(`Can open ${searchTypeName} page from the all view`, async ({
page,
}) => {
- await page.goto('/search/?q=birds')
+ await page.goto("/search/?q=birds")
const contentLink = await page.locator(
`a:not([role="radio"])[href*="/search/${searchTypeName}"][href$="q=birds"]`
)
diff --git a/test/playwright/e2e/search.spec.ts b/test/playwright/e2e/search.spec.ts
index 789cd8c72..678c74765 100644
--- a/test/playwright/e2e/search.spec.ts
+++ b/test/playwright/e2e/search.spec.ts
@@ -6,34 +6,34 @@
* When pending: does not show 'No images', Safer Browsing, search rating or error message
* On error: shows error message
*/
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
-import { mockProviderApis } from '~~/test/playwright/utils/route'
+import { mockProviderApis } from "~~/test/playwright/utils/route"
import {
goToSearchTerm,
scrollToBottom,
searchFromHeader,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
test.beforeEach(async ({ context }) => {
await mockProviderApis(context)
})
-test('shows no results page when no results', async ({ page }) => {
- await page.goto('/search/image?q=243f6a8885a308d3')
- await expect(page.locator('.error-section')).toBeVisible()
+test("shows no results page when no results", async ({ page }) => {
+ await page.goto("/search/image?q=243f6a8885a308d3")
+ await expect(page.locator(".error-section")).toBeVisible()
})
-test('scroll to top on new search term submitted', async ({ page }) => {
- await goToSearchTerm(page, 'galah')
+test("scroll to top on new search term submitted", async ({ page }) => {
+ await goToSearchTerm(page, "galah")
await scrollToBottom(page)
let scrollY = await page.evaluate(() => window.scrollY)
expect(scrollY).not.toBe(0)
- await searchFromHeader(page, 'honey')
+ await searchFromHeader(page, "honey")
scrollY = await page.evaluate(() => window.scrollY)
expect(scrollY).toBe(0)
diff --git a/test/playwright/e2e/translation-banner.spec.ts b/test/playwright/e2e/translation-banner.spec.ts
index 14ef8cb3a..a8eddb573 100644
--- a/test/playwright/e2e/translation-banner.spec.ts
+++ b/test/playwright/e2e/translation-banner.spec.ts
@@ -1,38 +1,38 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
-const russianSearchPath = '/ru/search?q=dog'
+const russianSearchPath = "/ru/search?q=dog"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('translation banner', () => {
- test('Can see the translation banner and go to the correct link', async ({
+test.describe("translation banner", () => {
+ test("Can see the translation banner and go to the correct link", async ({
page,
}) => {
await page.goto(russianSearchPath)
await expect(
page.locator(
- 'text=The translation for Russian locale is incomplete. Help us get to 100 percent by'
+ "text=The translation for Russian locale is incomplete. Help us get to 100 percent by"
)
).toBeVisible({ timeout: 500 })
const [page1] = await Promise.all([
- page.waitForEvent('popup'),
- page.click('text=contributing a translation'),
+ page.waitForEvent("popup"),
+ page.click("text=contributing a translation"),
])
await expect(page1).toHaveURL(
- 'https://translate.wordpress.org/projects/meta/openverse/ru/default/'
+ "https://translate.wordpress.org/projects/meta/openverse/ru/default/"
)
})
- test('Banner is not shown if dismissed state is saved in a cookie', async ({
+ test("Banner is not shown if dismissed state is saved in a cookie", async ({
page,
}) => {
await page.context().addCookies([
{
- name: 'uiDismissedBanners',
+ name: "uiDismissedBanners",
value: '["translation-ru"]',
- domain: 'localhost',
- path: '/',
+ domain: "localhost",
+ path: "/",
},
])
await page.goto(russianSearchPath)
@@ -41,7 +41,7 @@ test.describe('translation banner', () => {
).not.toBeVisible({ timeout: 500 })
})
- test('Can close the translation banner', async ({ page }) => {
+ test("Can close the translation banner", async ({ page }) => {
await page.goto(russianSearchPath)
await page.click('[data-testid="banner-translation"] button:visible', {
timeout: 500,
diff --git a/test/playwright/playwright.config.ts b/test/playwright/playwright.config.ts
index aab22097a..065f8703d 100644
--- a/test/playwright/playwright.config.ts
+++ b/test/playwright/playwright.config.ts
@@ -1,15 +1,15 @@
-import path from 'path'
+import path from "path"
-import { addAliases } from 'module-alias'
+import { addAliases } from "module-alias"
-import type { PlaywrightTestConfig } from '@playwright/test'
+import type { PlaywrightTestConfig } from "@playwright/test"
addAliases({
- '~': path.resolve(process.cwd(), 'src'),
- '~~': process.cwd(),
+ "~": path.resolve(process.cwd(), "src"),
+ "~~": process.cwd(),
})
-const UPDATE_TAPES = process.env.UPDATE_TAPES || 'false'
+const UPDATE_TAPES = process.env.UPDATE_TAPES || "false"
const config: PlaywrightTestConfig = {
webServer: {
@@ -28,19 +28,19 @@ const config: PlaywrightTestConfig = {
* verified that there is indeed a tape saved for the response in question,
* switch this back to `prod` and see if your tests pass.
*/
- command: './node_modules/.bin/npm-run-all -p -r talkback prod:playwright',
- cwd: '/app',
+ command: "./node_modules/.bin/npm-run-all -p -r talkback prod:playwright",
+ cwd: "/app",
timeout: 60_000 * 5, // 5 minutes
port: 8443,
- reuseExistingServer: !process.env.CI || process.env.PWDEBUG === '1',
+ reuseExistingServer: !process.env.CI || process.env.PWDEBUG === "1",
env: {
- API_URL: 'http://localhost:49153/',
+ API_URL: "http://localhost:49153/",
UPDATE_TAPES: UPDATE_TAPES,
},
},
use: {
- baseURL: 'http://localhost:8443',
- trace: 'retain-on-failure',
+ baseURL: "http://localhost:8443",
+ trace: "retain-on-failure",
},
timeout: 60 * 1e3,
/**
@@ -52,7 +52,7 @@ const config: PlaywrightTestConfig = {
* tapes then we can avoid this problem. Defaulting to `undefined` means the
* Playwright default of using 1/2 of the number of CPU cores continues to work otherwise.
*/
- workers: UPDATE_TAPES === 'true' ? 1 : undefined,
+ workers: UPDATE_TAPES === "true" ? 1 : undefined,
expect: {
toMatchSnapshot: {
// If the visual regression tests are flaky, we can increase this to 0.1 or 0.2.
diff --git a/test/playwright/utils/audio.ts b/test/playwright/utils/audio.ts
index 397a89467..b2c92b839 100644
--- a/test/playwright/utils/audio.ts
+++ b/test/playwright/utils/audio.ts
@@ -1,11 +1,11 @@
-import { expect, Locator } from '@playwright/test'
+import { expect, Locator } from "@playwright/test"
import {
activeAudioStatus,
inactiveAudioStatus,
statusVerbMap,
AudioStatusVerb,
-} from '~/constants/audio'
+} from "~/constants/audio"
const getPossibleAudioActions = async (
context: Locator,
@@ -37,7 +37,7 @@ const getAllActive = async (
...options,
state: activeAudioStatus.map((a) => statusVerbMap[a]),
})
- expect(locators, 'Could not find a pause or loading button.').toHaveLength(
+ expect(locators, "Could not find a pause or loading button.").toHaveLength(
options.filterVisible ? 1 : 2
)
return locators
@@ -54,7 +54,7 @@ const getAllInactive = async (
...options,
state: inactiveAudioStatus.map((a) => statusVerbMap[a]),
})
- expect(locators, 'Could not find a play or replay button.').toHaveLength(
+ expect(locators, "Could not find a play or replay button.").toHaveLength(
options.filterVisible ? 1 : 2
)
return locators
diff --git a/test/playwright/utils/breakpoints.ts b/test/playwright/utils/breakpoints.ts
index 89c73a50a..424200d9a 100644
--- a/test/playwright/utils/breakpoints.ts
+++ b/test/playwright/utils/breakpoints.ts
@@ -1,7 +1,7 @@
-import { test, expect, Expect } from '@playwright/test'
+import { test, expect, Expect } from "@playwright/test"
-import { VIEWPORTS } from '~/constants/screens'
-import type { Breakpoint } from '~/constants/screens'
+import { VIEWPORTS } from "~/constants/screens"
+import type { Breakpoint } from "~/constants/screens"
type ScreenshotAble = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -11,8 +11,8 @@ type ScreenshotAble = {
type ExpectSnapshot = <T extends ScreenshotAble>(
name: string,
s: T,
- options?: Parameters<T['screenshot']>[0],
- snapshotOptions?: Parameters<ReturnType<Expect>['toMatchSnapshot']>[0]
+ options?: Parameters<T["screenshot"]>[0],
+ snapshotOptions?: Parameters<ReturnType<Expect>["toMatchSnapshot"]>[0]
) => Promise<Buffer | void>
type BreakpointBlock = (options: {
@@ -23,8 +23,8 @@ type BreakpointBlock = (options: {
expectSnapshot: ExpectSnapshot
}) => void
-export const desktopBreakpoints = ['2xl', 'xl', 'lg'] as const
-export const mobileBreakpoints = ['md', 'sm', 'xs'] as const
+export const desktopBreakpoints = ["2xl", "xl", "lg"] as const
+export const mobileBreakpoints = ["md", "sm", "xs"] as const
export const isMobileBreakpoint = (
bp: Breakpoint
@@ -34,7 +34,7 @@ export const isMobileBreakpoint = (
// For desktop UA use the default
const desktopUa = undefined
const mobileUa =
- 'Mozilla/5.0 (Android 7.0; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0'
+ "Mozilla/5.0 (Android 7.0; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0"
const mockUaStrings: Readonly<Record<Breakpoint, string | undefined>> =
Object.freeze(
@@ -74,10 +74,10 @@ const makeBreakpointDescribe =
`screen at breakpoint ${breakpoint} with width ${screenWidth}`,
() => {
const _block = (
- typeof blockOrOptions === 'function' ? blockOrOptions : block
+ typeof blockOrOptions === "function" ? blockOrOptions : block
) as BreakpointBlock
const options =
- typeof blockOrOptions !== 'function'
+ typeof blockOrOptions !== "function"
? { ...defaultOptions, ...blockOrOptions }
: defaultOptions
@@ -93,8 +93,8 @@ const makeBreakpointDescribe =
const expectSnapshot = async <T extends ScreenshotAble>(
name: string,
screenshotAble: T,
- options?: Parameters<T['screenshot']>[0],
- snapshotOptions?: Parameters<ReturnType<Expect>['toMatchSnapshot']>[0]
+ options?: Parameters<T["screenshot"]>[0],
+ snapshotOptions?: Parameters<ReturnType<Expect>["toMatchSnapshot"]>[0]
) => {
const { name: snapshotName } = getConfigValues(name)
return expect(
@@ -127,7 +127,7 @@ const breakpointTests = Array.from(Object.entries(VIEWPORTS)).reduce(
[`describe${capitalize(breakpoint as Breakpoint)}`]:
makeBreakpointDescribe(
breakpoint as Breakpoint,
- parseFloat(width.replace('px', ''))
+ parseFloat(width.replace("px", ""))
),
}),
{} as Record<
@@ -145,7 +145,7 @@ const describeEachBreakpoint =
Object.entries(breakpointTests).forEach(([bp, describe]) => {
if (
breakpoints.includes(
- bp.replace('describe', '').toLowerCase() as Breakpoint
+ bp.replace("describe", "").toLowerCase() as Breakpoint
)
)
describe(blockOrOptions, block)
@@ -157,14 +157,14 @@ const describeEvery = describeEachBreakpoint(
)
const describeEachDesktopWithMd = describeEachBreakpoint([
...desktopBreakpoints,
- 'md',
+ "md",
])
const describeEachDesktop = describeEachBreakpoint(desktopBreakpoints)
const describeEachMobile = describeEachBreakpoint(mobileBreakpoints)
const describeEachMobileWithoutMd = describeEachBreakpoint(
- mobileBreakpoints.filter((b) => b !== 'md')
+ mobileBreakpoints.filter((b) => b !== "md")
)
-const describeMobileAndDesktop = describeEachBreakpoint(['sm', 'xl'])
+const describeMobileAndDesktop = describeEachBreakpoint(["sm", "xl"])
export default {
...breakpointTests,
diff --git a/test/playwright/utils/navigation.ts b/test/playwright/utils/navigation.ts
index 8889a843d..fd5231f5d 100644
--- a/test/playwright/utils/navigation.ts
+++ b/test/playwright/utils/navigation.ts
@@ -1,6 +1,6 @@
-import { BrowserContext, expect, Page } from '@playwright/test'
+import { BrowserContext, expect, Page } from "@playwright/test"
-import rtlMessages from '~~/test/locales/ar.json'
+import rtlMessages from "~~/test/locales/ar.json"
import {
ALL_MEDIA,
@@ -10,10 +10,10 @@ import {
MODEL_3D,
SupportedSearchType,
VIDEO,
-} from '~/constants/media'
-import { SCREEN_SIZES } from '~/constants/screens'
+} from "~/constants/media"
+import { SCREEN_SIZES } from "~/constants/screens"
-import enMessages from '~/locales/en.json'
+import enMessages from "~/locales/en.json"
const messages: Record<string, Record<string, unknown>> = {
ltr: enMessages,
@@ -24,8 +24,8 @@ const messages: Record<string, Record<string, unknown>> = {
* The new header is enabled using `new_header` feature flag. Some navigation methods
* are different depending on the header version.
*/
-export const OLD_HEADER = 'old_header'
-export const NEW_HEADER = 'new_header'
+export const OLD_HEADER = "old_header"
+export const NEW_HEADER = "new_header"
export type HeaderMode = typeof OLD_HEADER | typeof NEW_HEADER
const getNestedProperty = (
@@ -33,17 +33,17 @@ const getNestedProperty = (
path: string
): string => {
const value = path
- .split('.')
+ .split(".")
.reduce((acc: string | Record<string, unknown>, part) => {
- if (typeof acc === 'string') {
+ if (typeof acc === "string") {
return acc
}
if (Object.keys(acc as Record<string, unknown>).includes(part)) {
return (acc as Record<string, string | Record<string, unknown>>)[part]
}
- return ''
+ return ""
}, obj)
- return typeof value === 'string' ? value : JSON.stringify(value)
+ return typeof value === "string" ? value : JSON.stringify(value)
}
/**
@@ -52,26 +52,26 @@ const getNestedProperty = (
* @param path - The label to translate.
* @param dir - The language direction.
*/
-export const t = (path: string, dir: LanguageDirection = 'ltr'): string => {
- let value = ''
- if (dir === 'rtl') {
+export const t = (path: string, dir: LanguageDirection = "ltr"): string => {
+ let value = ""
+ if (dir === "rtl") {
value = getNestedProperty(messages.rtl, path)
}
- return value === '' ? getNestedProperty(messages.ltr, path) : value
+ return value === "" ? getNestedProperty(messages.ltr, path) : value
}
-export const languageDirections = ['ltr', 'rtl'] as const
+export const languageDirections = ["ltr", "rtl"] as const
export const renderingContexts = [
- ['SSR', 'ltr'],
- ['SSR', 'rtl'],
- ['CSR', 'ltr'],
- ['CSR', 'rtl'],
+ ["SSR", "ltr"],
+ ["SSR", "rtl"],
+ ["CSR", "ltr"],
+ ["CSR", "rtl"],
] as const
-export const renderModes = ['SSR', 'CSR'] as const
+export const renderModes = ["SSR", "CSR"] as const
export type RenderMode = typeof renderModes[number]
-export type LanguageDirection = 'ltr' | 'rtl'
+export type LanguageDirection = "ltr" | "rtl"
export const buttonSelectors = {
filter: 'button[aria-controls="filters"]',
@@ -84,22 +84,22 @@ export function sleep(ms: number) {
}
export const searchTypePath = (searchType: SupportedSearchType) =>
- searchType === 'all' ? '' : `${searchType}`
+ searchType === "all" ? "" : `${searchType}`
export const searchTypeNames = {
ltr: {
- [ALL_MEDIA]: t('search-type.all', 'ltr'),
- [AUDIO]: t('search-type.audio', 'ltr'),
- [IMAGE]: t('search-type.image', 'ltr'),
- [VIDEO]: t('search-type.video', 'ltr'),
- [MODEL_3D]: t('search-type.model-3d', 'ltr'),
+ [ALL_MEDIA]: t("search-type.all", "ltr"),
+ [AUDIO]: t("search-type.audio", "ltr"),
+ [IMAGE]: t("search-type.image", "ltr"),
+ [VIDEO]: t("search-type.video", "ltr"),
+ [MODEL_3D]: t("search-type.model-3d", "ltr"),
},
rtl: {
- [ALL_MEDIA]: t('search-type.all', 'rtl'),
- [AUDIO]: t('search-type.audio', 'rtl'),
- [IMAGE]: t('search-type.image', 'rtl'),
- [VIDEO]: t('search-type.video', 'rtl'),
- [MODEL_3D]: t('search-type.model-3d', 'rtl'),
+ [ALL_MEDIA]: t("search-type.all", "rtl"),
+ [AUDIO]: t("search-type.audio", "rtl"),
+ [IMAGE]: t("search-type.image", "rtl"),
+ [VIDEO]: t("search-type.video", "rtl"),
+ [MODEL_3D]: t("search-type.model-3d", "rtl"),
},
}
@@ -115,11 +115,11 @@ const isButtonPressed = async (
if (pageWidth > 640) {
return await getPressed(page, buttonSelector)
} else {
- return await page.locator('button', { hasText: 'Close' }).isVisible()
+ return await page.locator("button", { hasText: "Close" }).isVisible()
}
}
-const openMenu = async (page: Page, button: 'filter' | 'contentSwitcher') => {
+const openMenu = async (page: Page, button: "filter" | "contentSwitcher") => {
const selector = buttonSelectors[button]
if (!(await isButtonPressed(page, selector))) {
await page.click(selector)
@@ -130,24 +130,24 @@ const openMenu = async (page: Page, button: 'filter' | 'contentSwitcher') => {
export const openFilters = async (
page: Page,
mode: HeaderMode = NEW_HEADER,
- dir: LanguageDirection = 'ltr'
+ dir: LanguageDirection = "ltr"
) => {
if (mode === OLD_HEADER || (mode === NEW_HEADER && isPageDesktop(page))) {
- await openMenu(page, 'filter')
+ await openMenu(page, "filter")
} else {
- await openContentSettingsTab(page, 'filters', dir)
+ await openContentSettingsTab(page, "filters", dir)
}
}
export const openContentTypes = async (
page: Page,
mode: HeaderMode = NEW_HEADER,
- dir: LanguageDirection = 'ltr'
+ dir: LanguageDirection = "ltr"
) => {
if (mode === OLD_HEADER || (mode === NEW_HEADER && isPageDesktop(page))) {
- await openMenu(page, 'contentSwitcher')
+ await openMenu(page, "contentSwitcher")
} else {
- await openContentSettingsTab(page, 'contentTypes', dir)
+ await openContentSettingsTab(page, "contentTypes", dir)
}
}
@@ -162,8 +162,8 @@ export const isPageDesktop = (page: Page, mode: HeaderMode = NEW_HEADER) => {
*/
const getPressed = async (page: Page, selector: string) => {
return (
- (await page.getAttribute(selector, 'aria-pressed')) === 'true' ||
- (await page.getAttribute(selector, 'aria-expanded')) === 'true'
+ (await page.getAttribute(selector, "aria-pressed")) === "true" ||
+ (await page.getAttribute(selector, "aria-expanded")) === "true"
)
}
@@ -181,15 +181,15 @@ const ensureButtonPressed = async (page: Page, selector: string) => {
*/
export const openContentSettingsTab = async (
page: Page,
- tab: 'contentTypes' | 'filters' = 'contentTypes',
- dir: LanguageDirection = 'ltr'
+ tab: "contentTypes" | "filters" = "contentTypes",
+ dir: LanguageDirection = "ltr"
) => {
const selector = buttonSelectors.mobileContentSettings
await ensureButtonPressed(page, selector)
const tabLabel = t(
- tab === 'contentTypes' ? 'search-type.heading' : 'filters.title',
+ tab === "contentTypes" ? "search-type.heading" : "filters.title",
dir
)
await page.locator(`button[role="tab"]:has-text("${tabLabel}")`).click()
@@ -200,7 +200,7 @@ export const closeFilters = async (
mode: HeaderMode = NEW_HEADER
) => {
if (mode === OLD_HEADER || (mode === NEW_HEADER && isPageDesktop(page))) {
- const selector = buttonSelectors['filter']
+ const selector = buttonSelectors["filter"]
if (await isButtonPressed(page, selector)) {
await page.click(selector)
@@ -217,12 +217,12 @@ export const closeFilters = async (
export const closeMobileMenu = async (
page: Page,
mode: HeaderMode = NEW_HEADER,
- dir: LanguageDirection = 'ltr'
+ dir: LanguageDirection = "ltr"
) => {
if (mode === OLD_HEADER) {
- await page.click(`button:has-text('${t('modal.close', dir)}')`)
+ await page.click(`button:has-text('${t("modal.close", dir)}')`)
} else {
- await page.click(`button[aria-label="${t('modal.aria-close', dir)}"]`)
+ await page.click(`button[aria-label="${t("modal.aria-close", dir)}"]`)
}
}
@@ -232,26 +232,26 @@ export const isMobileMenuOpen = async (page: Page) =>
export const assertCheckboxStatus = async (
page: Page,
label: string,
- forValue = '',
- status: 'checked' | 'unchecked' | 'disabled' = 'checked'
+ forValue = "",
+ status: "checked" | "unchecked" | "disabled" = "checked"
) => {
const selector =
- forValue === ''
+ forValue === ""
? `label:has-text('${label}')`
: `label[for="${forValue}"]:has-text('${label}')`
const checkbox = page.locator(selector)
switch (status) {
- case 'checked': {
+ case "checked": {
await expect(checkbox).not.toBeDisabled()
await expect(checkbox).toBeChecked()
break
}
- case 'unchecked': {
+ case "unchecked": {
await expect(checkbox).not.toBeDisabled()
await expect(checkbox).not.toBeChecked()
break
}
- case 'disabled': {
+ case "disabled": {
await expect(checkbox).toBeDisabled()
}
}
@@ -259,7 +259,7 @@ export const assertCheckboxStatus = async (
export const changeContentType = async (
page: Page,
- to: 'Audio' | 'Images' | 'All content',
+ to: "Audio" | "Images" | "All content",
mode: HeaderMode = NEW_HEADER
) => {
if (mode === OLD_HEADER || isPageDesktop(page)) {
@@ -319,11 +319,11 @@ export const dismissTranslationBanner = async (page: Page) => {
export const selectHomepageSearchType = async (
page: Page,
searchType: SupportedSearchType,
- dir: LanguageDirection = 'ltr'
+ dir: LanguageDirection = "ltr"
) => {
const pageWidth = page.viewportSize()?.width
if (pageWidth && pageWidth > SCREEN_SIZES.sm) {
- await page.click(`[aria-label="${t('search-type.all', dir)}"]`)
+ await page.click(`[aria-label="${t("search-type.all", dir)}"]`)
await page.click(
`button[role="radio"]:has-text("${searchTypeNames[dir][searchType]}")`
)
@@ -343,11 +343,11 @@ export const goToSearchTerm = async (
} = {}
) => {
const searchType = options.searchType || ALL_MEDIA
- const dir = options.dir || 'ltr'
- const mode = options.mode ?? 'SSR'
- const query = options.query ? `&${options.query}` : ''
+ const dir = options.dir || "ltr"
+ const mode = options.mode ?? "SSR"
+ const query = options.query ? `&${options.query}` : ""
- if (mode === 'SSR') {
+ if (mode === "SSR") {
const path = `search/${searchTypePath(searchType)}?q=${term}${query}`
await page.goto(pathWithDir(path, dir))
await dismissTranslationBanner(page)
@@ -355,7 +355,7 @@ export const goToSearchTerm = async (
await page.goto(pathWithDir(`/${query}`, dir))
await dismissTranslationBanner(page)
// Select the search type
- if (searchType !== 'all') {
+ if (searchType !== "all") {
await selectHomepageSearchType(page, searchType, dir)
}
// Type search term
@@ -365,9 +365,9 @@ export const goToSearchTerm = async (
// Wait for navigation
await Promise.all([
page.waitForNavigation(),
- page.click(`[aria-label="${t('search.search', dir)}"]`),
+ page.click(`[aria-label="${t("search.search", dir)}"]`),
])
- await page.waitForLoadState('load')
+ await page.waitForLoadState("load")
}
await scrollDownAndUp(page)
}
@@ -378,9 +378,9 @@ export const goToSearchTerm = async (
*/
export const searchFromHeader = async (page: Page, term: string) => {
// Double click on the search bar to remove previous value
- await page.dblclick('id=search-bar')
- await page.fill('id=search-bar', term)
- await Promise.all([page.waitForNavigation(), page.keyboard.press('Enter')])
+ await page.dblclick("id=search-bar")
+ await page.fill("id=search-bar", term)
+ await Promise.all([page.waitForNavigation(), page.keyboard.press("Enter")])
}
/**
@@ -435,7 +435,7 @@ export const scrollToTop = async (page: Page) => {
*/
export const scrollDownAndUp = async (page: Page) => {
await scrollToBottom(page)
- await page.waitForLoadState('load')
+ await page.waitForLoadState("load")
await scrollToTop(page)
}
@@ -443,18 +443,18 @@ export const scrollDownAndUp = async (page: Page) => {
* Adds '/ar' prefix to a rtl route. The path should start with '/'
*/
export const pathWithDir = (rawPath: string, dir: string) => {
- const path = rawPath.startsWith('/') ? rawPath : `/${rawPath}`
- return dir === 'rtl' ? `/ar${path}` : path
+ const path = rawPath.startsWith("/") ? rawPath : `/${rawPath}`
+ return dir === "rtl" ? `/ar${path}` : path
}
export const enableNewHeader = async (page: Page) => {
// Add the new_header cookie
await page.context().addCookies([
{
- name: 'features',
- value: '%7B%22new_header%22%3A%22on%22%7D',
- domain: 'localhost',
- path: '/',
+ name: "features",
+ value: "%7B%22new_header%22%3A%22on%22%7D",
+ domain: "localhost",
+ path: "/",
},
])
}
@@ -467,8 +467,8 @@ export const setCookies = async (
Object.entries(cookies).map(([name, value]) => ({
name,
value: JSON.stringify(value),
- domain: 'localhost',
- path: '/',
+ domain: "localhost",
+ path: "/",
}))
)
}
diff --git a/test/playwright/utils/page.ts b/test/playwright/utils/page.ts
index 0a8c03ebf..6222afd22 100644
--- a/test/playwright/utils/page.ts
+++ b/test/playwright/utils/page.ts
@@ -1,19 +1,19 @@
-import type { Page } from '@playwright/test'
+import type { Page } from "@playwright/test"
export const removeHiddenOverflow = async (page: Page) => {
- const mainElement = await page.$('.main.embedded.overflow-x-hidden')
+ const mainElement = await page.$(".main.embedded.overflow-x-hidden")
await mainElement?.evaluate((node) =>
- node.classList.remove('main', 'embedded', 'overflow-x-hidden')
+ node.classList.remove("main", "embedded", "overflow-x-hidden")
)
mainElement?.dispose()
- const appElement = await page.$('.app.grid.h-screen.overflow-hidden.relative')
- await appElement?.evaluate((node) => node.classList.remove('overflow-hidden'))
+ const appElement = await page.$(".app.grid.h-screen.overflow-hidden.relative")
+ await appElement?.evaluate((node) => node.classList.remove("overflow-hidden"))
appElement?.dispose()
}
export const hideInputCursors = (page: Page) => {
return page.addStyleTag({
- content: '* { caret-color: transparent !important; }',
+ content: "* { caret-color: transparent !important; }",
})
}
diff --git a/test/playwright/utils/route.ts b/test/playwright/utils/route.ts
index 9cec9bbf0..6c1d9c39d 100644
--- a/test/playwright/utils/route.ts
+++ b/test/playwright/utils/route.ts
@@ -1,6 +1,6 @@
-import type { BrowserContext } from '@playwright/test'
+import type { BrowserContext } from "@playwright/test"
export const mockProviderApis = async (context: BrowserContext) => {
- await context.route('**.jamendo.com**', (route) => route.abort())
- await context.route('**.freesound.**', (r) => r.abort())
+ await context.route("**.jamendo.com**", (route) => route.abort())
+ await context.route("**.freesound.**", (r) => r.abort())
}
diff --git a/test/playwright/visual-regression/components/audio-results-old.spec.ts b/test/playwright/visual-regression/components/audio-results-old.spec.ts
index dc6aee0dc..996bee366 100644
--- a/test/playwright/visual-regression/components/audio-results-old.spec.ts
+++ b/test/playwright/visual-regression/components/audio-results-old.spec.ts
@@ -1,22 +1,22 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { closeFilters, OLD_HEADER } from '~~/test/playwright/utils/navigation'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { closeFilters, OLD_HEADER } from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('audio results', () => {
+test.describe("audio results", () => {
test.beforeEach(async ({ page }) => {
- await page.goto('/search/audio?q=birds')
+ await page.goto("/search/audio?q=birds")
})
breakpoints.describeEachMobileWithoutMd(
{ uaMocking: false },
({ expectSnapshot }) => {
- test('should render small row layout desktop UA with narrow viewport', async ({
+ test("should render small row layout desktop UA with narrow viewport", async ({
page,
}) => {
- await expectSnapshot('audio-results-narrow-viewport-desktop-UA', page)
+ await expectSnapshot("audio-results-narrow-viewport-desktop-UA", page)
})
}
)
@@ -24,26 +24,26 @@ test.describe('audio results', () => {
breakpoints.describeEachMobileWithoutMd(
{ uaMocking: true },
({ expectSnapshot }) => {
- test('should render small row layout mobile UA with narrow viewport', async ({
+ test("should render small row layout mobile UA with narrow viewport", async ({
page,
}) => {
- await expectSnapshot('audio-results-narrow-viewport-mobile-UA', page)
+ await expectSnapshot("audio-results-narrow-viewport-mobile-UA", page)
})
}
)
breakpoints.describeEachDesktopWithMd(({ expectSnapshot }) => {
- test('desktop audio results', async ({ context, page }) => {
+ test("desktop audio results", async ({ context, page }) => {
await context.addCookies([
{
- name: 'ui',
+ name: "ui",
value: JSON.stringify({ isDesktopLayout: true }),
- domain: 'localhost',
- path: '/',
+ domain: "localhost",
+ path: "/",
},
])
await closeFilters(page, OLD_HEADER)
- await expectSnapshot('audio-results-desktop', page)
+ await expectSnapshot("audio-results-desktop", page)
})
})
})
diff --git a/test/playwright/visual-regression/components/content-report-form.spec.ts b/test/playwright/visual-regression/components/content-report-form.spec.ts
index 5348d579f..5e1019221 100644
--- a/test/playwright/visual-regression/components/content-report-form.spec.ts
+++ b/test/playwright/visual-regression/components/content-report-form.spec.ts
@@ -1,26 +1,26 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
-test.describe('content report form', () => {
+test.describe("content report form", () => {
test.beforeEach(async ({ page }) => {
- await page.goto('/image/feb91b13-422d-46fa-8ef4-cbf1e6ddee9b')
+ await page.goto("/image/feb91b13-422d-46fa-8ef4-cbf1e6ddee9b")
})
- test('unfocused close button', async ({ page }) => {
+ test("unfocused close button", async ({ page }) => {
await page.click('button:has-text("report")', { timeout: 500 })
const form = page.locator('[data-testid="content-report-popover"]')
expect(await form.screenshot({ timeout: 500 })).toMatchSnapshot({
- name: 'content-report-unfocused.png',
+ name: "content-report-unfocused.png",
})
})
- test('focused close button', async ({ page }) => {
+ test("focused close button", async ({ page }) => {
await page.click('button:has-text("report")', { timeout: 500 })
const form = page.locator('[data-testid="content-report-popover"]')
await form.locator('[aria-label="Close"]').focus({ timeout: 500 })
expect(await form.screenshot()).toMatchSnapshot({
- name: 'content-report-focused.png',
+ name: "content-report-focused.png",
})
})
})
diff --git a/test/playwright/visual-regression/components/external-sources-section.spec.ts b/test/playwright/visual-regression/components/external-sources-section.spec.ts
index c2116dbb1..ae7055a58 100644
--- a/test/playwright/visual-regression/components/external-sources-section.spec.ts
+++ b/test/playwright/visual-regression/components/external-sources-section.spec.ts
@@ -1,20 +1,20 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
import {
goToSearchTerm,
languageDirections,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-import { supportedSearchTypes } from '~/constants/media'
+import { supportedSearchTypes } from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
for (const dir of languageDirections) {
for (const searchType of supportedSearchTypes) {
test(`External ${searchType} sources popover - ${dir}`, async ({
page,
}) => {
- await goToSearchTerm(page, 'birds', { searchType, dir })
+ await goToSearchTerm(page, "birds", { searchType, dir })
const externalSourcesButton = page.locator(
'[aria-controls="source-list-popover"]'
)
diff --git a/test/playwright/visual-regression/components/filters-sidebar.spec.ts b/test/playwright/visual-regression/components/filters-sidebar.spec.ts
index 69d8afd43..41039acc1 100644
--- a/test/playwright/visual-regression/components/filters-sidebar.spec.ts
+++ b/test/playwright/visual-regression/components/filters-sidebar.spec.ts
@@ -1,25 +1,25 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
import {
goToSearchTerm,
languageDirections,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
for (const dir of languageDirections) {
test(`Filters sidebar none selected - ${dir}`, async ({ page }) => {
- await goToSearchTerm(page, 'birds', { dir })
+ await goToSearchTerm(page, "birds", { dir })
- expect(await page.locator('.sidebar').screenshot()).toMatchSnapshot({
+ expect(await page.locator(".sidebar").screenshot()).toMatchSnapshot({
name: `filters-sidebar-${dir}.png`,
})
})
test(`Filters sidebar some filters selected - ${dir}`, async ({ page }) => {
- await goToSearchTerm(page, 'birds', { dir })
+ await goToSearchTerm(page, "birds", { dir })
await page.locator('input[type="checkbox"]').first().check()
- expect(await page.locator('.sidebar').screenshot()).toMatchSnapshot({
+ expect(await page.locator(".sidebar").screenshot()).toMatchSnapshot({
name: `filters-sidebar-filters-selected-${dir}.png`,
})
})
diff --git a/test/playwright/visual-regression/components/header-old.spec.ts b/test/playwright/visual-regression/components/header-old.spec.ts
index ac57018b9..da053300e 100644
--- a/test/playwright/visual-regression/components/header-old.spec.ts
+++ b/test/playwright/visual-regression/components/header-old.spec.ts
@@ -1,7 +1,7 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { hideInputCursors } from '~~/test/playwright/utils/page'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { hideInputCursors } from "~~/test/playwright/utils/page"
import {
closeFilters,
goToSearchTerm,
@@ -9,26 +9,26 @@ import {
OLD_HEADER,
scrollToBottom,
sleep,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-const headerSelector = '.main-header'
+const headerSelector = ".main-header"
for (const dir of languageDirections) {
test.describe(dir, () => {
test.beforeEach(async ({ page }) => {
- await goToSearchTerm(page, 'birds', { dir: dir })
+ await goToSearchTerm(page, "birds", { dir: dir })
})
breakpoints.describeEachDesktopWithMd(({ expectSnapshot }) => {
- test('filters open', async ({ context, page }) => {
+ test("filters open", async ({ context, page }) => {
await context.addCookies([
{
- name: 'ui',
+ name: "ui",
value: JSON.stringify({ isDesktopLayout: true }),
- domain: 'localhost',
- path: '/search',
+ domain: "localhost",
+ path: "/search",
},
])
await page.mouse.move(0, 150)
@@ -40,7 +40,7 @@ for (const dir of languageDirections) {
})
breakpoints.describeEvery(({ expectSnapshot }) => {
- test('resting', async ({ page }) => {
+ test("resting", async ({ page }) => {
// By default, filters are open. We need to close them.
await closeFilters(page, OLD_HEADER)
// Make sure the header is not hovered on
@@ -48,7 +48,7 @@ for (const dir of languageDirections) {
await expectSnapshot(`resting-${dir}`, page.locator(headerSelector))
})
- test('scrolled', async ({ page }) => {
+ test("scrolled", async ({ page }) => {
await closeFilters(page, OLD_HEADER)
await scrollToBottom(page)
await page.mouse.move(0, 150)
@@ -56,9 +56,9 @@ for (const dir of languageDirections) {
await expectSnapshot(`scrolled-${dir}`, page.locator(headerSelector))
})
- test('searchbar hovered', async ({ page }) => {
+ test("searchbar hovered", async ({ page }) => {
await closeFilters(page, OLD_HEADER)
- await page.hover('input')
+ await page.hover("input")
await hideInputCursors(page)
await expectSnapshot(
`searchbar-hovered-${dir}`,
diff --git a/test/playwright/visual-regression/components/header.spec.ts b/test/playwright/visual-regression/components/header.spec.ts
index 3258aa63d..1fdcb15f2 100644
--- a/test/playwright/visual-regression/components/header.spec.ts
+++ b/test/playwright/visual-regression/components/header.spec.ts
@@ -1,9 +1,9 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
import breakpoints, {
isMobileBreakpoint,
-} from '~~/test/playwright/utils/breakpoints'
-import { hideInputCursors } from '~~/test/playwright/utils/page'
+} from "~~/test/playwright/utils/breakpoints"
+import { hideInputCursors } from "~~/test/playwright/utils/page"
import {
closeFilters,
enableNewHeader,
@@ -11,11 +11,11 @@ import {
languageDirections,
scrollToBottom,
sleep,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-const headerSelector = '.main-header'
+const headerSelector = ".main-header"
for (const dir of languageDirections) {
test.describe(`header-${dir}`, () => {
@@ -24,19 +24,19 @@ for (const dir of languageDirections) {
if (!isMobileBreakpoint(breakpoint)) {
await context.addCookies([
{
- name: 'ui',
+ name: "ui",
value: JSON.stringify({ isDesktopLayout: true }),
- domain: 'localhost',
- path: '/',
+ domain: "localhost",
+ path: "/",
},
])
}
await enableNewHeader(page)
- await goToSearchTerm(page, 'birds', { dir })
+ await goToSearchTerm(page, "birds", { dir })
})
- test('filters open', async ({ page }) => {
+ test("filters open", async ({ page }) => {
await page.mouse.move(0, 150)
await expectSnapshot(
`filters-open-${dir}`,
@@ -44,7 +44,7 @@ for (const dir of languageDirections) {
)
})
- test('resting', async ({ page }) => {
+ test("resting", async ({ page }) => {
// By default, filters are open on desktop. We need to close them.
if (!isMobileBreakpoint(breakpoint)) {
await closeFilters(page)
@@ -54,7 +54,7 @@ for (const dir of languageDirections) {
await expectSnapshot(`resting-${dir}`, page.locator(headerSelector))
})
- test('scrolled', async ({ page }) => {
+ test("scrolled", async ({ page }) => {
if (!isMobileBreakpoint(breakpoint)) {
await closeFilters(page)
}
@@ -64,11 +64,11 @@ for (const dir of languageDirections) {
await expectSnapshot(`scrolled-${dir}`, page.locator(headerSelector))
})
- test('searchbar hovered', async ({ page }) => {
+ test("searchbar hovered", async ({ page }) => {
if (!isMobileBreakpoint(breakpoint)) {
await closeFilters(page)
}
- await page.hover('input')
+ await page.hover("input")
await hideInputCursors(page)
await expectSnapshot(
`searchbar-hovered-${dir}`,
@@ -76,12 +76,12 @@ for (const dir of languageDirections) {
)
})
- test('searchbar active', async ({ page }) => {
+ test("searchbar active", async ({ page }) => {
if (!isMobileBreakpoint(breakpoint)) {
await closeFilters(page)
}
await hideInputCursors(page)
- await page.click('input')
+ await page.click("input")
const locator = isMobileBreakpoint(breakpoint)
? page
: page.locator(headerSelector)
diff --git a/test/playwright/visual-regression/pages/homepage.spec.ts b/test/playwright/visual-regression/pages/homepage.spec.ts
index 8fbf58cd0..17b2c82f2 100644
--- a/test/playwright/visual-regression/pages/homepage.spec.ts
+++ b/test/playwright/visual-regression/pages/homepage.spec.ts
@@ -1,14 +1,14 @@
-import { test, Page } from '@playwright/test'
+import { test, Page } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { hideInputCursors } from '~~/test/playwright/utils/page'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { hideInputCursors } from "~~/test/playwright/utils/page"
import {
dismissTranslationBanner,
pathWithDir,
languageDirections,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
/**
* Remove the randomly-selected images from the homepage.
@@ -20,12 +20,12 @@ const deleteImageCarousel = async (page: Page) => {
}
for (const dir of languageDirections) {
test.describe(`${dir} homepage snapshots`, () => {
- const path = pathWithDir('/', dir)
+ const path = pathWithDir("/", dir)
test.beforeEach(async ({ page }) => {
await page.goto(path)
await dismissTranslationBanner(page)
// TODO: Remove this after the cookie-based layout is merged.
- await page.waitForLoadState('networkidle')
+ await page.waitForLoadState("networkidle")
})
breakpoints.describeEvery(({ expectSnapshot }) =>
@@ -35,21 +35,21 @@ for (const dir of languageDirections) {
})
)
- test.describe('search input', () => {
+ test.describe("search input", () => {
breakpoints.describeEvery(({ expectSnapshot }) => {
- test('unfocused', async ({ page }) => {
+ test("unfocused", async ({ page }) => {
await expectSnapshot(
`unfocused-search-${dir}`,
- page.locator('form:has(input)')
+ page.locator("form:has(input)")
)
})
- test('focused', async ({ page }) => {
- await page.focus('input')
+ test("focused", async ({ page }) => {
+ await page.focus("input")
await hideInputCursors(page)
await expectSnapshot(
`focused-search-${dir}`,
- page.locator('form:has(input)')
+ page.locator("form:has(input)")
)
})
})
diff --git a/test/playwright/visual-regression/pages/pages-single-result.spec.ts b/test/playwright/visual-regression/pages/pages-single-result.spec.ts
index 5e0d311e0..a3c49f3bd 100644
--- a/test/playwright/visual-regression/pages/pages-single-result.spec.ts
+++ b/test/playwright/visual-regression/pages/pages-single-result.spec.ts
@@ -1,18 +1,18 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import { removeHiddenOverflow } from '~~/test/playwright/utils/page'
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+import { removeHiddenOverflow } from "~~/test/playwright/utils/page"
+import breakpoints from "~~/test/playwright/utils/breakpoints"
import {
enableNewHeader,
goToSearchTerm,
languageDirections,
openFirstResult,
setCookies,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-import { supportedMediaTypes } from '~/constants/media'
+import { supportedMediaTypes } from "~/constants/media"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
for (const mediaType of supportedMediaTypes) {
for (const dir of languageDirections) {
@@ -23,9 +23,9 @@ for (const mediaType of supportedMediaTypes) {
await setCookies(context, {
uiBreakpoint: breakpoint,
uiIsFilterDismissed: true,
- uiDismissedBanners: ['translation-ar'],
+ uiDismissedBanners: ["translation-ar"],
})
- await goToSearchTerm(page, 'birds', { dir })
+ await goToSearchTerm(page, "birds", { dir })
})
test(`from search results`, async ({ page }) => {
diff --git a/test/playwright/visual-regression/pages/pages-with-old-header.spec.ts b/test/playwright/visual-regression/pages/pages-with-old-header.spec.ts
index 6a283ef8d..0b65bfaa9 100644
--- a/test/playwright/visual-regression/pages/pages-with-old-header.spec.ts
+++ b/test/playwright/visual-regression/pages/pages-with-old-header.spec.ts
@@ -1,24 +1,24 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { removeHiddenOverflow } from '~~/test/playwright/utils/page'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { removeHiddenOverflow } from "~~/test/playwright/utils/page"
import {
pathWithDir,
languageDirections,
setCookies,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-const contentPages = ['about', 'search-help', 'non-existent', 'sources']
+const contentPages = ["about", "search-help", "non-existent", "sources"]
for (const contentPage of contentPages) {
for (const dir of languageDirections) {
test.describe(`${contentPage} ${dir} page snapshots`, () => {
breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => {
- test('full page', async ({ context, page }) => {
+ test("full page", async ({ context, page }) => {
await setCookies(context, {
uiBreakpoint: breakpoint,
- uiDismissedBanners: ['translation-ar'],
+ uiDismissedBanners: ["translation-ar"],
})
await page.goto(pathWithDir(contentPage, dir))
diff --git a/test/playwright/visual-regression/pages/pages.spec.ts b/test/playwright/visual-regression/pages/pages.spec.ts
index 7b8cc7c50..7b1ef1cc9 100644
--- a/test/playwright/visual-regression/pages/pages.spec.ts
+++ b/test/playwright/visual-regression/pages/pages.spec.ts
@@ -1,22 +1,22 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { removeHiddenOverflow } from '~~/test/playwright/utils/page'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { removeHiddenOverflow } from "~~/test/playwright/utils/page"
import {
pathWithDir,
languageDirections,
enableNewHeader,
setCookies,
-} from '~~/test/playwright/utils/navigation'
+} from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
const contentPages = [
- 'about',
- 'privacy',
- 'search-help',
- 'non-existent',
- 'sources',
+ "about",
+ "privacy",
+ "search-help",
+ "non-existent",
+ "sources",
]
for (const contentPage of contentPages) {
for (const dir of languageDirections) {
@@ -27,12 +27,12 @@ for (const contentPage of contentPages) {
await setCookies(context, {
uiBreakpoint: breakpoint,
uiIsFilterDismissed: true,
- uiDismissedBanners: ['translation-ar'],
+ uiDismissedBanners: ["translation-ar"],
})
await page.goto(pathWithDir(contentPage, dir))
})
- test('full page', async ({ page }) => {
+ test("full page", async ({ page }) => {
await removeHiddenOverflow(page)
// Make sure header is not hovered on
await page.mouse.move(150, 150)
diff --git a/test/proxy.js b/test/proxy.js
index 18e2ab5f3..d99e81e6e 100644
--- a/test/proxy.js
+++ b/test/proxy.js
@@ -8,22 +8,22 @@
* This makes it possible for the e2e tests to run without internet, and makes the
* tests less flaky due to changes in the API or API data.
*/
-const process = require('process')
-const zlib = require('zlib')
+const process = require("process")
+const zlib = require("zlib")
// TS doesn't pull the type in correctly for the next dependency when it's `require`'d.
/** @type {import('talkback')['default']} */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
-const talkback = require('talkback')
+const talkback = require("talkback")
// Talkback does not export its types so we've got to pull them out of the Options
/** @typedef {Required<typeof talkback['Options']['Default']>} TalkbackOptions */
/** @typedef {ReturnType<TalkbackOptions['tapeDecorator']>} Tape */
const port = 49153
-const host = 'https://api.openverse.engineering'
+const host = "https://api.openverse.engineering"
const urlPatterns = {
search: /\/(?<mediaType>images|audio|video|model-3d)\/*\?(?<query>[\w&=]+)/,
@@ -54,10 +54,10 @@ const tapeNameGenerator = (tapeNumber, tape) => {
const groups = typeMatch.match.groups
const prefix = `${typeMatch.type}/${groups.mediaType}`
let suffix = `${tape.req.headers.connection}`
- if (tape.req.method !== 'GET') {
+ if (tape.req.method !== "GET") {
suffix = `${suffix}_${tape.req.method}`
}
- if (typeMatch.type === 'search') {
+ if (typeMatch.type === "search") {
return `${prefix}/${groups.query}_${suffix}`
} else {
return `${prefix}/${groups.uuid}_${suffix}`
@@ -68,7 +68,7 @@ const tapeNameGenerator = (tapeNumber, tape) => {
}
const updatingTapes =
- process.argv.includes('--update-tapes') || process.env.UPDATE_TAPES === 'true'
+ process.argv.includes("--update-tapes") || process.env.UPDATE_TAPES === "true"
/** @type {TalkbackOptions['record']} */
const recordMode = updatingTapes
@@ -97,7 +97,7 @@ const BodyUtils = Object.freeze({
*/
const getBodyUtil = (tape) =>
Object.entries(BodyUtils).find(([key]) =>
- tape.res?.headers['content-encoding']?.includes(key)
+ tape.res?.headers["content-encoding"]?.includes(key)
)?.[1] ?? BodyUtils.default
/**
@@ -135,7 +135,7 @@ const getBodyUtil = (tape) =>
* @type {TalkbackOptions['tapeDecorator']}
*/
const tapeDecorator = (tape) => {
- if (!tape.res || tape.req.url.endsWith('/thumb/') || tape.res.status >= 399)
+ if (!tape.res || tape.req.url.endsWith("/thumb/") || tape.res.status >= 399)
return tape
const bodyUtil = getBodyUtil(tape)
@@ -153,13 +153,13 @@ const tapeDecorator = (tape) => {
const opts = /** @type {Partial<TalkbackOptions>} */ ({
host,
port,
- path: './test/tapes',
+ path: "./test/tapes",
record: recordMode,
silent: true,
fallbackMode: talkback.Options.FallbackMode.NOT_FOUND,
ignoreBody: true,
- allowHeaders: ['connection'],
- name: 'Openverse e2e proxy',
+ allowHeaders: ["connection"],
+ name: "Openverse e2e proxy",
summary: false,
tapeNameGenerator,
tapeDecorator,
@@ -167,13 +167,13 @@ const opts = /** @type {Partial<TalkbackOptions>} */ ({
const server = talkback(opts)
-server.start(() => console.log('Talkback started with record mode', recordMode))
+server.start(() => console.log("Talkback started with record mode", recordMode))
function closeServer() {
server.close()
- console.log('Server closed, exiting process')
+ console.log("Server closed, exiting process")
process.exit(0)
}
-process.on('SIGTERM', () => {
- console.log('Received SIGTERM')
+process.on("SIGTERM", () => {
+ console.log("Received SIGTERM")
closeServer()
})
diff --git a/test/storybook/README.md b/test/storybook/README.md
index 161875448..d96b63d1f 100644
--- a/test/storybook/README.md
+++ b/test/storybook/README.md
@@ -1,10 +1,19 @@
# Storybook tests
-We run Playwright tests for our Nuxt application. We also run them for Storybook, where components are tested in isolation and (ideally) in a comprehensive way that is not always possible inside an actual application.
+We run Playwright tests for our Nuxt application. We also run them for
+Storybook, where components are tested in isolation and (ideally) in a
+comprehensive way that is not always possible inside an actual application.
-Generally it is preferrable to write regular Jest tests with `@testing-library/vue`, however, some interactions require a real web browser context (like loading audio files, testing drag and drop interactions, etc). For these, Playwright is the perfect tool. We can also use Playwright to write visual regression tests for components in isolation so that we don't have to dupliate things like focus state testing into our application level tests.
+Generally it is preferrable to write regular Jest tests with
+`@testing-library/vue`, however, some interactions require a real web browser
+context (like loading audio files, testing drag and drop interactions, etc). For
+these, Playwright is the perfect tool. We can also use Playwright to write
+visual regression tests for components in isolation so that we don't have to
+dupliate things like focus state testing into our application level tests.
-Our Nuxt playwright tests are described by the [README in the `playwright` test directory](../playwright/README.md). Please see the section on "Dockerization" as it also applies to the Storybook tests.
+Our Nuxt playwright tests are described by the
+[README in the `playwright` test directory](../playwright/README.md). Please see
+the section on "Dockerization" as it also applies to the Storybook tests.
## Running the tests
@@ -14,24 +23,35 @@ To run the tests:
pnpm test:storybook
```
-This will run the tests inside a docker container. Should you wish to run the tests locally, you can use the following:
+This will run the tests inside a docker container. Should you wish to run the
+tests locally, you can use the following:
```bash
pnpm test:storybook:local
```
-But please note that unless you are running the same operating system (down to the distro, in some cases) there are likely to be visual rendering differences that will cause snapshot tests to fail on false-positives.
+But please note that unless you are running the same operating system (down to
+the distro, in some cases) there are likely to be visual rendering differences
+that will cause snapshot tests to fail on false-positives.
## Writing tests
-It is preferrable to write tests using the iframed version of the component to avoid Storybook UI updates from effective snapshots. To access this, take the `path` query parameter for any story and apply it to the `/iframe.html` route. See [`v-checkbox.spec.ts` for an example](./visual-regression/v-checkbox.spec.ts).
+It is preferrable to write tests using the iframed version of the component to
+avoid Storybook UI updates from effective snapshots. To access this, take the
+`path` query parameter for any story and apply it to the `/iframe.html` route.
+See
+[`v-checkbox.spec.ts` for an example](./visual-regression/v-checkbox.spec.ts).
### Codegen
-You can use Playwright's `codegen` tool to generate tests. For this you will need to run Storybook locally on your own using `pnpm storybook`. Then run:
+You can use Playwright's `codegen` tool to generate tests. For this you will
+need to run Storybook locally on your own using `pnpm storybook`. Then run:
```bash
pnpm test:storybook:gen
```
-Please note that the codegen script automatically runs against the non-iframed version of storybook, so while you can record interactions and use the resulting script, you will likely need to adapt it for running inside the iframed version of the page in the actual test.
+Please note that the codegen script automatically runs against the non-iframed
+version of storybook, so while you can record interactions and use the resulting
+script, you will likely need to adapt it for running inside the iframed version
+of the page in the actual test.
diff --git a/test/storybook/playwright.config.ts b/test/storybook/playwright.config.ts
index df0d1f896..fd9ec3c26 100644
--- a/test/storybook/playwright.config.ts
+++ b/test/storybook/playwright.config.ts
@@ -1,24 +1,24 @@
-import path from 'path'
+import path from "path"
-import { addAliases } from 'module-alias'
+import { addAliases } from "module-alias"
-import type { PlaywrightTestConfig } from '@playwright/test'
+import type { PlaywrightTestConfig } from "@playwright/test"
addAliases({
- '~': path.resolve(process.cwd(), 'src'),
- '~~': process.cwd(),
+ "~": path.resolve(process.cwd(), "src"),
+ "~~": process.cwd(),
})
const config: PlaywrightTestConfig = {
webServer: {
- command: 'pnpm storybook',
+ command: "pnpm storybook",
timeout: 60_000 * 5, // 5 minutes
port: 54000,
- reuseExistingServer: !process.env.CI || process.env.PWDEBUG === '1',
+ reuseExistingServer: !process.env.CI || process.env.PWDEBUG === "1",
},
use: {
- baseURL: 'http://localhost:54000',
- trace: 'retain-on-failure',
+ baseURL: "http://localhost:54000",
+ trace: "retain-on-failure",
},
timeout: 2 * 60 * 1e3,
expect: {
diff --git a/test/storybook/utils/args.ts b/test/storybook/utils/args.ts
index 2baa31cb0..9f73132f4 100644
--- a/test/storybook/utils/args.ts
+++ b/test/storybook/utils/args.ts
@@ -1,11 +1,11 @@
-import type { Page } from '@playwright/test'
+import type { Page } from "@playwright/test"
export const makeGotoWithArgs =
(storySlug: string) => (page: Page, args?: Record<string, unknown>) => {
const argStrings = Object.entries(args ?? {})
.map(([k, v]) => `${k}:${v}`)
- .join(';')
- const argsParam = args ? `&args=${argStrings}` : ''
+ .join(";")
+ const argsParam = args ? `&args=${argStrings}` : ""
const url = `/iframe.html?id=${storySlug}${argsParam}`
return page.goto(url)
diff --git a/test/storybook/visual-regression/v-button.spec.ts b/test/storybook/visual-regression/v-button.spec.ts
index dc27b5b05..f42b8e47f 100644
--- a/test/storybook/visual-regression/v-button.spec.ts
+++ b/test/storybook/visual-regression/v-button.spec.ts
@@ -1,17 +1,17 @@
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
-import { makeGotoWithArgs } from '~~/test/storybook/utils/args'
+import { makeGotoWithArgs } from "~~/test/storybook/utils/args"
-import { buttonVariants } from '~/types/button'
+import { buttonVariants } from "~/types/button"
-const buttonLocator = 'text=Code is Poetry'
+const buttonLocator = "text=Code is Poetry"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('VButton', () => {
- const gotoWithArgs = makeGotoWithArgs('components-vbutton--v-button')
+test.describe("VButton", () => {
+ const gotoWithArgs = makeGotoWithArgs("components-vbutton--v-button")
const nonPressedVariants = buttonVariants.filter(
- (name) => !name.endsWith('pressed')
+ (name) => !name.endsWith("pressed")
)
for (const variant of nonPressedVariants) {
test(`${variant} resting`, async ({ page }) => {
@@ -43,7 +43,7 @@ test.describe('VButton', () => {
name: `${variant}-pressed-hovered.png`,
})
})
- if (variant.startsWith('action')) {
+ if (variant.startsWith("action")) {
test(`${variant} disabled`, async ({ page }) => {
await gotoWithArgs(page, { variant, disabled: true })
expect(await page.locator(buttonLocator).screenshot()).toMatchSnapshot({
diff --git a/test/storybook/visual-regression/v-checkbox.spec.ts b/test/storybook/visual-regression/v-checkbox.spec.ts
index 469d36449..ceb361bcc 100644
--- a/test/storybook/visual-regression/v-checkbox.spec.ts
+++ b/test/storybook/visual-regression/v-checkbox.spec.ts
@@ -1,27 +1,27 @@
-import { test, expect } from '@playwright/test'
+import { test, expect } from "@playwright/test"
-test.describe('v-checkbox', () => {
- test.describe('default', () => {
+test.describe("v-checkbox", () => {
+ test.describe("default", () => {
test.beforeEach(async ({ page }) => {
- await page.goto('/iframe.html?id=components-vcheckbox--default-story')
+ await page.goto("/iframe.html?id=components-vcheckbox--default-story")
})
- test('default', async ({ page }) => {
- expect(await page.screenshot()).toMatchSnapshot({ name: 'default.png' })
+ test("default", async ({ page }) => {
+ expect(await page.screenshot()).toMatchSnapshot({ name: "default.png" })
})
- test('on', async ({ page }) => {
+ test("on", async ({ page }) => {
await page.click('input[type="checkbox"]')
- expect(await page.screenshot()).toMatchSnapshot({ name: 'on.png' })
+ expect(await page.screenshot()).toMatchSnapshot({ name: "on.png" })
})
- test('off', async ({ page }) => {
+ test("off", async ({ page }) => {
// toggle on and off again
await page.click('input[type="checkbox"]')
// `force: true` is required because the `input`'s pointer events are actually intercepted by the visual SVG.
// We still want to check that it works though as that does mimic the user behavior of checking directly on the checkbox.
await page.click('input[type="checkbox"]', { force: true })
- expect(await page.screenshot()).toMatchSnapshot({ name: 'off.png' })
+ expect(await page.screenshot()).toMatchSnapshot({ name: "off.png" })
})
})
})
diff --git a/test/storybook/visual-regression/v-filter-button-old.spec.ts b/test/storybook/visual-regression/v-filter-button-old.spec.ts
index 09c5c5ba7..9cfc23972 100644
--- a/test/storybook/visual-regression/v-filter-button-old.spec.ts
+++ b/test/storybook/visual-regression/v-filter-button-old.spec.ts
@@ -1,60 +1,60 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { makeGotoWithArgs } from '~~/test/storybook/utils/args'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { makeGotoWithArgs } from "~~/test/storybook/utils/args"
const gotoWithArgs = makeGotoWithArgs(
- 'components-vheaderold-vfilterbuttonold--default-story'
+ "components-vheaderold-vfilterbuttonold--default-story"
)
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('VFilterButtonOld', () => {
+test.describe("VFilterButtonOld", () => {
breakpoints.describeMd(({ expectSnapshot }) => {
- test('no filters applied', async ({ page }) => {
+ test("no filters applied", async ({ page }) => {
await gotoWithArgs(page, { isMinMd: true })
- await expectSnapshot('filter-button-old-at-rest', page)
+ await expectSnapshot("filter-button-old-at-rest", page)
})
- test('no filters pressed', async ({ page }) => {
+ test("no filters pressed", async ({ page }) => {
await gotoWithArgs(page, { isMinMd: true, pressed: true })
- await expectSnapshot('filter-button-old-pressed', page)
+ await expectSnapshot("filter-button-old-pressed", page)
})
- test('filters applied', async ({ page }) => {
+ test("filters applied", async ({ page }) => {
await gotoWithArgs(page, { isMinMd: true, appliedFilters: 2 })
- await expectSnapshot('filter-button-old-2-filters', page)
+ await expectSnapshot("filter-button-old-2-filters", page)
})
- test('filters applied and pressed', async ({ page }) => {
+ test("filters applied and pressed", async ({ page }) => {
await gotoWithArgs(page, {
isMinMd: true,
appliedFilters: 2,
pressed: true,
})
- await expectSnapshot('filter-button-old-2-filters-pressed', page)
+ await expectSnapshot("filter-button-old-2-filters-pressed", page)
})
})
breakpoints.describeXs(({ expectSnapshot }) => {
- test('no filters applied and not scrolled', async ({ page }) => {
+ test("no filters applied and not scrolled", async ({ page }) => {
await gotoWithArgs(page)
- await expectSnapshot('filter-button-old-no-filters-not-scrolled', page)
+ await expectSnapshot("filter-button-old-no-filters-not-scrolled", page)
})
- test('no filters but scrolled', async ({ page }) => {
+ test("no filters but scrolled", async ({ page }) => {
await gotoWithArgs(page, { scrolled: true })
- await expectSnapshot('filter-button-old-no-filters-scrolled', page)
+ await expectSnapshot("filter-button-old-no-filters-scrolled", page)
})
- test('2 filters not scrolled', async ({ page }) => {
+ test("2 filters not scrolled", async ({ page }) => {
await gotoWithArgs(page, { appliedFilters: 2 })
- await expectSnapshot('filter-button-old-2-filters-not-scrolled', page)
+ await expectSnapshot("filter-button-old-2-filters-not-scrolled", page)
})
- test('2 filters and scrolled', async ({ page }) => {
+ test("2 filters and scrolled", async ({ page }) => {
await gotoWithArgs(page, { appliedFilters: 2, scrolled: true })
- await expectSnapshot('filter-button-old-2-filters-scrolled', page)
+ await expectSnapshot("filter-button-old-2-filters-scrolled", page)
})
})
})
diff --git a/test/storybook/visual-regression/v-filter-button.spec.ts b/test/storybook/visual-regression/v-filter-button.spec.ts
index 93dfeec34..4f8d612d3 100644
--- a/test/storybook/visual-regression/v-filter-button.spec.ts
+++ b/test/storybook/visual-regression/v-filter-button.spec.ts
@@ -1,50 +1,50 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { makeGotoWithArgs } from '~~/test/storybook/utils/args'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { makeGotoWithArgs } from "~~/test/storybook/utils/args"
const gotoWithArgs = makeGotoWithArgs(
- 'components-vheader-vfilterbutton--default-story'
+ "components-vheader-vfilterbutton--default-story"
)
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('VFilterButton', () => {
+test.describe("VFilterButton", () => {
breakpoints.describeLg(({ expectSnapshot }) => {
- test('no filters applied', async ({ page }) => {
+ test("no filters applied", async ({ page }) => {
await gotoWithArgs(page, { isMinMd: true })
- await expectSnapshot('filter-button-at-rest', page)
+ await expectSnapshot("filter-button-at-rest", page)
})
- test('no filters pressed', async ({ page }) => {
+ test("no filters pressed", async ({ page }) => {
await gotoWithArgs(page, { pressed: true })
- await expectSnapshot('filter-button-pressed', page)
+ await expectSnapshot("filter-button-pressed", page)
})
- test('filters applied', async ({ page }) => {
+ test("filters applied", async ({ page }) => {
await gotoWithArgs(page, { appliedFilters: 2 })
- await expectSnapshot('filter-button-2-filters', page)
+ await expectSnapshot("filter-button-2-filters", page)
})
- test('filters applied and pressed', async ({ page }) => {
+ test("filters applied and pressed", async ({ page }) => {
await gotoWithArgs(page, {
isMinMd: true,
appliedFilters: 2,
pressed: true,
})
- await expectSnapshot('filter-button-2-filters-pressed', page)
+ await expectSnapshot("filter-button-2-filters-pressed", page)
})
})
breakpoints.describeXl(({ expectSnapshot }) => {
- test('no filters applied', async ({ page }) => {
+ test("no filters applied", async ({ page }) => {
await gotoWithArgs(page)
- await expectSnapshot('filter-button-no-filters-not-scrolled', page)
+ await expectSnapshot("filter-button-no-filters-not-scrolled", page)
})
- test('2 filters', async ({ page }) => {
+ test("2 filters", async ({ page }) => {
await gotoWithArgs(page, { appliedFilters: 2 })
- await expectSnapshot('filter-button-2-filters-not-scrolled', page)
+ await expectSnapshot("filter-button-2-filters-not-scrolled", page)
})
})
})
diff --git a/test/storybook/visual-regression/v-footer.spec.ts b/test/storybook/visual-regression/v-footer.spec.ts
index 1714f3a51..1ef9eed95 100644
--- a/test/storybook/visual-regression/v-footer.spec.ts
+++ b/test/storybook/visual-regression/v-footer.spec.ts
@@ -1,34 +1,34 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { languageDirections } from '~~/test/playwright/utils/navigation'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { languageDirections } from "~~/test/playwright/utils/navigation"
-const footerKinds = ['internal', 'content'] as const
+const footerKinds = ["internal", "content"] as const
-const defaultUrl = '/iframe.html?id=components-vfooter--'
+const defaultUrl = "/iframe.html?id=components-vfooter--"
const pageUrl = (
dir: typeof languageDirections[number],
footerKind: typeof footerKinds[number]
) => {
const url = `${defaultUrl}${footerKind}`
- return dir === 'ltr' ? url : `${url}&globals=languageDirection:rtl`
+ return dir === "ltr" ? url : `${url}&globals=languageDirection:rtl`
}
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('VFooter', () => {
+test.describe("VFooter", () => {
for (const dir of languageDirections) {
for (const footerKind of footerKinds) {
breakpoints.describeEvery(({ expectSnapshot }) => {
test(`footer-${footerKind}-${dir}`, async ({ page }) => {
await page.goto(pageUrl(dir, footerKind))
- if (dir === 'rtl') {
- await page.locator('#language').selectOption({ value: 'ar' })
+ if (dir === "rtl") {
+ await page.locator("#language").selectOption({ value: "ar" })
}
await expectSnapshot(
`footer-${footerKind}-${dir}`,
- page.locator('footer')
+ page.locator("footer")
)
})
})
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts b/test/storybook/visual-regression/v-header-internal.spec.ts
index ce781317a..095f0b13d 100644
--- a/test/storybook/visual-regression/v-header-internal.spec.ts
+++ b/test/storybook/visual-regression/v-header-internal.spec.ts
@@ -1,17 +1,17 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { languageDirections } from '~~/test/playwright/utils/navigation'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { languageDirections } from "~~/test/playwright/utils/navigation"
-const headerSelector = '.main-header'
+const headerSelector = ".main-header"
const defaultUrl =
- '/iframe.html?id=components-vheader-vheaderinternal--default-story'
+ "/iframe.html?id=components-vheader-vheaderinternal--default-story"
const pageUrl = (dir: typeof languageDirections[number]) =>
- dir === 'ltr' ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`
+ dir === "ltr" ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('VHeaderInternal', () => {
+test.describe("VHeaderInternal", () => {
for (const dir of languageDirections) {
breakpoints.describeEachDesktopWithMd(({ expectSnapshot }) => {
test(`desktop-header-internal-${dir}`, async ({ page }) => {
diff --git a/test/storybook/visual-regression/v-icon-button.spec.ts b/test/storybook/visual-regression/v-icon-button.spec.ts
index 2007090f1..ad1e1557f 100644
--- a/test/storybook/visual-regression/v-icon-button.spec.ts
+++ b/test/storybook/visual-regression/v-icon-button.spec.ts
@@ -1,12 +1,12 @@
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
-test.describe('VIconButton', () => {
- const url = '/iframe.html?id=components-viconbutton--sizes'
+test.describe("VIconButton", () => {
+ const url = "/iframe.html?id=components-viconbutton--sizes"
- test('icon button sizes', async ({ page }) => {
+ test("icon button sizes", async ({ page }) => {
await page.goto(url)
expect(await page.screenshot()).toMatchSnapshot({
- name: 'v-icon-button-sizes.png',
+ name: "v-icon-button-sizes.png",
})
})
})
diff --git a/test/storybook/visual-regression/v-language-select.spec.ts b/test/storybook/visual-regression/v-language-select.spec.ts
index 370cb1394..88d5a1cd2 100644
--- a/test/storybook/visual-regression/v-language-select.spec.ts
+++ b/test/storybook/visual-regression/v-language-select.spec.ts
@@ -1,14 +1,14 @@
-import { Page, test, expect } from '@playwright/test'
+import { Page, test, expect } from "@playwright/test"
-import { makeGotoWithArgs } from '~~/test/storybook/utils/args'
+import { makeGotoWithArgs } from "~~/test/storybook/utils/args"
const expectSnapshot = async (name: string, page: Page) => {
expect(await page.screenshot()).toMatchSnapshot({ name: `${name}.png` })
}
-test.describe('VLanguageSelect', () => {
- test('default', async ({ page }) => {
- await makeGotoWithArgs('components-vlanguageselect--default-story')(page)
- await expectSnapshot('vlanguageselect-default', page)
+test.describe("VLanguageSelect", () => {
+ test("default", async ({ page }) => {
+ await makeGotoWithArgs("components-vlanguageselect--default-story")(page)
+ await expectSnapshot("vlanguageselect-default", page)
})
})
diff --git a/test/storybook/visual-regression/v-media-license.spec.ts b/test/storybook/visual-regression/v-media-license.spec.ts
index 95a63c599..6807de6ca 100644
--- a/test/storybook/visual-regression/v-media-license.spec.ts
+++ b/test/storybook/visual-regression/v-media-license.spec.ts
@@ -1,6 +1,6 @@
-import { test, Page } from '@playwright/test'
+import { test, Page } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
const goTo = async (page: Page, slug: string) => {
await page.goto(`/iframe.html?id=components-vmedialicense--${slug}`)
@@ -12,27 +12,27 @@ const goTo = async (page: Page, slug: string) => {
* 'sampling+' (changed to 'cc-sampling' here).
*/
const allSlugs = [
- 'cc-by',
- 'cc-by-sa',
- 'cc-by-nd',
- 'cc-by-nc',
- 'cc-by-nc-sa',
- 'cc-by-nc-nd',
- 'cc-0',
- 'pdm',
- 'cc-sampling',
- 'cc-nc-sampling',
+ "cc-by",
+ "cc-by-sa",
+ "cc-by-nd",
+ "cc-by-nc",
+ "cc-by-nc-sa",
+ "cc-by-nc-nd",
+ "cc-0",
+ "pdm",
+ "cc-sampling",
+ "cc-nc-sampling",
]
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('VMediaLicense', () => {
+test.describe("VMediaLicense", () => {
for (const slug of allSlugs) {
const name = `v-media-license-${slug}`
breakpoints.describeMobileAndDesktop(({ expectSnapshot }) => {
test(name, async ({ page }) => {
await goTo(page, slug)
- await expectSnapshot(name, page.locator('.media-attribution'))
+ await expectSnapshot(name, page.locator(".media-attribution"))
})
})
}
diff --git a/test/storybook/visual-regression/v-media-reuse.spec.ts b/test/storybook/visual-regression/v-media-reuse.spec.ts
index 02c7b6e64..ec74b3f0f 100644
--- a/test/storybook/visual-regression/v-media-reuse.spec.ts
+++ b/test/storybook/visual-regression/v-media-reuse.spec.ts
@@ -1,21 +1,21 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
-import { languageDirections, t } from '~~/test/playwright/utils/navigation'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
+import { languageDirections, t } from "~~/test/playwright/utils/navigation"
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
const tabs = [
- { id: 'rich', name: 'Rich Text' },
- { id: 'html', name: 'HTML' },
- { id: 'plain', name: 'Plain text' },
+ { id: "rich", name: "Rich Text" },
+ { id: "html", name: "HTML" },
+ { id: "plain", name: "Plain text" },
]
const defaultUrl =
- '/iframe.html?id=components-vmediainfo-vmediareuse--v-media-reuse'
+ "/iframe.html?id=components-vmediainfo-vmediareuse--v-media-reuse"
const pageUrl = (dir: typeof languageDirections[number]) =>
- dir === 'ltr' ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`
+ dir === "ltr" ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`
-test.describe('media-reuse', () => {
+test.describe("media-reuse", () => {
for (const tab of tabs) {
for (const dir of languageDirections) {
breakpoints.describeEvery(({ expectSnapshot }) => {
@@ -23,17 +23,17 @@ test.describe('media-reuse', () => {
page,
}) => {
await page.goto(pageUrl(dir))
- if (dir === 'rtl') {
- await page.locator('#language').selectOption({ value: 'ar' })
+ if (dir === "rtl") {
+ await page.locator("#language").selectOption({ value: "ar" })
}
await page.locator(`#tab-${tab.id}`).click()
// Make sure the tab is not focused and doesn't have a pink ring
- const reuseTitle = t('media-details.reuse.title', dir)
+ const reuseTitle = t("media-details.reuse.title", dir)
await page.locator(`h2:has-text("${reuseTitle}")`).click()
await expectSnapshot(
`media-reuse-${dir}-${tab.id}-tab`,
- page.locator('.media-reuse')
+ page.locator(".media-reuse")
)
})
})
diff --git a/test/storybook/visual-regression/v-search-bar-button.spec.ts b/test/storybook/visual-regression/v-search-bar-button.spec.ts
index 553167d83..9871c32e3 100644
--- a/test/storybook/visual-regression/v-search-bar-button.spec.ts
+++ b/test/storybook/visual-regression/v-search-bar-button.spec.ts
@@ -1,39 +1,39 @@
-import { expect, test } from '@playwright/test'
+import { expect, test } from "@playwright/test"
-test.describe.configure({ mode: 'parallel' })
-const wrapperLocator = '.wrapper'
-test.describe('VSearchBarButton', () => {
+test.describe.configure({ mode: "parallel" })
+const wrapperLocator = ".wrapper"
+test.describe("VSearchBarButton", () => {
test.beforeEach(async ({ page }) => {
await page.goto(
- '/iframe.html?id=components-vheader-vheadermobile-vsearchbarbutton--clear-and-back-buttons'
+ "/iframe.html?id=components-vheader-vheadermobile-vsearchbarbutton--clear-and-back-buttons"
)
})
- test('Clear and back buttons resting', async ({ page }) => {
+ test("Clear and back buttons resting", async ({ page }) => {
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `clear-back-buttons-resting.png`,
})
})
test(`Back button hovered`, async ({ page }) => {
- await page.hover('.wrapper>button:nth-child(1)')
+ await page.hover(".wrapper>button:nth-child(1)")
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `back-button-hovered.png`,
})
})
test(`Back button focused`, async ({ page }) => {
- await page.focus('.wrapper>button:nth-child(1)')
+ await page.focus(".wrapper>button:nth-child(1)")
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `back-button-focused.png`,
})
})
test(`Clear button hovered`, async ({ page }) => {
- await page.hover('.wrapper>button:nth-child(2)')
+ await page.hover(".wrapper>button:nth-child(2)")
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `clear-button-hovered.png`,
})
})
test(`Clear button focused`, async ({ page }) => {
- await page.hover('.wrapper>button:nth-child(2)')
+ await page.hover(".wrapper>button:nth-child(2)")
expect(await page.locator(wrapperLocator).screenshot()).toMatchSnapshot({
name: `clear-button-focused.png`,
})
diff --git a/test/storybook/visual-regression/v-search-type-button.spec.ts b/test/storybook/visual-regression/v-search-type-button.spec.ts
index 308046028..b2c82830b 100644
--- a/test/storybook/visual-regression/v-search-type-button.spec.ts
+++ b/test/storybook/visual-regression/v-search-type-button.spec.ts
@@ -1,83 +1,83 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
const defaultUrl =
- '/iframe.html?id=components-vcontentswitcher-vsearchtypebutton--default-story'
+ "/iframe.html?id=components-vcontentswitcher-vsearchtypebutton--default-story"
const pressedUrl = `${defaultUrl}&args=pressed:true`
const searchTypeButtonLocator = 'button[aria-haspopup="dialog"]'
-test.describe.configure({ mode: 'parallel' })
+test.describe.configure({ mode: "parallel" })
-test.describe('VSearchTypeButton', () => {
+test.describe("VSearchTypeButton", () => {
breakpoints.describeLg(({ expectSnapshot }) => {
- test('resting', async ({ page }) => {
+ test("resting", async ({ page }) => {
await page.goto(defaultUrl)
await expectSnapshot(
- 'v-search-type-button-at-rest',
+ "v-search-type-button-at-rest",
page.locator(searchTypeButtonLocator)
)
})
- test('hovered', async ({ page }) => {
+ test("hovered", async ({ page }) => {
await page.goto(defaultUrl)
await page.hover(searchTypeButtonLocator)
await expectSnapshot(
- 'v-search-type-button-hovered',
+ "v-search-type-button-hovered",
page.locator(searchTypeButtonLocator)
)
})
- test('pressed', async ({ page }) => {
+ test("pressed", async ({ page }) => {
await page.goto(pressedUrl)
await expectSnapshot(
- 'v-search-type-button-pressed',
+ "v-search-type-button-pressed",
page.locator(searchTypeButtonLocator)
)
})
- test('pressed-hovered', async ({ page }) => {
+ test("pressed-hovered", async ({ page }) => {
await page.goto(pressedUrl)
await page.hover(searchTypeButtonLocator)
await expectSnapshot(
- 'v-search-type-button-pressed-hovered',
+ "v-search-type-button-pressed-hovered",
page.locator(searchTypeButtonLocator)
)
})
})
breakpoints.describeXl(({ expectSnapshot }) => {
- test('resting', async ({ page }) => {
+ test("resting", async ({ page }) => {
await page.goto(defaultUrl)
await expectSnapshot(
- 'v-search-type-button-with-text-at-rest',
+ "v-search-type-button-with-text-at-rest",
page.locator(searchTypeButtonLocator)
)
})
- test('hovered', async ({ page }) => {
+ test("hovered", async ({ page }) => {
await page.goto(defaultUrl)
await page.hover(searchTypeButtonLocator)
await expectSnapshot(
- 'v-search-type-button-with-text-hovered',
+ "v-search-type-button-with-text-hovered",
page.locator(searchTypeButtonLocator)
)
})
- test('pressed', async ({ page }) => {
+ test("pressed", async ({ page }) => {
await page.goto(pressedUrl)
await expectSnapshot(
- 'v-search-type-button-with-text-pressed',
+ "v-search-type-button-with-text-pressed",
page.locator(searchTypeButtonLocator)
)
})
- test('pressed-hovered', async ({ page }) => {
+ test("pressed-hovered", async ({ page }) => {
await page.goto(pressedUrl)
await page.hover(searchTypeButtonLocator)
await expectSnapshot(
- 'v-search-type-button-with-text-pressed-hovered',
+ "v-search-type-button-with-text-pressed-hovered",
page.locator(searchTypeButtonLocator)
)
})
diff --git a/test/storybook/visual-regression/v-search-types.spec.ts b/test/storybook/visual-regression/v-search-types.spec.ts
index 201238388..8fbefb8dd 100644
--- a/test/storybook/visual-regression/v-search-types.spec.ts
+++ b/test/storybook/visual-regression/v-search-types.spec.ts
@@ -1,29 +1,29 @@
-import { test } from '@playwright/test'
+import { test } from "@playwright/test"
-import breakpoints from '~~/test/playwright/utils/breakpoints'
+import breakpoints from "~~/test/playwright/utils/breakpoints"
const defaultUrl =
- '/iframe.html?id=components-vcontentswitcher-vsearchtypes--default-story'
+ "/iframe.html?id=components-vcontentswitcher-vsearchtypes--default-story"
-const audioButtonLocator = 'text=images'
+const audioButtonLocator = "text=images"
-test.describe('VSearchTypes', () => {
+test.describe("VSearchTypes", () => {
breakpoints.describeMd(({ expectSnapshot }) => {
test.beforeEach(async ({ page }) => {
await page.goto(`${defaultUrl}&args=size%3Amedium`)
})
- test('medium resting', async ({ page }) => {
- await expectSnapshot('v-search-types-medium-at-rest', page)
+ test("medium resting", async ({ page }) => {
+ await expectSnapshot("v-search-types-medium-at-rest", page)
})
- test('medium images hovered', async ({ page }) => {
+ test("medium images hovered", async ({ page }) => {
await page.hover(audioButtonLocator)
- await expectSnapshot('v-search-types-medium-images-hovered', page)
+ await expectSnapshot("v-search-types-medium-images-hovered", page)
})
- test('medium focused', async ({ page }) => {
- await page.keyboard.press('Tab')
- await expectSnapshot('v-search-types-medium-focused', page)
+ test("medium focused", async ({ page }) => {
+ await page.keyboard.press("Tab")
+ await expectSnapshot("v-search-types-medium-focused", page)
})
})
@@ -32,18 +32,18 @@ test.describe('VSearchTypes', () => {
await page.goto(`${defaultUrl}&args=size%3Asmall`)
})
- test('small resting', async ({ page }) => {
- await expectSnapshot('v-search-types-small-at-rest', page)
+ test("small resting", async ({ page }) => {
+ await expectSnapshot("v-search-types-small-at-rest", page)
})
- test('small images hovered', async ({ page }) => {
+ test("small images hovered", async ({ page }) => {
await page.hover(audioButtonLocator)
- await expectSnapshot('v-search-types-small-images-hovered', page)
+ await expectSnapshot("v-search-types-small-images-hovered", page)
})
- test('small focused', async ({ page }) => {
- await page.keyboard.press('Tab')
- await expectSnapshot('v-search-types-small-focused', page)
+ test("small focused", async ({ page }) => {
+ await page.keyboard.press("Tab")
+ await expectSnapshot("v-search-types-small-focused", page)
})
})
})
diff --git a/test/storybook/visual-regression/v-select-field.spec.ts b/test/storybook/visual-regression/v-select-field.spec.ts
index 12185e785..3ba683949 100644
--- a/test/storybook/visual-regression/v-select-field.spec.ts
+++ b/test/storybook/visual-regression/v-select-field.spec.ts
@@ -1,24 +1,24 @@
-import { Page, test, expect } from '@playwright/test'
+import { Page, test, expect } from "@playwright/test"
-import { makeGotoWithArgs } from '~~/test/storybook/utils/args'
+import { makeGotoWithArgs } from "~~/test/storybook/utils/args"
const expectSnapshot = async (name: string, page: Page) => {
expect(await page.screenshot()).toMatchSnapshot({ name: `${name}.png` })
}
-test.describe('VSelectField', () => {
- test('default', async ({ page }) => {
- await makeGotoWithArgs('components-vselectfield--default-story')(page)
- await expectSnapshot('vselectfield-default', page)
+test.describe("VSelectField", () => {
+ test("default", async ({ page }) => {
+ await makeGotoWithArgs("components-vselectfield--default-story")(page)
+ await expectSnapshot("vselectfield-default", page)
})
- test('with icon', async ({ page }) => {
- await makeGotoWithArgs('components-vselectfield--with-icon')(page)
- await expectSnapshot('vselectfield-with-icon', page)
+ test("with icon", async ({ page }) => {
+ await makeGotoWithArgs("components-vselectfield--with-icon")(page)
+ await expectSnapshot("vselectfield-with-icon", page)
})
- test('without border', async ({ page }) => {
- await makeGotoWithArgs('components-vselectfield--without-border')(page)
- await expectSnapshot('vselectfield-without-border', page)
+ test("without border", async ({ page }) => {
+ await makeGotoWithArgs("components-vselectfield--without-border")(page)
+ await expectSnapshot("vselectfield-without-border", page)
})
})
diff --git a/test/unit/.eslintrc.js b/test/unit/.eslintrc.js
index 5a68b15df..bc4e06e6c 100644
--- a/test/unit/.eslintrc.js
+++ b/test/unit/.eslintrc.js
@@ -1,15 +1,15 @@
module.exports = {
- extends: ['../../.eslintrc.js'],
+ extends: ["../../.eslintrc.js"],
env: { jest: true },
rules: {
- 'import/no-named-as-default-member': ['off'],
- '@intlify/vue-i18n/no-raw-text': ['off'],
- 'no-restricted-imports': [
- 'error',
+ "import/no-named-as-default-member": ["off"],
+ "@intlify/vue-i18n/no-raw-text": ["off"],
+ "no-restricted-imports": [
+ "error",
{
- name: 'pinia',
+ name: "pinia",
message:
- 'Please import pinia test utils from `~~/test/unit/test-utils/pinia`. The test-utils version ensures proper setup of universally necessary Nuxt context mocks.',
+ "Please import pinia test utils from `~~/test/unit/test-utils/pinia`. The test-utils version ensures proper setup of universally necessary Nuxt context mocks.",
},
],
},
diff --git a/test/unit/fixtures/audio.js b/test/unit/fixtures/audio.js
index 407c9d08c..fa78ebfb9 100644
--- a/test/unit/fixtures/audio.js
+++ b/test/unit/fixtures/audio.js
@@ -1,33 +1,33 @@
export const getAudioObj = (overrides = {}) =>
Object.assign(
{
- id: 'e19345b8-6937-49f7-a0fd-03bf057efc28',
- title: 'La vie des bêtes',
- foreign_landing_url: 'https://www.jamendo.com/track/11188',
- creator: 'AS-POTIRONT!',
- creator_url: 'https://www.jamendo.com/artist/264/as-potiront',
- url: 'https://mp3d.jamendo.com/download/track/11188/mp32',
- license: 'by-nc-sa',
- license_version: '2.5',
- license_url: 'https://creativecommons.org/licenses/by-nc-sa/2.5/',
- provider: 'jamendo',
- source: 'jamendo',
- filetype: 'mp32',
+ id: "e19345b8-6937-49f7-a0fd-03bf057efc28",
+ title: "La vie des bêtes",
+ foreign_landing_url: "https://www.jamendo.com/track/11188",
+ creator: "AS-POTIRONT!",
+ creator_url: "https://www.jamendo.com/artist/264/as-potiront",
+ url: "https://mp3d.jamendo.com/download/track/11188/mp32",
+ license: "by-nc-sa",
+ license_version: "2.5",
+ license_url: "https://creativecommons.org/licenses/by-nc-sa/2.5/",
+ provider: "jamendo",
+ source: "jamendo",
+ filetype: "mp32",
tags: [
{
- name: 'vocal',
+ name: "vocal",
},
{
- name: 'male',
+ name: "male",
},
{
- name: 'speed_medium',
+ name: "speed_medium",
},
{
- name: 'party',
+ name: "party",
},
{
- name: 'cuivres',
+ name: "cuivres",
},
],
duration: 270000,
@@ -36,14 +36,14 @@ export const getAudioObj = (overrides = {}) =>
'"La vie des bêtes" by AS-POTIRONT! is licensed under CC BY-NC-SA 2.5. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/2.5/.',
mature: null,
thumbnail:
- 'https://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28/thumb',
+ "https://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28/thumb",
waveform:
- 'https://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28/waveform',
- genres: ['pop', 'rock', 'manouche'],
+ "https://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28/waveform",
+ genres: ["pop", "rock", "manouche"],
detail_url:
- 'http://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28',
+ "http://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28",
related_url:
- 'http://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28/recommendations',
+ "http://localhost:8000/v1/audio/e19345b8-6937-49f7-a0fd-03bf057efc28/recommendations",
},
overrides
)
diff --git a/test/unit/setup-after-env.js b/test/unit/setup-after-env.js
index 91e484b82..bf23aaddc 100644
--- a/test/unit/setup-after-env.js
+++ b/test/unit/setup-after-env.js
@@ -1,5 +1,5 @@
-import Vue from 'vue'
-import '@testing-library/jest-dom'
+import Vue from "vue"
+import "@testing-library/jest-dom"
Vue.prototype.$nuxt = {
context: {
diff --git a/test/unit/setup.js b/test/unit/setup.js
index 2eea4f547..f6720c7b4 100644
--- a/test/unit/setup.js
+++ b/test/unit/setup.js
@@ -1,8 +1,8 @@
-import Vue from 'vue'
-import VueI18n from 'vue-i18n'
-import { config } from '@vue/test-utils'
+import Vue from "vue"
+import VueI18n from "vue-i18n"
+import { config } from "@vue/test-utils"
-import { env } from '~/utils/env'
+import { env } from "~/utils/env"
// Attach nuxt config to process
for (const [key, value] of Object.entries(env)) {
@@ -16,8 +16,8 @@ Vue.use(VueI18n)
/**
* Simplified mock of a NuxtLink component.
*/
-config.stubs['nuxt-link'] = Vue.component('NuxtLink', {
- props: ['to'],
+config.stubs["nuxt-link"] = Vue.component("NuxtLink", {
+ props: ["to"],
template: '<a :href="to" v-on="$listeners"><slot /></a>',
})
diff --git a/test/unit/specs/components/AudioTrack/v-audio-track.spec.js b/test/unit/specs/components/AudioTrack/v-audio-track.spec.js
index 04ba36f4a..69c4ab10f 100644
--- a/test/unit/specs/components/AudioTrack/v-audio-track.spec.js
+++ b/test/unit/specs/components/AudioTrack/v-audio-track.spec.js
@@ -1,35 +1,35 @@
-import { fireEvent, render } from '@testing-library/vue'
-import Vuei18n from 'vue-i18n'
+import { fireEvent, render } from "@testing-library/vue"
+import Vuei18n from "vue-i18n"
import {
setActivePinia,
createPinia,
PiniaVuePlugin,
-} from '~~/test/unit/test-utils/pinia'
+} from "~~/test/unit/test-utils/pinia"
-import { getAudioObj } from '~~/test/unit/fixtures/audio'
+import { getAudioObj } from "~~/test/unit/fixtures/audio"
-import { useActiveMediaStore } from '~/stores/active-media'
+import { useActiveMediaStore } from "~/stores/active-media"
-import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
+import VAudioTrack from "~/components/VAudioTrack/VAudioTrack.vue"
-const enMessages = require('~/locales/en.json')
+const enMessages = require("~/locales/en.json")
window.HTMLMediaElement.prototype.play = () => {
/* mock */
}
const mockI18n = new Vuei18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: enMessages },
})
-jest.mock('~/composables/use-browser-detection', () => ({
+jest.mock("~/composables/use-browser-detection", () => ({
useBrowserIsBlink: jest.fn(() => false),
}))
-jest.mock('~/composables/use-i18n', () => ({
+jest.mock("~/composables/use-i18n", () => ({
useI18n: jest.fn(() => ({
t: jest.fn((val) => val),
tc: jest.fn((val) => val),
@@ -49,10 +49,10 @@ const useStore = (vue) => {
const activeMediaStore = useActiveMediaStore(pinia)
activeMediaStore.$patch({
state: {
- type: 'audio',
- id: 'e19345b8-6937-49f7-a0fd-03bf057efc28',
+ type: "audio",
+ id: "e19345b8-6937-49f7-a0fd-03bf057efc28",
message: null,
- state: 'paused',
+ state: "paused",
},
})
@@ -78,7 +78,7 @@ const stubs = {
VWaveform: true,
}
-describe('AudioTrack', () => {
+describe("AudioTrack", () => {
let options = null
let props = null
@@ -95,52 +95,52 @@ describe('AudioTrack', () => {
setActivePinia(createPinia())
})
- it('should render the full audio track component even without duration', () => {
+ it("should render the full audio track component even without duration", () => {
const { getByText } = render(VAudioTrack, options, configureVue)
getByText(props.audio.creator)
})
- it('should render the row audio track component even without duration', () => {
- options.propsData.layout = 'row'
+ it("should render the row audio track component even without duration", () => {
+ options.propsData.layout = "row"
const { getByText } = render(VAudioTrack, options, configureVue)
- getByText('by ' + props.audio.creator)
+ getByText("by " + props.audio.creator)
})
- it('should show audio title as main page title', () => {
+ it("should show audio title as main page title", () => {
const { getByText } = render(VAudioTrack, options, configureVue)
// Title text appears multiple times in the track, so need to specify selector
- const element = getByText(props.audio.title, { selector: 'H1' })
+ const element = getByText(props.audio.title, { selector: "H1" })
expect(element).toBeInTheDocument()
})
- it('should show audio creator with link', () => {
+ it("should show audio creator with link", () => {
const { getByText } = render(VAudioTrack, options, configureVue)
const element = getByText(props.audio.creator)
expect(element).toBeInstanceOf(HTMLAnchorElement)
- expect(element).toHaveAttribute('href', props.audio.creator_url)
+ expect(element).toHaveAttribute("href", props.audio.creator_url)
})
- it('on play error displays a message instead of the waveform', async () => {
- options.propsData.audio.url = 'bad.url'
- options.propsData.layout = 'row'
+ it("on play error displays a message instead of the waveform", async () => {
+ options.propsData.audio.url = "bad.url"
+ options.propsData.layout = "row"
options.stubs.VPlayPause = false
options.stubs.VWaveform = false
options.stubs.VAudioThumbnail = true
const pauseStub = jest
- .spyOn(window.HTMLMediaElement.prototype, 'pause')
+ .spyOn(window.HTMLMediaElement.prototype, "pause")
.mockImplementation(() => undefined)
const playStub = jest
- .spyOn(window.HTMLMediaElement.prototype, 'play')
+ .spyOn(window.HTMLMediaElement.prototype, "play")
.mockImplementation(() =>
- Promise.reject(new DOMException('msg', 'NotAllowedError'))
+ Promise.reject(new DOMException("msg", "NotAllowedError"))
)
const { getByRole, getByText } = render(VAudioTrack, options, configureVue)
- await fireEvent.click(getByRole('button'))
+ await fireEvent.click(getByRole("button"))
await expect(playStub).toHaveBeenCalledTimes(1)
await expect(pauseStub).toHaveBeenCalledTimes(1)
- await expect(getByText('audio-track.messages.err_unallowed')).toBeVisible()
+ await expect(getByText("audio-track.messages.err_unallowed")).toBeVisible()
// It's not possible to get the vm to test that Sentry has been called
})
})
diff --git a/test/unit/specs/components/AudioTrack/v-box-layout.spec.js b/test/unit/specs/components/AudioTrack/v-box-layout.spec.js
index 9439e379a..059638112 100644
--- a/test/unit/specs/components/AudioTrack/v-box-layout.spec.js
+++ b/test/unit/specs/components/AudioTrack/v-box-layout.spec.js
@@ -1,25 +1,25 @@
-import { render } from '@testing-library/vue'
-import Vuei18n from 'vue-i18n'
-import { createLocalVue } from '@vue/test-utils'
+import { render } from "@testing-library/vue"
+import Vuei18n from "vue-i18n"
+import { createLocalVue } from "@vue/test-utils"
-import { getAudioObj } from '~~/test/unit/fixtures/audio'
+import { getAudioObj } from "~~/test/unit/fixtures/audio"
-import VBoxLayout from '~/components/VAudioTrack/layouts/VBoxLayout.vue'
+import VBoxLayout from "~/components/VAudioTrack/layouts/VBoxLayout.vue"
-const enMessages = require('~/locales/en.json')
+const enMessages = require("~/locales/en.json")
const i18n = new Vuei18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: enMessages },
})
-describe('VBoxLayout', () => {
+describe("VBoxLayout", () => {
let options = null
let localVue
let props = {
audio: getAudioObj(),
- size: 'm',
+ size: "m",
}
beforeEach(() => {
@@ -33,18 +33,18 @@ describe('VBoxLayout', () => {
}
})
- it('renders audio title, license and category in v-box-layout', () => {
- props.audio.category = 'music'
+ it("renders audio title, license and category in v-box-layout", () => {
+ props.audio.category = "music"
const screen = render(VBoxLayout, options)
screen.getByText(props.audio.title)
- screen.getByLabelText('Attribution-NonCommercial-Share-Alike')
- screen.getByText('Music')
+ screen.getByLabelText("Attribution-NonCommercial-Share-Alike")
+ screen.getByText("Music")
})
- it('should not render category string if category is null', () => {
+ it("should not render category string if category is null", () => {
props.audio.category = null
const screen = render(VBoxLayout, options)
- const categoryLabel = screen.queryByText('Music')
+ const categoryLabel = screen.queryByText("Music")
expect(categoryLabel).toBeNull()
})
})
diff --git a/test/unit/specs/components/AudioTrack/v-full-layout.spec.js b/test/unit/specs/components/AudioTrack/v-full-layout.spec.js
index 9378e4284..fd5cdc85b 100644
--- a/test/unit/specs/components/AudioTrack/v-full-layout.spec.js
+++ b/test/unit/specs/components/AudioTrack/v-full-layout.spec.js
@@ -1,16 +1,16 @@
-import { createLocalVue } from '@vue/test-utils'
-import { render, screen } from '@testing-library/vue'
+import { createLocalVue } from "@vue/test-utils"
+import { render, screen } from "@testing-library/vue"
-import { getAudioObj } from '~~/test/unit/fixtures/audio'
-import { PiniaVuePlugin, createPinia } from '~~/test/unit/test-utils/pinia'
+import { getAudioObj } from "~~/test/unit/fixtures/audio"
+import { PiniaVuePlugin, createPinia } from "~~/test/unit/test-utils/pinia"
-import VFullLayout from '~/components/VAudioTrack/layouts/VFullLayout.vue'
+import VFullLayout from "~/components/VAudioTrack/layouts/VFullLayout.vue"
const localVue = createLocalVue()
localVue.use(PiniaVuePlugin)
-describe('VFullLayout', () => {
- it('should render the weblink button with the foreign landing url', () => {
+describe("VFullLayout", () => {
+ it("should render the weblink button with the foreign landing url", () => {
const audio = getAudioObj()
render(VFullLayout, {
@@ -18,13 +18,13 @@ describe('VFullLayout', () => {
pinia: createPinia(),
propsData: {
audio,
- size: 's',
- status: 'playing',
+ size: "s",
+ status: "playing",
currentTime: 1,
},
})
- const downloadButton = screen.getByText('audio-details.weblink')
- expect(downloadButton).toHaveAttribute('href', audio.foreign_landing_url)
+ const downloadButton = screen.getByText("audio-details.weblink")
+ expect(downloadButton).toHaveAttribute("href", audio.foreign_landing_url)
})
})
diff --git a/test/unit/specs/components/AudioTrack/waveform.spec.js b/test/unit/specs/components/AudioTrack/waveform.spec.js
index 7c4bf9d00..09772c172 100644
--- a/test/unit/specs/components/AudioTrack/waveform.spec.js
+++ b/test/unit/specs/components/AudioTrack/waveform.spec.js
@@ -1,21 +1,21 @@
-import { mount } from '@vue/test-utils'
+import { mount } from "@vue/test-utils"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import VWaveform from '~/components/VAudioTrack/VWaveform.vue'
+import VWaveform from "~/components/VAudioTrack/VWaveform.vue"
-jest.mock('~/composables/use-i18n', () => ({
+jest.mock("~/composables/use-i18n", () => ({
useI18n: jest.fn(),
}))
-jest.mock('~/utils/resampling', () => {
+jest.mock("~/utils/resampling", () => {
return {
downsampleArray: jest.fn((data) => data),
upsampleArray: jest.fn((data) => data),
}
})
-describe('VWaveform', () => {
+describe("VWaveform", () => {
let options = null
let props = null
@@ -23,7 +23,7 @@ describe('VWaveform', () => {
useI18n.mockImplementation(() => ({ t: (v) => v, tc: (v) => v }))
props = {
peaks: [],
- audioId: 'test',
+ audioId: "test",
}
options = {
@@ -34,18 +34,18 @@ describe('VWaveform', () => {
useI18n.mockReset()
})
- it('should use given peaks when peaks array is provided', () => {
+ it("should use given peaks when peaks array is provided", () => {
props.peaks = Array.from({ length: 5 }, () => 0)
const wrapper = mount(VWaveform, options)
expect(wrapper.vm.normalizedPeaks.length).toBe(5)
})
- it('should use random peaks when peaks not set', () => {
+ it("should use random peaks when peaks not set", () => {
const wrapper = mount(VWaveform, options)
expect(wrapper.vm.normalizedPeaks.length).toBe(100)
})
- it('should use random peaks when peaks array is blank', () => {
+ it("should use random peaks when peaks array is blank", () => {
props.peaks = null
const wrapper = mount(VWaveform, options)
expect(wrapper.vm.normalizedPeaks.length).toBe(100)
diff --git a/test/unit/specs/components/ImageDetails/v-copy-license.spec.js b/test/unit/specs/components/ImageDetails/v-copy-license.spec.js
index 6d91c3e8e..d7cffb1cb 100644
--- a/test/unit/specs/components/ImageDetails/v-copy-license.spec.js
+++ b/test/unit/specs/components/ImageDetails/v-copy-license.spec.js
@@ -1,8 +1,8 @@
-import VCopyLicense from '~/components/VMediaInfo/VCopyLicense.vue'
+import VCopyLicense from "~/components/VMediaInfo/VCopyLicense.vue"
-import render from '../../../test-utils/render'
+import render from "../../../test-utils/render"
-describe('VCopyLicense', () => {
+describe("VCopyLicense", () => {
let options = null
let props = null
@@ -10,26 +10,26 @@ describe('VCopyLicense', () => {
props = {
media: {
id: 0,
- title: 'foo',
- provider: 'flickr',
- url: 'foo.bar',
- thumbnail: 'http://foo.bar',
- foreign_landing_url: 'http://foo.bar',
- license: 'BY',
- license_version: '1.0',
- license_url: 'http://license.com',
- creator: 'John',
- creator_url: 'http://creator.com',
+ title: "foo",
+ provider: "flickr",
+ url: "foo.bar",
+ thumbnail: "http://foo.bar",
+ foreign_landing_url: "http://foo.bar",
+ license: "BY",
+ license_version: "1.0",
+ license_url: "http://license.com",
+ creator: "John",
+ creator_url: "http://creator.com",
},
- fullLicenseName: 'LICENSE',
+ fullLicenseName: "LICENSE",
}
options = {
propsData: props,
}
})
- it('should contain the correct contents', () => {
+ it("should contain the correct contents", () => {
const wrapper = render(VCopyLicense, options)
- expect(wrapper.find('.copy-license')).toBeDefined()
+ expect(wrapper.find(".copy-license")).toBeDefined()
})
})
diff --git a/test/unit/specs/components/InputField/input-field.spec.js b/test/unit/specs/components/InputField/input-field.spec.js
index ec109f7c0..01b1c939e 100644
--- a/test/unit/specs/components/InputField/input-field.spec.js
+++ b/test/unit/specs/components/InputField/input-field.spec.js
@@ -1,61 +1,61 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import VInputField from '~/components/VInputField/VInputField.vue'
+import VInputField from "~/components/VInputField/VInputField.vue"
const props = {
- fieldId: 'input-id',
- labelText: 'Label',
- size: 'small',
+ fieldId: "input-id",
+ labelText: "Label",
+ size: "small",
}
-describe('VInputField', () => {
+describe("VInputField", () => {
it('should render an `input` element with type="text"', () => {
render(VInputField, {
attrs: {
- placeholder: 'Enter some text',
+ placeholder: "Enter some text",
},
propsData: props,
})
- const element = screen.getByPlaceholderText('Enter some text')
+ const element = screen.getByPlaceholderText("Enter some text")
- expect(element.tagName).toBe('INPUT')
- expect(element).toHaveAttribute('type', 'text')
+ expect(element.tagName).toBe("INPUT")
+ expect(element).toHaveAttribute("type", "text")
})
- xit('should allow changing the type', () => {
+ xit("should allow changing the type", () => {
render(VInputField, {
attrs: {
- placeholder: 'Enter some number',
- type: 'number',
+ placeholder: "Enter some number",
+ type: "number",
},
propsData: props,
})
- const element = screen.getByPlaceholderText('Enter some number')
+ const element = screen.getByPlaceholderText("Enter some number")
- expect(element).toHaveAttribute('type', 'number')
+ expect(element).toHaveAttribute("type", "number")
})
- it('should set the ID on the `input` to allow attaching labels', () => {
+ it("should set the ID on the `input` to allow attaching labels", () => {
render(VInputField, {
attrs: {
- placeholder: 'Enter some text',
+ placeholder: "Enter some text",
},
propsData: props,
})
- const element = screen.getByPlaceholderText('Enter some text')
+ const element = screen.getByPlaceholderText("Enter some text")
- expect(element).toHaveAttribute('id', 'input-id')
+ expect(element).toHaveAttribute("id", "input-id")
})
- it('should render the label text connected to the input field if specified', () => {
+ it("should render the label text connected to the input field if specified", () => {
render(VInputField, {
propsData: props,
})
- const element = screen.getByLabelText('Label')
+ const element = screen.getByLabelText("Label")
- expect(element.tagName).toBe('INPUT')
+ expect(element.tagName).toBe("INPUT")
})
})
diff --git a/test/unit/specs/components/VAudioDetails/v-audio-details.spec.js b/test/unit/specs/components/VAudioDetails/v-audio-details.spec.js
index d2b7d13eb..f00739a1a 100644
--- a/test/unit/specs/components/VAudioDetails/v-audio-details.spec.js
+++ b/test/unit/specs/components/VAudioDetails/v-audio-details.spec.js
@@ -1,20 +1,20 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import { getAudioObj } from '~~/test/unit/fixtures/audio'
+import { getAudioObj } from "~~/test/unit/fixtures/audio"
-import VAudioDetails from '~/components/VAudioDetails/VAudioDetails.vue'
+import VAudioDetails from "~/components/VAudioDetails/VAudioDetails.vue"
-describe('VAudioDetails', () => {
+describe("VAudioDetails", () => {
let options
let props
const overrides = {
audio_set: {
- title: 'Test Album',
- foreign_landing_url: 'https://www.jamendo.com/album/3661/listen',
- creator: 'Tryad',
- creator_url: 'https://www.jamendo.com/artist/104/tryad',
- url: 'https://usercontent.jamendo.com?type=album&id=3661&width=200',
+ title: "Test Album",
+ foreign_landing_url: "https://www.jamendo.com/album/3661/listen",
+ creator: "Tryad",
+ creator_url: "https://www.jamendo.com/artist/104/tryad",
+ url: "https://usercontent.jamendo.com?type=album&id=3661&width=200",
},
}
@@ -24,46 +24,46 @@ describe('VAudioDetails', () => {
}
options = {
propsData: props,
- stubs: ['VAudioThumbnail', 'VContentReportPopover', 'VLink', 'VMediaTag'],
+ stubs: ["VAudioThumbnail", "VContentReportPopover", "VLink", "VMediaTag"],
}
})
- it('renders the album title', () => {
+ it("renders the album title", () => {
render(VAudioDetails, options)
- screen.getByText('audio-details.table.album')
+ screen.getByText("audio-details.table.album")
const album = screen.getByText(overrides.audio_set.title)
expect(album).toHaveAttribute(
- 'href',
+ "href",
overrides.audio_set.foreign_landing_url
)
})
- it('hides the album title tag when it does not exists', () => {
+ it("hides the album title tag when it does not exists", () => {
options.propsData.audio.audio_set = null
render(VAudioDetails, options)
- expect(screen.queryByText('Album')).toBeNull()
+ expect(screen.queryByText("Album")).toBeNull()
})
- it('displays the main filetype when no alternative files are available', () => {
+ it("displays the main filetype when no alternative files are available", () => {
render(VAudioDetails, options)
- screen.getByText('MP32') // throw if not found
+ screen.getByText("MP32") // throw if not found
})
- it('displays multiple filetypes when they are available in alt_files', () => {
+ it("displays multiple filetypes when they are available in alt_files", () => {
options.propsData.audio.alt_files = [
- { filetype: 'wav' },
- { filetype: 'ogg' },
+ { filetype: "wav" },
+ { filetype: "ogg" },
]
render(VAudioDetails, options)
- screen.getByText('MP32, WAV, OGG')
+ screen.getByText("MP32, WAV, OGG")
})
- it('displays only distinct filetypes', () => {
+ it("displays only distinct filetypes", () => {
options.propsData.audio.alt_files = [
- { filetype: 'ogg' },
- { filetype: 'ogg' },
+ { filetype: "ogg" },
+ { filetype: "ogg" },
]
render(VAudioDetails, options)
- screen.getByText('MP32, OGG')
+ screen.getByText("MP32, OGG")
})
})
diff --git a/test/unit/specs/components/VHeader/SearchBar/search-bar.spec.js b/test/unit/specs/components/VHeader/SearchBar/search-bar.spec.js
index 76fb26aa0..2de3a168c 100644
--- a/test/unit/specs/components/VHeader/SearchBar/search-bar.spec.js
+++ b/test/unit/specs/components/VHeader/SearchBar/search-bar.spec.js
@@ -1,17 +1,17 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import { createPinia, PiniaVuePlugin } from '~~/test/unit/test-utils/pinia'
+import { createPinia, PiniaVuePlugin } from "~~/test/unit/test-utils/pinia"
-import { useMatchHomeRoute } from '~/composables/use-match-routes'
+import { useMatchHomeRoute } from "~/composables/use-match-routes"
-import VSearchBar from '~/components/VHeader/VSearchBar/VSearchBar.vue'
+import VSearchBar from "~/components/VHeader/VSearchBar/VSearchBar.vue"
-jest.mock('~/composables/use-match-routes', () => ({
+jest.mock("~/composables/use-match-routes", () => ({
useMatchHomeRoute: jest.fn(),
}))
-const sizes = ['small', 'medium', 'large', 'standalone']
-const defaultPlaceholder = 'Enter search query'
+const sizes = ["small", "medium", "large", "standalone"]
+const defaultPlaceholder = "Enter search query"
const configureVue = (vue) => {
vue.use(PiniaVuePlugin)
@@ -20,11 +20,11 @@ const configureVue = (vue) => {
}
}
-describe('VSearchBar', () => {
+describe("VSearchBar", () => {
let options
beforeEach(() => {
options = {
- props: { placeholder: defaultPlaceholder, size: 'standalone' },
+ props: { placeholder: defaultPlaceholder, size: "standalone" },
mocks: {
$nuxt: {
context: {
@@ -44,9 +44,9 @@ describe('VSearchBar', () => {
const inputElement = screen.getByPlaceholderText(defaultPlaceholder)
- expect(inputElement.tagName).toBe('INPUT')
- expect(inputElement).toHaveAttribute('type', 'search')
- expect(inputElement).toHaveAttribute('placeholder', defaultPlaceholder)
+ expect(inputElement.tagName).toBe("INPUT")
+ expect(inputElement).toHaveAttribute("type", "search")
+ expect(inputElement).toHaveAttribute("placeholder", defaultPlaceholder)
}
)
@@ -57,26 +57,26 @@ describe('VSearchBar', () => {
options.props.size = size
render(VSearchBar, options, configureVue)
- const btnElement = screen.getByLabelText('search.search')
+ const btnElement = screen.getByLabelText("search.search")
- expect(btnElement.tagName).toBe('BUTTON')
- expect(btnElement).toHaveAttribute('type', 'submit')
- expect(btnElement).toHaveAttribute('aria-label', 'search.search')
+ expect(btnElement.tagName).toBe("BUTTON")
+ expect(btnElement).toHaveAttribute("type", "submit")
+ expect(btnElement).toHaveAttribute("aria-label", "search.search")
}
)
- describe('placeholder', () => {
- it('should default to hero.search.placeholder', () => {
+ describe("placeholder", () => {
+ it("should default to hero.search.placeholder", () => {
delete options.props.placeholder
render(VSearchBar, options, configureVue)
expect(
- screen.queryByPlaceholderText('hero.search.placeholder')
+ screen.queryByPlaceholderText("hero.search.placeholder")
).not.toBeNull()
})
- it('should use the prop when provided', () => {
- const placeholder = 'This is a different placeholder from the default'
+ it("should use the prop when provided", () => {
+ const placeholder = "This is a different placeholder from the default"
options.props.placeholder = placeholder
render(VSearchBar, options, configureVue)
expect(screen.queryByPlaceholderText(placeholder)).not.toBeNull()
diff --git a/test/unit/specs/components/VMediaTag/v-media-tag.spec.js b/test/unit/specs/components/VMediaTag/v-media-tag.spec.js
index 9dc9f301f..3b03774b8 100644
--- a/test/unit/specs/components/VMediaTag/v-media-tag.spec.js
+++ b/test/unit/specs/components/VMediaTag/v-media-tag.spec.js
@@ -1,10 +1,10 @@
-import { RouterLinkStub } from '@vue/test-utils'
+import { RouterLinkStub } from "@vue/test-utils"
-import render from '~/../test/unit/test-utils/render'
+import render from "~/../test/unit/test-utils/render"
-import VMediaTag from '~/components/VMediaTag/VMediaTag.vue'
+import VMediaTag from "~/components/VMediaTag/VMediaTag.vue"
-describe('VMediaTag', () => {
+describe("VMediaTag", () => {
let props = null
let options = null
@@ -13,48 +13,48 @@ describe('VMediaTag', () => {
options = { propsData: props }
})
- it('should render an span tag by default', () => {
+ it("should render an span tag by default", () => {
const wrapper = render(VMediaTag, options)
- expect(wrapper.vm.$props.tag).toEqual('span')
+ expect(wrapper.vm.$props.tag).toEqual("span")
expect(wrapper.vm.$el).toBeInstanceOf(HTMLSpanElement)
})
- it('should render the supplied tag', () => {
+ it("should render the supplied tag", () => {
options.propsData = {
...options.propsData,
- tag: 'a',
- href: 'https://example.com/',
+ tag: "a",
+ href: "https://example.com/",
}
const wrapper = render(VMediaTag, options)
- expect(wrapper.vm.$props.tag).toEqual('a')
+ expect(wrapper.vm.$props.tag).toEqual("a")
expect(wrapper.vm.$el).toBeInstanceOf(HTMLAnchorElement)
- expect(wrapper.vm.$el.href).toEqual('https://example.com/')
+ expect(wrapper.vm.$el.href).toEqual("https://example.com/")
})
- it('should render the supplied Vue component', () => {
+ it("should render the supplied Vue component", () => {
options.propsData = {
...options.propsData,
- tag: 'RouterLink',
- to: '/',
+ tag: "RouterLink",
+ to: "/",
}
options.stubs = {
RouterLink: RouterLinkStub,
}
const wrapper = render(VMediaTag, options)
- expect(wrapper.vm.$props.tag).toEqual('RouterLink')
+ expect(wrapper.vm.$props.tag).toEqual("RouterLink")
expect(wrapper.vm.$el).toBeInstanceOf(HTMLAnchorElement)
})
- it('renders slot content', () => {
+ it("renders slot content", () => {
options.slots = {
default: '<div id="slot-content">Hello</div>',
}
const wrapper = render(VMediaTag, options)
- const element = wrapper.find('#slot-content').element
+ const element = wrapper.find("#slot-content").element
expect(element).toBeInstanceOf(HTMLDivElement)
- expect(element.textContent).toEqual('Hello')
+ expect(element.textContent).toEqual("Hello")
})
})
diff --git a/test/unit/specs/components/image-grid.spec.js b/test/unit/specs/components/image-grid.spec.js
index 8482e530d..8ee8afb35 100644
--- a/test/unit/specs/components/image-grid.spec.js
+++ b/test/unit/specs/components/image-grid.spec.js
@@ -1,25 +1,25 @@
-import { render, screen } from '@testing-library/vue'
-import VueI18n from 'vue-i18n'
+import { render, screen } from "@testing-library/vue"
+import VueI18n from "vue-i18n"
-import { createLocalVue } from '@vue/test-utils'
+import { createLocalVue } from "@vue/test-utils"
-import { PiniaVuePlugin, createPinia } from '~~/test/unit/test-utils/pinia'
+import { PiniaVuePlugin, createPinia } from "~~/test/unit/test-utils/pinia"
-import messages from '~/locales/en.json'
+import messages from "~/locales/en.json"
-import VImageGrid from '~/components/VImageGrid/VImageGrid.vue'
+import VImageGrid from "~/components/VImageGrid/VImageGrid.vue"
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: messages },
})
const propsData = {
images: [
- { id: 'i1', url: 'http://localhost:8080/i1.png', title: 'image1' },
- { id: 'i2', url: 'http://localhost:8080/i2.jpg', title: 'image2' },
- { id: 'i3', url: 'http://localhost:8080/i3.svg', title: 'image3' },
+ { id: "i1", url: "http://localhost:8080/i1.png", title: "image1" },
+ { id: "i2", url: "http://localhost:8080/i2.jpg", title: "image2" },
+ { id: "i3", url: "http://localhost:8080/i3.svg", title: "image3" },
],
fetchState: {
isFetching: false,
@@ -27,7 +27,7 @@ const propsData = {
},
}
-describe('VImageGrid', () => {
+describe("VImageGrid", () => {
let localVue
let pinia
let options
@@ -39,16 +39,16 @@ describe('VImageGrid', () => {
localVue,
pinia,
props: propsData,
- stubs: ['VLicense'],
+ stubs: ["VLicense"],
mocks: { $nuxt: { context: { i18n } } },
}
})
- it('renders images without load more button', () => {
+ it("renders images without load more button", () => {
render(VImageGrid, options)
- expect(screen.queryAllByRole('img').length).toEqual(propsData.images.length)
- expect(screen.queryAllByRole('figure').length).toEqual(
+ expect(screen.queryAllByRole("img").length).toEqual(propsData.images.length)
+ expect(screen.queryAllByRole("figure").length).toEqual(
propsData.images.length
)
- expect(screen.queryByTestId('load-more')).not.toBeVisible()
+ expect(screen.queryByTestId("load-more")).not.toBeVisible()
})
})
diff --git a/test/unit/specs/components/loading-icon.spec.js b/test/unit/specs/components/loading-icon.spec.js
index b58c44412..cfcc7a8ad 100644
--- a/test/unit/specs/components/loading-icon.spec.js
+++ b/test/unit/specs/components/loading-icon.spec.js
@@ -1,10 +1,10 @@
-import LoadingIcon from '~/components/LoadingIcon.vue'
+import LoadingIcon from "~/components/LoadingIcon.vue"
-import render from '../../test-utils/render'
+import render from "../../test-utils/render"
-describe('LoadingIcon', () => {
- it('should render correct contents', () => {
+describe("LoadingIcon", () => {
+ it("should render correct contents", () => {
const wrapper = render(LoadingIcon)
- expect(wrapper.find('.lds-ring').vm).toBeDefined()
+ expect(wrapper.find(".lds-ring").vm).toBeDefined()
})
})
diff --git a/test/unit/specs/components/related-audios.spec.js b/test/unit/specs/components/related-audios.spec.js
index e0f5298ab..53c8f251d 100644
--- a/test/unit/specs/components/related-audios.spec.js
+++ b/test/unit/specs/components/related-audios.spec.js
@@ -1,13 +1,13 @@
-import { createLocalVue, mount } from '@vue/test-utils'
-import VueI18n from 'vue-i18n'
+import { createLocalVue, mount } from "@vue/test-utils"
+import VueI18n from "vue-i18n"
-import { PiniaVuePlugin, createPinia } from '~~/test/unit/test-utils/pinia'
+import { PiniaVuePlugin, createPinia } from "~~/test/unit/test-utils/pinia"
-import VRelatedAudio from '~/components/VAudioDetails/VRelatedAudio.vue'
+import VRelatedAudio from "~/components/VAudioDetails/VRelatedAudio.vue"
-import render from '../../test-utils/render'
+import render from "../../test-utils/render"
-const audioResults = [{ id: 'audio1' }, { id: 'audio2' }]
+const audioResults = [{ id: "audio1" }, { id: "audio2" }]
const localVue = createLocalVue()
localVue.use(VueI18n)
@@ -34,14 +34,14 @@ const doRender = async () => {
)
}
-describe('RelatedAudios', () => {
- it('should render content when finished loading related audios', async () => {
+describe("RelatedAudios", () => {
+ it("should render content when finished loading related audios", async () => {
const wrapper = await doRender()
- const header = wrapper.find('h2').text()
- expect(header).toEqual('audio-details.related-audios')
+ const header = wrapper.find("h2").text()
+ expect(header).toEqual("audio-details.related-audios")
- const audioTracks = wrapper.findAll('vaudiotrack-stub')
+ const audioTracks = wrapper.findAll("vaudiotrack-stub")
expect(audioTracks.length).toEqual(audioResults.length)
})
})
diff --git a/test/unit/specs/components/related-images.spec.js b/test/unit/specs/components/related-images.spec.js
index 5ae78d960..718142d31 100644
--- a/test/unit/specs/components/related-images.spec.js
+++ b/test/unit/specs/components/related-images.spec.js
@@ -1,26 +1,26 @@
-import VueI18n from 'vue-i18n'
-import { createLocalVue } from '@vue/test-utils'
-import { render, screen } from '@testing-library/vue'
+import VueI18n from "vue-i18n"
+import { createLocalVue } from "@vue/test-utils"
+import { render, screen } from "@testing-library/vue"
-import { PiniaVuePlugin, createPinia } from '~~/test/unit/test-utils/pinia'
+import { PiniaVuePlugin, createPinia } from "~~/test/unit/test-utils/pinia"
-import messages from '~/locales/en.json'
+import messages from "~/locales/en.json"
-import VRelatedImages from '~/components/VImageDetails/VRelatedImages.vue'
+import VRelatedImages from "~/components/VImageDetails/VRelatedImages.vue"
const media = [
- { id: 'img1', url: 'https://wp.org/img1.jpg' },
- { id: 'img2', url: 'https://wp.org/img2.jpg' },
+ { id: "img1", url: "https://wp.org/img1.jpg" },
+ { id: "img2", url: "https://wp.org/img2.jpg" },
]
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: messages },
})
const localVue = createLocalVue()
localVue.use(VueI18n)
localVue.use(PiniaVuePlugin)
-describe('RelatedImage', () => {
+describe("RelatedImage", () => {
let props
let options
let pinia
@@ -31,26 +31,26 @@ describe('RelatedImage', () => {
localVue,
pinia,
propsData: props,
- stubs: ['VLicense'],
+ stubs: ["VLicense"],
mocks: { $nuxt: { context: { i18n } } },
}
})
- it('should render an image grid', () => {
+ it("should render an image grid", () => {
render(VRelatedImages, options)
- expect(screen.getByRole('heading').textContent).toContain(
- 'image-details.related-images'
+ expect(screen.getByRole("heading").textContent).toContain(
+ "image-details.related-images"
)
- expect(screen.queryAllByRole('img').length).toEqual(2)
- expect(screen.queryAllByRole('figure').length).toEqual(2)
+ expect(screen.queryAllByRole("img").length).toEqual(2)
+ expect(screen.queryAllByRole("figure").length).toEqual(2)
})
- it('should not render data when media array is empty', () => {
+ it("should not render data when media array is empty", () => {
options.propsData.media = []
render(VRelatedImages, options)
- expect(screen.getByRole('heading').textContent).toContain(
- 'image-details.related-images'
+ expect(screen.getByRole("heading").textContent).toContain(
+ "image-details.related-images"
)
- expect(screen.queryAllByRole('img').length).toEqual(0)
+ expect(screen.queryAllByRole("img").length).toEqual(0)
})
})
diff --git a/test/unit/specs/components/scroll-button.spec.js b/test/unit/specs/components/scroll-button.spec.js
index fd4b39a2a..e413f4b8c 100644
--- a/test/unit/specs/components/scroll-button.spec.js
+++ b/test/unit/specs/components/scroll-button.spec.js
@@ -1,12 +1,12 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import VScrollButton from '~/components/VScrollButton.vue'
+import VScrollButton from "~/components/VScrollButton.vue"
-describe('Scroll button', () => {
- it('should render a scroll button', () => {
+describe("Scroll button", () => {
+ it("should render a scroll button", () => {
const { container } = render(VScrollButton)
- expect(screen.getByRole('button')).toBeTruthy()
+ expect(screen.getByRole("button")).toBeTruthy()
expect(screen.getByLabelText(/scroll/i)).toBeTruthy()
- expect(container.querySelectorAll('svg').length).toEqual(1)
+ expect(container.querySelectorAll("svg").length).toEqual(1)
})
})
diff --git a/test/unit/specs/components/v-button.spec.js b/test/unit/specs/components/v-button.spec.js
index 02cb3a9a2..e862d01e9 100644
--- a/test/unit/specs/components/v-button.spec.js
+++ b/test/unit/specs/components/v-button.spec.js
@@ -1,10 +1,10 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import { warn } from '~/utils/console'
+import { warn } from "~/utils/console"
-import VButton from '~/components/VButton.vue'
+import VButton from "~/components/VButton.vue"
-jest.mock('~/utils/console', () => ({ warn: jest.fn(), log: jest.fn() }))
+jest.mock("~/utils/console", () => ({ warn: jest.fn(), log: jest.fn() }))
const nextTick = () => new Promise((r) => setTimeout(r, 0))
/**
@@ -14,85 +14,85 @@ const nextTick = () => new Promise((r) => setTimeout(r, 0))
* to settle, then all the props that are changed after `onMounted` completes
* won't be rendered.
*/
-describe('VButton', () => {
+describe("VButton", () => {
afterEach(() => {
warn.mockReset()
})
it('should render a `button` by default with type="button" and no tabindex', async () => {
render(VButton, {
- slots: { default: 'Code is Poetry' },
+ slots: { default: "Code is Poetry" },
})
- const element = await screen.findByRole('button')
+ const element = await screen.findByRole("button")
- expect(element.tagName).toBe('BUTTON')
- expect(element).toHaveAttribute('type', 'button')
- expect(element).not.toHaveAttribute('tabindex')
+ expect(element.tagName).toBe("BUTTON")
+ expect(element).toHaveAttribute("type", "button")
+ expect(element).not.toHaveAttribute("tabindex")
})
- it('should allow passing an explicit type', async () => {
+ it("should allow passing an explicit type", async () => {
render(VButton, {
- props: { type: 'submit' },
- slots: { default: 'Code is Poetry' },
+ props: { type: "submit" },
+ slots: { default: "Code is Poetry" },
})
- const element = await screen.findByRole('button')
+ const element = await screen.findByRole("button")
- expect(element).toHaveAttribute('type', 'submit')
+ expect(element).toHaveAttribute("type", "submit")
})
- it('should render an anchor with no type attribute', async () => {
+ it("should render an anchor with no type attribute", async () => {
render(VButton, {
- attrs: { href: 'http://localhost' },
- props: { as: 'VLink' },
- slots: { default: 'Code is Poetry' },
+ attrs: { href: "http://localhost" },
+ props: { as: "VLink" },
+ slots: { default: "Code is Poetry" },
})
await nextTick()
const element = await screen.findByText(/code is poetry/i)
- expect(element.tagName).toBe('A')
- expect(element).not.toHaveAttribute('type')
+ expect(element.tagName).toBe("A")
+ expect(element).not.toHaveAttribute("type")
})
- it('should render the disabled attribute on a button when the element is explicitly unfocusableWhenDisabled and is disabled', async () => {
+ it("should render the disabled attribute on a button when the element is explicitly unfocusableWhenDisabled and is disabled", async () => {
render(VButton, {
props: { disabled: true, focusableWhenDisabled: false },
- slots: { default: 'Code is Poetry' },
+ slots: { default: "Code is Poetry" },
})
- const element = await screen.findByRole('button')
+ const element = await screen.findByRole("button")
// Vue renders the disabled attribute having a `true` value as `[disabled="disabled"]`
- expect(element).toHaveAttribute('disabled', 'disabled')
+ expect(element).toHaveAttribute("disabled", "disabled")
})
- it('should not render the disabled attribute if the element is focusableWhenDisabled', async () => {
+ it("should not render the disabled attribute if the element is focusableWhenDisabled", async () => {
render(VButton, {
props: { disabled: true, focusableWhenDisabled: true },
- slots: { default: 'Code is Poetry' },
+ slots: { default: "Code is Poetry" },
})
- const element = await screen.findByRole('button')
+ const element = await screen.findByRole("button")
- expect(element).not.toHaveAttribute('disabled')
- expect(element).toHaveAttribute('aria-disabled', 'true')
+ expect(element).not.toHaveAttribute("disabled")
+ expect(element).toHaveAttribute("aria-disabled", "true")
})
- it('should not render the disabled attribute on elements that do not support it', async () => {
+ it("should not render the disabled attribute on elements that do not support it", async () => {
render(VButton, {
props: {
- as: 'VLink',
+ as: "VLink",
disabled: true,
focusableWhenDisabled: true,
- href: 'https://wordpress.org',
+ href: "https://wordpress.org",
},
- slots: { default: 'Code is Poetry' },
+ slots: { default: "Code is Poetry" },
})
const element = await screen.findByText(/code is poetry/i)
- expect(element).not.toHaveAttribute('disabled')
- expect(element).toHaveAttribute('aria-disabled', 'true')
+ expect(element).not.toHaveAttribute("disabled")
+ expect(element).toHaveAttribute("aria-disabled", "true")
})
})
diff --git a/test/unit/specs/components/v-checkbox.spec.js b/test/unit/specs/components/v-checkbox.spec.js
index fcb6177a0..6ee4ebf2d 100644
--- a/test/unit/specs/components/v-checkbox.spec.js
+++ b/test/unit/specs/components/v-checkbox.spec.js
@@ -1,20 +1,20 @@
-import Vue from 'vue'
-import { fireEvent, render, screen } from '@testing-library/vue'
+import Vue from "vue"
+import { fireEvent, render, screen } from "@testing-library/vue"
-import VCheckbox from '~/components/VCheckbox/VCheckbox.vue'
+import VCheckbox from "~/components/VCheckbox/VCheckbox.vue"
const TestWrapperStringLabel = ({
- id = 'simple',
- value = 'simple',
+ id = "simple",
+ value = "simple",
checked = false,
- defaultSlot = 'JPGs',
+ defaultSlot = "JPGs",
disabled = false,
} = {}) => {
// eslint-disable-next-line vue/one-component-per-file
- return Vue.component('TestWrapper', {
+ return Vue.component("TestWrapper", {
components: { VCheckbox },
data() {
- return { checked, status: '' }
+ return { checked, status: "" }
},
computed: {
attrs() {
@@ -29,15 +29,15 @@ const TestWrapperStringLabel = ({
},
methods: {
updateStatus(params) {
- this.status = Object.values(params).join(',')
+ this.status = Object.values(params).join(",")
},
},
template: `<div><span>{{status}}</span><VCheckbox v-bind="attrs" @change="updateStatus">${defaultSlot}</VCheckbox></div>`,
})
}
-describe('VCheckbox', () => {
- it('should render a checkbox with a string label', async () => {
+describe("VCheckbox", () => {
+ it("should render a checkbox with a string label", async () => {
const wrapper = TestWrapperStringLabel()
const { container } = render(wrapper)
// Finding a checked input doesn't work using { checked: false/true }
@@ -45,40 +45,40 @@ describe('VCheckbox', () => {
// toHaveAttribute('checked', 'true') also doesn't work, screen.debug()
// returns an element without `checked` attribute, although the attribute
// exists in the app/Storybook.
- const checkboxes = screen.queryAllByLabelText(/jpgs/i, { role: 'checkbox' })
+ const checkboxes = screen.queryAllByLabelText(/jpgs/i, { role: "checkbox" })
// The checkmark svg should not be visible
- expect(container.querySelector('svg')).not.toBeVisible()
+ expect(container.querySelector("svg")).not.toBeVisible()
expect(checkboxes).toHaveLength(1)
})
- it('should render a checked checkbox if `checked` is true', async () => {
+ it("should render a checked checkbox if `checked` is true", async () => {
const wrapper = TestWrapperStringLabel({ checked: true })
const { container } = render(wrapper)
- const checkboxes = screen.queryAllByLabelText(/jpgs/i, { role: 'checkbox' })
+ const checkboxes = screen.queryAllByLabelText(/jpgs/i, { role: "checkbox" })
// The checkmark svg should be visible
- expect(container.querySelector('svg')).toBeVisible()
+ expect(container.querySelector("svg")).toBeVisible()
expect(checkboxes).toHaveLength(1)
})
- it('should emit event on change', async () => {
+ it("should emit event on change", async () => {
const wrapper = TestWrapperStringLabel()
const { container } = render(wrapper)
- await fireEvent.click(screen.queryByRole('checkbox'))
+ await fireEvent.click(screen.queryByRole("checkbox"))
// Testing the method that handles the emitted data instead of testing emitted event
- expect(container.querySelector('span').textContent).toEqual(
- 'simple,simple,true'
+ expect(container.querySelector("span").textContent).toEqual(
+ "simple,simple,true"
)
})
- it('should render a disabled checkbox if `disabled` is true', async () => {
+ it("should render a disabled checkbox if `disabled` is true", async () => {
const wrapper = TestWrapperStringLabel({ disabled: true })
render(wrapper)
- const checkboxes = screen.queryAllByLabelText(/jpgs/i, { role: 'checkbox' })
+ const checkboxes = screen.queryAllByLabelText(/jpgs/i, { role: "checkbox" })
expect(checkboxes).toHaveLength(1)
- expect(checkboxes[0]).toHaveAttribute('disabled', 'disabled')
+ expect(checkboxes[0]).toHaveAttribute("disabled", "disabled")
})
})
diff --git a/test/unit/specs/components/v-content-link.spec.js b/test/unit/specs/components/v-content-link.spec.js
index dfff92ca4..2d8ede4e0 100644
--- a/test/unit/specs/components/v-content-link.spec.js
+++ b/test/unit/specs/components/v-content-link.spec.js
@@ -1,22 +1,22 @@
-import { render, screen } from '@testing-library/vue'
-import VueI18n from 'vue-i18n'
+import { render, screen } from "@testing-library/vue"
+import VueI18n from "vue-i18n"
-import VContentLink from '~/components/VContentLink/VContentLink.vue'
+import VContentLink from "~/components/VContentLink/VContentLink.vue"
-const enMessages = require('~/locales/en.json')
+const enMessages = require("~/locales/en.json")
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: enMessages },
})
-describe('VContentLink', () => {
+describe("VContentLink", () => {
let options = {}
beforeEach(() => {
options = {
- props: { mediaType: 'image', resultsCount: 123, to: '/images' },
+ props: { mediaType: "image", resultsCount: 123, to: "/images" },
mocks: {
$nuxt: {
context: {
@@ -27,21 +27,21 @@ describe('VContentLink', () => {
}
})
- it('is enabled when there are results', () => {
+ it("is enabled when there are results", () => {
render(VContentLink, options)
- const btn = screen.getByRole('link')
+ const btn = screen.getByRole("link")
- expect(btn).toHaveAttribute('href')
- expect(btn).not.toHaveAttribute('aria-disabled')
+ expect(btn).toHaveAttribute("href")
+ expect(btn).not.toHaveAttribute("aria-disabled")
})
- it('is disabled when there are no results', () => {
+ it("is disabled when there are no results", () => {
options.props.resultsCount = 0
render(VContentLink, options)
- const btn = screen.getByRole('link')
+ const btn = screen.getByRole("link")
- expect(btn).not.toHaveAttribute('href')
- expect(btn).toHaveAttribute('aria-disabled')
- expect(btn.getAttribute('aria-disabled')).toBeTruthy()
+ expect(btn).not.toHaveAttribute("href")
+ expect(btn).toHaveAttribute("aria-disabled")
+ expect(btn.getAttribute("aria-disabled")).toBeTruthy()
})
})
diff --git a/test/unit/specs/components/v-content-report-form.spec.js b/test/unit/specs/components/v-content-report-form.spec.js
index 746ca0168..486bdf730 100644
--- a/test/unit/specs/components/v-content-report-form.spec.js
+++ b/test/unit/specs/components/v-content-report-form.spec.js
@@ -1,49 +1,49 @@
-import { fireEvent, render, screen } from '@testing-library/vue'
-import VueI18n from 'vue-i18n'
+import { fireEvent, render, screen } from "@testing-library/vue"
+import VueI18n from "vue-i18n"
-import VContentReportForm from '~/components/VContentReport/VContentReportForm.vue'
+import VContentReportForm from "~/components/VContentReport/VContentReportForm.vue"
-const messages = require('~/locales/en.json')
+const messages = require("~/locales/en.json")
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: messages },
})
const getDmcaInput = () =>
- screen.getByRole('radio', {
+ screen.getByRole("radio", {
name: /dmca/i,
})
const getMatureInput = () =>
- screen.getByRole('radio', {
+ screen.getByRole("radio", {
name: /mature/i,
})
const getOtherInput = () =>
- screen.getByRole('radio', {
+ screen.getByRole("radio", {
name: /other/i,
})
const getCancelButton = () =>
- screen.getByRole('button', {
+ screen.getByRole("button", {
name: /cancel/i,
})
const getReportButton = () =>
- screen.getByRole('button', {
+ screen.getByRole("button", {
name: /submit/i,
})
// When DMCA selected
const getReportLink = () =>
- screen.getByRole('link', {
+ screen.getByRole("link", {
name: /dmca\.open/i,
})
// When other selected
const getDescriptionTextarea = () =>
- screen.getByRole('textbox', {
+ screen.getByRole("textbox", {
name: /other\.note/i,
})
-describe('VContentReportForm', () => {
+describe("VContentReportForm", () => {
let props = null
let options = {}
@@ -52,12 +52,12 @@ describe('VContentReportForm', () => {
beforeEach(() => {
props = {
media: {
- id: '0aff3595-8168-440b-83ff-7a80b65dea42',
- foreign_landing_url: 'https://wordpress.org/openverse/',
- provider: 'provider',
- frontendMediaType: 'image',
+ id: "0aff3595-8168-440b-83ff-7a80b65dea42",
+ foreign_landing_url: "https://wordpress.org/openverse/",
+ provider: "provider",
+ frontendMediaType: "image",
},
- providerName: 'Provider',
+ providerName: "Provider",
closeFn: jest.fn(),
reportService: reportServiceProp,
}
@@ -65,11 +65,11 @@ describe('VContentReportForm', () => {
options = {
propsData: props,
i18n,
- stubs: ['VIcon'],
+ stubs: ["VIcon"],
}
})
- it('should contain the correct contents', async () => {
+ it("should contain the correct contents", async () => {
await render(VContentReportForm, options)
getDmcaInput()
getMatureInput()
@@ -78,7 +78,7 @@ describe('VContentReportForm', () => {
getReportLink()
})
- it('should render thank you note when report is sent', async () => {
+ it("should render thank you note when report is sent", async () => {
const { getByText } = render(VContentReportForm, options)
await fireEvent.click(getMatureInput())
await fireEvent.click(getReportButton())
@@ -87,7 +87,7 @@ describe('VContentReportForm', () => {
getByText(/Thank you for reporting this content/i)
})
- it('should render error message if report sending fails', async () => {
+ it("should render error message if report sending fails", async () => {
options.propsData.reportService = { sendReport: () => Promise.reject() }
const { getByText } = render(VContentReportForm, options)
@@ -95,10 +95,10 @@ describe('VContentReportForm', () => {
await fireEvent.click(getReportButton())
// Submission error message
- getByText('media-details.content-report.failure.note')
+ getByText("media-details.content-report.failure.note")
})
- it('should render DMCA notice', async () => {
+ it("should render DMCA notice", async () => {
const { getByText } = render(VContentReportForm, options)
await fireEvent.click(getDmcaInput())
@@ -109,16 +109,16 @@ describe('VContentReportForm', () => {
getReportLink()
})
- it('should render other description form', async () => {
+ it("should render other description form", async () => {
const { getByText } = render(VContentReportForm, options)
await fireEvent.click(getOtherInput())
// Report form with a submit button
- getByText('media-details.content-report.form.other.note')
+ getByText("media-details.content-report.form.other.note")
getDescriptionTextarea()
})
- it('should dispatch SEND_CONTENT_REPORT on next when mature is selected', async () => {
+ it("should dispatch SEND_CONTENT_REPORT on next when mature is selected", async () => {
const serviceMock = { sendReport: jest.fn() }
options.propsData.reportService = serviceMock
render(VContentReportForm, options)
@@ -127,38 +127,38 @@ describe('VContentReportForm', () => {
expect(serviceMock.sendReport).toHaveBeenCalledWith({
identifier: props.media.id,
- reason: 'mature',
+ reason: "mature",
mediaType: props.media.frontendMediaType,
- description: '',
+ description: "",
})
})
- it('should dispatch SEND_CONTENT_REPORT on other form submit', async () => {
+ it("should dispatch SEND_CONTENT_REPORT on other form submit", async () => {
const serviceMock = { sendReport: jest.fn() }
options.propsData.reportService = serviceMock
render(VContentReportForm, options)
await fireEvent.click(getOtherInput())
- const description = 'description that has more than 20 characters'
+ const description = "description that has more than 20 characters"
await fireEvent.update(getDescriptionTextarea(), description)
await fireEvent.click(getReportButton())
expect(serviceMock.sendReport).toHaveBeenCalledWith({
identifier: props.media.id,
- reason: 'other',
- mediaType: 'image',
+ reason: "other",
+ mediaType: "image",
description,
})
})
- it('should not send other report if description is short', async () => {
+ it("should not send other report if description is short", async () => {
options.propsData.reportService = { sendReport: jest.fn() }
render(VContentReportForm, options)
await fireEvent.click(getOtherInput())
- const description = 'less than 20 chars'
+ const description = "less than 20 chars"
await fireEvent.update(getDescriptionTextarea(), description)
})
})
diff --git a/test/unit/specs/components/v-copy-button.spec.js b/test/unit/specs/components/v-copy-button.spec.js
index c8e7d33eb..36a296e30 100644
--- a/test/unit/specs/components/v-copy-button.spec.js
+++ b/test/unit/specs/components/v-copy-button.spec.js
@@ -3,20 +3,20 @@
* Actual copying is being tested by the e2e tests:
* test/playwright/e2e/attribution.spec.ts
*/
-import { render } from '@testing-library/vue'
+import { render } from "@testing-library/vue"
-import VCopyButton from '~/components/VCopyButton.vue'
+import VCopyButton from "~/components/VCopyButton.vue"
-describe('VCopyButton', () => {
- it('should render correct contents', () => {
+describe("VCopyButton", () => {
+ it("should render correct contents", () => {
const screen = render(VCopyButton, {
propsData: {
- el: '#foo',
- id: 'foo',
+ el: "#foo",
+ id: "foo",
},
})
- expect(screen.getByRole('button')).toHaveTextContent(
- 'media-details.reuse.copy-license.copy-text'
+ expect(screen.getByRole("button")).toHaveTextContent(
+ "media-details.reuse.copy-license.copy-text"
)
})
})
diff --git a/test/unit/specs/components/v-filter-checklist.spec.js b/test/unit/specs/components/v-filter-checklist.spec.js
index 34fc12440..fe956d53a 100644
--- a/test/unit/specs/components/v-filter-checklist.spec.js
+++ b/test/unit/specs/components/v-filter-checklist.spec.js
@@ -1,17 +1,17 @@
-import { createLocalVue } from '@vue/test-utils'
-import { fireEvent, render, screen } from '@testing-library/vue'
+import { createLocalVue } from "@vue/test-utils"
+import { fireEvent, render, screen } from "@testing-library/vue"
-import { PiniaVuePlugin, createPinia } from '~~/test/unit/test-utils/pinia'
+import { PiniaVuePlugin, createPinia } from "~~/test/unit/test-utils/pinia"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import FilterChecklist from '~/components/VFilters/VFilterChecklist.vue'
+import FilterChecklist from "~/components/VFilters/VFilterChecklist.vue"
-jest.mock('~/composables/use-i18n', () => ({
+jest.mock("~/composables/use-i18n", () => ({
useI18n: jest.fn(),
}))
-describe('FilterChecklist', () => {
+describe("FilterChecklist", () => {
let options = {}
let props = null
let localVue = null
@@ -24,9 +24,9 @@ describe('FilterChecklist', () => {
useI18n.mockImplementation(() => ({ t: (v) => v }))
props = {
- options: [{ code: 'foo', name: 'bar', checked: false }],
- title: 'Foo',
- filterType: 'bar',
+ options: [{ code: "foo", name: "bar", checked: false }],
+ title: "Foo",
+ filterType: "bar",
disabled: false,
}
options = {
@@ -36,16 +36,16 @@ describe('FilterChecklist', () => {
}
})
- it('should render correct contents', async () => {
+ it("should render correct contents", async () => {
const { container } = render(FilterChecklist, options)
- const checkbox = screen.getByRole('checkbox', {
+ const checkbox = screen.getByRole("checkbox", {
checked: false,
label: /bar/i,
})
expect(checkbox).toBeTruthy()
- expect(container.querySelector('svg')).not.toBeVisible()
+ expect(container.querySelector("svg")).not.toBeVisible()
await fireEvent.click(checkbox)
- expect(container.querySelector('svg')).toBeVisible()
+ expect(container.querySelector("svg")).toBeVisible()
})
})
diff --git a/test/unit/specs/components/v-item-group.spec.js b/test/unit/specs/components/v-item-group.spec.js
index 21759bd24..3821429b3 100644
--- a/test/unit/specs/components/v-item-group.spec.js
+++ b/test/unit/specs/components/v-item-group.spec.js
@@ -1,14 +1,14 @@
-import Vue from 'vue'
-import { ref } from '@nuxtjs/composition-api'
-import { render, screen } from '@testing-library/vue'
-import userEvent from '@testing-library/user-event'
+import Vue from "vue"
+import { ref } from "@nuxtjs/composition-api"
+import { render, screen } from "@testing-library/vue"
+import userEvent from "@testing-library/user-event"
-import { useI18n } from '~/composables/use-i18n'
+import { useI18n } from "~/composables/use-i18n"
-import VItemGroup from '~/components/VItemGroup/VItemGroup.vue'
-import VItem from '~/components/VItemGroup/VItem.vue'
+import VItemGroup from "~/components/VItemGroup/VItemGroup.vue"
+import VItem from "~/components/VItemGroup/VItem.vue"
-jest.mock('~/composables/use-i18n', () => ({
+jest.mock("~/composables/use-i18n", () => ({
useI18n: jest.fn(),
}))
@@ -17,7 +17,7 @@ const doFocus = (element) => {
return new Promise((r) => setTimeout(r, 0))
}
-const TestWrapper = Vue.component('TestWrapper', {
+const TestWrapper = Vue.component("TestWrapper", {
components: { VItemGroup, VItem },
props: {
hasDefaultSelection: {
@@ -53,26 +53,26 @@ const TestWrapper = Vue.component('TestWrapper', {
`,
})
-describe('VItemGroup', () => {
+describe("VItemGroup", () => {
let mockDir
beforeEach(() => {
- mockDir = 'ltr'
+ mockDir = "ltr"
useI18n.mockImplementation(() => ({ localeProperties: { dir: mockDir } }))
})
afterEach(() => {
useI18n.mockReset()
})
- it('should render buttons with the appropriate roles', () => {
+ it("should render buttons with the appropriate roles", () => {
render(TestWrapper)
- expect(screen.queryByRole('menu')).not.toBe(null)
- const items = screen.queryAllByRole('menuitemcheckbox')
+ expect(screen.queryByRole("menu")).not.toBe(null)
+ const items = screen.queryAllByRole("menuitemcheckbox")
expect(items).toHaveLength(4)
- expect(items.every((item) => item.tagName === 'BUTTON')).toBe(true)
+ expect(items.every((item) => item.tagName === "BUTTON")).toBe(true)
})
- it('should render functional buttons', async () => {
+ it("should render functional buttons", async () => {
const { container } = render(TestWrapper)
- const [, secondItem] = screen.queryAllByRole('menuitemcheckbox')
+ const [, secondItem] = screen.queryAllByRole("menuitemcheckbox")
expect(
container.querySelector('[aria-pressed="true"][aria-checked="true"]')
).not.toBe(secondItem)
@@ -82,12 +82,12 @@ describe('VItemGroup', () => {
).toBe(secondItem)
})
- it('should render a radio group', async () => {
+ it("should render a radio group", async () => {
const { container } = render(TestWrapper, {
- attrs: { type: 'radiogroup' },
+ attrs: { type: "radiogroup" },
})
- expect(screen.queryByRole('radiogroup')).not.toBe(null)
- const [, secondItem] = screen.queryAllByRole('radio')
+ expect(screen.queryByRole("radiogroup")).not.toBe(null)
+ const [, secondItem] = screen.queryAllByRole("radio")
expect(
container.querySelector('[aria-pressed="true"][aria-checked="true"]')
).not.toBe(secondItem)
@@ -97,33 +97,33 @@ describe('VItemGroup', () => {
).toBe(secondItem)
})
- describe('navigation', () => {
- it('should render the first item tabbable when there is no default selection and none are selected', () => {
+ describe("navigation", () => {
+ it("should render the first item tabbable when there is no default selection and none are selected", () => {
const { container } = render(TestWrapper, {
props: { hasDefaultSelection: false },
- attrs: { type: 'radiogroup' },
+ attrs: { type: "radiogroup" },
})
const tabbableElements = container.querySelectorAll('[tabindex="0"]')
expect(tabbableElements).toHaveLength(1)
const [tabbableElement] = tabbableElements
- expect(tabbableElement).toBe(screen.queryAllByRole('radio')[0])
+ expect(tabbableElement).toBe(screen.queryAllByRole("radio")[0])
})
- it('should render all items tabbable when in a menu', () => {
+ it("should render all items tabbable when in a menu", () => {
const { container } = render(TestWrapper, {
- attrs: { type: 'menu' },
+ attrs: { type: "menu" },
})
const tabbableElements = container.querySelectorAll('[tabindex="0"]')
- const items = screen.queryAllByRole('menuitemcheckbox')
+ const items = screen.queryAllByRole("menuitemcheckbox")
items.forEach((item) => expect(tabbableElements).toContain(item))
})
- it('should render only the selected item as tabbable', async () => {
+ it("should render only the selected item as tabbable", async () => {
const { container } = render(TestWrapper, {
- attrs: { type: 'radiogroup' },
+ attrs: { type: "radiogroup" },
props: { hasDefaultSelection: false },
})
- const [, secondItem] = screen.queryAllByRole('radio')
+ const [, secondItem] = screen.queryAllByRole("radio")
await userEvent.click(secondItem)
// Focus off the clicked item and outside the group so that the group does not have focus but there is still a selected item
await doFocus(screen.getByText(/external element/i))
@@ -133,11 +133,11 @@ describe('VItemGroup', () => {
expect(tabbableElement).toBe(secondItem)
})
- it('should render the currently focused item as tabbable even when there is a selection', async () => {
+ it("should render the currently focused item as tabbable even when there is a selection", async () => {
const { container } = render(TestWrapper, {
- attrs: { type: 'radiogroup' },
+ attrs: { type: "radiogroup" },
})
- const [, secondItem] = screen.queryAllByRole('radio')
+ const [, secondItem] = screen.queryAllByRole("radio")
await doFocus(secondItem)
const tabbableElements = container.querySelectorAll('[tabindex="0"]')
expect(tabbableElements).toHaveLength(1)
@@ -145,12 +145,12 @@ describe('VItemGroup', () => {
expect(tabbableElement).toBe(secondItem)
})
- describe('arrow keys', () => {
- it.each(['ArrowUp', 'ArrowLeft'])(
- 'should focus to the previous item on %s',
+ describe("arrow keys", () => {
+ it.each(["ArrowUp", "ArrowLeft"])(
+ "should focus to the previous item on %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, secondItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, secondItem] = screen.queryAllByRole("radio")
await doFocus(secondItem)
await userEvent.keyboard(`{${key}}`)
@@ -158,22 +158,22 @@ describe('VItemGroup', () => {
}
)
- it.each(['ArrowUp', 'ArrowLeft'])(
- 'should go to the last item when on the first item and pressing %s',
+ it.each(["ArrowUp", "ArrowLeft"])(
+ "should go to the last item when on the first item and pressing %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, , , lastItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, , , lastItem] = screen.queryAllByRole("radio")
await doFocus(firstItem)
await userEvent.keyboard(`{${key}}`)
expect(lastItem).toHaveFocus()
}
)
- it.each(['ArrowDown', 'ArrowRight'])(
- 'should focus to the next item on %s',
+ it.each(["ArrowDown", "ArrowRight"])(
+ "should focus to the next item on %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, secondItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, secondItem] = screen.queryAllByRole("radio")
await doFocus(firstItem)
await userEvent.keyboard(`{${key}}`)
@@ -181,11 +181,11 @@ describe('VItemGroup', () => {
}
)
- it.each(['ArrowDown', 'ArrowRight'])(
- 'should go to the first item when on the last item and pressing %s',
+ it.each(["ArrowDown", "ArrowRight"])(
+ "should go to the first item when on the last item and pressing %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, , , lastItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, , , lastItem] = screen.queryAllByRole("radio")
await doFocus(lastItem)
await userEvent.keyboard(`{${key}}`)
@@ -193,17 +193,17 @@ describe('VItemGroup', () => {
}
)
- describe('rtl', () => {
+ describe("rtl", () => {
beforeEach(() => {
- mockDir = 'rtl'
+ mockDir = "rtl"
})
- describe('vertical', () => {
- it.each(['ArrowUp', 'ArrowLeft'])(
- 'should focus to the previous item on %s',
+ describe("vertical", () => {
+ it.each(["ArrowUp", "ArrowLeft"])(
+ "should focus to the previous item on %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, secondItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, secondItem] = screen.queryAllByRole("radio")
await doFocus(secondItem)
await userEvent.keyboard(`{${key}}`)
@@ -211,22 +211,22 @@ describe('VItemGroup', () => {
}
)
- it.each(['ArrowUp', 'ArrowLeft'])(
- 'should go to the last item when on the first item and pressing %s',
+ it.each(["ArrowUp", "ArrowLeft"])(
+ "should go to the last item when on the first item and pressing %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, , , lastItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, , , lastItem] = screen.queryAllByRole("radio")
await doFocus(firstItem)
await userEvent.keyboard(`{${key}}`)
expect(lastItem).toHaveFocus()
}
)
- it.each(['ArrowDown', 'ArrowRight'])(
- 'should focus to the next item on %s',
+ it.each(["ArrowDown", "ArrowRight"])(
+ "should focus to the next item on %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, secondItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, secondItem] = screen.queryAllByRole("radio")
await doFocus(firstItem)
await userEvent.keyboard(`{${key}}`)
@@ -234,11 +234,11 @@ describe('VItemGroup', () => {
}
)
- it.each(['ArrowDown', 'ArrowRight'])(
- 'should go to the first item when on the last item and pressing %s',
+ it.each(["ArrowDown", "ArrowRight"])(
+ "should go to the first item when on the last item and pressing %s",
async (key) => {
- render(TestWrapper, { attrs: { type: 'radiogroup' } })
- const [firstItem, , , lastItem] = screen.queryAllByRole('radio')
+ render(TestWrapper, { attrs: { type: "radiogroup" } })
+ const [firstItem, , , lastItem] = screen.queryAllByRole("radio")
await doFocus(lastItem)
await userEvent.keyboard(`{${key}}`)
@@ -247,14 +247,14 @@ describe('VItemGroup', () => {
)
})
- describe('horizontal', () => {
- it.each(['ArrowUp', 'ArrowRight'])(
- 'should focus to the previous item on %s',
+ describe("horizontal", () => {
+ it.each(["ArrowUp", "ArrowRight"])(
+ "should focus to the previous item on %s",
async (key) => {
render(TestWrapper, {
- attrs: { type: 'radiogroup', direction: 'horizontal' },
+ attrs: { type: "radiogroup", direction: "horizontal" },
})
- const [firstItem, secondItem] = screen.queryAllByRole('radio')
+ const [firstItem, secondItem] = screen.queryAllByRole("radio")
await doFocus(secondItem)
await userEvent.keyboard(`{${key}}`)
@@ -262,26 +262,26 @@ describe('VItemGroup', () => {
}
)
- it.each(['ArrowUp', 'ArrowRight'])(
- 'should go to the last item when on the first item and pressing %s',
+ it.each(["ArrowUp", "ArrowRight"])(
+ "should go to the last item when on the first item and pressing %s",
async (key) => {
render(TestWrapper, {
- attrs: { type: 'radiogroup', direction: 'horizontal' },
+ attrs: { type: "radiogroup", direction: "horizontal" },
})
- const [firstItem, , , lastItem] = screen.queryAllByRole('radio')
+ const [firstItem, , , lastItem] = screen.queryAllByRole("radio")
await doFocus(firstItem)
await userEvent.keyboard(`{${key}}`)
expect(lastItem).toHaveFocus()
}
)
- it.each(['ArrowDown', 'ArrowLeft'])(
- 'should focus to the next item on %s',
+ it.each(["ArrowDown", "ArrowLeft"])(
+ "should focus to the next item on %s",
async (key) => {
render(TestWrapper, {
- attrs: { type: 'radiogroup', direction: 'horizontal' },
+ attrs: { type: "radiogroup", direction: "horizontal" },
})
- const [firstItem, secondItem] = screen.queryAllByRole('radio')
+ const [firstItem, secondItem] = screen.queryAllByRole("radio")
await doFocus(firstItem)
await userEvent.keyboard(`{${key}}`)
@@ -289,13 +289,13 @@ describe('VItemGroup', () => {
}
)
- it.each(['ArrowDown', 'ArrowLeft'])(
- 'should go to the first item when on the last item and pressing %s',
+ it.each(["ArrowDown", "ArrowLeft"])(
+ "should go to the first item when on the last item and pressing %s",
async (key) => {
render(TestWrapper, {
- attrs: { type: 'radiogroup', direction: 'horizontal' },
+ attrs: { type: "radiogroup", direction: "horizontal" },
})
- const [firstItem, , , lastItem] = screen.queryAllByRole('radio')
+ const [firstItem, , , lastItem] = screen.queryAllByRole("radio")
await doFocus(lastItem)
await userEvent.keyboard(`{${key}}`)
diff --git a/test/unit/specs/components/v-license.spec.js b/test/unit/specs/components/v-license.spec.js
index 4b9a92798..7bb322320 100644
--- a/test/unit/specs/components/v-license.spec.js
+++ b/test/unit/specs/components/v-license.spec.js
@@ -1,11 +1,11 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import VLicense from '~/components/VLicense/VLicense.vue'
+import VLicense from "~/components/VLicense/VLicense.vue"
-describe('VLicense', () => {
+describe("VLicense", () => {
let options = {
props: {
- license: 'by',
+ license: "by",
},
mocks: {
$nuxt: {
@@ -16,30 +16,30 @@ describe('VLicense', () => {
},
}
- it('should render the license name and icons', () => {
+ it("should render the license name and icons", () => {
const { container } = render(VLicense, options)
- const licenseName = screen.getByLabelText('license-readable-names.by')
+ const licenseName = screen.getByLabelText("license-readable-names.by")
expect(licenseName).toBeInTheDocument()
- const licenseIcons = container.querySelectorAll('svg')
+ const licenseIcons = container.querySelectorAll("svg")
expect(licenseIcons).toHaveLength(2) // 'CC' and 'BY' icons
})
- it('should render only the license icons', () => {
+ it("should render only the license icons", () => {
options.props.hideName = true
const { container } = render(VLicense, options)
- const licenseName = screen.queryByLabelText('license-readable-names.by')
+ const licenseName = screen.queryByLabelText("license-readable-names.by")
expect(licenseName).not.toBeVisible()
- const licenseIcons = container.querySelectorAll('svg')
+ const licenseIcons = container.querySelectorAll("svg")
expect(licenseIcons).toHaveLength(2)
})
- it('should have background filled with black text', () => {
+ it("should have background filled with black text", () => {
options.props.bgFilled = true
const { container } = render(VLicense, options)
- const licenseIcons = container.querySelectorAll('svg')
+ const licenseIcons = container.querySelectorAll("svg")
expect(licenseIcons).toHaveLength(2)
licenseIcons.forEach((icon) => {
- expect(icon).toHaveClass('bg-filled', 'text-black')
+ expect(icon).toHaveClass("bg-filled", "text-black")
})
})
})
diff --git a/test/unit/specs/components/v-link.spec.js b/test/unit/specs/components/v-link.spec.js
index 67801fd06..8f8fe4ac8 100644
--- a/test/unit/specs/components/v-link.spec.js
+++ b/test/unit/specs/components/v-link.spec.js
@@ -1,60 +1,60 @@
-import { fireEvent, render, screen } from '@testing-library/vue'
-import Vue from 'vue'
+import { fireEvent, render, screen } from "@testing-library/vue"
+import Vue from "vue"
-import VLink from '~/components/VLink.vue'
+import VLink from "~/components/VLink.vue"
const nuxtContextMock = {
$nuxt: { context: { app: { localePath: jest.fn((v) => v) } } },
}
-describe('VLink', () => {
+describe("VLink", () => {
it.each`
href | target | rel
- ${'/about'} | ${null} | ${null}
- ${'http://localhost:8443/'} | ${'_blank'} | ${'noopener noreferrer'}
+ ${"/about"} | ${null} | ${null}
+ ${"http://localhost:8443/"} | ${"_blank"} | ${"noopener noreferrer"}
`(
- 'Creates a correct link component based on href',
+ "Creates a correct link component based on href",
({ href, target, rel }) => {
render(VLink, {
props: { href },
- slots: { default: 'Code is Poetry' },
+ slots: { default: "Code is Poetry" },
mocks: nuxtContextMock,
})
- const link = screen.getByRole('link')
- const expectedHref = href.startsWith('/')
+ const link = screen.getByRole("link")
+ const expectedHref = href.startsWith("/")
? `http://localhost${href}`
: href
expect(link.href).toEqual(expectedHref)
- expect(link.getAttribute('target')).toEqual(target)
- expect(link.getAttribute('rel')).toEqual(rel)
+ expect(link.getAttribute("target")).toEqual(target)
+ expect(link.getAttribute("rel")).toEqual(rel)
}
)
it.each`
href | component
- ${'/about'} | ${'NuxtLink'}
- ${'http://localhost'} | ${'A'}
- `('VLink as a $component handles click', async ({ href }) => {
+ ${"/about"} | ${"NuxtLink"}
+ ${"http://localhost"} | ${"A"}
+ `("VLink as a $component handles click", async ({ href }) => {
const createVLinkWrapper = (href) =>
// eslint-disable-next-line vue/one-component-per-file
- Vue.component('VLinkWrapper', {
- data: () => ({ text: 'Link Text' }),
+ Vue.component("VLinkWrapper", {
+ data: () => ({ text: "Link Text" }),
methods: {
handleClick(e) {
e.preventDefault()
- this.text = 'Code is Poetry'
+ this.text = "Code is Poetry"
},
},
template: `<div><VLink href="${href}" @click="handleClick">{{ text }}</VLink></div>`,
})
const WrapperComponent = createVLinkWrapper(href)
render(WrapperComponent, { mocks: nuxtContextMock }, (localVue) => {
- localVue.component('VLink', VLink)
+ localVue.component("VLink", VLink)
})
- const linkBefore = await screen.getByRole('link')
- expect(linkBefore.textContent).toEqual('Link Text')
+ const linkBefore = await screen.getByRole("link")
+ expect(linkBefore.textContent).toEqual("Link Text")
await fireEvent.click(linkBefore)
- const linkAfter = await screen.findByText('Code is Poetry')
- expect(linkAfter.tagName).toBe('A')
+ const linkAfter = await screen.findByText("Code is Poetry")
+ expect(linkAfter.tagName).toBe("A")
})
})
diff --git a/test/unit/specs/components/v-logo-loader.spec.js b/test/unit/specs/components/v-logo-loader.spec.js
index 5a017de43..8da4cd02f 100644
--- a/test/unit/specs/components/v-logo-loader.spec.js
+++ b/test/unit/specs/components/v-logo-loader.spec.js
@@ -1,43 +1,43 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import { useReducedMotion } from '~/composables/use-media-query'
+import { useReducedMotion } from "~/composables/use-media-query"
-import VLogoLoader from '~/components/VLogoLoader/VLogoLoader.vue'
+import VLogoLoader from "~/components/VLogoLoader/VLogoLoader.vue"
-jest.mock('~/utils/console', () => ({
+jest.mock("~/utils/console", () => ({
warn: jest.fn(),
log: jest.fn(),
}))
-jest.mock('~/composables/use-media-query', () => ({
+jest.mock("~/composables/use-media-query", () => ({
useReducedMotion: jest.fn(),
}))
-describe('VLogoLoader', () => {
- it('should render the logo', () => {
+describe("VLogoLoader", () => {
+ it("should render the logo", () => {
render(VLogoLoader)
- const element = screen.getByTestId('logo-loader')
+ const element = screen.getByTestId("logo-loader")
expect(element).toBeInTheDocument()
})
- describe('accessibility', () => {
- it('should render differently when the user prefers reduced motion', () => {
+ describe("accessibility", () => {
+ it("should render differently when the user prefers reduced motion", () => {
useReducedMotion.mockImplementation(() => true)
render(VLogoLoader, {
- props: { status: 'loading' },
+ props: { status: "loading" },
})
- const element = screen.getByTestId('logo-loader')
- expect(element).toHaveAttribute('data-prefers-reduced-motion', 'true')
+ const element = screen.getByTestId("logo-loader")
+ expect(element).toHaveAttribute("data-prefers-reduced-motion", "true")
})
- it('should show the default loading style when no motion preference is set', () => {
+ it("should show the default loading style when no motion preference is set", () => {
useReducedMotion.mockImplementation(() => false)
render(VLogoLoader, {
- props: { status: 'loading' },
+ props: { status: "loading" },
})
- const element = screen.getByTestId('logo-loader')
- expect(element).not.toHaveAttribute('data-prefers-reduced-motion')
+ const element = screen.getByTestId("logo-loader")
+ expect(element).not.toHaveAttribute("data-prefers-reduced-motion")
})
})
})
diff --git a/test/unit/specs/components/v-modal.spec.js b/test/unit/specs/components/v-modal.spec.js
index 7a5940c14..7afa64d0b 100644
--- a/test/unit/specs/components/v-modal.spec.js
+++ b/test/unit/specs/components/v-modal.spec.js
@@ -1,15 +1,15 @@
-import Vue from 'vue'
-import { ref, computed } from '@nuxtjs/composition-api'
-import { render, screen } from '@testing-library/vue'
-import userEvent from '@testing-library/user-event'
+import Vue from "vue"
+import { ref, computed } from "@nuxtjs/composition-api"
+import { render, screen } from "@testing-library/vue"
+import userEvent from "@testing-library/user-event"
-import VModal from '~/components/VModal/VModal.vue'
-import VModalTarget from '~/components/VModal/VModalTarget.vue'
-import VButton from '~/components/VButton.vue'
+import VModal from "~/components/VModal/VModal.vue"
+import VModalTarget from "~/components/VModal/VModalTarget.vue"
+import VButton from "~/components/VButton.vue"
-const TestWrapper = Vue.component('TestWrapper', {
+const TestWrapper = Vue.component("TestWrapper", {
components: { VModal, VButton, VModalTarget },
- props: ['useCustomInitialFocus'],
+ props: ["useCustomInitialFocus"],
setup(props) {
const initialFocusElement = ref()
@@ -38,10 +38,10 @@ const TestWrapper = Vue.component('TestWrapper', {
const nextTick = async () =>
await new Promise((resolve) => setTimeout(resolve, 1))
-const getCloseButton = () => screen.getByText('modal.close')
-const getDialog = () => screen.getByRole('dialog')
-const queryDialog = () => screen.queryByRole('dialog')
-const getTrigger = () => screen.getByRole('button')
+const getCloseButton = () => screen.getByText("modal.close")
+const getDialog = () => screen.getByRole("dialog")
+const queryDialog = () => screen.queryByRole("dialog")
+const getTrigger = () => screen.getByRole("button")
const doOpen = async () => {
await userEvent.click(getTrigger())
await nextTick()
@@ -50,7 +50,7 @@ const doOpen = async () => {
// `useDialogContent` functionality is already tested by `VPopover` tests.
// Eventually we'll want to abstract those tests out but for now it's not worth
// the work.
-describe('VModal', () => {
+describe("VModal", () => {
let options
let _scrollTo
beforeAll(() => {
@@ -68,7 +68,7 @@ describe('VModal', () => {
jest.resetAllMocks()
})
- it('should render a close button that hides the modal', async () => {
+ it("should render a close button that hides the modal", async () => {
render(TestWrapper, options)
await doOpen()
@@ -80,24 +80,24 @@ describe('VModal', () => {
expect(queryDialog()).toBe(null)
})
- it('should scroll lock the body when modal opens and unlock when modal closes', async () => {
+ it("should scroll lock the body when modal opens and unlock when modal closes", async () => {
const { container } = render(TestWrapper, options)
const scrollY = 10
window.scrollY = scrollY
await doOpen()
expect(getDialog()).toBeVisible()
- expect(container.ownerDocument.body.style.position).toBe('fixed')
+ expect(container.ownerDocument.body.style.position).toBe("fixed")
expect(container.ownerDocument.body.style.top).toBe(`-${scrollY}px`)
- await userEvent.click(screen.getByText('modal.close'))
+ await userEvent.click(screen.getByText("modal.close"))
await nextTick()
expect(window.scrollTo).toHaveBeenCalledWith(0, scrollY)
- expect(container.ownerDocument.body.style.position).not.toBe('fixed')
+ expect(container.ownerDocument.body.style.position).not.toBe("fixed")
})
- it('should focus the close button by default', async () => {
+ it("should focus the close button by default", async () => {
render(TestWrapper, options)
await doOpen()
@@ -105,7 +105,7 @@ describe('VModal', () => {
expect(getCloseButton()).toHaveFocus()
})
- it('should focus the explicit initial focus element when specified', async () => {
+ it("should focus the explicit initial focus element when specified", async () => {
options.props = { useCustomInitialFocus: true }
render(TestWrapper, options)
await doOpen()
@@ -114,13 +114,13 @@ describe('VModal', () => {
expect(screen.getByText(/custom initial focus/i))
})
- it('should hide the modal on escape', async () => {
+ it("should hide the modal on escape", async () => {
render(TestWrapper, options)
await doOpen()
expect(getDialog()).toBeVisible()
- await userEvent.keyboard('{Escape}')
+ await userEvent.keyboard("{Escape}")
await nextTick()
expect(queryDialog()).toBe(null)
diff --git a/test/unit/specs/components/v-popover.spec.js b/test/unit/specs/components/v-popover.spec.js
index 59a00d95b..f6a6b863c 100644
--- a/test/unit/specs/components/v-popover.spec.js
+++ b/test/unit/specs/components/v-popover.spec.js
@@ -1,19 +1,19 @@
-import Vue from 'vue'
-import { render, screen } from '@testing-library/vue'
-import userEvent from '@testing-library/user-event'
+import Vue from "vue"
+import { render, screen } from "@testing-library/vue"
+import userEvent from "@testing-library/user-event"
-import { noFocusableElementWarning } from '~/composables/use-focus-on-show'
+import { noFocusableElementWarning } from "~/composables/use-focus-on-show"
-import { warn } from '~/utils/console'
+import { warn } from "~/utils/console"
-import VButton from '~/components/VButton.vue'
-import VPopover from '~/components/VPopover/VPopover.vue'
+import VButton from "~/components/VButton.vue"
+import VPopover from "~/components/VPopover/VPopover.vue"
-jest.mock('~/utils/console', () => ({
+jest.mock("~/utils/console", () => ({
warn: jest.fn(),
}))
-const TestWrapper = Vue.component('TestWrapper', {
+const TestWrapper = Vue.component("TestWrapper", {
components: { VButton, VPopover },
props: {
popoverProps: {
@@ -44,7 +44,7 @@ const nextTick = async () =>
const getPopover = () => screen.getByText(/code is poetry/i)
const queryPopover = () => screen.queryByText(/code is poetry/i)
-const getTrigger = () => screen.getByRole('button')
+const getTrigger = () => screen.getByRole("button")
const getExternalArea = () => screen.getByText(/external area/i)
const clickOutside = () => userEvent.click(getExternalArea())
@@ -62,16 +62,16 @@ const expectOpen = () => {
const expectClosed = () => {
expect(queryPopover().parentElement.parentElement.style.display).toEqual(
- 'none'
+ "none"
)
}
-describe('VPopover', () => {
+describe("VPopover", () => {
afterEach(() => {
warn.mockReset()
})
- it('should open the popover when the trigger is clicked', async () => {
+ it("should open the popover when the trigger is clicked", async () => {
render(TestWrapper)
expectClosed()
@@ -80,25 +80,25 @@ describe('VPopover', () => {
await doOpen()
})
- describe('accessibility', () => {
- it('should render a11y props for the trigger', async () => {
+ describe("accessibility", () => {
+ it("should render a11y props for the trigger", async () => {
render(TestWrapper)
const trigger = getTrigger()
// This attribute will always exist
- expect(trigger).toHaveAttribute('aria-haspopup', 'dialog')
+ expect(trigger).toHaveAttribute("aria-haspopup", "dialog")
// This attribute will only exist when the trigger's related popover is open and the trigger was the current disclosure
- expect(trigger).not.toHaveAttribute('aria-expanded')
+ expect(trigger).not.toHaveAttribute("aria-expanded")
await doOpen(trigger)
- expect(trigger).toHaveAttribute('aria-expanded', 'true')
+ expect(trigger).toHaveAttribute("aria-expanded", "true")
})
- describe('autoFocusOnShow', () => {
- it('should focus the popover by default when opening if there is no tabbable content in the popover and warn', async () => {
+ describe("autoFocusOnShow", () => {
+ it("should focus the popover by default when opening if there is no tabbable content in the popover and warn", async () => {
render(TestWrapper)
await doOpen()
expect(getPopover().parentElement).toHaveFocus()
@@ -106,7 +106,7 @@ describe('VPopover', () => {
expect(warn).toHaveBeenCalledWith(noFocusableElementWarning)
})
- it('should focus the first tabbable element in the popover by default and not warn', async () => {
+ it("should focus the first tabbable element in the popover by default and not warn", async () => {
render(TestWrapper, { props: { popoverContentTabIndex: 0 } })
await doOpen()
await nextTick(() => {
@@ -115,7 +115,7 @@ describe('VPopover', () => {
})
})
- it('should neither focus no warn when the prop is false', async () => {
+ it("should neither focus no warn when the prop is false", async () => {
render(TestWrapper, {
props: { popoverProps: { autoFocusOnShow: false } },
})
@@ -126,8 +126,8 @@ describe('VPopover', () => {
})
})
- describe('autoFocusOnHide', () => {
- it('should return focus to the trigger', async () => {
+ describe("autoFocusOnHide", () => {
+ it("should return focus to the trigger", async () => {
render(TestWrapper)
await doOpen()
await clickOutside()
@@ -135,7 +135,7 @@ describe('VPopover', () => {
expect(getTrigger()).toHaveFocus()
})
- it('should not return focus to the trigger when false', async () => {
+ it("should not return focus to the trigger when false", async () => {
render(TestWrapper, {
props: { popoverProps: { autoFocusOnHide: false } },
})
@@ -146,8 +146,8 @@ describe('VPopover', () => {
})
})
- describe('hideOnClickOutside', () => {
- it('should hide the popover if a click happens outside the popover by default', async () => {
+ describe("hideOnClickOutside", () => {
+ it("should hide the popover if a click happens outside the popover by default", async () => {
render(TestWrapper)
await doOpen()
@@ -156,7 +156,7 @@ describe('VPopover', () => {
expectClosed()
})
- it('should not hide the popover if a click happens outside the popover when false', async () => {
+ it("should not hide the popover if a click happens outside the popover when false", async () => {
render(TestWrapper, {
props: { popoverProps: { hideOnClickOutside: false } },
})
@@ -168,18 +168,18 @@ describe('VPopover', () => {
})
})
- describe('hideOnEsc', () => {
- it('should hide the popover if escape is sent in the popover by default', async () => {
+ describe("hideOnEsc", () => {
+ it("should hide the popover if escape is sent in the popover by default", async () => {
render(TestWrapper)
await doOpen()
- await userEvent.keyboard('{escape}')
+ await userEvent.keyboard("{escape}")
expectClosed()
})
- it('should not hide if the escape is sent in the popover when false', async () => {
+ it("should not hide if the escape is sent in the popover when false", async () => {
render(TestWrapper, { props: { popoverProps: { hideOnEsc: false } } })
await doOpen()
- await userEvent.keyboard('{escape}')
+ await userEvent.keyboard("{escape}")
expectOpen()
})
})
diff --git a/test/unit/specs/components/v-search-grid-filter.spec.js b/test/unit/specs/components/v-search-grid-filter.spec.js
index 564ef2cdc..68e13b1fc 100644
--- a/test/unit/specs/components/v-search-grid-filter.spec.js
+++ b/test/unit/specs/components/v-search-grid-filter.spec.js
@@ -1,16 +1,16 @@
-import { fireEvent, render, screen } from '@testing-library/vue'
-import { createLocalVue } from '@vue/test-utils'
-import VueI18n from 'vue-i18n'
+import { fireEvent, render, screen } from "@testing-library/vue"
+import { createLocalVue } from "@vue/test-utils"
+import VueI18n from "vue-i18n"
-import { PiniaVuePlugin, createPinia } from '~~/test/unit/test-utils/pinia'
+import { PiniaVuePlugin, createPinia } from "~~/test/unit/test-utils/pinia"
-import { useSearchStore } from '~/stores/search'
+import { useSearchStore } from "~/stores/search"
-import messages from '~/locales/en.json'
+import messages from "~/locales/en.json"
-import VSearchGridFilter from '~/components/VFilters/VSearchGridFilter.vue'
+import VSearchGridFilter from "~/components/VFilters/VSearchGridFilter.vue"
-describe('VSearchGridFilter', () => {
+describe("VSearchGridFilter", () => {
let options = {}
let localVue
let pinia
@@ -24,8 +24,8 @@ describe('VSearchGridFilter', () => {
localVue.use(VueI18n)
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: messages },
})
pinia = createPinia()
@@ -48,25 +48,25 @@ describe('VSearchGridFilter', () => {
searchStore = useSearchStore(pinia)
})
- it('toggles filter', async () => {
+ it("toggles filter", async () => {
render(VSearchGridFilter, options)
- const checked = screen.queryAllByRole('checkbox', { checked: true })
+ const checked = screen.queryAllByRole("checkbox", { checked: true })
expect(checked.length).toEqual(0)
await fireEvent.click(screen.queryByLabelText(/commercial/i))
// `getBy` serves as expect because it throws an error if no element is found
- screen.getByRole('checkbox', { checked: true })
+ screen.getByRole("checkbox", { checked: true })
screen.getByLabelText(/commercial/, { checked: true })
})
- it('clears filters', async () => {
- searchStore.toggleFilter({ filterType: 'licenses', code: 'by' })
+ it("clears filters", async () => {
+ searchStore.toggleFilter({ filterType: "licenses", code: "by" })
await render(VSearchGridFilter, options)
// if no checked checkboxes were found, this would raise an error
- screen.getByRole('checkbox', { checked: true })
+ screen.getByRole("checkbox", { checked: true })
- await fireEvent.click(screen.getByText('filter-list.clear'))
- const checkedFilters = screen.queryAllByRole('checkbox', { checked: true })
- const uncheckedFilters = screen.queryAllByRole('checkbox', {
+ await fireEvent.click(screen.getByText("filter-list.clear"))
+ const checkedFilters = screen.queryAllByRole("checkbox", { checked: true })
+ const uncheckedFilters = screen.queryAllByRole("checkbox", {
checked: false,
})
diff --git a/test/unit/specs/components/v-search-results-title.spec.js b/test/unit/specs/components/v-search-results-title.spec.js
index 375454f57..ed97e1ab9 100644
--- a/test/unit/specs/components/v-search-results-title.spec.js
+++ b/test/unit/specs/components/v-search-results-title.spec.js
@@ -1,20 +1,20 @@
-import { render, screen } from '@testing-library/vue'
+import { render, screen } from "@testing-library/vue"
-import VSearchResultsTitle from '~/components/VSearchResultsTitle.vue'
+import VSearchResultsTitle from "~/components/VSearchResultsTitle.vue"
-describe('VSearchResultsTitle', () => {
+describe("VSearchResultsTitle", () => {
let options = {
props: {
- size: 'large',
+ size: "large",
},
scopedSlots: {
- default: () => 'zack',
+ default: () => "zack",
},
}
- it('should render an h1 tag containing the correct text', async () => {
+ it("should render an h1 tag containing the correct text", async () => {
render(VSearchResultsTitle, options)
- const button = await screen.findByText('zack')
- expect(button.tagName).toBe('H1')
+ const button = await screen.findByText("zack")
+ expect(button.tagName).toBe("H1")
})
})
diff --git a/test/unit/specs/components/v-sources-table.spec.js b/test/unit/specs/components/v-sources-table.spec.js
index 8a082dcc7..9b82a5085 100644
--- a/test/unit/specs/components/v-sources-table.spec.js
+++ b/test/unit/specs/components/v-sources-table.spec.js
@@ -1,18 +1,18 @@
-import { render, screen } from '@testing-library/vue'
-import userEvent from '@testing-library/user-event'
+import { render, screen } from "@testing-library/vue"
+import userEvent from "@testing-library/user-event"
-import { createTestingPinia } from '@pinia/testing'
-import VueI18n from 'vue-i18n'
+import { createTestingPinia } from "@pinia/testing"
+import VueI18n from "vue-i18n"
-import { PiniaVuePlugin } from '~~/test/unit/test-utils/pinia'
+import { PiniaVuePlugin } from "~~/test/unit/test-utils/pinia"
-import VSourcesTableVue from '~/components/VSourcesTable.vue'
+import VSourcesTableVue from "~/components/VSourcesTable.vue"
-const enMessages = require('~/locales/en.json')
+const enMessages = require("~/locales/en.json")
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: enMessages },
})
@@ -24,21 +24,21 @@ const useMockStore = (vue) => {
providers: {
image: [
{
- source_name: 'Provider_B',
- display_name: 'Provider B',
- source_url: 'http://yyy.com',
+ source_name: "Provider_B",
+ display_name: "Provider B",
+ source_url: "http://yyy.com",
media_count: 1111,
},
{
- source_name: 'Provider_C',
- display_name: 'Provider C',
- source_url: 'www.xxx.com',
+ source_name: "Provider_C",
+ display_name: "Provider C",
+ source_url: "www.xxx.com",
media_count: 2222,
},
{
- source_name: 'Provider_A',
- display_name: 'Provider A',
- source_url: 'https://zzz.com',
+ source_name: "Provider_A",
+ display_name: "Provider A",
+ source_url: "https://zzz.com",
media_count: 3333,
},
],
@@ -69,13 +69,13 @@ const getTableData = (table) => {
return data
}
-describe('VSourcesTable', () => {
+describe("VSourcesTable", () => {
let options
beforeEach(() => {
options = {
- propsData: { media: 'image' },
- stubs: ['TableSortIcon', 'VLink'],
+ propsData: { media: "image" },
+ stubs: ["TableSortIcon", "VLink"],
mocks: {
$nuxt: { context: { i18n } },
},
@@ -84,41 +84,41 @@ describe('VSourcesTable', () => {
it('should be sorted by display_name ("Source") by default', () => {
render(VSourcesTableVue, options, configureVue)
- const table = getTableData(screen.getByLabelText('sources.aria.table'))
+ const table = getTableData(screen.getByLabelText("sources.aria.table"))
const expectedTable = [
- ['Provider A', 'zzz.com', '3,333'],
- ['Provider B', 'yyy.com', '1,111'],
- ['Provider C', 'xxx.com', '2,222'],
+ ["Provider A", "zzz.com", "3,333"],
+ ["Provider B", "yyy.com", "1,111"],
+ ["Provider C", "xxx.com", "2,222"],
]
expect(table).toEqual(expectedTable)
})
it('should be sorted by clean url when click on "Domain" header', async () => {
render(VSourcesTableVue, options, configureVue)
- const domainCell = screen.getByRole('columnheader', {
- name: 'sources.providers.domain',
+ const domainCell = screen.getByRole("columnheader", {
+ name: "sources.providers.domain",
})
await userEvent.click(domainCell)
- const table = getTableData(screen.getByLabelText('sources.aria.table'))
+ const table = getTableData(screen.getByLabelText("sources.aria.table"))
const expectedTable = [
- ['Provider C', 'xxx.com', '2,222'],
- ['Provider B', 'yyy.com', '1,111'],
- ['Provider A', 'zzz.com', '3,333'],
+ ["Provider C", "xxx.com", "2,222"],
+ ["Provider B", "yyy.com", "1,111"],
+ ["Provider A", "zzz.com", "3,333"],
]
expect(table).toEqual(expectedTable)
})
it('should be sorted by media_count when click on "Total items" header', async () => {
render(VSourcesTableVue, options, configureVue)
- const domainCell = screen.getByRole('columnheader', {
- name: 'sources.providers.item',
+ const domainCell = screen.getByRole("columnheader", {
+ name: "sources.providers.item",
})
await userEvent.click(domainCell)
- const table = getTableData(screen.getByLabelText('sources.aria.table'))
+ const table = getTableData(screen.getByLabelText("sources.aria.table"))
const expectedTable = [
- ['Provider B', 'yyy.com', '1,111'],
- ['Provider C', 'xxx.com', '2,222'],
- ['Provider A', 'zzz.com', '3,333'],
+ ["Provider B", "yyy.com", "1,111"],
+ ["Provider C", "xxx.com", "2,222"],
+ ["Provider A", "zzz.com", "3,333"],
]
expect(table).toEqual(expectedTable)
})
diff --git a/test/unit/specs/components/v-tabs.spec.js b/test/unit/specs/components/v-tabs.spec.js
index c42aafb9d..c27e9208d 100644
--- a/test/unit/specs/components/v-tabs.spec.js
+++ b/test/unit/specs/components/v-tabs.spec.js
@@ -1,12 +1,12 @@
-import { render } from '@testing-library/vue'
+import { render } from "@testing-library/vue"
-import Vue from 'vue'
+import Vue from "vue"
-import userEvent from '@testing-library/user-event'
+import userEvent from "@testing-library/user-event"
-import VTabs from '~/components/VTabs/VTabs.vue'
-import VTab from '~/components/VTabs/VTab.vue'
-import VTabPanel from '~/components/VTabs/VTabPanel.vue'
+import VTabs from "~/components/VTabs/VTabs.vue"
+import VTab from "~/components/VTabs/VTab.vue"
+import VTabPanel from "~/components/VTabs/VTabPanel.vue"
/**
* Checks for visibility. We cannot check using `toBeVisible`
@@ -16,14 +16,14 @@ import VTabPanel from '~/components/VTabs/VTabPanel.vue'
* @param {boolean?} visibility
*/
const expectVisibitility = (screen, text, visibility = true) => {
- const classes = screen.getByText(text).getAttribute('class')
+ const classes = screen.getByText(text).getAttribute("class")
return visibility
- ? expect(classes).not.toContain('hidden')
- : expect(classes).toContain('hidden')
+ ? expect(classes).not.toContain("hidden")
+ : expect(classes).toContain("hidden")
}
const TestVTabsComponent = (manual = false) => {
- return Vue.component('VTabsComponent', {
+ return Vue.component("VTabsComponent", {
components: { VTabs, VTab, VTabPanel },
data() {
return { manual }
@@ -38,13 +38,13 @@ const TestVTabsComponent = (manual = false) => {
})
}
-describe('VTabs', () => {
- it('should render default tabs', async () => {
+describe("VTabs", () => {
+ it("should render default tabs", async () => {
const screen = render(TestVTabsComponent())
- expect(screen.getByRole('tablist')).toHaveTextContent('Tab1Tab2Tab3')
- expect(screen.queryAllByRole('tab')).toHaveLength(3)
- expect(screen.queryAllByRole('tabpanel')).toHaveLength(3)
+ expect(screen.getByRole("tablist")).toHaveTextContent("Tab1Tab2Tab3")
+ expect(screen.queryAllByRole("tab")).toHaveLength(3)
+ expect(screen.queryAllByRole("tabpanel")).toHaveLength(3)
/**
* Panel visibility is set after the tabs and panels are registered
@@ -52,33 +52,33 @@ describe('VTabs', () => {
* for the rendering using `nextTick`.
*/
await Vue.nextTick()
- expectVisibitility(screen, 'Panel 1 content')
- expectVisibitility(screen, 'Panel 2 content', false)
- expectVisibitility(screen, 'Panel 3 content', false)
+ expectVisibitility(screen, "Panel 1 content")
+ expectVisibitility(screen, "Panel 2 content", false)
+ expectVisibitility(screen, "Panel 3 content", false)
})
- it('should change tabs on Right arrow press', async () => {
+ it("should change tabs on Right arrow press", async () => {
const screen = render(TestVTabsComponent())
- await userEvent.click(screen.queryByText('Tab1'))
- await userEvent.keyboard('{ArrowRight}')
+ await userEvent.click(screen.queryByText("Tab1"))
+ await userEvent.keyboard("{ArrowRight}")
- expectVisibitility(screen, 'Panel 1 content', false)
- expectVisibitility(screen, 'Panel 2 content')
+ expectVisibitility(screen, "Panel 1 content", false)
+ expectVisibitility(screen, "Panel 2 content")
})
- it('should change tabs on Right arrow and Enter press on manual activation', async () => {
+ it("should change tabs on Right arrow and Enter press on manual activation", async () => {
const screen = render(TestVTabsComponent(true))
- await userEvent.click(screen.queryByText('Tab1'))
- await userEvent.keyboard('{ArrowRight}')
+ await userEvent.click(screen.queryByText("Tab1"))
+ await userEvent.keyboard("{ArrowRight}")
- expectVisibitility(screen, 'Panel 1 content')
- expectVisibitility(screen, 'Panel 2 content', false)
+ expectVisibitility(screen, "Panel 1 content")
+ expectVisibitility(screen, "Panel 2 content", false)
- await userEvent.keyboard('{Enter}')
+ await userEvent.keyboard("{Enter}")
- expectVisibitility(screen, 'Panel 1 content', false)
- expectVisibitility(screen, 'Panel 2 content')
+ expectVisibitility(screen, "Panel 1 content", false)
+ expectVisibitility(screen, "Panel 2 content")
})
})
diff --git a/test/unit/specs/composables/default-ref.spec.ts b/test/unit/specs/composables/default-ref.spec.ts
index 037b21b54..c2ea48f0f 100644
--- a/test/unit/specs/composables/default-ref.spec.ts
+++ b/test/unit/specs/composables/default-ref.spec.ts
@@ -1,22 +1,22 @@
-import { defaultRef } from '~/composables/default-ref'
+import { defaultRef } from "~/composables/default-ref"
-describe('defaultRef', () => {
- it('should use the default value', () => {
+describe("defaultRef", () => {
+ it("should use the default value", () => {
const getDefault = () => 100
const value = defaultRef(getDefault)
expect(value.value).toBe(100)
})
- it('should use the set value', () => {
- const value = defaultRef(() => 'a')
- value.value = 'b'
- expect(value.value).toBe('b')
+ it("should use the set value", () => {
+ const value = defaultRef(() => "a")
+ value.value = "b"
+ expect(value.value).toBe("b")
})
- it.each([0, '', false, undefined, null] as const)(
- 'should use the set value even if it is falsy as `%s`',
+ it.each([0, "", false, undefined, null] as const)(
+ "should use the set value even if it is falsy as `%s`",
(v) => {
- const value = defaultRef(() => 'non-null default' as typeof v)
+ const value = defaultRef(() => "non-null default" as typeof v)
value.value = v
expect(value.value).toBe(v)
}
diff --git a/test/unit/specs/composables/use-get-locale-formatted-number.spec.js b/test/unit/specs/composables/use-get-locale-formatted-number.spec.js
index 264316744..2da31eff7 100644
--- a/test/unit/specs/composables/use-get-locale-formatted-number.spec.js
+++ b/test/unit/specs/composables/use-get-locale-formatted-number.spec.js
@@ -1,12 +1,12 @@
-import Vue from 'vue'
-import { render } from '@testing-library/vue'
-import VueI18n from 'vue-i18n'
+import Vue from "vue"
+import { render } from "@testing-library/vue"
+import VueI18n from "vue-i18n"
-import messages from '~/locales/en.json'
-import { useGetLocaleFormattedNumber } from '~/composables/use-get-locale-formatted-number'
+import messages from "~/locales/en.json"
+import { useGetLocaleFormattedNumber } from "~/composables/use-get-locale-formatted-number"
-const TestWrapper = Vue.component('TestWrapper', {
- props: ['n'],
+const TestWrapper = Vue.component("TestWrapper", {
+ props: ["n"],
setup() {
const getLocaleFormattedNumber = useGetLocaleFormattedNumber()
@@ -15,21 +15,21 @@ const TestWrapper = Vue.component('TestWrapper', {
template: `<div>{{ getLocaleFormattedNumber(n) }}</div>`,
})
-describe('use-get-locale-formatted-number', () => {
+describe("use-get-locale-formatted-number", () => {
const getMockedI18n = (locale) => ({
$nuxt: {
context: {
i18n: new VueI18n({
locale,
- fallbackLocale: 'en',
+ fallbackLocale: "en",
messages: { en: messages },
}),
},
},
})
- it.each(['ar', 'fa', 'ckb', 'ps'])(
- 'should use en formatting for locales like %s that use Eastern Arabic Numerals',
+ it.each(["ar", "fa", "ckb", "ps"])(
+ "should use en formatting for locales like %s that use Eastern Arabic Numerals",
(locale) => {
const { container } = render(TestWrapper, {
mocks: getMockedI18n(locale),
@@ -37,7 +37,7 @@ describe('use-get-locale-formatted-number', () => {
})
expect(container.firstChild.textContent).toEqual(
- (1000.01).toLocaleString('en')
+ (1000.01).toLocaleString("en")
)
expect(container.firstChild.textContent).not.toEqual(
(1000.01).toLocaleString(locale)
@@ -45,8 +45,8 @@ describe('use-get-locale-formatted-number', () => {
}
)
- it.each(['pt-br', 'en-us', 'en-gb', 'ru'])(
- 'should use the default formatting for locales not matching eastern arabic numeral locales like %s',
+ it.each(["pt-br", "en-us", "en-gb", "ru"])(
+ "should use the default formatting for locales not matching eastern arabic numeral locales like %s",
(locale) => {
const { container } = render(TestWrapper, {
mocks: getMockedI18n(locale),
diff --git a/test/unit/specs/composables/use-i18n-utilities.spec.js b/test/unit/specs/composables/use-i18n-utilities.spec.js
index 839cd6b95..d67e43bc3 100644
--- a/test/unit/specs/composables/use-i18n-utilities.spec.js
+++ b/test/unit/specs/composables/use-i18n-utilities.spec.js
@@ -1,6 +1,6 @@
-import { useI18nResultsCount } from '~/composables/use-i18n-utilities'
+import { useI18nResultsCount } from "~/composables/use-i18n-utilities"
-jest.mock('@nuxtjs/composition-api', () => ({
+jest.mock("@nuxtjs/composition-api", () => ({
useContext: () => ({
i18n: {
tc: (fullKey, resultsCount, { localeCount }) => ({
@@ -8,20 +8,20 @@ jest.mock('@nuxtjs/composition-api', () => ({
resultsCount,
localeCount,
}),
- locale: 'en',
+ locale: "en",
},
}),
}))
-describe('i18nResultsCount', () => {
+describe("i18nResultsCount", () => {
it.each`
resultCount | expectedResult
- ${0} | ${{ fullKey: 'browse-page.all-no-results', resultsCount: 0, localeCount: '0' }}
- ${1} | ${{ fullKey: 'browse-page.all-result-count', resultsCount: 1, localeCount: '1' }}
- ${10} | ${{ fullKey: 'browse-page.all-result-count', resultsCount: 10, localeCount: '10' }}
- ${10000} | ${{ fullKey: 'browse-page.all-result-count-more', resultsCount: 10000, localeCount: '10,000' }}
+ ${0} | ${{ fullKey: "browse-page.all-no-results", resultsCount: 0, localeCount: "0" }}
+ ${1} | ${{ fullKey: "browse-page.all-result-count", resultsCount: 1, localeCount: "1" }}
+ ${10} | ${{ fullKey: "browse-page.all-result-count", resultsCount: 10, localeCount: "10" }}
+ ${10000} | ${{ fullKey: "browse-page.all-result-count-more", resultsCount: 10000, localeCount: "10,000" }}
`(
- 'Should show correct result for $resultCount of type $mediaType',
+ "Should show correct result for $resultCount of type $mediaType",
({ resultCount, expectedResult }) => {
const { getI18nCount } = useI18nResultsCount()
const result = getI18nCount(resultCount)
diff --git a/test/unit/specs/composables/use-window-scroll.spec.ts b/test/unit/specs/composables/use-window-scroll.spec.ts
index 541a51dd7..6e2433313 100644
--- a/test/unit/specs/composables/use-window-scroll.spec.ts
+++ b/test/unit/specs/composables/use-window-scroll.spec.ts
@@ -1,8 +1,8 @@
-import Vue from 'vue'
-import { ref } from '@nuxtjs/composition-api'
-import { render } from '@testing-library/vue'
+import Vue from "vue"
+import { ref } from "@nuxtjs/composition-api"
+import { render } from "@testing-library/vue"
-import { useWindowScroll } from '~/composables/use-window-scroll'
+import { useWindowScroll } from "~/composables/use-window-scroll"
const getMockWindow = <T>(props: T) =>
({
@@ -12,9 +12,9 @@ const getMockWindow = <T>(props: T) =>
} as unknown as typeof window)
const UseWindowScrollTestContainer = Vue.component(
- 'UseWindowScrollTestContainer',
+ "UseWindowScrollTestContainer",
{
- props: ['initX', 'initY', 'throttleMs'],
+ props: ["initX", "initY", "throttleMs"],
setup(props) {
return useWindowScroll({
window: getMockWindow({
@@ -24,12 +24,12 @@ const UseWindowScrollTestContainer = Vue.component(
throttleMs: props.throttleMs as number | undefined,
})
},
- template: '<div>x={{x}} y={{y}} isScrolled={{isScrolled}}</div>',
+ template: "<div>x={{x}} y={{y}} isScrolled={{isScrolled}}</div>",
}
)
-describe('useWindowScroll', () => {
- it('should return [0, 0] and false when no window', () => {
+describe("useWindowScroll", () => {
+ it("should return [0, 0] and false when no window", () => {
expect(useWindowScroll({})).toMatchObject({
x: ref(0),
y: ref(0),
@@ -46,7 +46,7 @@ describe('useWindowScroll', () => {
})
expect(container.firstChild?.textContent).toEqual(
- 'x=10 y=0 isScrolled=false'
+ "x=10 y=0 isScrolled=false"
)
})
@@ -59,7 +59,7 @@ describe('useWindowScroll', () => {
})
expect(container.firstChild?.textContent).toEqual(
- 'x=31 y=1 isScrolled=true'
+ "x=31 y=1 isScrolled=true"
)
})
})
diff --git a/test/unit/specs/locales/json-to-pot.spec.js b/test/unit/specs/locales/json-to-pot.spec.js
index 77adb5070..69a735e97 100644
--- a/test/unit/specs/locales/json-to-pot.spec.js
+++ b/test/unit/specs/locales/json-to-pot.spec.js
@@ -1,18 +1,18 @@
-import { replaceVarsPlaceholders } from '~/locales/scripts/json-pot-helpers'
+import { replaceVarsPlaceholders } from "~/locales/scripts/json-pot-helpers"
-describe('replaceVarsPlaceholders', () => {
- it('replaces lower case placeholders', () => {
- const string = 'string with a {placeholder}'
- const expected = 'string with a ###placeholder###'
+describe("replaceVarsPlaceholders", () => {
+ it("replaces lower case placeholders", () => {
+ const string = "string with a {placeholder}"
+ const expected = "string with a ###placeholder###"
expect(replaceVarsPlaceholders(string)).toEqual(expected)
})
/**
* Replaces placeholders no matter what casing they use
*/
- it('replaces upper case placeholders', () => {
- const string = '{strinG} {WITH} {Placeholders}'
- const expected = '###strinG### ###WITH### ###Placeholders###'
+ it("replaces upper case placeholders", () => {
+ const string = "{strinG} {WITH} {Placeholders}"
+ const expected = "###strinG### ###WITH### ###Placeholders###"
expect(replaceVarsPlaceholders(string)).toEqual(expected)
})
@@ -20,10 +20,10 @@ describe('replaceVarsPlaceholders', () => {
* Replaces lower- and upper- case placeholders with one or more
* dashes anywhere in the string
*/
- it('replaces placeholders with dashes', () => {
- const string = '{a-string-and-a-half} {WITH--} {Place-holders}'
+ it("replaces placeholders with dashes", () => {
+ const string = "{a-string-and-a-half} {WITH--} {Place-holders}"
const expected =
- '###a-string-and-a-half### ###WITH--### ###Place-holders###'
+ "###a-string-and-a-half### ###WITH--### ###Place-holders###"
expect(replaceVarsPlaceholders(string)).toEqual(expected)
})
@@ -31,11 +31,11 @@ describe('replaceVarsPlaceholders', () => {
* Does not replace placeholders with anything other than letters and dashes,
* or ### placeholders
*/
- it('returns the string if no placeholders are found', () => {
+ it("returns the string if no placeholders are found", () => {
const string =
- '{some{ ###phrase### that {does--not {have.any} {place_holders}'
+ "{some{ ###phrase### that {does--not {have.any} {place_holders}"
const expected =
- '{some{ ###phrase### that {does--not {have.any} {place_holders}'
+ "{some{ ###phrase### that {does--not {have.any} {place_holders}"
expect(replaceVarsPlaceholders(string)).toEqual(expected)
})
diff --git a/test/unit/specs/pages/browse-page.spec.js b/test/unit/specs/pages/browse-page.spec.js
index 5e323130e..bd2b28090 100644
--- a/test/unit/specs/pages/browse-page.spec.js
+++ b/test/unit/specs/pages/browse-page.spec.js
@@ -1,15 +1,15 @@
-import { render, screen } from '@testing-library/vue'
-import { createLocalVue } from '@vue/test-utils'
-import { ref } from '@nuxtjs/composition-api'
+import { render, screen } from "@testing-library/vue"
+import { createLocalVue } from "@vue/test-utils"
+import { ref } from "@nuxtjs/composition-api"
-import { createPinia, PiniaVuePlugin } from '~~/test/unit/test-utils/pinia'
+import { createPinia, PiniaVuePlugin } from "~~/test/unit/test-utils/pinia"
-import SearchIndex from '~/pages/search.vue'
-import { IMAGE } from '~/constants/media'
+import SearchIndex from "~/pages/search.vue"
+import { IMAGE } from "~/constants/media"
-import { useSearchStore } from '~/stores/search'
+import { useSearchStore } from "~/stores/search"
-describe('SearchIndex', () => {
+describe("SearchIndex", () => {
let options
let localVue
let pinia
@@ -20,14 +20,14 @@ describe('SearchIndex', () => {
localVue.use(PiniaVuePlugin)
pinia = createPinia()
searchStore = useSearchStore(pinia)
- searchStore.setSearchTerm('cat')
+ searchStore.setSearchTerm("cat")
searchStore.setSearchType(IMAGE)
options = {
localVue,
pinia,
mocks: {
- $router: { path: { name: 'search-image' } },
- $route: { path: '/search/image' },
+ $router: { path: { name: "search-image" } },
+ $route: { path: "/search/image" },
},
stubs: {
NuxtChild: true,
@@ -37,7 +37,7 @@ describe('SearchIndex', () => {
}
})
- it('hides the scroll button when injected value is false', () => {
+ it("hides the scroll button when injected value is false", () => {
options.provide = { showScrollButton: ref(false) }
render(SearchIndex, options)
@@ -45,7 +45,7 @@ describe('SearchIndex', () => {
expect(screen.queryByLabelText(/scroll/i)).not.toBeVisible()
})
- it('shows the scroll button when injected value is false', () => {
+ it("shows the scroll button when injected value is false", () => {
options.provide = { showScrollButton: ref(true) }
render(SearchIndex, options)
diff --git a/test/unit/specs/plugins/api-token.server.spec.ts b/test/unit/specs/plugins/api-token.server.spec.ts
index 9a253a4af..51dd662b1 100644
--- a/test/unit/specs/plugins/api-token.server.spec.ts
+++ b/test/unit/specs/plugins/api-token.server.spec.ts
@@ -1,16 +1,16 @@
-import { mockCreateApiService } from '~~/test/unit/test-utils/api-service-mock'
+import { mockCreateApiService } from "~~/test/unit/test-utils/api-service-mock"
import apiTokenPlugin, {
Process,
expiryThreshold,
-} from '~/plugins/api-token.server'
+} from "~/plugins/api-token.server"
-import type { AxiosRequestConfig } from 'axios'
+import type { AxiosRequestConfig } from "axios"
-import type { Context } from '@nuxt/types'
+import type { Context } from "@nuxt/types"
// Comment this out if you need to debug the tests as the logs are quite helpful
-jest.mock('~/utils/console', () => ({
+jest.mock("~/utils/console", () => ({
log: () => {
/* noop */
},
@@ -29,14 +29,14 @@ type $config = Partial<{
}>
const defaultConfig: Required<$config> = {
- apiClientId: 'abcdefg_client_i_d',
- apiClientSecret: 'shhhhhhhhh_1234_super_secret',
+ apiClientId: "abcdefg_client_i_d",
+ apiClientSecret: "shhhhhhhhh_1234_super_secret",
}
const matchTokenDataRequestBody = new URLSearchParams({
client_id: defaultConfig.apiClientId,
client_secret: defaultConfig.apiClientSecret,
- grant_type: 'client_credentials',
+ grant_type: "client_credentials",
}).toString()
const getMockContext = ($config: $config = defaultConfig) =>
@@ -51,7 +51,7 @@ const mockInject = jest.fn()
const frozenNow = Date.now()
const frozenSeconds = Math.floor(frozenNow / 1e3)
-jest.spyOn(global.Date, 'now').mockReturnValue(frozenNow)
+jest.spyOn(global.Date, "now").mockReturnValue(frozenNow)
const twelveHoursInSeconds = 12 * 3600
let tokenCount = 1
const getMockTokenResponse = (expires_in = twelveHoursInSeconds) => ({
@@ -68,18 +68,18 @@ const mockResponseAndAssertData =
const defaultPromise = Promise.resolve()
-describe('api-token.server plugin', () => {
+describe("api-token.server plugin", () => {
afterEach(() => {
mockInject.mockReset()
process.tokenData = {
- accessToken: '',
+ accessToken: "",
accessTokenExpiry: 0,
}
process.tokenFetching = defaultPromise
})
- describe('successful token retrieval', () => {
- it('should save the token into the process and inject into the context', async () => {
+ describe("successful token retrieval", () => {
+ it("should save the token into the process and inject into the context", async () => {
const mockTokenResponse = getMockTokenResponse()
mockCreateApiService((axiosMockAdapter) => {
axiosMockAdapter
@@ -95,12 +95,12 @@ describe('api-token.server plugin', () => {
})
expect(mockInject).toHaveBeenCalledWith(
- 'openverseApiToken',
+ "openverseApiToken",
process.tokenData.accessToken
)
})
- it('should re-retrieve the token when about to expire', async () => {
+ it("should re-retrieve the token when about to expire", async () => {
const mockTokenResponse = getMockTokenResponse(expiryThreshold - 1)
const nextMockTokenResponse = getMockTokenResponse()
mockCreateApiService((axiosMockAdapter) => {
@@ -121,7 +121,7 @@ describe('api-token.server plugin', () => {
})
})
- it('should not request a new token if the token is not about to expire', async () => {
+ it("should not request a new token if the token is not about to expire", async () => {
const mockTokenResponse = getMockTokenResponse(twelveHoursInSeconds)
const nextMockTokenResponse = getMockTokenResponse()
mockCreateApiService((axiosMockAdapter) => {
@@ -142,7 +142,7 @@ describe('api-token.server plugin', () => {
})
})
- it('subsequent requests should all block on the same token retrieval promise', async () => {
+ it("subsequent requests should all block on the same token retrieval promise", async () => {
/**
* This test is pretty complicated because we need to simulate
* multiple requests coming in at the same time with requests
@@ -207,8 +207,8 @@ describe('api-token.server plugin', () => {
})
})
- describe('unnecessful token retrieval', () => {
- it('should record the error in sentry', async () => {
+ describe("unnecessful token retrieval", () => {
+ it("should record the error in sentry", async () => {
mockCreateApiService((mockAdapter) => {
mockAdapter
.onPost(matchTokenDataRequest)
@@ -228,11 +228,11 @@ describe('api-token.server plugin', () => {
expect(mockContext.$sentry.captureException).toHaveBeenCalledTimes(1)
expect(capturedError).not.toBeUndefined()
expect((capturedError as unknown as Error).message).toMatch(
- 'Unable to retrieve API token. Request failed with status code 418'
+ "Unable to retrieve API token. Request failed with status code 418"
)
})
- it('should empty the token data', async () => {
+ it("should empty the token data", async () => {
mockCreateApiService((mockAdapter) => {
mockAdapter
.onPost(matchTokenDataRequest)
@@ -248,12 +248,12 @@ describe('api-token.server plugin', () => {
})
await apiTokenPlugin(getMockContext(), mockInject)
- expect(process.tokenData.accessToken).not.toEqual('')
+ expect(process.tokenData.accessToken).not.toEqual("")
await apiTokenPlugin(getMockContext(), mockInject)
- expect(process.tokenData.accessToken).toEqual('')
+ expect(process.tokenData.accessToken).toEqual("")
})
- it('should properly release the mutex and allow for subsequent requests to retry the token refresh', async () => {
+ it("should properly release the mutex and allow for subsequent requests to retry the token refresh", async () => {
const finalTokenResponse = getMockTokenResponse()
mockCreateApiService((mockAdapter) => {
mockAdapter
@@ -282,16 +282,16 @@ describe('api-token.server plugin', () => {
})
})
- describe('missing client credentials', () => {
- describe('completely missing', () => {
- it('should not make any requests and fall back to tokenless', async () => {
+ describe("missing client credentials", () => {
+ describe("completely missing", () => {
+ it("should not make any requests and fall back to tokenless", async () => {
await apiTokenPlugin(getMockContext({}), mockInject)
- expect(mockInject).toHaveBeenCalledWith('openverseApiToken', '')
+ expect(mockInject).toHaveBeenCalledWith("openverseApiToken", "")
})
})
- describe('explicitly undefined', () => {
- it('should not make any requests and fall back to tokenless', async () => {
+ describe("explicitly undefined", () => {
+ it("should not make any requests and fall back to tokenless", async () => {
await apiTokenPlugin(
getMockContext({
apiClientId: undefined,
@@ -299,7 +299,7 @@ describe('api-token.server plugin', () => {
}),
mockInject
)
- expect(mockInject).toHaveBeenCalledWith('openverseApiToken', '')
+ expect(mockInject).toHaveBeenCalledWith("openverseApiToken", "")
})
})
})
diff --git a/test/unit/specs/stores/active-media-store.spec.js b/test/unit/specs/stores/active-media-store.spec.js
index ab5a9ee0d..f96c9bf16 100644
--- a/test/unit/specs/stores/active-media-store.spec.js
+++ b/test/unit/specs/stores/active-media-store.spec.js
@@ -1,18 +1,18 @@
-import { setActivePinia, createPinia } from '~~/test/unit/test-utils/pinia'
+import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"
-import { AUDIO } from '~/constants/media'
+import { AUDIO } from "~/constants/media"
-import { useActiveMediaStore } from '~/stores/active-media'
+import { useActiveMediaStore } from "~/stores/active-media"
-const initialState = { type: null, id: null, status: 'ejected', message: null }
-const statuses = ['ejected', 'paused', 'playing']
+const initialState = { type: null, id: null, status: "ejected", message: null }
+const statuses = ["ejected", "paused", "playing"]
-describe('Active Media Store', () => {
+describe("Active Media Store", () => {
beforeEach(() => {
setActivePinia(createPinia())
})
- describe('state', () => {
- it('sets initial filters to filterData', () => {
+ describe("state", () => {
+ it("sets initial filters to filterData", () => {
const activeMediaStore = useActiveMediaStore()
expect(activeMediaStore.type).toEqual(initialState.type)
expect(activeMediaStore.id).toEqual(initialState.id)
@@ -20,10 +20,10 @@ describe('Active Media Store', () => {
expect(activeMediaStore.message).toEqual(initialState.message)
})
})
- describe('actions', () => {
+ describe("actions", () => {
it.each(statuses)(`can set active media with status $status`, (status) => {
const activeMediaStore = useActiveMediaStore()
- const mediaItem = { type: AUDIO, id: 'audio1' }
+ const mediaItem = { type: AUDIO, id: "audio1" }
activeMediaStore.setActiveMediaItem({ ...mediaItem, status })
const expectedState = { ...initialState, ...mediaItem, status }
@@ -32,20 +32,20 @@ describe('Active Media Store', () => {
expect(activeMediaStore.status).toEqual(expectedState.status)
})
- it.each(statuses)('can pause an item with any status', (status) => {
+ it.each(statuses)("can pause an item with any status", (status) => {
const activeMediaStore = useActiveMediaStore()
activeMediaStore.setActiveMediaItem({ status })
activeMediaStore.pauseActiveMediaItem()
- expect(activeMediaStore.status).toEqual('paused')
+ expect(activeMediaStore.status).toEqual("paused")
})
- it('can eject an item', () => {
+ it("can eject an item", () => {
const activeMediaStore = useActiveMediaStore()
activeMediaStore.setActiveMediaItem({
type: AUDIO,
- id: 'audio1',
- status: 'playing',
+ id: "audio1",
+ status: "playing",
})
activeMediaStore.ejectActiveMediaItem()
@@ -53,9 +53,9 @@ describe('Active Media Store', () => {
expect(activeMediaStore.type).toEqual(initialState.type)
expect(activeMediaStore.status).toEqual(initialState.status)
})
- it('can set a message', () => {
+ it("can set a message", () => {
const activeMediaStore = useActiveMediaStore()
- const expectedMessage = 'Cannot play this audio'
+ const expectedMessage = "Cannot play this audio"
activeMediaStore.setMessage({ message: expectedMessage })
expect(activeMediaStore.message).toEqual(expectedMessage)
})
diff --git a/test/unit/specs/stores/feature-flag-store.spec.js b/test/unit/specs/stores/feature-flag-store.spec.js
index 9507b78fd..bc5b0863f 100644
--- a/test/unit/specs/stores/feature-flag-store.spec.js
+++ b/test/unit/specs/stores/feature-flag-store.spec.js
@@ -1,75 +1,75 @@
-import { setActivePinia, createPinia } from '~~/test/unit/test-utils/pinia'
+import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"
-import { useFeatureFlagStore, getFlagStatus } from '~/stores/feature-flag'
-import { OFF, ON } from '~/constants/feature-flag'
+import { useFeatureFlagStore, getFlagStatus } from "~/stores/feature-flag"
+import { OFF, ON } from "~/constants/feature-flag"
jest.mock(
- '~~/feat/feature-flags.json',
+ "~~/feat/feature-flags.json",
() => ({
features: {
feat_enabled: {
- status: 'enabled',
- description: 'Will always be enabled',
+ status: "enabled",
+ description: "Will always be enabled",
},
feat_disabled: {
- status: 'disabled',
- description: 'Will always be disabled',
+ status: "disabled",
+ description: "Will always be disabled",
},
feat_switchable_optout: {
- status: 'switchable',
- description: 'Can be switched between on and off',
- defaultState: 'on',
+ status: "switchable",
+ description: "Can be switched between on and off",
+ defaultState: "on",
},
feat_switchable_optin: {
- status: 'switchable',
- description: 'Can be switched between on and off',
- defaultState: 'off',
+ status: "switchable",
+ description: "Can be switched between on and off",
+ defaultState: "off",
},
feat_env_specific: {
status: {
- local: 'enabled',
- staging: 'switchable',
- production: 'disabled',
+ local: "enabled",
+ staging: "switchable",
+ production: "disabled",
},
- description: 'Depends on the environment',
- defaultState: 'off',
+ description: "Depends on the environment",
+ defaultState: "off",
},
},
}),
{ virtual: true }
)
-describe('Feature flag store', () => {
+describe("Feature flag store", () => {
beforeEach(() => {
setActivePinia(createPinia())
})
- it('initialises state from JSON', () => {
+ it("initialises state from JSON", () => {
const featureFlagStore = useFeatureFlagStore()
expect(Object.keys(featureFlagStore.flags).length).toBe(5)
})
it.each`
flagName | featureState
- ${'feat_enabled'} | ${'on'}
- ${'feat_disabled'} | ${'off'}
+ ${"feat_enabled"} | ${"on"}
+ ${"feat_disabled"} | ${"off"}
`(
- 'does not allow modification of fixed flags',
+ "does not allow modification of fixed flags",
({ flagName, featureState }) => {
const featureFlagStore = useFeatureFlagStore()
expect(featureFlagStore.featureState(flagName)).toEqual(featureState)
- expect(featureFlagStore.isOn(flagName)).toEqual(featureState === 'on')
+ expect(featureFlagStore.isOn(flagName)).toEqual(featureState === "on")
}
)
it.each`
flagName | doCookieInit | featureState
- ${'feat_switchable_optout'} | ${false} | ${'on'}
- ${'feat_switchable_optin'} | ${false} | ${'off'}
- ${'feat_switchable_optout'} | ${true} | ${'off'}
- ${'feat_switchable_optin'} | ${true} | ${'on'}
+ ${"feat_switchable_optout"} | ${false} | ${"on"}
+ ${"feat_switchable_optin"} | ${false} | ${"off"}
+ ${"feat_switchable_optout"} | ${true} | ${"off"}
+ ${"feat_switchable_optin"} | ${true} | ${"on"}
`(
- 'cascades flag $flagName from cookies',
+ "cascades flag $flagName from cookies",
({ flagName, doCookieInit, featureState }) => {
const featureFlagStore = useFeatureFlagStore()
if (doCookieInit)
@@ -78,18 +78,18 @@ describe('Feature flag store', () => {
feat_switchable_optin: ON,
})
expect(featureFlagStore.featureState(flagName)).toEqual(featureState)
- expect(featureFlagStore.isOn(flagName)).toEqual(featureState === 'on')
+ expect(featureFlagStore.isOn(flagName)).toEqual(featureState === "on")
}
)
it.each`
cookieState | queryState | finalState
- ${'off'} | ${'on'} | ${'on'}
- ${'on'} | ${'off'} | ${'off'}
+ ${"off"} | ${"on"} | ${"on"}
+ ${"on"} | ${"off"} | ${"off"}
`(
- 'cascades flag from cookies and query params',
+ "cascades flag from cookies and query params",
({ cookieState, queryState, finalState }) => {
- const flagName = 'feat_switchable_optout'
+ const flagName = "feat_switchable_optout"
const featureFlagStore = useFeatureFlagStore()
featureFlagStore.initFromCookies({
[flagName]: cookieState,
@@ -104,10 +104,10 @@ describe('Feature flag store', () => {
it.each`
flagName | queryState | finalState
- ${'feat_disabled'} | ${'on'} | ${'off'}
- ${'feat_enabled'} | ${'off'} | ${'on'}
+ ${"feat_disabled"} | ${"on"} | ${"off"}
+ ${"feat_enabled"} | ${"off"} | ${"on"}
`(
- 'does not cascade non-switchable flags from query params',
+ "does not cascade non-switchable flags from query params",
({ flagName, queryState, finalState }) => {
const featureFlagStore = useFeatureFlagStore()
featureFlagStore.initFromQuery({
@@ -120,22 +120,22 @@ describe('Feature flag store', () => {
it.each`
environment | featureState
- ${'local'} | ${'on'}
- ${'staging'} | ${'off'}
- ${'production'} | ${'off'}
+ ${"local"} | ${"on"}
+ ${"staging"} | ${"off"}
+ ${"production"} | ${"off"}
`(
- 'returns $expectedState for $environment',
+ "returns $expectedState for $environment",
({ environment, featureState }) => {
// Back up value of `DEPLOYMENT_ENV` and replace it
const old_env = process.env.DEPLOYMENT_ENV
process.env.DEPLOYMENT_ENV = environment
const featureFlagStore = useFeatureFlagStore()
- expect(featureFlagStore.featureState('feat_env_specific')).toEqual(
+ expect(featureFlagStore.featureState("feat_env_specific")).toEqual(
featureState
)
- expect(featureFlagStore.isOn('feat_env_specific')).toEqual(
- featureState === 'on'
+ expect(featureFlagStore.isOn("feat_env_specific")).toEqual(
+ featureState === "on"
)
// Restore `DEPLOYMENT_ENV` value
@@ -145,17 +145,17 @@ describe('Feature flag store', () => {
it.each`
environment | flagStatus
- ${'local'} | ${'switchable'}
- ${'staging'} | ${'switchable'}
- ${'production'} | ${'disabled'}
+ ${"local"} | ${"switchable"}
+ ${"staging"} | ${"switchable"}
+ ${"production"} | ${"disabled"}
`(
- 'handles fallback for missing $environment',
+ "handles fallback for missing $environment",
({ environment, flagStatus }) => {
// Back up value of `DEPLOYMENT_ENV` and replace it
const old_env = process.env.DEPLOYMENT_ENV
process.env.DEPLOYMENT_ENV = environment
- expect(getFlagStatus({ status: { staging: 'switchable' } })).toEqual(
+ expect(getFlagStatus({ status: { staging: "switchable" } })).toEqual(
flagStatus
)
@@ -164,14 +164,14 @@ describe('Feature flag store', () => {
}
)
- it('returns mapping of switchable flags', () => {
+ it("returns mapping of switchable flags", () => {
const featureFlagStore = useFeatureFlagStore()
const flagStateMap = featureFlagStore.flagStateMap
- expect(flagStateMap).toHaveProperty('feat_switchable_optout')
- expect(flagStateMap).toHaveProperty('feat_switchable_optin')
+ expect(flagStateMap).toHaveProperty("feat_switchable_optout")
+ expect(flagStateMap).toHaveProperty("feat_switchable_optin")
- expect(flagStateMap).not.toHaveProperty('feat_enabled')
- expect(flagStateMap).not.toHaveProperty('feat_disabled')
+ expect(flagStateMap).not.toHaveProperty("feat_enabled")
+ expect(flagStateMap).not.toHaveProperty("feat_disabled")
})
})
diff --git a/test/unit/specs/stores/media-store.spec.js b/test/unit/specs/stores/media-store.spec.js
index 06d69b45c..d2a5c4cef 100644
--- a/test/unit/specs/stores/media-store.spec.js
+++ b/test/unit/specs/stores/media-store.spec.js
@@ -1,18 +1,18 @@
-import { AxiosError } from 'axios'
+import { AxiosError } from "axios"
-import { setActivePinia, createPinia } from '~~/test/unit/test-utils/pinia'
+import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"
-import { deepClone } from '~/utils/clone'
+import { deepClone } from "~/utils/clone"
-import { initialResults, useMediaStore } from '~/stores/media'
-import { useSearchStore } from '~/stores/search'
-import { ALL_MEDIA, AUDIO, IMAGE, supportedMediaTypes } from '~/constants/media'
+import { initialResults, useMediaStore } from "~/stores/media"
+import { useSearchStore } from "~/stores/search"
+import { ALL_MEDIA, AUDIO, IMAGE, supportedMediaTypes } from "~/constants/media"
const uuids = [
- '0dea3af1-27a4-4635-bab6-4b9fb76a59f5',
- '32c22b5b-f2f9-47db-b64f-6b86c2431942',
- 'fd527776-00f8-4000-9190-724fc4f07346',
- '81e551de-52ab-4852-90eb-bc3973c342a0',
+ "0dea3af1-27a4-4635-bab6-4b9fb76a59f5",
+ "32c22b5b-f2f9-47db-b64f-6b86c2431942",
+ "fd527776-00f8-4000-9190-724fc4f07346",
+ "81e551de-52ab-4852-90eb-bc3973c342a0",
]
const items = (mediaType) =>
uuids.map((uuid, i) => ({
@@ -48,7 +48,7 @@ const mockImplementation = (mediaType) => () =>
const mockSearchAudio = jest.fn().mockImplementation(mockImplementation(AUDIO))
const mockSearchImage = jest.fn().mockImplementation(mockImplementation(IMAGE))
const mockGetMediaDetail = jest.fn()
-jest.mock('~/stores/media/services', () => ({
+jest.mock("~/stores/media/services", () => ({
initServices: {
audio: () =>
/** @type {typeof import('~/data/services').MediaService} */ ({
@@ -63,9 +63,9 @@ jest.mock('~/stores/media/services', () => ({
},
}))
-describe('Media Store', () => {
- describe('state', () => {
- it('sets default state', () => {
+describe("Media Store", () => {
+ describe("state", () => {
+ it("sets default state", () => {
setActivePinia(createPinia())
const mediaStore = useMediaStore()
@@ -90,22 +90,22 @@ describe('Media Store', () => {
})
})
- describe('getters', () => {
+ describe("getters", () => {
beforeEach(() => {
setActivePinia(createPinia())
})
- it('getItemById returns undefined if there are no items', () => {
+ it("getItemById returns undefined if there are no items", () => {
const mediaStore = useMediaStore()
- expect(mediaStore.getItemById(IMAGE, 'foo')).toBe(undefined)
+ expect(mediaStore.getItemById(IMAGE, "foo")).toBe(undefined)
})
- it('getItemById returns correct item', () => {
+ it("getItemById returns correct item", () => {
const mediaStore = useMediaStore()
- const expectedItem = { id: 'foo', title: 'ImageFoo' }
+ const expectedItem = { id: "foo", title: "ImageFoo" }
mediaStore.results.image.items = { foo: expectedItem }
- expect(mediaStore.getItemById(IMAGE, 'foo')).toEqual(expectedItem)
+ expect(mediaStore.getItemById(IMAGE, "foo")).toEqual(expectedItem)
})
- it('resultItems returns correct items', () => {
+ it("resultItems returns correct items", () => {
const mediaStore = useMediaStore()
mediaStore.results.audio = testResult(AUDIO)
mediaStore.results.image = testResult(IMAGE)
@@ -115,7 +115,7 @@ describe('Media Store', () => {
[IMAGE]: imageItems,
})
})
- it('allMedia returns correct items', () => {
+ it("allMedia returns correct items", () => {
const mediaStore = useMediaStore()
mediaStore.results.audio = testResult(AUDIO)
mediaStore.results.image = testResult(IMAGE)
@@ -135,7 +135,7 @@ describe('Media Store', () => {
* Now, however, it simply returns the audio items in order.
* TODO: Add video and check for randomization.
*/
- it('allMedia returns items even if there are no images', () => {
+ it("allMedia returns items even if there are no images", () => {
const mediaStore = useMediaStore()
mediaStore.results.audio = testResult(AUDIO)
@@ -146,7 +146,7 @@ describe('Media Store', () => {
audioItems[3],
])
})
- it('resultCountsPerMediaType returns correct items for %s', () => {
+ it("resultCountsPerMediaType returns correct items for %s", () => {
const mediaStore = useMediaStore()
mediaStore.results.image = testResult(IMAGE)
@@ -162,7 +162,7 @@ describe('Media Store', () => {
${ALL_MEDIA} | ${10000}
${AUDIO} | ${0}
${IMAGE} | ${10000}
- `('resultCount for $searchType returns $count', ({ searchType, count }) => {
+ `("resultCount for $searchType returns $count", ({ searchType, count }) => {
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
searchStore.setSearchType(searchType)
@@ -174,26 +174,26 @@ describe('Media Store', () => {
it.each`
searchType | fetchState
${ALL_MEDIA} | ${{ fetchingError: null, hasStarted: true, isFetching: true, isFinished: false }}
- ${AUDIO} | ${{ fetchingError: 'Error', hasStarted: true, isFetching: false, isFinished: true }}
+ ${AUDIO} | ${{ fetchingError: "Error", hasStarted: true, isFetching: false, isFinished: true }}
${IMAGE} | ${{ fetchingError: null, hasStarted: true, isFetching: true, isFinished: false }}
`(
- 'fetchState for $searchType returns $fetchState',
+ "fetchState for $searchType returns $fetchState",
({ searchType, fetchState }) => {
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
searchStore.setSearchType(searchType)
- mediaStore._updateFetchState(AUDIO, 'end', 'Error')
- mediaStore._updateFetchState(IMAGE, 'start')
+ mediaStore._updateFetchState(AUDIO, "end", "Error")
+ mediaStore._updateFetchState(IMAGE, "start")
expect(mediaStore.fetchState).toEqual(fetchState)
}
)
- it('fetchState for ALL_MEDIA returns compound error if all types have errors', () => {
+ it("fetchState for ALL_MEDIA returns compound error if all types have errors", () => {
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
searchStore.setSearchType(ALL_MEDIA)
- mediaStore._updateFetchState(AUDIO, 'end', 'Error')
- mediaStore._updateFetchState(IMAGE, 'end', 'Error')
+ mediaStore._updateFetchState(AUDIO, "end", "Error")
+ mediaStore._updateFetchState(IMAGE, "end", "Error")
expect(mediaStore.fetchState).toEqual({
fetchingError: '{"image":"Error","audio":"Error"}',
@@ -204,7 +204,7 @@ describe('Media Store', () => {
})
})
- describe('actions', () => {
+ describe("actions", () => {
let searchStore
beforeEach(() => {
@@ -216,19 +216,19 @@ describe('Media Store', () => {
mockGetMediaDetail.mockClear()
})
- it('setMedia updates state persisting images', () => {
+ it("setMedia updates state persisting images", () => {
const mediaStore = useMediaStore()
const img1 = {
- id: '81e551de-52ab-4852-90eb-bc3973c342a0',
- title: 'Foo',
- creator: 'foo',
+ id: "81e551de-52ab-4852-90eb-bc3973c342a0",
+ title: "Foo",
+ creator: "foo",
tags: [],
}
const img2 = {
- id: '0dea3af1-27a4-4635-bab6-4b9fb76a59f5',
- title: 'Bar',
- creator: 'bar',
+ id: "0dea3af1-27a4-4635-bab6-4b9fb76a59f5",
+ title: "Bar",
+ creator: "bar",
tags: [],
}
mediaStore.results.image.items = { [img1.id]: img1 }
@@ -249,10 +249,10 @@ describe('Media Store', () => {
expect(mediaStore.results.image.page).toBe(params.page)
})
- it('setMedia updates state not persisting images', () => {
+ it("setMedia updates state not persisting images", () => {
const mediaStore = useMediaStore()
- const img = { title: 'Foo', creator: 'bar', tags: [] }
- mediaStore.results.image.items = ['img1']
+ const img = { title: "Foo", creator: "bar", tags: [] }
+ mediaStore.results.image.items = ["img1"]
const params = {
media: [img],
mediaCount: 2,
@@ -269,11 +269,11 @@ describe('Media Store', () => {
})
})
- it('setMedia updates state with default count and page', () => {
+ it("setMedia updates state with default count and page", () => {
const mediaStore = useMediaStore()
- const img = { title: 'Foo', creator: 'bar', tags: [] }
- mediaStore.results.image.items = ['img1']
+ const img = { title: "Foo", creator: "bar", tags: [] }
+ mediaStore.results.image.items = ["img1"]
const params = { media: [img], mediaType: IMAGE }
mediaStore.setMedia(params)
@@ -282,21 +282,21 @@ describe('Media Store', () => {
expect(mediaStore.results.image.page).toBe(1)
})
- it('mediaNotFound throws an error', () => {
+ it("mediaNotFound throws an error", () => {
const mediaStore = useMediaStore()
expect(() => mediaStore.mediaNotFound(AUDIO)).toThrow(
- 'Media of type audio not found'
+ "Media of type audio not found"
)
})
it.each(supportedMediaTypes)(
- 'fetchSingleMediaType (%s) on success',
+ "fetchSingleMediaType (%s) on success",
async (mediaType) => {
const mediaStore = useMediaStore()
searchStore = useSearchStore()
- searchStore.setSearchTerm('cat')
+ searchStore.setSearchTerm("cat")
const params = {
shouldPersistMedia: true,
mediaType,
@@ -314,7 +314,7 @@ describe('Media Store', () => {
}
)
- it('fetchSingleMediaType resets images if shouldPersistMedia is false', async () => {
+ it("fetchSingleMediaType resets images if shouldPersistMedia is false", async () => {
const mediaStore = useMediaStore()
const mediaType = IMAGE
@@ -332,12 +332,12 @@ describe('Media Store', () => {
})
})
- it('fetchSingleMediaType does not reset images if page is defined', async () => {
+ it("fetchSingleMediaType does not reset images if page is defined", async () => {
const mediaStore = useMediaStore()
const mediaType = IMAGE
const params = {
- q: 'foo',
+ q: "foo",
page: 1,
shouldPersistMedia: false,
mediaType,
@@ -345,7 +345,7 @@ describe('Media Store', () => {
await mediaStore.fetchSingleMediaType(params)
})
- it('clearMedia resets the results', () => {
+ it("clearMedia resets the results", () => {
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
searchStore.setSearchType(ALL_MEDIA)
@@ -356,55 +356,55 @@ describe('Media Store', () => {
})
})
- it('handleMediaError handles 500 error', () => {
+ it("handleMediaError handles 500 error", () => {
const mediaType = AUDIO
const error = new AxiosError(
- '500 server error',
- 'ERR_BAD_RESPONSE',
+ "500 server error",
+ "ERR_BAD_RESPONSE",
undefined,
- { path: '/foo' },
+ { path: "/foo" },
{ status: 500 }
)
const mediaStore = useMediaStore()
mediaStore.handleMediaError({ mediaType, error })
expect(mediaStore.$nuxt.$sentry.captureEvent).toHaveBeenCalledWith({
message:
- 'Error fetching audio from API. Request failed with status code: 500',
+ "Error fetching audio from API. Request failed with status code: 500",
extra: { mediaType, error },
})
})
- it('handleMediaError handles a 403 error', () => {
+ it("handleMediaError handles a 403 error", () => {
const mediaType = AUDIO
const error = new AxiosError(
- '403 error',
- 'ERR_BAD_REQUEST',
+ "403 error",
+ "ERR_BAD_REQUEST",
undefined,
- { path: '/foo' },
+ { path: "/foo" },
{ status: 403 }
)
const mediaStore = useMediaStore()
mediaStore.handleMediaError({ mediaType, error })
expect(mediaStore.$nuxt.$sentry.captureEvent).toHaveBeenCalledWith({
message:
- 'Error fetching audio from API. Request failed with status code: 403',
+ "Error fetching audio from API. Request failed with status code: 403",
extra: { mediaType, error },
})
expect(mediaStore.mediaFetchState.audio.fetchingError).toEqual(
- 'Error fetching audio from API. Request failed with status code: 403'
+ "Error fetching audio from API. Request failed with status code: 403"
)
expect(mediaStore.mediaFetchState.audio.isFetching).toEqual(false)
})
- it('handleMediaError handles an error when server did not respond', async () => {
+ it("handleMediaError handles an error when server did not respond", async () => {
const mediaStore = useMediaStore()
const mediaType = AUDIO
const noResponseAxiosError = new AxiosError(
- 'Unknown error',
- 'ETIMEDOUT',
+ "Unknown error",
+ "ETIMEDOUT",
undefined,
{
- path: '/foo',
+ path: "/foo",
}
)
await mediaStore.handleMediaError({
@@ -413,7 +413,7 @@ describe('Media Store', () => {
})
const expectedErrorMessage =
- 'Error fetching audio from API. No response received from the server'
+ "Error fetching audio from API. No response received from the server"
expect(mediaStore.mediaFetchState.audio.fetchingError).toEqual(
expectedErrorMessage
)
@@ -424,12 +424,12 @@ describe('Media Store', () => {
})
})
- it('handleMediaError re-throws a non-Axios error', async () => {
+ it("handleMediaError re-throws a non-Axios error", async () => {
const mediaStore = useMediaStore()
- const nonAxiosError = new Error('non-Axios error')
+ const nonAxiosError = new Error("non-Axios error")
const expectedErrorMessage =
- 'Error fetching audio from API. Unknown error'
+ "Error fetching audio from API. Unknown error"
await expect(
mediaStore.handleMediaError({
mediaType: AUDIO,
@@ -441,8 +441,8 @@ describe('Media Store', () => {
)
})
- describe('setMediaProperties', () => {
- it('merges the existing media item together with the properties passed in allowing overwriting', () => {
+ describe("setMediaProperties", () => {
+ it("merges the existing media item together with the properties passed in allowing overwriting", () => {
const mediaStore = useMediaStore()
mediaStore.results.audio = testResult(AUDIO)
diff --git a/test/unit/specs/stores/nav-store.spec.js b/test/unit/specs/stores/nav-store.spec.js
index 3986e0231..e5d007075 100644
--- a/test/unit/specs/stores/nav-store.spec.js
+++ b/test/unit/specs/stores/nav-store.spec.js
@@ -1,17 +1,17 @@
-import { setActivePinia, createPinia } from '~~/test/unit/test-utils/pinia'
+import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"
-import { useNavigationStore } from '~/stores/navigation'
+import { useNavigationStore } from "~/stores/navigation"
const initialState = {
isEmbedded: true,
isReferredFromCc: false,
}
-describe('Nav Store', () => {
+describe("Nav Store", () => {
beforeEach(() => {
setActivePinia(createPinia())
})
- it('sets the initial state correctly', () => {
+ it("sets the initial state correctly", () => {
const navigationStore = useNavigationStore()
expect(navigationStore.isEmbedded).toEqual(initialState.isEmbedded)
expect(navigationStore.isReferredFromCc).toEqual(
@@ -19,7 +19,7 @@ describe('Nav Store', () => {
)
})
- it.each([true, false, undefined])('sets isEmbedded', (embedded) => {
+ it.each([true, false, undefined])("sets isEmbedded", (embedded) => {
const navigationStore = useNavigationStore()
navigationStore.setIsEmbedded(embedded)
const expectedValue = embedded ?? true
@@ -28,7 +28,7 @@ describe('Nav Store', () => {
})
it.each([true, false, undefined])(
- 'sets isReferredFromCc',
+ "sets isReferredFromCc",
(isReferredFromCc) => {
const navigationStore = useNavigationStore()
navigationStore.setIsReferredFromCc(isReferredFromCc)
diff --git a/test/unit/specs/stores/provider.spec.js b/test/unit/specs/stores/provider.spec.js
index f5ee3ae3c..9579ca9b7 100644
--- a/test/unit/specs/stores/provider.spec.js
+++ b/test/unit/specs/stores/provider.spec.js
@@ -1,42 +1,42 @@
-import { setActivePinia, createPinia } from '~~/test/unit/test-utils/pinia'
+import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"
-import { warn } from '~/utils/console'
-import { AUDIO, IMAGE, supportedMediaTypes } from '~/constants/media'
-import { useSearchStore } from '~/stores/search'
-import { useProviderStore } from '~/stores/provider'
-import { initProviderServices } from '~/data/media-provider-service'
+import { warn } from "~/utils/console"
+import { AUDIO, IMAGE, supportedMediaTypes } from "~/constants/media"
+import { useSearchStore } from "~/stores/search"
+import { useProviderStore } from "~/stores/provider"
+import { initProviderServices } from "~/data/media-provider-service"
-jest.mock('axios', () => ({
- ...jest.requireActual('axios'),
- isAxiosError: jest.fn((obj) => 'response' in obj),
+jest.mock("axios", () => ({
+ ...jest.requireActual("axios"),
+ isAxiosError: jest.fn((obj) => "response" in obj),
}))
-jest.mock('@nuxtjs/composition-api', () => ({
- ...jest.requireActual('@nuxtjs/composition-api'),
+jest.mock("@nuxtjs/composition-api", () => ({
+ ...jest.requireActual("@nuxtjs/composition-api"),
ssrRef: (v) => jest.fn(v),
}))
-jest.mock('~/utils/console', () => ({ warn: jest.fn(), log: jest.fn() }))
+jest.mock("~/utils/console", () => ({ warn: jest.fn(), log: jest.fn() }))
-process.env.providerUpdateFrequency = '0'
+process.env.providerUpdateFrequency = "0"
const mockData = [
{
- source_name: 'test_source',
- display_name: '',
- source_url: 'https://test.org',
+ source_name: "test_source",
+ display_name: "",
+ source_url: "https://test.org",
logo_url: null,
media_count: 4,
},
{
- source_name: 'wikimedia',
- display_name: 'Wikimedia Commons',
- source_url: 'https://commons.wikimedia.org',
+ source_name: "wikimedia",
+ display_name: "Wikimedia Commons",
+ source_url: "https://commons.wikimedia.org",
logo_url: null,
media_count: 47823833,
},
{
- source_name: 'wordpress',
- display_name: 'WP Photo Directory',
- source_url: 'https://wordpress.org/photos',
+ source_name: "wordpress",
+ display_name: "WP Photo Directory",
+ source_url: "https://wordpress.org/photos",
logo_url: null,
media_count: 154,
},
@@ -44,7 +44,7 @@ const mockData = [
const mockImplementation = () => Promise.resolve({ data: [...mockData] })
const mock = jest.fn().mockImplementation(mockImplementation)
-jest.mock('~/data/media-provider-service', () => ({
+jest.mock("~/data/media-provider-service", () => ({
initProviderServices: {
audio: () =>
/** @type {typeof import('~/data/media-provider-services').MediaProviderService} */ ({
@@ -57,7 +57,7 @@ jest.mock('~/data/media-provider-service', () => ({
},
}))
-describe('Provider Store', () => {
+describe("Provider Store", () => {
let providerStore
beforeEach(() => {
setActivePinia(createPinia())
@@ -70,7 +70,7 @@ describe('Provider Store', () => {
warn.mockReset()
})
- it('sets the default state', () => {
+ it("sets the default state", () => {
expect(providerStore.providers).toEqual({
[AUDIO]: [],
[IMAGE]: [],
@@ -83,11 +83,11 @@ describe('Provider Store', () => {
it.each`
providerCode | displayName
- ${'wikimedia'} | ${'Wikimedia Commons'}
- ${'wordpress'} | ${'WP Photo Directory'}
- ${'test_source'} | ${'Test Source'}
+ ${"wikimedia"} | ${"Wikimedia Commons"}
+ ${"wordpress"} | ${"WP Photo Directory"}
+ ${"test_source"} | ${"Test Source"}
`(
- 'getProviderName returns provider name or capitalizes providerCode',
+ "getProviderName returns provider name or capitalizes providerCode",
async ({ providerCode, displayName }) => {
await providerStore.fetchMediaProviders()
expect(providerStore.getProviderName(providerCode, IMAGE)).toEqual(
@@ -96,7 +96,7 @@ describe('Provider Store', () => {
}
)
- it('fetchMediaProviders on success', async () => {
+ it("fetchMediaProviders on success", async () => {
await providerStore.fetchMediaProviders()
expect(providerStore.fetchState[IMAGE]).toEqual({
fetchingError: null,
@@ -106,12 +106,12 @@ describe('Provider Store', () => {
expect(providerStore.providers[IMAGE]).toEqual(mockData)
})
- it('fetchMediaProviders on error', async () => {
+ it("fetchMediaProviders on error", async () => {
for (const mediaType of supportedMediaTypes) {
initProviderServices[mediaType] = () => ({
getProviderStats: jest
.fn()
- .mockImplementation(() => Promise.reject(new Error('Not found'))),
+ .mockImplementation(() => Promise.reject(new Error("Not found"))),
})
}
const searchStore = useSearchStore()
diff --git a/test/unit/specs/stores/search-store.spec.js b/test/unit/specs/stores/search-store.spec.js
index 8a9706574..ec54b6dc2 100644
--- a/test/unit/specs/stores/search-store.spec.js
+++ b/test/unit/specs/stores/search-store.spec.js
@@ -1,32 +1,32 @@
-import { nextTick } from '@nuxtjs/composition-api'
+import { nextTick } from "@nuxtjs/composition-api"
-import { setActivePinia, createPinia } from '~~/test/unit/test-utils/pinia'
+import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"
-import { env } from '~/utils/env'
+import { env } from "~/utils/env"
-import { filterData, mediaFilterKeys } from '~/constants/filters'
+import { filterData, mediaFilterKeys } from "~/constants/filters"
import {
ALL_MEDIA,
AUDIO,
IMAGE,
supportedSearchTypes,
VIDEO,
-} from '~/constants/media'
+} from "~/constants/media"
-import { useSearchStore } from '~/stores/search'
-import { useFeatureFlagStore } from '~/stores/feature-flag'
+import { useSearchStore } from "~/stores/search"
+import { useFeatureFlagStore } from "~/stores/feature-flag"
-describe('Search Store', () => {
+describe("Search Store", () => {
beforeEach(() => {
setActivePinia(createPinia())
})
- describe('state', () => {
- it('sets initial filters to filterData', () => {
+ describe("state", () => {
+ it("sets initial filters to filterData", () => {
const searchStore = useSearchStore()
expect(searchStore.filters).toEqual(filterData)
})
})
- describe('getters', () => {
+ describe("getters", () => {
/**
* Check for some special cases:
* - `mature` and `searchBy`.
@@ -36,14 +36,14 @@ describe('Search Store', () => {
*/
it.each`
query | searchType | filterCount
- ${{ licenses: ['by'], mature: ['mature'] }} | ${IMAGE} | ${1}
- ${{ licenses: ['by'], searchBy: ['creator'] }} | ${ALL_MEDIA} | ${2}
- ${{ licenses: ['cc0', 'pdm', 'by', 'by-nc'] }} | ${ALL_MEDIA} | ${4}
- ${{ lengths: ['medium'] }} | ${AUDIO} | ${1}
- ${{ imageExtensions: ['svg'] }} | ${IMAGE} | ${1}
- ${{ audioExtensions: ['mp3'] }} | ${AUDIO} | ${1}
+ ${{ licenses: ["by"], mature: ["mature"] }} | ${IMAGE} | ${1}
+ ${{ licenses: ["by"], searchBy: ["creator"] }} | ${ALL_MEDIA} | ${2}
+ ${{ licenses: ["cc0", "pdm", "by", "by-nc"] }} | ${ALL_MEDIA} | ${4}
+ ${{ lengths: ["medium"] }} | ${AUDIO} | ${1}
+ ${{ imageExtensions: ["svg"] }} | ${IMAGE} | ${1}
+ ${{ audioExtensions: ["mp3"] }} | ${AUDIO} | ${1}
`(
- 'returns correct filter status for $query and searchType $searchType',
+ "returns correct filter status for $query and searchType $searchType",
({ query, searchType, filterCount }) => {
const searchStore = useSearchStore()
searchStore.setSearchType(searchType)
@@ -58,7 +58,7 @@ describe('Search Store', () => {
}
)
})
- describe('getters', () => {
+ describe("getters", () => {
/**
* For non-supported search types, the filters fall back to 'All content' filters.
* Number of displayed filters is one less than the number of mediaFilterKeys
@@ -71,10 +71,10 @@ describe('Search Store', () => {
${ALL_MEDIA} | ${mediaFilterKeys[ALL_MEDIA].length}
${VIDEO} | ${mediaFilterKeys[VIDEO].length}
`(
- 'mediaFiltersForDisplay returns $filterTypeCount filters for $searchType',
+ "mediaFiltersForDisplay returns $filterTypeCount filters for $searchType",
({ searchType, filterTypeCount }) => {
const featureFlagStore = useFeatureFlagStore()
- featureFlagStore.toggleFeature('external_sources', 'on')
+ featureFlagStore.toggleFeature("external_sources", "on")
const searchStore = useSearchStore()
searchStore.setSearchType(searchType)
@@ -95,44 +95,44 @@ describe('Search Store', () => {
*/
it.each`
query | searchType
- ${{ q: 'cat', license: 'by', mature: 'true' }} | ${IMAGE}
- ${{ license: 'by', mature: 'true' }} | ${IMAGE}
- ${{ license: '', mature: '' }} | ${IMAGE}
- ${{ q: 'cat', license: 'by', searchBy: 'creator' }} | ${ALL_MEDIA}
- ${{ q: 'cat', license: 'pdm,cc0,by,by-nc' }} | ${ALL_MEDIA}
- ${{ q: 'cat', length: 'medium' }} | ${AUDIO}
- ${{ q: 'cat', extension: 'svg' }} | ${IMAGE}
- ${{ q: 'cat', extension: 'svg' }} | ${AUDIO}
- ${{ q: 'cat', extension: 'mp3' }} | ${AUDIO}
+ ${{ q: "cat", license: "by", mature: "true" }} | ${IMAGE}
+ ${{ license: "by", mature: "true" }} | ${IMAGE}
+ ${{ license: "", mature: "" }} | ${IMAGE}
+ ${{ q: "cat", license: "by", searchBy: "creator" }} | ${ALL_MEDIA}
+ ${{ q: "cat", license: "pdm,cc0,by,by-nc" }} | ${ALL_MEDIA}
+ ${{ q: "cat", length: "medium" }} | ${AUDIO}
+ ${{ q: "cat", extension: "svg" }} | ${IMAGE}
+ ${{ q: "cat", extension: "svg" }} | ${AUDIO}
+ ${{ q: "cat", extension: "mp3" }} | ${AUDIO}
`(
- 'returns correct searchQueryParams and filter status for $query and searchType $searchType',
+ "returns correct searchQueryParams and filter status for $query and searchType $searchType",
({ query, searchType }) => {
const searchStore = useSearchStore()
const expectedQueryParams = query
// It should discard the values that are not applicable for the search type:
- if (searchType === AUDIO && query.extension === 'svg') {
+ if (searchType === AUDIO && query.extension === "svg") {
delete expectedQueryParams.extension
}
searchStore.setSearchStateFromUrl({
- path: `/search/${searchType === ALL_MEDIA ? '' : searchType}`,
+ path: `/search/${searchType === ALL_MEDIA ? "" : searchType}`,
urlQuery: { ...expectedQueryParams },
})
// Edge-case: query parameter value is a blank string
for (let param in expectedQueryParams) {
- if (expectedQueryParams[param] === '')
+ if (expectedQueryParams[param] === "")
delete expectedQueryParams[param]
}
// Should add a blank string as `q` value if `q` is not in query
- if (!('q' in expectedQueryParams)) {
- expectedQueryParams.q = ''
+ if (!("q" in expectedQueryParams)) {
+ expectedQueryParams.q = ""
}
expect(searchStore.searchQueryParams).toEqual(expectedQueryParams)
}
)
})
- describe('actions', () => {
- it.each(['foo', ''])(
- '`setSearchTerm correctly updates the searchTerm',
+ describe("actions", () => {
+ it.each(["foo", ""])(
+ "`setSearchTerm correctly updates the searchTerm",
(searchTerm) => {
const searchStore = useSearchStore()
const expectedSearchTerm = searchTerm
@@ -141,7 +141,7 @@ describe('Search Store', () => {
}
)
it.each(supportedSearchTypes)(
- 'setSearchType correctly updates the searchType',
+ "setSearchType correctly updates the searchType",
(type) => {
const searchStore = useSearchStore()
searchStore.setSearchType(type)
@@ -153,10 +153,10 @@ describe('Search Store', () => {
// TODO: add support for video path
it.each`
searchType | path
- ${'all'} | ${'/search/'}
- ${'image'} | ${'/search/image/'}
- ${'audio'} | ${'/search/audio/'}
- ${'video'} | ${'/search/video'}
+ ${"all"} | ${"/search/"}
+ ${"image"} | ${"/search/image/"}
+ ${"audio"} | ${"/search/audio/"}
+ ${"video"} | ${"/search/video"}
`(
"`setSearchStateFromUrl` should set searchType '$searchType' from path '$path'",
({ searchType, path }) => {
@@ -169,10 +169,10 @@ describe('Search Store', () => {
it.each`
query | path | searchType
- ${{ license: 'cc0,by', q: 'cat' }} | ${'/search/'} | ${ALL_MEDIA}
- ${{ searchBy: 'creator', q: 'dog' }} | ${'/search/image/'} | ${IMAGE}
- ${{ mature: 'true', q: 'galah' }} | ${'/search/audio/'} | ${AUDIO}
- ${{ length: 'medium' }} | ${'/search/image'} | ${IMAGE}
+ ${{ license: "cc0,by", q: "cat" }} | ${"/search/"} | ${ALL_MEDIA}
+ ${{ searchBy: "creator", q: "dog" }} | ${"/search/image/"} | ${IMAGE}
+ ${{ mature: "true", q: "galah" }} | ${"/search/audio/"} | ${AUDIO}
+ ${{ length: "medium" }} | ${"/search/image"} | ${IMAGE}
`(
"`setSearchStateFromUrl` should set '$searchType' from query $query and path '$path'",
({ query, path, searchType }) => {
@@ -192,13 +192,13 @@ describe('Search Store', () => {
it.each`
filters | query
- ${[['licenses', 'by'], ['licenses', 'by-nc-sa']]} | ${['license', 'by,by-nc-sa']}
- ${[['licenseTypes', 'commercial'], ['licenseTypes', 'modification']]} | ${['license_type', 'commercial,modification']}
- ${[['searchBy', 'creator']]} | ${['searchBy', 'creator']}
- ${[['mature', 'mature']]} | ${['mature', 'true']}
- ${[['sizes', 'large']]} | ${['size', undefined]}
+ ${[["licenses", "by"], ["licenses", "by-nc-sa"]]} | ${["license", "by,by-nc-sa"]}
+ ${[["licenseTypes", "commercial"], ["licenseTypes", "modification"]]} | ${["license_type", "commercial,modification"]}
+ ${[["searchBy", "creator"]]} | ${["searchBy", "creator"]}
+ ${[["mature", "mature"]]} | ${["mature", "true"]}
+ ${[["sizes", "large"]]} | ${["size", undefined]}
`(
- 'toggleFilter updates the query values to $query',
+ "toggleFilter updates the query values to $query",
({ filters, query }) => {
const searchStore = useSearchStore()
for (const filterItem of filters) {
@@ -210,17 +210,17 @@ describe('Search Store', () => {
)
it.each([ALL_MEDIA, IMAGE, AUDIO, VIDEO])(
- 'Clears filters when search type is %s',
+ "Clears filters when search type is %s",
(searchType) => {
const searchStore = useSearchStore()
- const expectedQueryParams = { q: 'cat' }
+ const expectedQueryParams = { q: "cat" }
searchStore.setSearchStateFromUrl({
- path: `/search/${searchType === ALL_MEDIA ? '' : searchType}`,
+ path: `/search/${searchType === ALL_MEDIA ? "" : searchType}`,
urlQuery: {
- q: 'cat',
- license: 'cc0',
- sizes: 'large',
- extension: 'jpg,mp3',
+ q: "cat",
+ license: "cc0",
+ sizes: "large",
+ extension: "jpg,mp3",
},
})
if (supportedSearchTypes.includes(searchType)) {
@@ -231,19 +231,19 @@ describe('Search Store', () => {
}
)
})
- describe('actions', () => {
+ describe("actions", () => {
it.each`
filterType | codeIdx
- ${'licenses'} | ${0}
- ${'licenseTypes'} | ${0}
- ${'imageExtensions'} | ${0}
- ${'imageCategories'} | ${0}
- ${'searchBy'} | ${0}
- ${'aspectRatios'} | ${0}
- ${'sizes'} | ${0}
- ${'mature'} | ${0}
+ ${"licenses"} | ${0}
+ ${"licenseTypes"} | ${0}
+ ${"imageExtensions"} | ${0}
+ ${"imageCategories"} | ${0}
+ ${"searchBy"} | ${0}
+ ${"aspectRatios"} | ${0}
+ ${"sizes"} | ${0}
+ ${"mature"} | ${0}
`(
- 'toggleFilter updates $filterType filter state',
+ "toggleFilter updates $filterType filter state",
({ filterType, codeIdx }) => {
const searchStore = useSearchStore()
@@ -253,72 +253,72 @@ describe('Search Store', () => {
}
)
- it('toggleFilter updates isFilterApplied with provider', () => {
+ it("toggleFilter updates isFilterApplied with provider", () => {
const searchStore = useSearchStore()
searchStore.setSearchType(IMAGE)
searchStore.updateProviderFilters({
mediaType: IMAGE,
- providers: [{ source_name: 'met', display_name: 'Met' }],
+ providers: [{ source_name: "met", display_name: "Met" }],
})
- searchStore.toggleFilter({ filterType: 'imageProviders', code: 'met' })
+ searchStore.toggleFilter({ filterType: "imageProviders", code: "met" })
expect(searchStore.appliedFilterCount).toEqual(1)
expect(searchStore.isAnyFilterApplied).toEqual(true)
})
- it('toggleFilter updates isFilterApplied with license type', () => {
+ it("toggleFilter updates isFilterApplied with license type", () => {
const searchStore = useSearchStore()
- searchStore.toggleFilter({ filterType: 'licenseTypes', codeIdx: 0 })
+ searchStore.toggleFilter({ filterType: "licenseTypes", codeIdx: 0 })
expect(searchStore.isAnyFilterApplied).toEqual(true)
})
- it('updateProviderFilters merges with existing provider filters', () => {
+ it("updateProviderFilters merges with existing provider filters", () => {
const searchStore = useSearchStore()
- const existingProviderFilters = [{ code: 'met', checked: true }]
+ const existingProviderFilters = [{ code: "met", checked: true }]
searchStore.$patch({
filters: { imageProviders: existingProviderFilters },
})
const providers = [
- { source_name: 'met', display_name: 'Metropolitan' },
- { source_name: 'flickr', display_name: 'Flickr' },
+ { source_name: "met", display_name: "Metropolitan" },
+ { source_name: "flickr", display_name: "Flickr" },
]
searchStore.updateProviderFilters({
- mediaType: 'image',
+ mediaType: "image",
providers: providers,
})
expect(searchStore.filters.imageProviders).toEqual([
- { code: 'met', name: 'Metropolitan', checked: true },
- { code: 'flickr', name: 'Flickr', checked: false },
+ { code: "met", name: "Metropolitan", checked: true },
+ { code: "flickr", name: "Flickr", checked: false },
])
})
- it('clearFilters resets filters to initial state', () => {
+ it("clearFilters resets filters to initial state", () => {
const searchStore = useSearchStore()
- searchStore.toggleFilter({ filterType: 'licenses', code: 'by' })
- searchStore.toggleFilter({ filterType: 'licenses', code: 'by-nc' })
- searchStore.toggleFilter({ filterType: 'licenses', code: 'by-nd' })
+ searchStore.toggleFilter({ filterType: "licenses", code: "by" })
+ searchStore.toggleFilter({ filterType: "licenses", code: "by-nc" })
+ searchStore.toggleFilter({ filterType: "licenses", code: "by-nd" })
searchStore.clearFilters()
expect(searchStore.filters).toEqual(filterData)
})
- it('clearFilters sets providers filters checked to false', () => {
+ it("clearFilters sets providers filters checked to false", () => {
const searchStore = useSearchStore()
searchStore.filters.imageProviders = [
- { code: 'met', name: 'Metropolitan', checked: true },
- { code: 'flickr', name: 'Flickr', checked: false },
+ { code: "met", name: "Metropolitan", checked: true },
+ { code: "flickr", name: "Flickr", checked: false },
]
searchStore.clearFilters()
const expectedFilters = {
...searchStore.filters,
imageProviders: [
- { code: 'met', name: 'Metropolitan', checked: false },
- { code: 'flickr', name: 'Flickr', checked: false },
+ { code: "met", name: "Metropolitan", checked: false },
+ { code: "flickr", name: "Flickr", checked: false },
],
}
expect(searchStore.filters).toEqual(expectedFilters)
@@ -326,14 +326,14 @@ describe('Search Store', () => {
it.each`
filterType | code | idx
- ${'licenses'} | ${'cc0'} | ${1}
- ${'licenseTypes'} | ${'modification'} | ${1}
- ${'imageExtensions'} | ${'svg'} | ${3}
- ${'imageCategories'} | ${'photograph'} | ${0}
- ${'searchBy'} | ${'creator'} | ${0}
- ${'mature'} | ${'mature'} | ${-0}
- ${'aspectRatios'} | ${'tall'} | ${0}
- ${'sizes'} | ${'medium'} | ${1}
+ ${"licenses"} | ${"cc0"} | ${1}
+ ${"licenseTypes"} | ${"modification"} | ${1}
+ ${"imageExtensions"} | ${"svg"} | ${3}
+ ${"imageCategories"} | ${"photograph"} | ${0}
+ ${"searchBy"} | ${"creator"} | ${0}
+ ${"mature"} | ${"mature"} | ${-0}
+ ${"aspectRatios"} | ${"tall"} | ${0}
+ ${"sizes"} | ${"medium"} | ${1}
`(
"toggleFilter should set filter '$code' of type '$filterType",
({ filterType, code, idx }) => {
@@ -347,20 +347,20 @@ describe('Search Store', () => {
)
it.each`
item | dependency | disabled
- ${{ code: 'by-nc', filterType: 'licenses' }} | ${{ filterType: 'licenseTypes', code: 'commercial' }} | ${true}
- ${{ code: 'by-nc-nd', filterType: 'licenses' }} | ${{ filterType: 'licenseTypes', code: 'commercial' }} | ${true}
- ${{ code: 'by-nc-sa', filterType: 'licenses' }} | ${{ filterType: 'licenseTypes', code: 'commercial' }} | ${true}
- ${{ code: 'by-nd', filterType: 'licenses' }} | ${{ filterType: 'licenseTypes', code: 'modification' }} | ${true}
- ${{ code: 'by-nc-nd', filterType: 'licenses' }} | ${{ filterType: 'licenseTypes', code: 'modification' }} | ${true}
- ${{ code: 'by-nc', filterType: 'licenses' }} | ${{ filterType: 'licenseTypes', code: 'modification' }} | ${false}
- ${{ code: 'by-nd', filterType: 'licenses' }} | ${{ filterType: 'licenseTypes', code: 'commercial' }} | ${false}
- ${{ code: 'commercial', filterType: 'licenseTypes' }} | ${{ filterType: 'licenses', code: 'by-nc' }} | ${true}
- ${{ code: 'commercial', filterType: 'licenseTypes' }} | ${{ filterType: 'licenses', code: 'by-nc-nd' }} | ${true}
- ${{ code: 'commercial', filterType: 'licenseTypes' }} | ${{ filterType: 'licenses', code: 'by-nc-sa' }} | ${true}
- ${{ code: 'modification', filterType: 'licenseTypes' }} | ${{ filterType: 'licenses', code: 'by-nd' }} | ${true}
- ${{ code: 'modification', filterType: 'licenseTypes' }} | ${{ filterType: 'licenses', code: 'by-nc-nd' }} | ${true}
+ ${{ code: "by-nc", filterType: "licenses" }} | ${{ filterType: "licenseTypes", code: "commercial" }} | ${true}
+ ${{ code: "by-nc-nd", filterType: "licenses" }} | ${{ filterType: "licenseTypes", code: "commercial" }} | ${true}
+ ${{ code: "by-nc-sa", filterType: "licenses" }} | ${{ filterType: "licenseTypes", code: "commercial" }} | ${true}
+ ${{ code: "by-nd", filterType: "licenses" }} | ${{ filterType: "licenseTypes", code: "modification" }} | ${true}
+ ${{ code: "by-nc-nd", filterType: "licenses" }} | ${{ filterType: "licenseTypes", code: "modification" }} | ${true}
+ ${{ code: "by-nc", filterType: "licenses" }} | ${{ filterType: "licenseTypes", code: "modification" }} | ${false}
+ ${{ code: "by-nd", filterType: "licenses" }} | ${{ filterType: "licenseTypes", code: "commercial" }} | ${false}
+ ${{ code: "commercial", filterType: "licenseTypes" }} | ${{ filterType: "licenses", code: "by-nc" }} | ${true}
+ ${{ code: "commercial", filterType: "licenseTypes" }} | ${{ filterType: "licenses", code: "by-nc-nd" }} | ${true}
+ ${{ code: "commercial", filterType: "licenseTypes" }} | ${{ filterType: "licenses", code: "by-nc-sa" }} | ${true}
+ ${{ code: "modification", filterType: "licenseTypes" }} | ${{ filterType: "licenses", code: "by-nd" }} | ${true}
+ ${{ code: "modification", filterType: "licenseTypes" }} | ${{ filterType: "licenses", code: "by-nc-nd" }} | ${true}
`(
- 'isFilterDisabled for $item.code should return $disabled when $dependency.code is checked',
+ "isFilterDisabled for $item.code should return $disabled when $dependency.code is checked",
({ item, dependency, disabled }) => {
const searchStore = useSearchStore()
searchStore.toggleFilter({
@@ -372,14 +372,14 @@ describe('Search Store', () => {
}
)
- it('toggleFilter without code or codeIdx parameters warns about it', () => {
+ it("toggleFilter without code or codeIdx parameters warns about it", () => {
const searchStore = useSearchStore()
const expectedFilters = searchStore.filters
expect(() =>
- searchStore.toggleFilter({ filterType: 'licenses' })
+ searchStore.toggleFilter({ filterType: "licenses" })
).toThrow(
- 'Cannot toggle filter of type licenses. Use code or codeIdx parameter'
+ "Cannot toggle filter of type licenses. Use code or codeIdx parameter"
)
expect(searchStore.filters).toEqual(expectedFilters)
@@ -394,13 +394,13 @@ describe('Search Store', () => {
${VIDEO} | ${AUDIO} | ${30}
${ALL_MEDIA} | ${IMAGE} | ${25}
`(
- 'changing searchType from $searchType clears all but $expectedFilterCount $nextSearchType filters',
+ "changing searchType from $searchType clears all but $expectedFilterCount $nextSearchType filters",
async ({ searchType, nextSearchType, expectedFilterCount }) => {
const searchStore = useSearchStore()
searchStore.setSearchType(searchType)
const featureFlagStore = useFeatureFlagStore()
- featureFlagStore.toggleFeature('external_sources', 'on')
+ featureFlagStore.toggleFeature("external_sources", "on")
// Set all filters to checked
for (let ft in searchStore.filters) {
@@ -420,59 +420,59 @@ describe('Search Store', () => {
}
)
- it('Does not set filter or count filter as applied, and does not raise error for unsupported search types', () => {
+ it("Does not set filter or count filter as applied, and does not raise error for unsupported search types", () => {
const searchStore = useSearchStore()
const featureFlagStore = useFeatureFlagStore()
- featureFlagStore.toggleFeature('external_sources', 'on')
+ featureFlagStore.toggleFeature("external_sources", "on")
searchStore.toggleFilter({
- filterType: 'licenseTypes',
- code: 'commercial',
+ filterType: "licenseTypes",
+ code: "commercial",
})
expect(searchStore.isAnyFilterApplied).toEqual(true)
searchStore.setSearchType(VIDEO)
searchStore.toggleFilter({
- filterType: 'licenseTypes',
- code: 'commercial',
+ filterType: "licenseTypes",
+ code: "commercial",
})
expect(searchStore.isAnyFilterApplied).toEqual(false)
})
- describe('Recent searches', () => {
- it('are saved, without duplication and not exceeding the limit.', () => {
+ describe("Recent searches", () => {
+ it("are saved, without duplication and not exceeding the limit.", () => {
const searchStore = useSearchStore()
const featureFlagStore = useFeatureFlagStore()
- featureFlagStore.toggleFeature('new_header', 'on')
+ featureFlagStore.toggleFeature("new_header", "on")
- searchStore.setSearchTerm('boop')
- searchStore.setSearchTerm('bar')
- searchStore.setSearchTerm('foo')
- searchStore.setSearchTerm('baz')
- searchStore.setSearchTerm('boom')
- searchStore.setSearchTerm('foo')
+ searchStore.setSearchTerm("boop")
+ searchStore.setSearchTerm("bar")
+ searchStore.setSearchTerm("foo")
+ searchStore.setSearchTerm("baz")
+ searchStore.setSearchTerm("boom")
+ searchStore.setSearchTerm("foo")
expect(searchStore.recentSearches).toEqual([
- 'foo',
- 'boom',
- 'baz',
- 'bar',
+ "foo",
+ "boom",
+ "baz",
+ "bar",
])
expect(searchStore.recentSearches.length).toEqual(
parseInt(env.savedSearchCount)
)
})
- it('can be cleared', () => {
+ it("can be cleared", () => {
const searchStore = useSearchStore()
const featureFlagStore = useFeatureFlagStore()
- featureFlagStore.toggleFeature('new_header', 'on')
+ featureFlagStore.toggleFeature("new_header", "on")
// Clear up front in case of any preserved searches
searchStore.clearRecentSearches()
- searchStore.setSearchTerm('boop')
- searchStore.setSearchTerm('bar')
+ searchStore.setSearchTerm("boop")
+ searchStore.setSearchTerm("bar")
- expect(searchStore.recentSearches).toEqual(['bar', 'boop'])
+ expect(searchStore.recentSearches).toEqual(["bar", "boop"])
searchStore.clearRecentSearches()
diff --git a/test/unit/specs/stores/single-result-store.spec.js b/test/unit/specs/stores/single-result-store.spec.js
index 1ef7d6a23..d87e2cbbf 100644
--- a/test/unit/specs/stores/single-result-store.spec.js
+++ b/test/unit/specs/stores/single-result-store.spec.js
@@ -1,16 +1,16 @@
-import { createPinia, setActivePinia } from '~~/test/unit/test-utils/pinia'
+import { createPinia, setActivePinia } from "~~/test/unit/test-utils/pinia"
-import { AUDIO, IMAGE, supportedMediaTypes } from '~/constants/media'
-import { useMediaStore } from '~/stores/media'
-import { useSingleResultStore } from '~/stores/media/single-result'
+import { AUDIO, IMAGE, supportedMediaTypes } from "~/constants/media"
+import { useMediaStore } from "~/stores/media"
+import { useSingleResultStore } from "~/stores/media/single-result"
const detailData = {
- [AUDIO]: { title: 'audioDetails', id: 'audio1', frontendMediaType: AUDIO },
- [IMAGE]: { title: 'imageDetails', id: 'image1', frontendMediaType: IMAGE },
+ [AUDIO]: { title: "audioDetails", id: "audio1", frontendMediaType: AUDIO },
+ [IMAGE]: { title: "imageDetails", id: "image1", frontendMediaType: IMAGE },
}
-jest.mock('axios', () => ({
- ...jest.requireActual('axios'),
- isAxiosError: jest.fn((obj) => 'response' in obj),
+jest.mock("axios", () => ({
+ ...jest.requireActual("axios"),
+ isAxiosError: jest.fn((obj) => "response" in obj),
}))
const mockImplementation = (mediaType) => () =>
@@ -25,7 +25,7 @@ const mocks = {
audio: mockGetMediaDetailAudio,
image: mockGetMediaDetailImage,
}
-jest.mock('~/stores/media/services', () => ({
+jest.mock("~/stores/media/services", () => ({
initServices: {
audio: () =>
/** @type {import('~/data/services').MediaService} */ ({
@@ -38,9 +38,9 @@ jest.mock('~/stores/media/services', () => ({
},
}))
-describe('Media Item Store', () => {
- describe('state', () => {
- it('sets default state', () => {
+describe("Media Item Store", () => {
+ describe("state", () => {
+ it("sets default state", () => {
setActivePinia(createPinia())
const singleResultStore = useSingleResultStore()
expect(singleResultStore.fetchState).toEqual({
@@ -53,7 +53,7 @@ describe('Media Item Store', () => {
})
})
- describe('actions', () => {
+ describe("actions", () => {
beforeEach(() => {
setActivePinia(createPinia())
useMediaStore()
@@ -64,16 +64,16 @@ describe('Media Item Store', () => {
})
it.each(supportedMediaTypes)(
- 'fetchMediaItem (%s) fetches a new media if none is found in the store',
+ "fetchMediaItem (%s) fetches a new media if none is found in the store",
async (type) => {
const singleResultStore = useSingleResultStore()
- await singleResultStore.fetchMediaItem(type, 'foo')
+ await singleResultStore.fetchMediaItem(type, "foo")
expect(singleResultStore.mediaItem).toEqual(detailData[type])
}
)
it.each(supportedMediaTypes)(
- 'fetchMediaItem (%s) re-uses existing media from the store',
+ "fetchMediaItem (%s) re-uses existing media from the store",
async (type) => {
const singleResultStore = useSingleResultStore()
const mediaStore = useMediaStore()
@@ -86,9 +86,9 @@ describe('Media Item Store', () => {
)
it.each(supportedMediaTypes)(
- 'fetchMediaItem throws not found error on request error',
+ "fetchMediaItem throws not found error on request error",
async (type) => {
- const expectedErrorMessage = 'error'
+ const expectedErrorMessage = "error"
mocks[type].mockImplementationOnce(() =>
Promise.reject(new Error(expectedErrorMessage))
@@ -97,19 +97,19 @@ describe('Media Item Store', () => {
const singleResultStore = useSingleResultStore()
await expect(() =>
- singleResultStore.fetchMediaItem(type, 'foo')
+ singleResultStore.fetchMediaItem(type, "foo")
).rejects.toThrow(expectedErrorMessage)
}
)
it.each(supportedMediaTypes)(
- 'fetchMediaItem on 404 sets fetchingError and throws a new error',
+ "fetchMediaItem on 404 sets fetchingError and throws a new error",
async (type) => {
mocks[type].mockImplementationOnce(() =>
Promise.reject({ response: { status: 404 } })
)
const singleResultStore = useSingleResultStore()
- const id = 'foo'
+ const id = "foo"
await expect(() =>
singleResultStore.fetchMediaItem(type, id)
).rejects.toThrow(`Media of type ${type} with id ${id} not found`)
diff --git a/test/unit/specs/stores/ui-store.spec.js b/test/unit/specs/stores/ui-store.spec.js
index 2f55ccfe3..a5a9b8712 100644
--- a/test/unit/specs/stores/ui-store.spec.js
+++ b/test/unit/specs/stores/ui-store.spec.js
@@ -1,9 +1,9 @@
-import { setActivePinia, createPinia } from '~~/test/unit/test-utils/pinia'
+import { setActivePinia, createPinia } from "~~/test/unit/test-utils/pinia"
-import { useUiStore } from '~/stores/ui'
+import { useUiStore } from "~/stores/ui"
const initialState = {
- instructionsSnackbarState: 'not_shown',
+ instructionsSnackbarState: "not_shown",
innerFilterVisible: false,
isFilterDismissed: false,
isDesktopLayout: false,
@@ -30,17 +30,17 @@ const NOT_VISIBLE_AND_NOT_DISMISSED = {
const cookieOptions = {
maxAge: 5184000,
- path: '/',
- sameSite: 'none',
+ path: "/",
+ sameSite: "none",
secure: false,
}
-describe('Ui Store', () => {
+describe("Ui Store", () => {
beforeEach(() => {
setActivePinia(createPinia())
})
- describe('state', () => {
- it('sets the initial state correctly', () => {
+ describe("state", () => {
+ it("sets the initial state correctly", () => {
const uiStore = useUiStore()
for (const key of Object.keys(initialState)) {
expect(uiStore[key]).toEqual(initialState[key])
@@ -48,14 +48,14 @@ describe('Ui Store', () => {
})
})
- describe('getters', () => {
+ describe("getters", () => {
test.each`
status | isVisible
- ${'not_shown'} | ${false}
- ${'visible'} | ${true}
- ${'dismissed'} | ${false}
+ ${"not_shown"} | ${false}
+ ${"visible"} | ${true}
+ ${"dismissed"} | ${false}
`(
- 'areInstructionsVisible return $isVisible when status is $status',
+ "areInstructionsVisible return $isVisible when status is $status",
({ status, isVisible }) => {
const uiStore = useUiStore()
uiStore.$patch({ instructionsSnackbarState: status })
@@ -75,7 +75,7 @@ describe('Ui Store', () => {
${false} | ${false} | ${true} | ${false}
${false} | ${false} | ${false} | ${false}
`(
- 'isFilterVisible return $isVisible when isDesktopLayout is $isDesktopLayout, innerFilterVisible is $innerFilterVisible, and isFilterDismissed is $isFilterDismissed',
+ "isFilterVisible return $isVisible when isDesktopLayout is $isDesktopLayout, innerFilterVisible is $innerFilterVisible, and isFilterDismissed is $isFilterDismissed",
({
innerFilterVisible,
isFilterDismissed,
@@ -94,14 +94,14 @@ describe('Ui Store', () => {
)
})
- describe('actions', () => {
- it('initFromCookies sets initial state without cookie', () => {
+ describe("actions", () => {
+ it("initFromCookies sets initial state without cookie", () => {
const uiStore = useUiStore()
uiStore.initFromCookies({})
for (const key of Object.keys(initialState)) {
// isMobileUa is set to true only if we explicitly get a mobile UA
// from cookie or the browser request
- if (key === 'isMobileUa') {
+ if (key === "isMobileUa") {
expect(uiStore[key]).toEqual(false)
} else {
expect(uiStore[key]).toEqual(initialState[key])
@@ -109,39 +109,39 @@ describe('Ui Store', () => {
}
})
- it('initFromCookies sets initial state with a desktop cookie', () => {
+ it("initFromCookies sets initial state with a desktop cookie", () => {
const uiStore = useUiStore()
uiStore.initFromCookies({
- uiBreakpoint: 'lg',
+ uiBreakpoint: "lg",
uiIsFilterDismissed: true,
})
- expect(uiStore.instructionsSnackbarState).toEqual('not_shown')
- expect(uiStore.breakpoint).toEqual('lg')
+ expect(uiStore.instructionsSnackbarState).toEqual("not_shown")
+ expect(uiStore.breakpoint).toEqual("lg")
expect(uiStore.isDesktopLayout).toEqual(true)
expect(uiStore.isMobileUa).toEqual(false)
expect(uiStore.isFilterVisible).toEqual(false)
expect(uiStore.isFilterDismissed).toEqual(true)
})
- it('initFromCookies sets initial state with a mobile cookie', () => {
+ it("initFromCookies sets initial state with a mobile cookie", () => {
const uiStore = useUiStore()
uiStore.initFromCookies({
uiIsMobileUa: true,
uiIsFilterDismissed: false,
})
- expect(uiStore.instructionsSnackbarState).toEqual('not_shown')
+ expect(uiStore.instructionsSnackbarState).toEqual("not_shown")
expect(uiStore.isDesktopLayout).toEqual(false)
- expect(uiStore.breakpoint).toEqual('sm')
+ expect(uiStore.breakpoint).toEqual("sm")
expect(uiStore.isMobileUa).toEqual(true)
expect(uiStore.isFilterDismissed).toEqual(false)
expect(uiStore.isFilterVisible).toEqual(false)
})
- it('initFromCookies sets initial state with a dismissed banner', () => {
+ it("initFromCookies sets initial state with a dismissed banner", () => {
const uiStore = useUiStore()
- const dismissedBanners = ['ru', 'ar', 'cc-referral']
+ const dismissedBanners = ["ru", "ar", "cc-referral"]
uiStore.initFromCookies({
uiDismissedBanners: dismissedBanners,
})
@@ -152,11 +152,11 @@ describe('Ui Store', () => {
test.each`
before | after
- ${'not_shown'} | ${'visible'}
- ${'visible'} | ${'visible'}
- ${'dismissed'} | ${'dismissed'}
+ ${"not_shown"} | ${"visible"}
+ ${"visible"} | ${"visible"}
+ ${"dismissed"} | ${"dismissed"}
`(
- 'showInstructionsSnackbar changes instructionsSnackbarState from $before to $after',
+ "showInstructionsSnackbar changes instructionsSnackbarState from $before to $after",
({ before, after }) => {
const uiStore = useUiStore()
uiStore.$patch({ instructionsSnackbarState: before })
@@ -168,11 +168,11 @@ describe('Ui Store', () => {
test.each`
before | after
- ${'not_shown'} | ${'dismissed'}
- ${'visible'} | ${'dismissed'}
- ${'dismissed'} | ${'dismissed'}
+ ${"not_shown"} | ${"dismissed"}
+ ${"visible"} | ${"dismissed"}
+ ${"dismissed"} | ${"dismissed"}
`(
- 'hideInstructionsSnackbar changes instructionsSnackbarState from $before to $after',
+ "hideInstructionsSnackbar changes instructionsSnackbarState from $before to $after",
({ before, after }) => {
const uiStore = useUiStore()
uiStore.$patch({ instructionsSnackbarState: before })
@@ -184,10 +184,10 @@ describe('Ui Store', () => {
test.each`
initialState | breakpoint | expected
- ${[true, false]} | ${'xm'} | ${{ isDesktopLayout: false, isMobileUa: false }}
- ${[false, true]} | ${'lg'} | ${{ isDesktopLayout: true, isMobileUa: true }}
+ ${[true, false]} | ${"xm"} | ${{ isDesktopLayout: false, isMobileUa: false }}
+ ${[false, true]} | ${"lg"} | ${{ isDesktopLayout: true, isMobileUa: true }}
`(
- 'updateBreakpoint gets breakpoint $breakpoint and returns $expected',
+ "updateBreakpoint gets breakpoint $breakpoint and returns $expected",
({ initialState, breakpoint, expected }) => {
const uiStore = useUiStore()
uiStore.$patch({
@@ -216,7 +216,7 @@ describe('Ui Store', () => {
${false} | ${NOT_VISIBLE_AND_DISMISSED} | ${true} | ${VISIBLE_AND_DISMISSED}
${false} | ${NOT_VISIBLE_AND_DISMISSED} | ${false} | ${NOT_VISIBLE_AND_DISMISSED}
`(
- 'setFiltersState sets state to $expectedState when visible is $visible and isDesktopLayout is $isDesktopLayout',
+ "setFiltersState sets state to $expectedState when visible is $visible and isDesktopLayout is $isDesktopLayout",
({ isDesktopLayout, currentState, visible, expectedState }) => {
const uiStore = useUiStore()
uiStore.$patch({
@@ -243,7 +243,7 @@ describe('Ui Store', () => {
${false} | ${VISIBLE_AND_NOT_DISMISSED} | ${NOT_VISIBLE_AND_NOT_DISMISSED}
${false} | ${NOT_VISIBLE_AND_DISMISSED} | ${VISIBLE_AND_DISMISSED}
`(
- 'toggleFilters sets state to $expectedState when isDesktopLayout is $isDesktopLayout',
+ "toggleFilters sets state to $expectedState when isDesktopLayout is $isDesktopLayout",
({ isDesktopLayout, currentState, expectedState }) => {
const uiStore = useUiStore()
uiStore.$patch({
@@ -259,11 +259,11 @@ describe('Ui Store', () => {
)
it.each`
originalState | bannerId | expectedState | areCookiesSet
- ${[]} | ${'es'} | ${['es']} | ${true}
- ${['es']} | ${'es'} | ${['es']} | ${false}
- ${['cc-referral', 'es']} | ${'de'} | ${['cc-referral', 'es', 'de']} | ${true}
+ ${[]} | ${"es"} | ${["es"]} | ${true}
+ ${["es"]} | ${"es"} | ${["es"]} | ${false}
+ ${["cc-referral", "es"]} | ${"de"} | ${["cc-referral", "es", "de"]} | ${true}
`(
- 'dismissBanner($bannerId): $originalState -> $expectedState',
+ "dismissBanner($bannerId): $originalState -> $expectedState",
({ originalState, bannerId, expectedState, areCookiesSet }) => {
const uiStore = useUiStore()
uiStore.$patch({ dismissedBanners: originalState })
@@ -272,7 +272,7 @@ describe('Ui Store', () => {
expect(uiStore.dismissedBanners).toEqual(expectedState)
if (areCookiesSet) {
expect(uiStore.$nuxt.$cookies.set).toHaveBeenCalledWith(
- 'uiDismissedBanners',
+ "uiDismissedBanners",
expectedState,
cookieOptions
)
@@ -281,11 +281,11 @@ describe('Ui Store', () => {
)
it.each`
originalState | bannerId | expectedState
- ${[]} | ${'es'} | ${false}
- ${['es']} | ${'es'} | ${true}
- ${['cc-referral', 'es']} | ${'de'} | ${false}
+ ${[]} | ${"es"} | ${false}
+ ${["es"]} | ${"es"} | ${true}
+ ${["cc-referral", "es"]} | ${"de"} | ${false}
`(
- 'isBannerDismissed($bannerId) for $originalState returns $expectedState',
+ "isBannerDismissed($bannerId) for $originalState returns $expectedState",
({ originalState, bannerId, expectedState }) => {
const uiStore = useUiStore()
uiStore.$patch({ dismissedBanners: originalState })
diff --git a/test/unit/specs/utils/attribution-html.spec.ts b/test/unit/specs/utils/attribution-html.spec.ts
index 01da747a7..fff242474 100644
--- a/test/unit/specs/utils/attribution-html.spec.ts
+++ b/test/unit/specs/utils/attribution-html.spec.ts
@@ -1,32 +1,32 @@
-import Vuei18n from 'vue-i18n'
+import Vuei18n from "vue-i18n"
-import type { AttributableMedia } from '~/utils/attribution-html'
-import { getAttribution } from '~/utils/attribution-html'
-import enMessages from '~/locales/en.json'
+import type { AttributableMedia } from "~/utils/attribution-html"
+import { getAttribution } from "~/utils/attribution-html"
+import enMessages from "~/locales/en.json"
const i18n = new Vuei18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: enMessages },
})
const mediaItem: AttributableMedia = {
- originalTitle: 'Title',
- foreign_landing_url: 'https://foreign.landing/url',
- creator: 'Creator',
- creator_url: 'https://creator/url',
- license: 'pdm',
- license_version: '1.0',
- license_url: 'https://license/url',
+ originalTitle: "Title",
+ foreign_landing_url: "https://foreign.landing/url",
+ creator: "Creator",
+ creator_url: "https://creator/url",
+ license: "pdm",
+ license_version: "1.0",
+ license_url: "https://license/url",
}
-describe('getAttribution', () => {
+describe("getAttribution", () => {
it.each`
sendI18n | attributionText
${true} | ${'"Title" by Creator is marked with Public Domain Mark 1.0 .'}
${false} | ${'"Title" by Creator is marked with PDM 1.0 .'}
`(
- 'returns attribution for media with i18n $sendI18n',
+ "returns attribution for media with i18n $sendI18n",
({
sendI18n,
attributionText,
@@ -38,22 +38,22 @@ describe('getAttribution', () => {
mediaItem,
sendI18n ? i18n : null
)
- const attributionP = document.getElementsByClassName('attribution')[0]
+ const attributionP = document.getElementsByClassName("attribution")[0]
expect(attributionP.textContent?.trim()).toEqual(attributionText)
}
)
- it('uses generic title if not known', () => {
- const mediaItemNoTitle = { ...mediaItem, originalTitle: '' }
+ it("uses generic title if not known", () => {
+ const mediaItemNoTitle = { ...mediaItem, originalTitle: "" }
const attrText = getAttribution(mediaItemNoTitle, i18n, {
isPlaintext: true,
})
const expectation =
- 'This work by Creator is marked with Public Domain Mark 1.0'
+ "This work by Creator is marked with Public Domain Mark 1.0"
expect(attrText).toContain(expectation)
})
- it('omits creator if not known', () => {
+ it("omits creator if not known", () => {
const mediaItemNoCreator = { ...mediaItem, creator: undefined }
const attrText = getAttribution(mediaItemNoCreator, i18n, {
isPlaintext: true,
@@ -62,37 +62,37 @@ describe('getAttribution', () => {
expect(attrText).toContain(expectation)
})
- it('does not use anchors in plain-text mode', () => {
+ it("does not use anchors in plain-text mode", () => {
document.body.innerHTML = getAttribution(mediaItem, i18n)
- expect(document.getElementsByTagName('a').length !== 0)
+ expect(document.getElementsByTagName("a").length !== 0)
document.body.innerHTML = getAttribution(mediaItem, i18n, {
isPlaintext: true,
})
- expect(document.getElementsByTagName('a').length === 0)
+ expect(document.getElementsByTagName("a").length === 0)
})
- it('renders the correct text in plain-text mode', () => {
+ it("renders the correct text in plain-text mode", () => {
const attrText = getAttribution(mediaItem, i18n, { isPlaintext: true })
const expectation =
'"Title" by Creator is marked with Public Domain Mark 1.0. To view the terms, visit https://license/url?ref=openverse.'
expect(attrText).toEqual(expectation)
})
- it('skips the link if URL is missing', () => {
+ it("skips the link if URL is missing", () => {
const mediaItemNoLicenseUrl = { ...mediaItem, license_url: undefined }
const attrText = getAttribution(mediaItemNoLicenseUrl, i18n, {
isPlaintext: true,
})
- const antiExpectation = 'To view'
+ const antiExpectation = "To view"
expect(attrText).not.toContain(antiExpectation)
})
- it('does not add license element icons in no-icons mode', () => {
+ it("does not add license element icons in no-icons mode", () => {
document.body.innerHTML = getAttribution(mediaItem, i18n)
- expect(document.getElementsByTagName('img').length !== 0)
+ expect(document.getElementsByTagName("img").length !== 0)
document.body.innerHTML = getAttribution(mediaItem, i18n, {
includeIcons: false,
})
- expect(document.getElementsByTagName('img').length === 0)
+ expect(document.getElementsByTagName("img").length === 0)
})
})
diff --git a/test/unit/specs/utils/decode-data.spec.js b/test/unit/specs/utils/decode-data.spec.js
index 4de26cc8e..32371cf5c 100644
--- a/test/unit/specs/utils/decode-data.spec.js
+++ b/test/unit/specs/utils/decode-data.spec.js
@@ -1,38 +1,38 @@
-import { decodeData } from '~/utils/decode-data'
+import { decodeData } from "~/utils/decode-data"
-describe('decodeData', () => {
- it('returns empty string for empty string', () => {
- const data = ''
+describe("decodeData", () => {
+ it("returns empty string for empty string", () => {
+ const data = ""
- expect(decodeData(data)).toEqual('')
+ expect(decodeData(data)).toEqual("")
})
- it('returns empty string for undefined data', () => {
+ it("returns empty string for undefined data", () => {
const data = undefined
- expect(decodeData(data)).toEqual('')
+ expect(decodeData(data)).toEqual("")
})
- it('returns decoded ASCII hexacode strings', () => {
- const data = 's\\xe9'
+ it("returns decoded ASCII hexacode strings", () => {
+ const data = "s\\xe9"
- expect(decodeData(data)).toBe('sé')
+ expect(decodeData(data)).toBe("sé")
})
- it('returns decoded unicode strings', () => {
- const data = 's\\u1234'
+ it("returns decoded unicode strings", () => {
+ const data = "s\\u1234"
- expect(decodeData(data)).toBe('s\u1234')
+ expect(decodeData(data)).toBe("s\u1234")
})
- it('returns decoded strings consisting of both unicode and ASCII hexacode characters', () => {
- const data = 's\\u1234\xe9'
+ it("returns decoded strings consisting of both unicode and ASCII hexacode characters", () => {
+ const data = "s\\u1234\xe9"
- expect(decodeData(data)).toBe('s\u1234\xe9')
+ expect(decodeData(data)).toBe("s\u1234\xe9")
})
- it('shouldnt throw exception', () => {
- const data = 'Classic Twill - SlipcoverFabrics.com 100% Cotton'
+ it("shouldnt throw exception", () => {
+ const data = "Classic Twill - SlipcoverFabrics.com 100% Cotton"
expect(decodeData(data)).toBe(data)
})
diff --git a/test/unit/specs/utils/decode-image-data.spec.js b/test/unit/specs/utils/decode-image-data.spec.js
index ef28fab23..6da6c5104 100644
--- a/test/unit/specs/utils/decode-image-data.spec.js
+++ b/test/unit/specs/utils/decode-image-data.spec.js
@@ -1,97 +1,97 @@
-import { decodeMediaData } from '~/utils/decode-media-data'
-import { IMAGE } from '~/constants/media'
+import { decodeMediaData } from "~/utils/decode-media-data"
+import { IMAGE } from "~/constants/media"
const requiredFields = {
- id: 'id',
- url: 'https://example.com/image.jpg',
- foreign_landing_url: 'https://example.com',
- license: 'by',
- license_version: '4.0',
- attribution: 'Attribution',
+ id: "id",
+ url: "https://example.com/image.jpg",
+ foreign_landing_url: "https://example.com",
+ license: "by",
+ license_version: "4.0",
+ attribution: "Attribution",
category: null,
- provider: 'provider',
+ provider: "provider",
- detail_url: 'url',
- related_url: 'url',
+ detail_url: "url",
+ related_url: "url",
tags: [],
}
-describe('decodeImageData', () => {
- it('decodes symbols correctly', () => {
+describe("decodeImageData", () => {
+ it("decodes symbols correctly", () => {
const data = {
...requiredFields,
- creator: 'S\\xe3',
- title: 'S\\xe9',
- tags: [{ name: 'ma\\xdf' }],
+ creator: "S\\xe3",
+ title: "S\\xe9",
+ tags: [{ name: "ma\\xdf" }],
}
const expected = {
...requiredFields,
- title: 'Sé',
- originalTitle: 'Sé',
- creator: 'Sã',
- tags: [{ name: 'maß' }],
+ title: "Sé",
+ originalTitle: "Sé",
+ creator: "Sã",
+ tags: [{ name: "maß" }],
frontendMediaType: IMAGE,
}
expect(decodeMediaData(data, IMAGE)).toEqual(expected)
})
- it('strips the extension if the same as media filetype', () => {
+ it("strips the extension if the same as media filetype", () => {
const data = {
...requiredFields,
- creator: 'Creator',
- title: 'Image.JPEG',
- filetype: 'jpg',
+ creator: "Creator",
+ title: "Image.JPEG",
+ filetype: "jpg",
}
const expected = {
...requiredFields,
- title: 'Image',
- originalTitle: 'Image.JPEG',
- creator: 'Creator',
- filetype: 'jpg',
+ title: "Image",
+ originalTitle: "Image.JPEG",
+ creator: "Creator",
+ filetype: "jpg",
frontendMediaType: IMAGE,
}
expect(decodeMediaData(data, IMAGE)).toEqual(expected)
})
- it('strips the extension if the same as url extension', () => {
+ it("strips the extension if the same as url extension", () => {
const data = {
...requiredFields,
- url: 'https://example.com/image.jpg',
- creator: 'Creator',
- title: 'Image.JPG',
+ url: "https://example.com/image.jpg",
+ creator: "Creator",
+ title: "Image.JPG",
}
const expected = {
...requiredFields,
- title: 'Image',
- originalTitle: 'Image.JPG',
- creator: 'Creator',
+ title: "Image",
+ originalTitle: "Image.JPG",
+ creator: "Creator",
frontendMediaType: IMAGE,
}
expect(decodeMediaData(data, IMAGE)).toEqual(expected)
})
- it('does not strip the extension if different from filetype in url extension', () => {
+ it("does not strip the extension if different from filetype in url extension", () => {
const data = {
...requiredFields,
- url: 'https://example.com/image.png',
- creator: 'Creator',
- title: 'Image.JPG',
+ url: "https://example.com/image.png",
+ creator: "Creator",
+ title: "Image.JPG",
}
const expected = {
...requiredFields,
- url: 'https://example.com/image.png',
- title: 'Image.JPG',
- originalTitle: 'Image.JPG',
- creator: 'Creator',
+ url: "https://example.com/image.png",
+ title: "Image.JPG",
+ originalTitle: "Image.JPG",
+ creator: "Creator",
frontendMediaType: IMAGE,
}
diff --git a/test/unit/specs/utils/deep-freeze.spec.js b/test/unit/specs/utils/deep-freeze.spec.js
index 251533611..cb3fb5e88 100644
--- a/test/unit/specs/utils/deep-freeze.spec.js
+++ b/test/unit/specs/utils/deep-freeze.spec.js
@@ -1,37 +1,37 @@
-import { deepFreeze } from '~/utils/deep-freeze'
+import { deepFreeze } from "~/utils/deep-freeze"
-describe('deepFreeze', () => {
- it('should freeze shallow arrays', () => {
+describe("deepFreeze", () => {
+ it("should freeze shallow arrays", () => {
const a = [1, 2]
deepFreeze(a)
- expect(() => (a[0] = 'a')).toThrow()
+ expect(() => (a[0] = "a")).toThrow()
})
- it('should freeze shallow objects', () => {
+ it("should freeze shallow objects", () => {
const a = { a: 1, b: 2 }
deepFreeze(a)
expect(() => (a.a = 5)).toThrow()
})
- it('should freeze nested arrays', () => {
+ it("should freeze nested arrays", () => {
const a = [[2], 5]
deepFreeze(a)
- expect(() => (a[0][0] = 'a')).toThrow()
+ expect(() => (a[0][0] = "a")).toThrow()
})
- it('should freeze nested objects', () => {
+ it("should freeze nested objects", () => {
const a = { a: { b: 2 } }
deepFreeze(a)
expect(() => (a.a.b = 5)).toThrow()
})
- it('should freeze objects inside of an array', () => {
- const a = [[{ a: 'b' }]]
+ it("should freeze objects inside of an array", () => {
+ const a = [[{ a: "b" }]]
deepFreeze(a)
- expect(() => (a[0][0].a = '1')).toThrow()
+ expect(() => (a[0][0].a = "1")).toThrow()
})
- it('should freeze arrays inside of objects', () => {
+ it("should freeze arrays inside of objects", () => {
const a = { b: [1] }
deepFreeze(a)
expect(() => a.b.push(3)).toThrow()
diff --git a/test/unit/specs/utils/get-additional-sources.spec.ts b/test/unit/specs/utils/get-additional-sources.spec.ts
index 215294e50..ca3c9d799 100644
--- a/test/unit/specs/utils/get-additional-sources.spec.ts
+++ b/test/unit/specs/utils/get-additional-sources.spec.ts
@@ -1,11 +1,11 @@
-import { getAdditionalSources } from '~/utils/get-additional-sources'
-import { AUDIO, IMAGE, MediaType, MODEL_3D, VIDEO } from '~/constants/media'
+import { getAdditionalSources } from "~/utils/get-additional-sources"
+import { AUDIO, IMAGE, MediaType, MODEL_3D, VIDEO } from "~/constants/media"
/**
* These tests do not test the health or uptime of URLS, only that a valid URL
* string is returned.
*/
-describe('getAdditionalSources', () => {
+describe("getAdditionalSources", () => {
it.each`
mediaType
${AUDIO}
@@ -15,11 +15,11 @@ describe('getAdditionalSources', () => {
`(
`returns a URL for each $mediaType source`,
({ mediaType }: { mediaType: MediaType }) => {
- const search = { q: 'dogs' }
+ const search = { q: "dogs" }
const audioSources = getAdditionalSources(mediaType, search)
const urls = audioSources.map((source) => source.url)
- expect(urls.every((url) => url?.startsWith('http'))).toBeTruthy()
+ expect(urls.every((url) => url?.startsWith("http"))).toBeTruthy()
}
)
})
diff --git a/test/unit/specs/utils/get-parameter-by-name.spec.js b/test/unit/specs/utils/get-parameter-by-name.spec.js
index 654fd2e03..ed5da9278 100644
--- a/test/unit/specs/utils/get-parameter-by-name.spec.js
+++ b/test/unit/specs/utils/get-parameter-by-name.spec.js
@@ -1,31 +1,31 @@
-import { getParameterByName } from '~/utils/url-params'
+import { getParameterByName } from "~/utils/url-params"
-describe('getParameterByName', () => {
- const queryStr = '?q=nature&provider=flickr&li=by&lt='
+describe("getParameterByName", () => {
+ const queryStr = "?q=nature&provider=flickr&li=by&lt="
it('finds "q" key', () => {
- expect(getParameterByName('q', queryStr)).toBe('nature')
+ expect(getParameterByName("q", queryStr)).toBe("nature")
})
it('finds "provider" key', () => {
- expect(getParameterByName('provider', queryStr)).toBe('flickr')
+ expect(getParameterByName("provider", queryStr)).toBe("flickr")
})
it('finds "li" key', () => {
- expect(getParameterByName('li', queryStr)).toBe('by')
+ expect(getParameterByName("li", queryStr)).toBe("by")
})
it('finds "lt" to be empty', () => {
- expect(getParameterByName('lt', queryStr)).toBe('')
+ expect(getParameterByName("lt", queryStr)).toBe("")
})
it('finds "lt"', () => {
const query = `${queryStr}commercial`
- expect(getParameterByName('lt', query)).toBe('commercial')
+ expect(getParameterByName("lt", query)).toBe("commercial")
})
it('finds multiple "lt" parameter values', () => {
const query = `${queryStr}commercial&lt=modification`
- expect(getParameterByName('lt', query)).toBe('commercial,modification')
+ expect(getParameterByName("lt", query)).toBe("commercial,modification")
})
})
diff --git a/test/unit/specs/utils/license.spec.ts b/test/unit/specs/utils/license.spec.ts
index c23f8ed22..37d98b121 100644
--- a/test/unit/specs/utils/license.spec.ts
+++ b/test/unit/specs/utils/license.spec.ts
@@ -1,27 +1,27 @@
-import Vuei18n from 'vue-i18n'
+import Vuei18n from "vue-i18n"
-import { getFullLicenseName, getElements } from '~/utils/license'
-import type { License, LicenseVersion } from '~/constants/license'
-import enMessages from '~/locales/en.json'
+import { getFullLicenseName, getElements } from "~/utils/license"
+import type { License, LicenseVersion } from "~/constants/license"
+import enMessages from "~/locales/en.json"
const i18n = new Vuei18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages: { en: enMessages },
})
-describe('getFullLicenseName', () => {
+describe("getFullLicenseName", () => {
it.each`
license | licenseVersion | sendI18n | fullName
- ${'by'} | ${''} | ${false} | ${'CC BY'}
- ${'by-nc-nd'} | ${'4.0'} | ${false} | ${'CC BY-NC-ND 4.0'}
- ${'cc0'} | ${''} | ${false} | ${'CC0'}
- ${'sampling+'} | ${''} | ${false} | ${'CC Sampling+'}
- ${'nc-sampling+'} | ${''} | ${false} | ${'CC NC-Sampling+'}
- ${'pdm'} | ${''} | ${false} | ${'PDM'}
- ${'pdm'} | ${''} | ${true} | ${'Public Domain Mark'}
+ ${"by"} | ${""} | ${false} | ${"CC BY"}
+ ${"by-nc-nd"} | ${"4.0"} | ${false} | ${"CC BY-NC-ND 4.0"}
+ ${"cc0"} | ${""} | ${false} | ${"CC0"}
+ ${"sampling+"} | ${""} | ${false} | ${"CC Sampling+"}
+ ${"nc-sampling+"} | ${""} | ${false} | ${"CC NC-Sampling+"}
+ ${"pdm"} | ${""} | ${false} | ${"PDM"}
+ ${"pdm"} | ${""} | ${true} | ${"Public Domain Mark"}
`(
- 'returns license name for license $license and version $licenseVersion',
+ "returns license name for license $license and version $licenseVersion",
({
license,
licenseVersion,
@@ -40,21 +40,21 @@ describe('getFullLicenseName', () => {
)
})
-describe('getElements', () => {
+describe("getElements", () => {
it.each`
license | icons
- ${'by'} | ${['cc', 'by']}
- ${'by-sa'} | ${['cc', 'by', 'sa']}
- ${'by-nd'} | ${['cc', 'by', 'nd']}
- ${'by-nc'} | ${['cc', 'by', 'nc']}
- ${'by-nc-sa'} | ${['cc', 'by', 'nc', 'sa']}
- ${'by-nc-nd'} | ${['cc', 'by', 'nc', 'nd']}
- ${'nc-sampling+'} | ${['cc', 'nc', 'sampling-plus']}
- ${'sampling+'} | ${['cc', 'sampling-plus']}
- ${'pdm'} | ${['pd']}
- ${'cc0'} | ${['cc', 'zero']}
+ ${"by"} | ${["cc", "by"]}
+ ${"by-sa"} | ${["cc", "by", "sa"]}
+ ${"by-nd"} | ${["cc", "by", "nd"]}
+ ${"by-nc"} | ${["cc", "by", "nc"]}
+ ${"by-nc-sa"} | ${["cc", "by", "nc", "sa"]}
+ ${"by-nc-nd"} | ${["cc", "by", "nc", "nd"]}
+ ${"nc-sampling+"} | ${["cc", "nc", "sampling-plus"]}
+ ${"sampling+"} | ${["cc", "sampling-plus"]}
+ ${"pdm"} | ${["pd"]}
+ ${"cc0"} | ${["cc", "zero"]}
`(
- 'returns $icons for $license',
+ "returns $icons for $license",
({ license, icons }: { license: License; icons: string[] }) => {
expect(getElements(license)).toEqual(icons)
}
diff --git a/test/unit/specs/utils/prepare-search-query-params.spec.js b/test/unit/specs/utils/prepare-search-query-params.spec.js
index 1872fb87e..8ff7e1318 100644
--- a/test/unit/specs/utils/prepare-search-query-params.spec.js
+++ b/test/unit/specs/utils/prepare-search-query-params.spec.js
@@ -1,9 +1,9 @@
-import prepareSearchQueryParams from '~/utils/prepare-search-query-params'
+import prepareSearchQueryParams from "~/utils/prepare-search-query-params"
-describe('prepareSearchQueryParams', () => {
- it('returns params object clone', () => {
+describe("prepareSearchQueryParams", () => {
+ it("returns params object clone", () => {
const params = {
- q: 'foo',
+ q: "foo",
}
const result = prepareSearchQueryParams(params)
@@ -13,42 +13,42 @@ describe('prepareSearchQueryParams', () => {
it('swaps "q" key for "creator" key when searchBy equals "creator', () => {
const params = {
- q: 'foo',
- searchBy: 'creator',
+ q: "foo",
+ searchBy: "creator",
}
const result = prepareSearchQueryParams(params)
expect(result.q).toBeUndefined()
- expect(result.creator).toBe('foo')
+ expect(result.creator).toBe("foo")
})
it('swaps "q" key for "tags" key when searchBy equals "tags', () => {
const params = {
- q: 'foo',
- searchBy: 'tags',
+ q: "foo",
+ searchBy: "tags",
}
const result = prepareSearchQueryParams(params)
expect(result.q).toBeUndefined()
- expect(result.tags).toBe('foo')
+ expect(result.tags).toBe("foo")
})
- it('doesnt remove q key when searchBy value is empty', () => {
+ it("doesnt remove q key when searchBy value is empty", () => {
const params = {
- q: 'foo',
+ q: "foo",
searchBy: [],
}
const result = prepareSearchQueryParams(params)
- expect(result.q).toBe('foo')
+ expect(result.q).toBe("foo")
})
it('removes leading and trailing whitespace from "q" key', () => {
const params = {
- q: ' foo ',
+ q: " foo ",
}
const result = prepareSearchQueryParams(params)
- expect(result.q).toBe('foo')
+ expect(result.q).toBe("foo")
})
})
diff --git a/test/unit/specs/utils/resampling.spec.js b/test/unit/specs/utils/resampling.spec.js
index 8cd9934a2..4e646a2c2 100644
--- a/test/unit/specs/utils/resampling.spec.js
+++ b/test/unit/specs/utils/resampling.spec.js
@@ -1,13 +1,13 @@
-import { downsampleArray, upsampleArray } from '~/utils/resampling'
+import { downsampleArray, upsampleArray } from "~/utils/resampling"
-describe('upsampleArray', () => {
+describe("upsampleArray", () => {
const baseArray = [0, 10, 30, 20]
- it('should scale up array by filling points between elements', () => {
+ it("should scale up array by filling points between elements", () => {
expect(upsampleArray(baseArray, 7)).toEqual([0, 5, 10, 20, 30, 25, 20])
})
- it('should scale up array even when not exactly divisible', () => {
+ it("should scale up array even when not exactly divisible", () => {
const upsampledArray = upsampleArray(baseArray, 8)
expect(upsampledArray[0]).toEqual(0)
expect(upsampledArray[1]).toBeCloseTo(4.285, 2)
@@ -20,14 +20,14 @@ describe('upsampleArray', () => {
})
})
-describe('downsampleArray', () => {
+describe("downsampleArray", () => {
const baseArray = [5, 10, 15, 10, 5, 0, 5]
- it('should scale down array by dropping points between elements', () => {
+ it("should scale down array by dropping points between elements", () => {
expect(downsampleArray(baseArray, 4)).toEqual([5, 15, 0, 5])
})
- it('should scale down array even when not exactly divisible', () => {
+ it("should scale down array even when not exactly divisible", () => {
expect(downsampleArray(baseArray, 3)).toEqual([5, 15, 5])
})
})
diff --git a/test/unit/specs/utils/search-query-transform.spec.js b/test/unit/specs/utils/search-query-transform.spec.js
index 52f9f0b4d..03b22c925 100644
--- a/test/unit/specs/utils/search-query-transform.spec.js
+++ b/test/unit/specs/utils/search-query-transform.spec.js
@@ -1,15 +1,15 @@
-import { deepClone } from '~/utils/clone'
+import { deepClone } from "~/utils/clone"
import {
filtersToQueryData,
queryToFilterData,
queryStringToQueryData,
-} from '~/utils/search-query-transform'
-import { AUDIO, IMAGE } from '~/constants/media'
+} from "~/utils/search-query-transform"
+import { AUDIO, IMAGE } from "~/constants/media"
-import { filterData, initFilters } from '~/constants/filters'
+import { filterData, initFilters } from "~/constants/filters"
-describe('searchQueryTransform', () => {
- it('converts initial filters to query data', () => {
+describe("searchQueryTransform", () => {
+ it("converts initial filters to query data", () => {
const filters = {
...filterData,
}
@@ -17,94 +17,94 @@ describe('searchQueryTransform', () => {
const result = filtersToQueryData(filters)
expect(result).toEqual({})
})
- it('converts filter to query data', () => {
+ it("converts filter to query data", () => {
const filters = { ...filterData }
const result = filtersToQueryData(filters)
expect(result).toEqual({})
})
- it('converts all filters to query data', () => {
+ it("converts all filters to query data", () => {
const filters = {
licenses: [
- { code: 'cc0', name: 'filters.licenses.cc0', checked: true },
- { code: 'pdm', name: 'filters.licenses.pdm', checked: false },
- { code: 'by', name: 'filters.licenses.by', checked: false },
- { code: 'by-sa', name: 'filters.licenses.by-sa', checked: false },
- { code: 'by-nc', name: 'filters.licenses.by-nc', checked: false },
- { code: 'by-nd', name: 'filters.licenses.by-nd', checked: false },
- { code: 'by-nc-sa', name: 'filters.licenses.by-nc-sa', checked: false },
- { code: 'by-nc-nd', name: 'filters.licenses.by-nc-nd', checked: false },
+ { code: "cc0", name: "filters.licenses.cc0", checked: true },
+ { code: "pdm", name: "filters.licenses.pdm", checked: false },
+ { code: "by", name: "filters.licenses.by", checked: false },
+ { code: "by-sa", name: "filters.licenses.by-sa", checked: false },
+ { code: "by-nc", name: "filters.licenses.by-nc", checked: false },
+ { code: "by-nd", name: "filters.licenses.by-nd", checked: false },
+ { code: "by-nc-sa", name: "filters.licenses.by-nc-sa", checked: false },
+ { code: "by-nc-nd", name: "filters.licenses.by-nc-nd", checked: false },
],
licenseTypes: [
{
- code: 'commercial',
- name: 'filters.license-types.commercial',
+ code: "commercial",
+ name: "filters.license-types.commercial",
checked: true,
},
{
- code: 'modification',
- name: 'filters.license-types.modification',
+ code: "modification",
+ name: "filters.license-types.modification",
checked: false,
},
],
imageCategories: [
{
- code: 'photograph',
- name: 'filters.image-categories.photograph',
+ code: "photograph",
+ name: "filters.image-categories.photograph",
checked: true,
},
{
- code: 'illustration',
- name: 'filters.image-categories.illustration',
+ code: "illustration",
+ name: "filters.image-categories.illustration",
checked: false,
},
{
- code: 'digitized-artwork',
- name: 'filters.image-categories.digitized-artwork',
+ code: "digitized-artwork",
+ name: "filters.image-categories.digitized-artwork",
checked: false,
},
],
imageExtensions: [
- { code: 'jpg', name: 'filters.image-extensions.jpg', checked: true },
- { code: 'png', name: 'filters.image-extensions.png', checked: false },
- { code: 'gif', name: 'filters.image-extensions.gif', checked: false },
- { code: 'svg', name: 'filters.image-extensions.svg', checked: false },
+ { code: "jpg", name: "filters.image-extensions.jpg", checked: true },
+ { code: "png", name: "filters.image-extensions.png", checked: false },
+ { code: "gif", name: "filters.image-extensions.gif", checked: false },
+ { code: "svg", name: "filters.image-extensions.svg", checked: false },
],
aspectRatios: [
- { code: 'tall', name: 'filters.aspect-ratios.tall', checked: true },
- { code: 'wide', name: 'filters.aspect-ratios.wide', checked: false },
+ { code: "tall", name: "filters.aspect-ratios.tall", checked: true },
+ { code: "wide", name: "filters.aspect-ratios.wide", checked: false },
{
- code: 'square',
- name: 'filters.aspect-ratios.square',
+ code: "square",
+ name: "filters.aspect-ratios.square",
checked: false,
},
],
sizes: [
- { code: 'small', name: 'filters.sizes.small', checked: false },
- { code: 'medium', name: 'filters.sizes.medium', checked: true },
- { code: 'large', name: 'filters.sizes.large', checked: false },
+ { code: "small", name: "filters.sizes.small", checked: false },
+ { code: "medium", name: "filters.sizes.medium", checked: true },
+ { code: "large", name: "filters.sizes.large", checked: false },
],
imageProviders: [
- { code: 'animaldiversity', checked: true },
- { code: 'brooklynmuseum', checked: true },
+ { code: "animaldiversity", checked: true },
+ { code: "brooklynmuseum", checked: true },
],
- searchBy: [{ code: 'creator', checked: true }],
- mature: [{ code: 'mature', checked: true }],
+ searchBy: [{ code: "creator", checked: true }],
+ mature: [{ code: "mature", checked: true }],
}
const expectedQueryData = {
- aspect_ratio: 'tall',
- category: 'photograph',
- extension: 'jpg',
- license: 'cc0',
- license_type: 'commercial',
- mature: 'true',
- searchBy: 'creator',
- size: 'medium',
- source: 'animaldiversity,brooklynmuseum',
+ aspect_ratio: "tall",
+ category: "photograph",
+ extension: "jpg",
+ license: "cc0",
+ license_type: "commercial",
+ mature: "true",
+ searchBy: "creator",
+ size: "medium",
+ source: "animaldiversity,brooklynmuseum",
}
const result = filtersToQueryData(filters, IMAGE)
expect(result).toEqual(expectedQueryData) // toEqual checks for value equality
})
- it('queryToFilterData blank', () => {
+ it("queryToFilterData blank", () => {
const filters = {
...filterData,
}
@@ -113,159 +113,159 @@ describe('searchQueryTransform', () => {
const result = queryToFilterData({ query, defaultFilters: filters })
expect(result).toEqual(filters) // toEqual checks for value equality
})
- it('queryToFilterData all image filters', () => {
+ it("queryToFilterData all image filters", () => {
const filters = {
licenses: [
- { code: 'cc0', name: 'filters.licenses.cc0', checked: true },
- { code: 'pdm', name: 'filters.licenses.pdm', checked: false },
- { code: 'by', name: 'filters.licenses.by', checked: false },
- { code: 'by-sa', name: 'filters.licenses.by-sa', checked: false },
- { code: 'by-nc', name: 'filters.licenses.by-nc', checked: false },
- { code: 'by-nd', name: 'filters.licenses.by-nd', checked: false },
- { code: 'by-nc-sa', name: 'filters.licenses.by-nc-sa', checked: false },
- { code: 'by-nc-nd', name: 'filters.licenses.by-nc-nd', checked: false },
+ { code: "cc0", name: "filters.licenses.cc0", checked: true },
+ { code: "pdm", name: "filters.licenses.pdm", checked: false },
+ { code: "by", name: "filters.licenses.by", checked: false },
+ { code: "by-sa", name: "filters.licenses.by-sa", checked: false },
+ { code: "by-nc", name: "filters.licenses.by-nc", checked: false },
+ { code: "by-nd", name: "filters.licenses.by-nd", checked: false },
+ { code: "by-nc-sa", name: "filters.licenses.by-nc-sa", checked: false },
+ { code: "by-nc-nd", name: "filters.licenses.by-nc-nd", checked: false },
],
licenseTypes: [
{
- code: 'commercial',
- name: 'filters.license-types.commercial',
+ code: "commercial",
+ name: "filters.license-types.commercial",
checked: true,
},
{
- code: 'modification',
- name: 'filters.license-types.modification',
+ code: "modification",
+ name: "filters.license-types.modification",
checked: false,
},
],
imageCategories: [
{
- code: 'photograph',
- name: 'filters.image-categories.photograph',
+ code: "photograph",
+ name: "filters.image-categories.photograph",
checked: true,
},
{
- code: 'illustration',
- name: 'filters.image-categories.illustration',
+ code: "illustration",
+ name: "filters.image-categories.illustration",
checked: false,
},
{
- code: 'digitized_artwork',
- name: 'filters.image-categories.digitized-artwork',
+ code: "digitized_artwork",
+ name: "filters.image-categories.digitized-artwork",
checked: false,
},
],
lengths: [
{
checked: false,
- code: 'shortest',
- name: 'filters.lengths.shortest',
+ code: "shortest",
+ name: "filters.lengths.shortest",
},
{
checked: false,
- code: 'short',
- name: 'filters.lengths.short',
+ code: "short",
+ name: "filters.lengths.short",
},
{
checked: true,
- code: 'medium',
- name: 'filters.lengths.medium',
+ code: "medium",
+ name: "filters.lengths.medium",
},
{
checked: false,
- code: 'long',
- name: 'filters.lengths.long',
+ code: "long",
+ name: "filters.lengths.long",
},
],
imageExtensions: [
- { code: 'jpg', name: 'filters.image-extensions.jpg', checked: true },
- { code: 'png', name: 'filters.image-extensions.png', checked: false },
- { code: 'gif', name: 'filters.image-extensions.gif', checked: false },
- { code: 'svg', name: 'filters.image-extensions.svg', checked: false },
+ { code: "jpg", name: "filters.image-extensions.jpg", checked: true },
+ { code: "png", name: "filters.image-extensions.png", checked: false },
+ { code: "gif", name: "filters.image-extensions.gif", checked: false },
+ { code: "svg", name: "filters.image-extensions.svg", checked: false },
],
aspectRatios: [
- { code: 'tall', name: 'filters.aspect-ratios.tall', checked: true },
- { code: 'wide', name: 'filters.aspect-ratios.wide', checked: false },
+ { code: "tall", name: "filters.aspect-ratios.tall", checked: true },
+ { code: "wide", name: "filters.aspect-ratios.wide", checked: false },
{
- code: 'square',
- name: 'filters.aspect-ratios.square',
+ code: "square",
+ name: "filters.aspect-ratios.square",
checked: false,
},
],
sizes: [
- { code: 'small', name: 'filters.sizes.small', checked: false },
- { code: 'medium', name: 'filters.sizes.medium', checked: true },
- { code: 'large', name: 'filters.sizes.large', checked: false },
+ { code: "small", name: "filters.sizes.small", checked: false },
+ { code: "medium", name: "filters.sizes.medium", checked: true },
+ { code: "large", name: "filters.sizes.large", checked: false },
],
imageProviders: [
- { code: 'animaldiversity', checked: true },
- { code: 'brooklynmuseum', checked: true },
+ { code: "animaldiversity", checked: true },
+ { code: "brooklynmuseum", checked: true },
],
audioCategories: [
{
checked: true,
- code: 'music',
- name: 'filters.audio-categories.music',
+ code: "music",
+ name: "filters.audio-categories.music",
},
{
checked: false,
- code: 'soundEffects',
- name: 'filters.audio-categories.sound_effects',
+ code: "soundEffects",
+ name: "filters.audio-categories.sound_effects",
},
{
checked: false,
- code: 'podcast',
- name: 'filters.audio-categories.podcast',
+ code: "podcast",
+ name: "filters.audio-categories.podcast",
},
],
audioExtensions: [
{
checked: true,
- code: 'mp3',
- name: 'filters.audio-extensions.mp3',
+ code: "mp3",
+ name: "filters.audio-extensions.mp3",
},
{
checked: false,
- code: 'ogg',
- name: 'filters.audio-extensions.ogg',
+ code: "ogg",
+ name: "filters.audio-extensions.ogg",
},
{
checked: false,
- code: 'flac',
- name: 'filters.audio-extensions.flac',
+ code: "flac",
+ name: "filters.audio-extensions.flac",
},
],
audioProviders: [
{
checked: true,
- code: 'jamendo',
+ code: "jamendo",
},
{
checked: true,
- code: 'wikimedia',
+ code: "wikimedia",
},
],
searchBy: [
- { code: 'creator', checked: true, name: 'filters.searchBy.creator' },
+ { code: "creator", checked: true, name: "filters.searchBy.creator" },
],
mature: [
- { code: 'mature', name: 'filters.mature.mature', checked: true },
+ { code: "mature", name: "filters.mature.mature", checked: true },
],
}
const query = {
- q: 'cat',
- license: 'cc0',
- license_type: 'commercial',
- category: 'music',
- extension: 'mp3',
- length: 'medium',
- source: 'jamendo',
- searchBy: 'creator',
- mature: 'true',
+ q: "cat",
+ license: "cc0",
+ license_type: "commercial",
+ category: "music",
+ extension: "mp3",
+ length: "medium",
+ source: "jamendo",
+ searchBy: "creator",
+ mature: "true",
}
const testFilters = deepClone(filters)
testFilters.audioProviders = [
- { code: 'jamendo', checked: true },
- { code: 'wikimedia', checked: true },
+ { code: "jamendo", checked: true },
+ { code: "wikimedia", checked: true },
]
const result = queryToFilterData({
query,
@@ -275,11 +275,11 @@ describe('searchQueryTransform', () => {
expect(result).toEqual(filters) // toEqual checks for value equality
})
- it('queryToFilterData discards all image filters when search type is audio', () => {
+ it("queryToFilterData discards all image filters when search type is audio", () => {
const filters = initFilters()
filters.audioProviders = [
- { code: 'jamendo', checked: false },
- { code: 'wikimedia_audio', checked: false },
+ { code: "jamendo", checked: false },
+ { code: "wikimedia_audio", checked: false },
]
/**
* `category` and `extension` parameter values will not be used because those
@@ -294,15 +294,15 @@ describe('searchQueryTransform', () => {
* are discarded.
*/
const query = {
- q: 'cat',
- license: 'cc0,nonexistent',
- license_type: 'commercial',
- category: 'photograph',
- extension: 'svg',
- length: 'medium',
- source: 'animaldiversity,wikimedia,nonexistent,wikimedia_audio,jamendo',
- searchBy: 'creator',
- mature: 'true',
+ q: "cat",
+ license: "cc0,nonexistent",
+ license_type: "commercial",
+ category: "photograph",
+ extension: "svg",
+ length: "medium",
+ source: "animaldiversity,wikimedia,nonexistent,wikimedia_audio,jamendo",
+ searchBy: "creator",
+ mature: "true",
}
const expectedFilters = deepClone(filters)
const setChecked = (code, filterCategory) => {
@@ -311,13 +311,13 @@ describe('searchQueryTransform', () => {
)
expectedFilters[filterCategory][idx].checked = true
}
- setChecked('cc0', 'licenses')
- setChecked('commercial', 'licenseTypes')
- setChecked('medium', 'lengths')
- setChecked('creator', 'searchBy')
- setChecked('mature', 'mature')
- setChecked('jamendo', 'audioProviders')
- setChecked('wikimedia_audio', 'audioProviders')
+ setChecked("cc0", "licenses")
+ setChecked("commercial", "licenseTypes")
+ setChecked("medium", "lengths")
+ setChecked("creator", "searchBy")
+ setChecked("mature", "mature")
+ setChecked("jamendo", "audioProviders")
+ setChecked("wikimedia_audio", "audioProviders")
const result = queryToFilterData({
query,
@@ -326,21 +326,21 @@ describe('searchQueryTransform', () => {
})
expect(result).toEqual(expectedFilters) // toEqual checks for value equality
})
- it('queryStringToQueryData', () => {
+ it("queryStringToQueryData", () => {
const expectedQueryData = {
- license: 'cc0',
- license_type: 'commercial',
- category: 'photograph',
- extension: 'jpg',
- aspect_ratio: 'tall',
- size: 'medium',
- source: 'animaldiversity,brooklynmuseum',
- q: 'cat',
- searchBy: 'creator',
- mature: 'true',
+ license: "cc0",
+ license_type: "commercial",
+ category: "photograph",
+ extension: "jpg",
+ aspect_ratio: "tall",
+ size: "medium",
+ source: "animaldiversity,brooklynmuseum",
+ q: "cat",
+ searchBy: "creator",
+ mature: "true",
}
const queryString =
- 'http://localhost:8443/search/image?q=cat&license=cc0&license_type=commercial&category=photograph&extension=jpg&aspect_ratio=tall&size=medium&source=animaldiversity,brooklynmuseum&searchBy=creator&mature=true'
+ "http://localhost:8443/search/image?q=cat&license=cc0&license_type=commercial&category=photograph&extension=jpg&aspect_ratio=tall&size=medium&source=animaldiversity,brooklynmuseum&searchBy=creator&mature=true"
const result = queryStringToQueryData(queryString)
expect(result).toEqual(expectedQueryData)
})
diff --git a/test/unit/specs/utils/string-to-boolean.spec.js b/test/unit/specs/utils/string-to-boolean.spec.js
index 9e09367df..64e1a4c2c 100644
--- a/test/unit/specs/utils/string-to-boolean.spec.js
+++ b/test/unit/specs/utils/string-to-boolean.spec.js
@@ -1,30 +1,30 @@
-import { stringToBoolean } from '~/utils/string-to-boolean'
+import { stringToBoolean } from "~/utils/string-to-boolean"
-describe('stringToBoolean', () => {
+describe("stringToBoolean", () => {
it('returns true for "true", "yes" and "1"', () => {
- expect(stringToBoolean('true')).toBe(true)
- expect(stringToBoolean('yes')).toBe(true)
- expect(stringToBoolean('1')).toBe(true)
+ expect(stringToBoolean("true")).toBe(true)
+ expect(stringToBoolean("yes")).toBe(true)
+ expect(stringToBoolean("1")).toBe(true)
})
it('returns false for "false", "no" and "0"', () => {
- expect(stringToBoolean('false')).toBe(false)
- expect(stringToBoolean('no')).toBe(false)
- expect(stringToBoolean('0')).toBe(false)
+ expect(stringToBoolean("false")).toBe(false)
+ expect(stringToBoolean("no")).toBe(false)
+ expect(stringToBoolean("0")).toBe(false)
})
- it('returns booleans as-is', () => {
+ it("returns booleans as-is", () => {
expect(stringToBoolean(true)).toBe(true)
expect(stringToBoolean(false)).toBe(false)
})
- it('converts null-ish values to false', () => {
+ it("converts null-ish values to false", () => {
expect(stringToBoolean(null)).toBe(false)
expect(stringToBoolean(undefined)).toBe(false)
})
- it('handles other strings', () => {
- expect(stringToBoolean('any content')).toBe(true)
- expect(stringToBoolean('')).toBe(false)
+ it("handles other strings", () => {
+ expect(stringToBoolean("any content")).toBe(true)
+ expect(stringToBoolean("")).toBe(false)
})
})
diff --git a/test/unit/specs/utils/time-fmt.spec.ts b/test/unit/specs/utils/time-fmt.spec.ts
index 1e0dcc0bf..3e283f809 100644
--- a/test/unit/specs/utils/time-fmt.spec.ts
+++ b/test/unit/specs/utils/time-fmt.spec.ts
@@ -1,33 +1,33 @@
-import { timeFmt } from '~/utils/time-fmt'
+import { timeFmt } from "~/utils/time-fmt"
-describe('timeFmt', () => {
- it('omits hours if zero', () => {
- expect(timeFmt(59)).toEqual('0:59')
- expect(timeFmt(60)).toEqual('1:00')
- expect(timeFmt(61)).toEqual('1:01')
+describe("timeFmt", () => {
+ it("omits hours if zero", () => {
+ expect(timeFmt(59)).toEqual("0:59")
+ expect(timeFmt(60)).toEqual("1:00")
+ expect(timeFmt(61)).toEqual("1:01")
})
- it('handles zero minutes', () => {
- expect(timeFmt(59)).toEqual('0:59')
- expect(timeFmt(3600)).toEqual('1:00:00')
- expect(timeFmt(3659)).toEqual('1:00:59')
+ it("handles zero minutes", () => {
+ expect(timeFmt(59)).toEqual("0:59")
+ expect(timeFmt(3600)).toEqual("1:00:00")
+ expect(timeFmt(3659)).toEqual("1:00:59")
})
- it('handles zero seconds', () => {
- expect(timeFmt(60)).toEqual('1:00')
- expect(timeFmt(3600)).toEqual('1:00:00')
- expect(timeFmt(3660)).toEqual('1:01:00')
+ it("handles zero seconds", () => {
+ expect(timeFmt(60)).toEqual("1:00")
+ expect(timeFmt(3600)).toEqual("1:00:00")
+ expect(timeFmt(3660)).toEqual("1:01:00")
})
- it('pads minutes if hours present', () => {
- expect(timeFmt(3661)).toEqual('1:01:01')
+ it("pads minutes if hours present", () => {
+ expect(timeFmt(3661)).toEqual("1:01:01")
})
- it('handles duration of zero', () => {
- expect(timeFmt(0)).toEqual('0:00')
+ it("handles duration of zero", () => {
+ expect(timeFmt(0)).toEqual("0:00")
})
- it('handles durations over 24 hours', () => {
- expect(timeFmt(86469)).toEqual('24:01:09')
+ it("handles durations over 24 hours", () => {
+ expect(timeFmt(86469)).toEqual("24:01:09")
})
})
diff --git a/test/unit/svg-transform.js b/test/unit/svg-transform.js
index 8de8467fa..10ae43b81 100644
--- a/test/unit/svg-transform.js
+++ b/test/unit/svg-transform.js
@@ -1,4 +1,4 @@
-const vueJest = require('vue-jest/lib/template-compiler')
+const vueJest = require("vue-jest/lib/template-compiler")
module.exports = {
process(content) {
diff --git a/test/unit/test-utils/api-service-mock.ts b/test/unit/test-utils/api-service-mock.ts
index 98334caba..c0d8a49db 100644
--- a/test/unit/test-utils/api-service-mock.ts
+++ b/test/unit/test-utils/api-service-mock.ts
@@ -1,9 +1,9 @@
-import MockAdapter from 'axios-mock-adapter'
+import MockAdapter from "axios-mock-adapter"
-import * as apiService from '~/data/api-service'
+import * as apiService from "~/data/api-service"
-jest.mock('~/data/api-service', () => ({ createApiService: jest.fn() }))
-const originalApiService = jest.requireActual('~/data/api-service')
+jest.mock("~/data/api-service", () => ({ createApiService: jest.fn() }))
+const originalApiService = jest.requireActual("~/data/api-service")
const createApiService = apiService.createApiService as jest.Mock<
ReturnType<typeof apiService.createApiService>,
diff --git a/test/unit/test-utils/i18n.js b/test/unit/test-utils/i18n.js
index 86ca5c9ee..9b347af3d 100644
--- a/test/unit/test-utils/i18n.js
+++ b/test/unit/test-utils/i18n.js
@@ -1,10 +1,10 @@
-import VueI18n from 'vue-i18n'
+import VueI18n from "vue-i18n"
-const messages = require('~/locales/en.json')
+const messages = require("~/locales/en.json")
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages,
})
diff --git a/test/unit/test-utils/pinia.js b/test/unit/test-utils/pinia.js
index fe8f4948e..9f2ec008f 100644
--- a/test/unit/test-utils/pinia.js
+++ b/test/unit/test-utils/pinia.js
@@ -1,10 +1,10 @@
// eslint-disable-next-line no-restricted-imports
-import * as pinia from 'pinia'
+import * as pinia from "pinia"
export const createPinia = () =>
pinia.createPinia().use(() => ({
$nuxt: {
- $openverseApiToken: '',
+ $openverseApiToken: "",
$sentry: {
captureException: jest.fn(),
captureEvent: jest.fn(),
@@ -16,9 +16,9 @@ export const createPinia = () =>
},
i18n: {
localeProperties: {
- code: 'es',
+ code: "es",
translated: 100,
- name: 'Spanish',
+ name: "Spanish",
},
},
},
diff --git a/test/unit/test-utils/render.js b/test/unit/test-utils/render.js
index 91e4815eb..f082ddb07 100644
--- a/test/unit/test-utils/render.js
+++ b/test/unit/test-utils/render.js
@@ -1,14 +1,14 @@
-import VueI18n from 'vue-i18n'
-import { shallowMount, createLocalVue } from '@vue/test-utils'
+import VueI18n from "vue-i18n"
+import { shallowMount, createLocalVue } from "@vue/test-utils"
const localVue = createLocalVue()
localVue.use(VueI18n)
-const messages = require('../../../src/locales/en.json')
+const messages = require("../../../src/locales/en.json")
const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
+ locale: "en",
+ fallbackLocale: "en",
messages,
})
diff --git a/typings/csstype/index.d.ts b/typings/csstype/index.d.ts
index 9cd77adbf..f25e298b7 100644
--- a/typings/csstype/index.d.ts
+++ b/typings/csstype/index.d.ts
@@ -2,18 +2,18 @@
// however eslint sees this import as unused.
// https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors
// eslint-disable-next-line @typescript-eslint/no-unused-vars
-import type * as CSS from 'csstype'
+import type * as CSS from "csstype"
/**
* To use CSS custom properties in a component that uses TypeScript, add them here.
* See example in `VWaveform.vue`
*/
-declare module 'csstype' {
+declare module "csstype" {
interface Properties {
- '--usable-height'?: string
- '--unusable-height'?: string
- '--progress-time-left'?: string
- '--seek-time-left'?: string
- '--popover-height'?: string
- '--link-col-height'?: number
+ "--usable-height"?: string
+ "--unusable-height"?: string
+ "--progress-time-left"?: string
+ "--seek-time-left"?: string
+ "--popover-height"?: string
+ "--link-col-height"?: number
}
}
diff --git a/typings/nuxt__types/index.d.ts b/typings/nuxt__types/index.d.ts
index 8f942f981..3b6b3ea11 100644
--- a/typings/nuxt__types/index.d.ts
+++ b/typings/nuxt__types/index.d.ts
@@ -1,10 +1,10 @@
-import '@nuxt/types'
-import '@nuxtjs/i18n'
-import { CookieSerializeOptions } from 'cookie'
+import "@nuxt/types"
+import "@nuxtjs/i18n"
+import { CookieSerializeOptions } from "cookie"
-import type { OpenverseCookieState } from '~/types/cookies'
+import type { OpenverseCookieState } from "~/types/cookies"
-import type { Details as UADetails } from 'express-useragent'
+import type { Details as UADetails } from "express-useragent"
export interface SetParams<Key extends keyof OpenverseCookieState> {
name: Key
@@ -31,7 +31,7 @@ export interface NuxtCookies {
removeAll: () => void
}
-declare module '@nuxt/types' {
+declare module "@nuxt/types" {
export interface Context {
$ua: UADetails | null
$cookies: NuxtCookies
@@ -42,7 +42,7 @@ declare module '@nuxt/types' {
}
}
-declare module '@nuxtjs/i18n' {
+declare module "@nuxtjs/i18n" {
/**
* We put a little extra information in the Vue-i18n `locales` field such as the
* locale's name and native name, which comes in use here.
diff --git a/typings/openverse/index.d.ts b/typings/openverse/index.d.ts
index 6c1132a47..d5d1bf25e 100644
--- a/typings/openverse/index.d.ts
+++ b/typings/openverse/index.d.ts
@@ -1,14 +1,14 @@
-declare module '*.svg' {
+declare module "*.svg" {
const SVG: string
export default SVG
}
-declare module '*.svg?inline' {
+declare module "*.svg?inline" {
const SVG: unknown
export default SVG
}
-declare module '*.png' {
+declare module "*.png" {
const PNG: string
export default PNG
}
diff --git a/typings/vue-router/index.d.ts b/typings/vue-router/index.d.ts
index 03b1e8791..1a073f193 100644
--- a/typings/vue-router/index.d.ts
+++ b/typings/vue-router/index.d.ts
@@ -1,6 +1,6 @@
-import 'vue-router'
+import "vue-router"
-declare module 'vue-router' {
+declare module "vue-router" {
export interface RouteMeta {
backToSearchPath?: string
}
diff --git a/typings/vue/index.d.ts b/typings/vue/index.d.ts
index 5596f90ef..1d1deb364 100644
--- a/typings/vue/index.d.ts
+++ b/typings/vue/index.d.ts
@@ -1,5 +1,5 @@
-declare module '*.vue' {
- import Vue from 'vue'
+declare module "*.vue" {
+ import Vue from "vue"
export default Vue
}