Skip to content

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

Add SVG Sprite Module for icons (#1808)

Olga Bulat7a071e23282a
diff --git a/documentation/guides/frontend/icons.md b/documentation/guides/frontend/icons.md
new file mode 100644
index 000000000..25acb6e7b
--- /dev/null
+++ b/documentation/guides/frontend/icons.md
@@ -0,0 +1,66 @@
+# SVG Icon Sprites in Openverse Frontend
+
+We use SVG for icons in Openverse frontend because it allows for high-quality
+graphics, easy scalability without losing quality, and small file sizes. To
+reduce the number of HTTP requests for icons and reduce load times, we combine
+all of them into a single file called SVG sprite. An SVG sprite is a single SVG
+file that contains multiple SVG symbols. Each symbol can be accessed using its
+unique ID.
+
+This guide explains how to use SVG sprites in Openverse Frontend and how to add
+a new SVG file to the sprite.
+
+## Using SVG Sprites in Openverse Frontend
+
+You can use SVG sprites through the `VIcon` component. To use it, first, import
+it into your component:
+
+```js
+import { VIcon } from "~/components/VIcon"
+```
+
+Then, add the VIcon component to your template, passing the name of the icon as
+a prop:
+
+```html
+<template>
+ <VIcon name="arrow-up" />
+</template>
+```
+
+The name prop is used to identify the icon within the SVG sprite. You can find
+the names of the available icons in the `frontend/src/assets/icons/sprites.json`
+file. The default icons listed in the object with the name `icons` use the name
+as is, without prefixes. To use the license icons, you would need to add
+`license/` as a prefix to the name. For example, to use an `external-link` icon,
+you would use the name `external-link`, and for the `cc-by` icon, you would use
+the name `license/cc-by`.
+
+You can also view a list of all available icons if you go to
+`http://localhost:8443/_icons`. You can copy the icon name (with the prefix, if
+necessary) by clicking on the icon. This page is only available in development
+environment and is not available in production.
+
+## Adding New Icons to the Sprite
+
+Openverse uses
+[svg-sprite-module](https://github.com/nuxt-community/svg-sprite-module) to
+automatically generate the SVG sprite when you add an SVG file to
+`frontned/src/assets/icons/raw/`. It runs when you run `just frontend/run dev`
+or `just frontend/run build`. The module also watches the content of the
+`frontend/src/assets/icons/raw` directory, and re-generates the sprite if you
+add an icon there, so you don't need to re-run the app.
+
+So, to add a new icon to the SVG sprite, you only need to create an SVG file
+containing the icon in `frontend/src/assets/icons/raw/` directory. The name of
+the file without the `.svg` extension will be used in the component. There are
+several requirements for the file:
+
+- It should contain the SVG code for the icon, with a `path` with `id` icon that
+ wraps the inner contents.
+- The color of the icon should be `currentColor`. This allows the icon to
+ inherit the color of the parent element. Also, remove white backgrounds from
+ the icon.
+- It should have a `viewBox` attribute with the dimensions of the icon.
+ Openverse uses 24x24 icons. If you are exporting the icon from Figma, resize
+ the containing frame to 24x24 before exporting.
diff --git a/frontend/.storybook/main.js b/frontend/.storybook/main.js
index 94e745799..e72ad6527 100644
--- a/frontend/.storybook/main.js
+++ b/frontend/.storybook/main.js
@@ -1,6 +1,6 @@
const { nuxifyStorybook } = require("../.nuxt-storybook/storybook/main")
-module.exports = nuxifyStorybook({
+const storybook = nuxifyStorybook({
webpackFinal(config) {
// extend config here
@@ -13,3 +13,11 @@ module.exports = nuxifyStorybook({
// Add your addons here
],
})
+
+const generatedIconsStory = storybook.stories.indexOf(
+ "@nuxtjs/svg-sprite/stories/*.stories.js"
+)
+storybook.stories[generatedIconsStory] =
+ "../node_modules/@nuxtjs/svg-sprite/stories/*.stories.js"
+
+module.exports = storybook
diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts
index 8f92b614c..1e19040f8 100644
--- a/frontend/nuxt.config.ts
+++ b/frontend/nuxt.config.ts
@@ -155,6 +155,7 @@ const config: NuxtConfig = {
"@nuxtjs/composition-api/module",
"@nuxtjs/style-resources",
"@nuxtjs/svg",
+ "@nuxtjs/svg-sprite",
"@nuxtjs/eslint-module",
"@pinia/nuxt",
],
@@ -174,6 +175,10 @@ const config: NuxtConfig = {
{ path: "/healthcheck", handler: "~/server-middleware/healthcheck.js" },
{ path: "/robots.txt", handler: "~/server-middleware/robots.js" },
],
+ svgSprite: {
+ input: "~/assets/svg/raw",
+ output: "~/assets/svg/sprite",
+ },
i18n: {
baseUrl: "https://openverse.org",
locales: openverseLocales,
diff --git a/frontend/package.json b/frontend/package.json
index 483323cb9..f6db01324 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -68,6 +68,7 @@
"@nuxtjs/sentry": "^7.1.4",
"@nuxtjs/sitemap": "^2.4.0",
"@nuxtjs/svg": "^0.4.0",
+ "@nuxtjs/svg-sprite": "0.5.2",
"@pinia/nuxt": "0.2.1",
"@popperjs/core": "^2.11.2",
"@tailwindcss/typography": "^0.5.9",
diff --git a/frontend/src/assets/icons/audio-wave.svg b/frontend/src/assets/icons/audio-wave.svg
deleted file mode 100644
index 7ba84b1c3..000000000
--- a/frontend/src/assets/icons/audio-wave.svg
+++ /dev/null
@@ -1,9 +0,0 @@
-<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
- <g id="icon" fill="currentColor">
- <path fill-rule="evenodd" clip-rule="evenodd" d="M3.25 7L3.25 17H4.75V7H3.25Z" />
- <path fill-rule="evenodd" clip-rule="evenodd" d="M19.25 7V17H20.75V7H19.25Z" />
- <path fill-rule="evenodd" clip-rule="evenodd" d="M7.25 4L7.25 20H8.75V4H7.25Z" />
- <path fill-rule="evenodd" clip-rule="evenodd" d="M12.75 7L12.75 17L11.25 17L11.25 7L12.75 7Z" />
- <path fill-rule="evenodd" clip-rule="evenodd" d="M15.25 4V20H16.75V4H15.25Z" />
- </g>
-</svg>
diff --git a/frontend/src/assets/icons/image.svg b/frontend/src/assets/icons/image.svg
deleted file mode 100644
index bf5751153..000000000
--- a/frontend/src/assets/icons/image.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
- <g id="icon" fill="currentColor">
- <path fill-rule="evenodd" clip-rule="evenodd" d="M19 4.5H5C4.72386 4.5 4.5 4.72386 4.5 5V19C4.5 19.2761 4.72386 19.5 5 19.5H19C19.2761 19.5 19.5 19.2761 19.5 19V5C19.5 4.72386 19.2761 4.5 19 4.5ZM5 3C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3H5Z"/>
- <path fill-rule="evenodd" clip-rule="evenodd" d="M15.4772 10.4623C15.7683 10.1792 16.2317 10.1792 16.5228 10.4623L20.5228 14.3511L19.4772 15.4266L16 12.046L12.5228 15.4266C12.2719 15.6706 11.8857 15.7086 11.5921 15.5183L8.59643 13.5766L4.44186 16.606L3.55811 15.394L8.12953 12.0607C8.38061 11.8776 8.71858 11.8683 8.97934 12.0373L11.906 13.9342L15.4772 10.4623Z"/>
- </g>
-</svg>
diff --git a/frontend/src/assets/icons/source.svg b/frontend/src/assets/icons/source.svg
deleted file mode 100644
index b72f9c247..000000000
--- a/frontend/src/assets/icons/source.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path id="icon" fill-rule="evenodd" clip-rule="evenodd" d="M7.114 8.5H4V7h3.114a2.501 2.501 0 0 1 4.772 0H20v1.5h-8.114a2.501 2.501 0 0 1-4.772 0ZM4 17h8.114a2.501 2.501 0 0 0 4.771 0H20v-1.5h-3.114a2.501 2.501 0 0 0-4.771 0H4V17Z" fill="currentColor"/></svg>
diff --git a/frontend/src/assets/icons/openverse-logo-text.svg b/frontend/src/assets/openverse-logo-text.svg
similarity index 100%
rename from frontend/src/assets/icons/openverse-logo-text.svg
rename to frontend/src/assets/openverse-logo-text.svg
diff --git a/frontend/src/assets/icons/radiomark.svg b/frontend/src/assets/radiomark.svg
similarity index 100%
rename from frontend/src/assets/icons/radiomark.svg
rename to frontend/src/assets/radiomark.svg
diff --git a/frontend/src/assets/icons/all-content.svg b/frontend/src/assets/svg/raw/all.svg
similarity index 100%
rename from frontend/src/assets/icons/all-content.svg
rename to frontend/src/assets/svg/raw/all.svg
diff --git a/frontend/src/assets/icons/audio-content.svg b/frontend/src/assets/svg/raw/audio.svg
similarity index 100%
rename from frontend/src/assets/icons/audio-content.svg
rename to frontend/src/assets/svg/raw/audio.svg
diff --git a/frontend/src/assets/icons/caret-down.svg b/frontend/src/assets/svg/raw/caret-down.svg
similarity index 100%
rename from frontend/src/assets/icons/caret-down.svg
rename to frontend/src/assets/svg/raw/caret-down.svg
diff --git a/frontend/src/assets/icons/check.svg b/frontend/src/assets/svg/raw/check.svg
similarity index 100%
rename from frontend/src/assets/icons/check.svg
rename to frontend/src/assets/svg/raw/check.svg
diff --git a/frontend/src/assets/icons/checkmark.svg b/frontend/src/assets/svg/raw/checkmark.svg
similarity index 100%
rename from frontend/src/assets/icons/checkmark.svg
rename to frontend/src/assets/svg/raw/checkmark.svg
diff --git a/frontend/src/assets/icons/chevron-left.svg b/frontend/src/assets/svg/raw/chevron-left.svg
similarity index 100%
rename from frontend/src/assets/icons/chevron-left.svg
rename to frontend/src/assets/svg/raw/chevron-left.svg
diff --git a/frontend/src/assets/icons/close-small.svg b/frontend/src/assets/svg/raw/close-small.svg
similarity index 100%
rename from frontend/src/assets/icons/close-small.svg
rename to frontend/src/assets/svg/raw/close-small.svg
diff --git a/frontend/src/assets/icons/close.svg b/frontend/src/assets/svg/raw/close.svg
similarity index 100%
rename from frontend/src/assets/icons/close.svg
rename to frontend/src/assets/svg/raw/close.svg
diff --git a/frontend/src/assets/icons/ellipsis.svg b/frontend/src/assets/svg/raw/ellipsis.svg
similarity index 100%
rename from frontend/src/assets/icons/ellipsis.svg
rename to frontend/src/assets/svg/raw/ellipsis.svg
diff --git a/frontend/src/assets/icons/external-link.svg b/frontend/src/assets/svg/raw/external-link.svg
similarity index 100%
rename from frontend/src/assets/icons/external-link.svg
rename to frontend/src/assets/svg/raw/external-link.svg
diff --git a/frontend/src/assets/icons/filter.svg b/frontend/src/assets/svg/raw/filter.svg
similarity index 100%
rename from frontend/src/assets/icons/filter.svg
rename to frontend/src/assets/svg/raw/filter.svg
diff --git a/frontend/src/assets/icons/flag.svg b/frontend/src/assets/svg/raw/flag.svg
similarity index 100%
rename from frontend/src/assets/icons/flag.svg
rename to frontend/src/assets/svg/raw/flag.svg
diff --git a/frontend/src/assets/icons/globe.svg b/frontend/src/assets/svg/raw/globe.svg
similarity index 100%
rename from frontend/src/assets/icons/globe.svg
rename to frontend/src/assets/svg/raw/globe.svg
diff --git a/frontend/src/assets/icons/help.svg b/frontend/src/assets/svg/raw/help.svg
similarity index 100%
rename from frontend/src/assets/icons/help.svg
rename to frontend/src/assets/svg/raw/help.svg
diff --git a/frontend/src/assets/icons/image-content.svg b/frontend/src/assets/svg/raw/image.svg
similarity index 100%
rename from frontend/src/assets/icons/image-content.svg
rename to frontend/src/assets/svg/raw/image.svg
diff --git a/frontend/src/assets/icons/item-indicator.svg b/frontend/src/assets/svg/raw/item-indicator.svg
similarity index 100%
rename from frontend/src/assets/icons/item-indicator.svg
rename to frontend/src/assets/svg/raw/item-indicator.svg
diff --git a/frontend/src/assets/licenses/by.svg b/frontend/src/assets/svg/raw/licenses/by.svg
similarity index 100%
rename from frontend/src/assets/licenses/by.svg
rename to frontend/src/assets/svg/raw/licenses/by.svg
diff --git a/frontend/src/assets/licenses/cc.svg b/frontend/src/assets/svg/raw/licenses/cc.svg
similarity index 100%
rename from frontend/src/assets/licenses/cc.svg
rename to frontend/src/assets/svg/raw/licenses/cc.svg
diff --git a/frontend/src/assets/licenses/nc.svg b/frontend/src/assets/svg/raw/licenses/nc.svg
similarity index 100%
rename from frontend/src/assets/licenses/nc.svg
rename to frontend/src/assets/svg/raw/licenses/nc.svg
diff --git a/frontend/src/assets/licenses/nd.svg b/frontend/src/assets/svg/raw/licenses/nd.svg
similarity index 100%
rename from frontend/src/assets/licenses/nd.svg
rename to frontend/src/assets/svg/raw/licenses/nd.svg
diff --git a/frontend/src/assets/licenses/pd.svg b/frontend/src/assets/svg/raw/licenses/pd.svg
similarity index 100%
rename from frontend/src/assets/licenses/pd.svg
rename to frontend/src/assets/svg/raw/licenses/pd.svg
diff --git a/frontend/src/assets/licenses/remix.svg b/frontend/src/assets/svg/raw/licenses/remix.svg
similarity index 100%
rename from frontend/src/assets/licenses/remix.svg
rename to frontend/src/assets/svg/raw/licenses/remix.svg
diff --git a/frontend/src/assets/licenses/sa.svg b/frontend/src/assets/svg/raw/licenses/sa.svg
similarity index 100%
rename from frontend/src/assets/licenses/sa.svg
rename to frontend/src/assets/svg/raw/licenses/sa.svg
diff --git a/frontend/src/assets/licenses/sampling.plus.svg b/frontend/src/assets/svg/raw/licenses/sampling.plus.svg
similarity index 100%
rename from frontend/src/assets/licenses/sampling.plus.svg
rename to frontend/src/assets/svg/raw/licenses/sampling.plus.svg
diff --git a/frontend/src/assets/licenses/sampling.svg b/frontend/src/assets/svg/raw/licenses/sampling.svg
similarity index 100%
rename from frontend/src/assets/licenses/sampling.svg
rename to frontend/src/assets/svg/raw/licenses/sampling.svg
diff --git a/frontend/src/assets/svg/raw/licenses/share.svg b/frontend/src/assets/svg/raw/licenses/share.svg
new file mode 100644
index 000000000..446a1a4cc
--- /dev/null
+++ b/frontend/src/assets/svg/raw/licenses/share.svg
@@ -0,0 +1,5 @@
+<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <g id="icon">
+ <path d="M14.9733 0C19.1691 0 22.7222 1.45547 25.6336 4.36641C28.5436 7.25953 30 10.8038 30 15C30 19.1972 28.5708 22.7142 25.7133 25.5534C22.6959 28.5178 19.1152 30 14.9733 30C10.9191 30 7.40156 28.5267 4.41984 25.5802C1.47375 22.6341 0 19.1081 0 15.0005C0 10.9116 1.47375 7.36688 4.41984 4.36687C7.33031 1.45547 10.8483 0 14.9733 0ZM15.0267 2.70563C11.6161 2.70563 8.73234 3.91125 6.375 6.32203C3.92813 8.80453 2.70516 11.6972 2.70516 15C2.70516 18.3398 3.91922 21.2142 6.34734 23.625C8.77594 26.0541 11.6686 27.2677 15.0258 27.2677C18.3647 27.2677 21.2761 26.0447 23.7581 23.5983C26.1155 21.3127 27.2939 18.4467 27.2939 15C27.2939 11.572 26.0972 8.67891 23.7052 6.32203C21.33 3.91031 18.4369 2.70563 15.0267 2.70563ZM21.1341 10.7142C21.3656 10.7142 21.5625 10.7944 21.7228 10.9547C21.8841 11.1155 21.9647 11.3123 21.9647 11.5444V22.5797C21.9647 22.8117 21.8841 23.0081 21.7228 23.1684C21.6464 23.2468 21.5547 23.3087 21.4535 23.3503C21.3522 23.3919 21.2435 23.4123 21.1341 23.4103H12.9642C12.7317 23.4103 12.5358 23.3302 12.3745 23.1684C12.2962 23.0921 12.2343 23.0004 12.1929 22.8991C12.1514 22.7978 12.1313 22.6891 12.1336 22.5797V19.3111H8.86594C8.63297 19.3111 8.43703 19.2314 8.27625 19.0706C8.19792 18.994 8.13613 18.9022 8.09469 18.8007C8.05325 18.6993 8.03304 18.5905 8.03531 18.4809V7.44656C8.03531 7.23187 8.10609 7.04906 8.25 6.89766C8.39182 6.74648 8.58037 6.64742 8.78531 6.61641H17.0348C17.2664 6.61641 17.4633 6.69656 17.6245 6.85734C17.7848 7.01766 17.8655 7.215 17.8655 7.44703V10.7152H21.1341V10.7142ZM9.66938 17.6784H12.1336V11.5444C12.1336 11.3302 12.2044 11.1473 12.3483 10.9955C12.4827 10.8489 12.6613 10.7502 12.8569 10.7142H16.2319V8.27672H9.66938V17.6784ZM20.3302 12.3478H13.7677V21.75H20.3302V12.3478Z" fill="black"/>
+ </g>
+</svg>
diff --git a/frontend/src/assets/licenses/zero.svg b/frontend/src/assets/svg/raw/licenses/zero.svg
similarity index 100%
rename from frontend/src/assets/licenses/zero.svg
rename to frontend/src/assets/svg/raw/licenses/zero.svg
diff --git a/frontend/src/assets/icons/menu.svg b/frontend/src/assets/svg/raw/menu.svg
similarity index 100%
rename from frontend/src/assets/icons/menu.svg
rename to frontend/src/assets/svg/raw/menu.svg
diff --git a/frontend/src/assets/icons/model-3d.svg b/frontend/src/assets/svg/raw/model-3d.svg
similarity index 100%
rename from frontend/src/assets/icons/model-3d.svg
rename to frontend/src/assets/svg/raw/model-3d.svg
diff --git a/frontend/src/assets/icons/pause.svg b/frontend/src/assets/svg/raw/pause.svg
similarity index 100%
rename from frontend/src/assets/icons/pause.svg
rename to frontend/src/assets/svg/raw/pause.svg
diff --git a/frontend/src/assets/icons/play.svg b/frontend/src/assets/svg/raw/play.svg
similarity index 100%
rename from frontend/src/assets/icons/play.svg
rename to frontend/src/assets/svg/raw/play.svg
diff --git a/frontend/src/assets/svg/raw/radiomark.svg b/frontend/src/assets/svg/raw/radiomark.svg
new file mode 100644
index 000000000..ad1d2bc0d
--- /dev/null
+++ b/frontend/src/assets/svg/raw/radiomark.svg
@@ -0,0 +1,5 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <g id="icon">
+ <circle cx="12" cy="12" r="7.2" fill="currentColor"/>
+ </g>
+</svg>
diff --git a/frontend/src/assets/icons/replay.svg b/frontend/src/assets/svg/raw/replay.svg
similarity index 100%
rename from frontend/src/assets/icons/replay.svg
rename to frontend/src/assets/svg/raw/replay.svg
diff --git a/frontend/src/assets/icons/search.svg b/frontend/src/assets/svg/raw/search.svg
similarity index 100%
rename from frontend/src/assets/icons/search.svg
rename to frontend/src/assets/svg/raw/search.svg
diff --git a/frontend/src/assets/svg/raw/source.svg b/frontend/src/assets/svg/raw/source.svg
new file mode 100644
index 000000000..95c20936b
--- /dev/null
+++ b/frontend/src/assets/svg/raw/source.svg
@@ -0,0 +1 @@
+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path id="icon" fill-rule="evenodd" clip-rule="evenodd" d="M7.114 8.5H4V7h3.114a2.501 2.501 0 0 1 4.772 0H20v1.5h-8.114a2.501 2.501 0 0 1-4.772 0ZM4 17h8.114a2.501 2.501 0 0 0 4.771 0H20v-1.5h-3.114a2.501 2.501 0 0 0-4.771 0H4V17Z" fill="currentColor"/></svg>
diff --git a/frontend/src/assets/icons/video-content.svg b/frontend/src/assets/svg/raw/video.svg
similarity index 100%
rename from frontend/src/assets/icons/video-content.svg
rename to frontend/src/assets/svg/raw/video.svg
diff --git a/frontend/src/components/VAudioTrack/VPlayPause.vue b/frontend/src/components/VAudioTrack/VPlayPause.vue
index 6a9dd14e6..a3fef9c08 100644
--- a/frontend/src/components/VAudioTrack/VPlayPause.vue
+++ b/frontend/src/components/VAudioTrack/VPlayPause.vue
@@ -3,7 +3,7 @@
v-bind="$attrs"
:tabindex="isTabbable ? 0 : -1"
class="play-pause flex-shrink-0 border-dark-charcoal bg-dark-charcoal text-white focus-visible:border-pink focus-visible:shadow-ring focus-visible:outline-none active:shadow-ring disabled:opacity-70"
- :icon-props="icon === undefined ? undefined : { iconPath: icon }"
+ :icon-props="icon === undefined ? undefined : { name: icon }"
:label="$t(label)"
:button-props="buttonProps"
@click.stop.prevent="handleClick"
@@ -38,14 +38,10 @@ import type { ButtonConnections, ButtonVariant } from "~/types/button"
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"
-
const statusIconMap = {
- playing: pauseIcon,
- paused: playIcon,
- played: replayIcon,
+ playing: "pause",
+ paused: "play",
+ played: "replay",
loading: undefined,
} as const
diff --git a/frontend/src/components/VBackToSearchResultsLink.vue b/frontend/src/components/VBackToSearchResultsLink.vue
index a43734c4d..c6c4c1ecd 100644
--- a/frontend/src/components/VBackToSearchResultsLink.vue
+++ b/frontend/src/components/VBackToSearchResultsLink.vue
@@ -4,7 +4,7 @@
class="time inline-flex flex-row items-center gap-2 rounded-sm p-2 pe-3 text-xs font-semibold text-dark-charcoal-70 hover:text-dark-charcoal"
v-bind="$attrs"
>
- <VIcon :icon-path="chevronIcon" :rtl-flip="true" />
+ <VIcon name="chevron-left" :rtl-flip="true" />
{{ $t("single-result.back") }}
</VLink>
</template>
@@ -15,8 +15,6 @@ import { defineComponent } from "vue"
import VIcon from "~/components/VIcon/VIcon.vue"
import VLink from "~/components/VLink.vue"
-import chevronIcon from "~/assets/icons/chevron-left.svg"
-
/**
* This link takes the user from a single result back to the list of all
* results. It only appears if the user navigated from the search results.
@@ -27,8 +25,5 @@ export default defineComponent({
VLink,
},
inheritAttrs: false,
- setup() {
- return { chevronIcon }
- },
})
</script>
diff --git a/frontend/src/components/VCheckbox/VCheckbox.vue b/frontend/src/components/VCheckbox/VCheckbox.vue
index af522a213..aba006bcc 100644
--- a/frontend/src/components/VCheckbox/VCheckbox.vue
+++ b/frontend/src/components/VCheckbox/VCheckbox.vue
@@ -48,7 +48,7 @@
v-else
v-show="localCheckedState"
class="absolute inset-0 transform text-white"
- :icon-path="checkIcon"
+ name="check"
:size="5"
/>
</span>
@@ -64,8 +64,6 @@ import { defineEvent } from "~/types/emits"
import VIcon from "~/components/VIcon/VIcon.vue"
-import checkIcon from "~/assets/icons/check.svg"
-
type CheckboxAttrs = {
name: string
value: string
@@ -182,7 +180,6 @@ export default defineComponent({
})
}
return {
- checkIcon,
localCheckedState,
labelClasses,
inputAttrs,
diff --git a/frontend/src/components/VCloseButton.vue b/frontend/src/components/VCloseButton.vue
index 32092142c..34f0a05c6 100644
--- a/frontend/src/components/VCloseButton.vue
+++ b/frontend/src/components/VCloseButton.vue
@@ -1,14 +1,7 @@
<template>
<VIconButton
- :button-props="{
- variant:
- variant === 'black'
- ? 'plain--avoid'
- : variant === 'filled-white-light'
- ? 'filled-white'
- : variant,
- }"
- :icon-props="{ iconPath }"
+ :button-props="buttonProps"
+ :icon-props="iconProps"
:borderless="true"
:size="size"
:class="{
@@ -24,12 +17,19 @@
<script lang="ts">
import { computed, defineComponent, PropType } from "vue"
+import type { ButtonVariant } from "~/types/button"
+
import VIconButton from "~/components/VIconButton/VIconButton.vue"
import type { TranslateResult } from "vue-i18n"
-import closeIcon from "~/assets/icons/close.svg"
-import closeIconSmall from "~/assets/icons/close-small.svg"
+type CloseButtonVariant =
+ | "filled-white"
+ | "filled-white-light"
+ | "filled-transparent"
+ | "filled-dark"
+ | "black"
+ | "plain--avoid"
/**
* The square icon button with a cross in it. Used to close popovers,
@@ -54,13 +54,7 @@ export default defineComponent({
* @default "filled-white-light"
*/
variant: {
- type: String as PropType<
- | "filled-white"
- | "filled-white-light"
- | "filled-transparent"
- | "filled-dark"
- | "black"
- >,
+ type: String as PropType<CloseButtonVariant>,
default: "filled-white-light",
},
/**
@@ -81,12 +75,23 @@ export default defineComponent({
},
},
setup(props) {
- const iconPath = computed<string>(() => {
- return props.iconSize === "small" ? closeIconSmall : closeIcon
+ const iconProps = computed(() => {
+ return { name: props.iconSize === "small" ? "close-small" : "close" }
+ })
+
+ const buttonProps = computed<{ variant: ButtonVariant }>(() => {
+ const variant =
+ props.variant === "black"
+ ? "plain--avoid"
+ : props.variant === "filled-white-light"
+ ? "filled-white"
+ : props.variant
+ return { variant }
})
return {
- iconPath,
+ buttonProps,
+ iconProps,
}
},
})
diff --git a/frontend/src/components/VContentLink/VContentLink.vue b/frontend/src/components/VContentLink/VContentLink.vue
index 6bc03aa0c..4c1565caf 100644
--- a/frontend/src/components/VContentLink/VContentLink.vue
+++ b/frontend/src/components/VContentLink/VContentLink.vue
@@ -11,7 +11,7 @@
@keydown.native.shift.tab.exact="$emit('shift-tab', $event)"
>
<div class="flex flex-col items-start md:flex-row md:items-center">
- <VIcon :icon-path="iconPath" />
+ <VIcon :name="mediaType" />
<p class="hidden pt-1 font-semibold md:block md:ps-2 md:pt-0 md:text-2xl">
{{ $t(`search-type.see-${mediaType}`) }}
</p>
@@ -27,24 +27,15 @@
import { computed, defineComponent, PropType } from "vue"
import { useI18nResultsCount } from "~/composables/use-i18n-utilities"
-import { AUDIO, IMAGE, SupportedMediaType } from "~/constants/media"
+import type { SupportedMediaType } from "~/constants/media"
import { defineEvent } from "~/types/emits"
-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"
-
-const iconMapping = {
- [AUDIO]: audioIcon,
- [IMAGE]: imageIcon,
-}
-
export default defineComponent({
name: "VContentLink",
- components: { VIcon, VLink },
+ components: { VLink },
props: {
/**
* One of the media types supported.
@@ -72,14 +63,11 @@ export default defineComponent({
"shift-tab": defineEvent<[KeyboardEvent]>(),
},
setup(props) {
- const iconPath = computed(() => iconMapping[props.mediaType])
const { getI18nCount } = useI18nResultsCount()
const hasResults = computed(() => props.resultsCount > 0)
const resultsCountLabel = computed(() => getI18nCount(props.resultsCount))
return {
- iconPath,
- imageIcon,
resultsCountLabel,
hasResults,
}
diff --git a/frontend/src/components/VContentReport/VContentReportButton.vue b/frontend/src/components/VContentReport/VContentReportButton.vue
index 0ed1238ff..228d22373 100644
--- a/frontend/src/components/VContentReport/VContentReportButton.vue
+++ b/frontend/src/components/VContentReport/VContentReportButton.vue
@@ -9,7 +9,7 @@
<span class="hidden text-sr md:inline md:text-base">{{
$t("media-details.content-report.long")
}}</span>
- <VIcon :icon-path="icons.flag" class="ms-2" />
+ <VIcon name="flag" class="ms-2" />
</VButton>
</template>
@@ -19,18 +19,9 @@ import { defineComponent } from "vue"
import VIcon from "~/components/VIcon/VIcon.vue"
import VButton from "~/components/VButton.vue"
-import flagIcon from "~/assets/icons/flag.svg"
-
export default defineComponent({
name: "VContentReportButton",
components: { VButton, VIcon },
- setup() {
- return {
- icons: {
- flag: flagIcon,
- },
- }
- },
})
</script>
diff --git a/frontend/src/components/VContentReport/VContentReportForm.vue b/frontend/src/components/VContentReport/VContentReportForm.vue
index a8466fec9..498d9ca79 100644
--- a/frontend/src/components/VContentReport/VContentReportForm.vue
+++ b/frontend/src/components/VContentReport/VContentReportForm.vue
@@ -92,7 +92,7 @@
:href="DMCA_FORM_URL"
>
{{ $t("media-details.content-report.form.dmca.open") }}
- <VIcon :size="4" class="ms-1" :icon-path="icons.externalLink" />
+ <VIcon :size="4" class="ms-1" name="external-link" />
</VButton>
<VButton
v-else
@@ -136,8 +136,6 @@ 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"
-
export default defineComponent({
name: "VContentReportForm",
components: {
@@ -201,9 +199,6 @@ export default defineComponent({
}
return {
- icons: {
- externalLink: externalLinkIcon,
- },
reasons,
DMCA,
OTHER,
diff --git a/frontend/src/components/VContentSwitcher/VSearchTypeButton.vue b/frontend/src/components/VContentSwitcher/VSearchTypeButton.vue
index e0762fdbd..16ab1f279 100644
--- a/frontend/src/components/VContentSwitcher/VSearchTypeButton.vue
+++ b/frontend/src/components/VContentSwitcher/VSearchTypeButton.vue
@@ -8,10 +8,10 @@
v-bind="$attrs"
@click="$emit('click')"
>
- <VIcon :icon-path="icon" />
+ <VIcon :name="searchType" class="h-6 w-6" />
<template v-if="showLabel">
<span class="label-regular block truncate text-start">{{ label }}</span>
- <VIcon :icon-path="caretDownIcon" />
+ <VIcon name="caret-down" />
</template>
</VButton>
</template>
@@ -25,8 +25,6 @@ import { warn } from "~/utils/console"
import VIcon from "~/components/VIcon/VIcon.vue"
import VButton from "~/components/VButton.vue"
-import caretDownIcon from "~/assets/icons/caret-down.svg"
-
/**
* This is the search type switcher button that appears in the header or the homepage search bar.
*/
@@ -60,10 +58,6 @@ export default defineComponent({
"You should provide `aria-haspopup` and `aria-expanded` props to VSearchTypeButton."
)
}
-
- return {
- caretDownIcon,
- }
},
})
</script>
diff --git a/frontend/src/components/VContentSwitcher/VSearchTypeItem.vue b/frontend/src/components/VContentSwitcher/VSearchTypeItem.vue
index 9461bf258..d811d66ab 100644
--- a/frontend/src/components/VContentSwitcher/VSearchTypeItem.vue
+++ b/frontend/src/components/VContentSwitcher/VSearchTypeItem.vue
@@ -8,7 +8,7 @@
v-bind="{ href }"
@click.native="$emit('click', item)"
>
- <VIcon :icon-path="icon" />
+ <VIcon :name="icon" class="h-6 w-6" />
<span>{{ $t(`search-type.${item}`) }}</span>
<VPill v-if="isBeta" class="ms-auto">{{
$t("search-type.status-beta")
diff --git a/frontend/src/components/VErrorSection/VNoResults.vue b/frontend/src/components/VErrorSection/VNoResults.vue
index 262e64fe4..4d5dbd8ed 100644
--- a/frontend/src/components/VErrorSection/VNoResults.vue
+++ b/frontend/src/components/VErrorSection/VNoResults.vue
@@ -17,7 +17,7 @@
class="label-bold justify-between text-dark-charcoal md:justify-start md:gap-x-2"
>
{{ source.name }}
- <VIcon :icon-path="externalLinkIcon" :size="4" rtl-flip />
+ <VIcon name="external-link" :size="4" rtl-flip />
</VButton>
</div>
</div>
@@ -29,11 +29,8 @@ import { defineComponent, PropType } from "vue"
import type { ExternalSource } from "~/types/external-source"
import VButton from "~/components/VButton.vue"
-
import VIcon from "~/components/VIcon/VIcon.vue"
-import externalLinkIcon from "~/assets/icons/external-link.svg"
-
export default defineComponent({
name: "VNoResults",
components: { VIcon, VButton },
@@ -47,10 +44,5 @@ export default defineComponent({
required: true,
},
},
- setup() {
- return {
- externalLinkIcon,
- }
- },
})
</script>
diff --git a/frontend/src/components/VExternalSearch/VExternalSearchForm.vue b/frontend/src/components/VExternalSearch/VExternalSearchForm.vue
index 77014ce9f..5e4eb6670 100644
--- a/frontend/src/components/VExternalSearch/VExternalSearchForm.vue
+++ b/frontend/src/components/VExternalSearch/VExternalSearchForm.vue
@@ -48,7 +48,7 @@
}}<VIcon
class="text-dark-charcoal-40"
:class="{ 'text-white': triggerA11yProps['aria-expanded'] }"
- :icon-path="caretDownIcon"
+ name="caret-down"
/>
</VButton>
<template v-if="triggerElement">
@@ -103,8 +103,6 @@ import VIcon from "~/components/VIcon/VIcon.vue"
import VPopoverContent from "~/components/VPopover/VPopoverContent.vue"
import VModalContent from "~/components/VModal/VModalContent.vue"
-import caretDownIcon from "~/assets/icons/caret-down.svg"
-
export default defineComponent({
name: "VExternalSearchForm",
components: {
@@ -176,8 +174,6 @@ export default defineComponent({
triggerA11yProps,
isVisible,
-
- caretDownIcon,
}
},
})
diff --git a/frontend/src/components/VExternalSearch/VExternalSourceList.vue b/frontend/src/components/VExternalSearch/VExternalSourceList.vue
index 5a7bc9042..cf226fae1 100644
--- a/frontend/src/components/VExternalSearch/VExternalSourceList.vue
+++ b/frontend/src/components/VExternalSearch/VExternalSourceList.vue
@@ -21,12 +21,7 @@
:href="source.url"
>
{{ source.name }}
- <VIcon
- :icon-path="icons.externalLink"
- :size="4"
- :rtl-flip="true"
- class="ms-2"
- />
+ <VIcon name="external-link" :size="4" :rtl-flip="true" class="ms-2" />
</VButton>
</div>
</template>
@@ -40,9 +35,6 @@ import VButton from "~/components/VButton.vue"
import VCloseButton from "~/components/VCloseButton.vue"
import VIcon from "~/components/VIcon/VIcon.vue"
-import externalLinkIcon from "~/assets/icons/external-link.svg"
-import caretDownIcon from "~/assets/icons/caret-down.svg"
-
/**
* This component renders a list of pre-populated links to additional sources
* when there are insufficient or zero search results.
@@ -59,13 +51,5 @@ export default defineComponent({
required: true,
},
},
- setup() {
- return {
- icons: {
- externalLink: externalLinkIcon,
- caretDown: caretDownIcon,
- },
- }
- },
})
</script>
diff --git a/frontend/src/components/VFilters/VFilterChecklist.vue b/frontend/src/components/VFilters/VFilterChecklist.vue
index ac13b6014..15bc07f64 100644
--- a/frontend/src/components/VFilters/VFilterChecklist.vue
+++ b/frontend/src/components/VFilters/VFilterChecklist.vue
@@ -34,7 +34,7 @@
class="text-dark-charcoal-70"
type="button"
>
- <VIcon :icon-path="icons.help" />
+ <VIcon name="help" />
</VButton>
</template>
<template #default="{ close }">
@@ -73,15 +73,13 @@ import VLicense from "~/components/VLicense/VLicense.vue"
import VLicenseExplanation from "~/components/VFilters/VLicenseExplanation.vue"
import VPopover from "~/components/VPopover/VPopover.vue"
-import helpIcon from "~/assets/icons/help.svg"
-
type toggleFilterPayload = {
filterType: NonMatureFilterCategory
code: string
}
export default defineComponent({
- name: "FilterCheckList",
+ name: "VFilterCheckList",
components: {
VCloseButton,
VCheckbox,
@@ -139,7 +137,6 @@ export default defineComponent({
const isDisabled = (item: FilterItem) =>
useSearchStore().isFilterDisabled(item, props.filterType) ??
props.disabled
- const icons = { help: helpIcon }
const isLicense = (code: string): code is License => {
// Quick check that also prevents "`code` is declared but its value is never read" warning.
@@ -147,7 +144,6 @@ export default defineComponent({
}
return {
- icons,
isDisabled,
itemLabel,
onValueChange,
diff --git a/frontend/src/components/VHeader/VFilterIconOrCounter.vue b/frontend/src/components/VHeader/VFilterIconOrCounter.vue
index bd38e0058..76fb0be5c 100644
--- a/frontend/src/components/VHeader/VFilterIconOrCounter.vue
+++ b/frontend/src/components/VHeader/VFilterIconOrCounter.vue
@@ -1,5 +1,5 @@
<template>
- <VIcon v-if="showIcon" :icon-path="filterIcon" />
+ <VIcon v-if="showIcon" name="filter" />
<p
v-else
class="flex h-6 w-6 items-center justify-center rounded-sm"
@@ -13,8 +13,6 @@ import { computed, defineComponent } from "@nuxtjs/composition-api"
import VIcon from "~/components/VIcon/VIcon.vue"
-import filterIcon from "~/assets/icons/filter.svg"
-
export default defineComponent({
name: "VFilterIconOrCounter",
components: { VIcon },
@@ -33,7 +31,6 @@ export default defineComponent({
return {
showIcon,
- filterIcon,
}
},
})
diff --git a/frontend/src/components/VHeader/VHeaderDesktop.vue b/frontend/src/components/VHeader/VHeaderDesktop.vue
index ce6e36f48..1aaa97ae8 100644
--- a/frontend/src/components/VHeader/VHeaderDesktop.vue
+++ b/frontend/src/components/VHeader/VHeaderDesktop.vue
@@ -18,7 +18,7 @@
>
<VSearchBarButton
v-show="searchTerm !== ''"
- :icon-path="closeIcon"
+ icon="close-small"
:label="$t('browse-page.search-form.clear')"
inner-area-classes="bg-white hover:bg-dark-charcoal-10"
class="hidden group-focus-within:flex"
@@ -64,8 +64,6 @@ 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"
-
/**
* The desktop search header.
*/
@@ -113,7 +111,6 @@ export default defineComponent({
const isXl = computed(() => uiStore.isBreakpoint("xl"))
return {
- closeIcon,
filterButtonRef,
searchBarRef,
isFetching,
diff --git a/frontend/src/components/VHeader/VHeaderInternal.vue b/frontend/src/components/VHeader/VHeaderInternal.vue
index 6c44b2ba7..8e3d668c6 100644
--- a/frontend/src/components/VHeader/VHeaderInternal.vue
+++ b/frontend/src/components/VHeader/VHeaderInternal.vue
@@ -15,7 +15,7 @@
<VIconButton
id="menu-button"
ref="menuButtonRef"
- :icon-props="{ iconPath: menuIcon }"
+ :icon-props="{ name: 'menu' }"
:label="$t('header.aria.menu')"
v-bind="triggerA11yProps"
class="border-tx hover:bg-dark-charcoal hover:text-white"
@@ -101,8 +101,6 @@ import VModalContent from "~/components/VModal/VModalContent.vue"
import VPopoverContent from "~/components/VPopover/VPopoverContent.vue"
import VWordPressLink from "~/components/VHeader/VWordPressLink.vue"
-import menuIcon from "~/assets/icons/menu.svg"
-
export default defineComponent({
name: "VHeaderInternal",
components: {
@@ -164,8 +162,6 @@ export default defineComponent({
modalContentRef,
nodeRef,
- menuIcon,
-
allPages,
currentPage,
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
index 5a6f30fd9..f2152fbaf 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
@@ -1,7 +1,7 @@
<template>
<VSearchBarButton
id="content-settings-button"
- :icon-path="sourceIcon"
+ icon="source"
:label="
appliedFilterCount
? $tc('header.content-settings-button.with-count', appliedFilterCount)
@@ -24,8 +24,6 @@
<script lang="ts">
import VSearchBarButton from "~/components/VHeader/VHeaderMobile/VSearchBarButton.vue"
-import sourceIcon from "~/assets/icons/source.svg"
-
export default {
name: "VContentSettingsButton",
components: { VSearchBarButton },
@@ -39,10 +37,5 @@ export default {
default: 0,
},
},
- setup() {
- return {
- sourceIcon: sourceIcon as unknown as string,
- }
- },
}
</script>
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue
index 3af28506c..df4cd8caa 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue
@@ -21,14 +21,14 @@
id="content-settings"
size="medium"
class="me-4 gap-x-2"
- ><VIcon :icon-path="searchType.icon" />
+ ><VIcon :name="searchType.searchType" />
<h2 class="label-regular">{{ $t("search-type.heading") }}</h2></VTab
>
<h2
v-else
class="label-regular relative my-2 me-4 flex h-12 items-center gap-x-2 px-2 after:absolute after:bottom-[-0.625rem] after:right-1/2 after:h-0.5 after:w-full after:translate-x-1/2 after:translate-y-[-50%] after:bg-dark-charcoal"
>
- <VIcon :icon-path="searchType.icon" />
+ <VIcon :name="searchType.searchType" />
{{ $t("search-type.heading") }}
</h2>
<VFilterTab
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
index 9f1429aef..17e341bda 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
@@ -32,7 +32,7 @@
/>
<VSearchBarButton
v-show="searchBarIsActive"
- :icon-path="chevronLeftIcon"
+ icon="chevron-left"
:inner-size="8"
:label="$t('header.back-button')"
:rtl-flip="true"
@@ -69,7 +69,7 @@
<slot>
<VSearchBarButton
v-show="searchBarIsActive && searchTerm"
- :icon-path="closeIcon"
+ icon="close-small"
:label="$t('browse-page.search-form.clear')"
inner-area-classes="bg-white hover:bg-dark-charcoal-10"
@click="clearSearchText"
@@ -134,9 +134,6 @@ import VContentSettingsButton from "~/components/VHeader/VHeaderMobile/VContentS
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"
-
/**
* Displays a text field for a search query and is attached to an action button
* that fires a search request. The loading state and number of hits are also
@@ -292,8 +289,6 @@ export default defineComponent({
})
return {
- chevronLeftIcon: chevronLeftIcon as unknown as string,
- closeIcon: closeIcon as unknown as string,
searchInputRef,
headerRef,
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue b/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
index 24229e845..d4e35cafb 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
@@ -11,7 +11,7 @@
:class="[`h-${innerSize} w-${innerSize}`, innerAreaClasses]"
>
<VIcon
- :icon-path="iconPath"
+ :name="icon"
:rtl-flip="rtlFlip"
class="pointer-events-none"
:size="iconSize"
@@ -43,7 +43,7 @@ export default defineComponent({
/**
* The path for the icon.
*/
- iconPath: {
+ icon: {
type: String,
required: true,
},
diff --git a/frontend/src/components/VHeader/VPageLinks.vue b/frontend/src/components/VHeader/VPageLinks.vue
index 926c1d18f..7c8c46312 100644
--- a/frontend/src/components/VHeader/VPageLinks.vue
+++ b/frontend/src/components/VHeader/VPageLinks.vue
@@ -19,7 +19,7 @@
<span class="pe-2">{{ $t(page.name) }}</span>
<VIcon
v-if="isLinkExternal(page)"
- :icon-path="externalLinkIcon"
+ name="external-link"
:size="4"
class="self-center"
rtl-flip
@@ -41,7 +41,7 @@
>{{ $t(page.name)
}}<VIcon
v-if="isLinkExternal(page)"
- :icon-path="externalLinkIcon"
+ name="external-link"
:size="externalIconSize"
class="ms-2 self-center"
rtl-flip
@@ -60,8 +60,6 @@ import VItem from "~/components/VItemGroup/VItem.vue"
import VIcon from "~/components/VIcon/VIcon.vue"
import VLink from "~/components/VLink.vue"
-import externalLinkIcon from "~/assets/icons/external-link.svg"
-
export default defineComponent({
name: "VPageLinks",
components: {
@@ -116,7 +114,7 @@ export default defineComponent({
currentPage,
onClick,
isLinkExternal,
- externalLinkIcon,
+
externalIconSize,
}
},
diff --git a/frontend/src/components/VHeader/VSearchBar/VSearchButton.vue b/frontend/src/components/VHeader/VSearchBar/VSearchButton.vue
index 30bbd6472..dcfb4f792 100644
--- a/frontend/src/components/VHeader/VSearchBar/VSearchButton.vue
+++ b/frontend/src/components/VHeader/VSearchBar/VSearchButton.vue
@@ -16,7 +16,7 @@
sizeClasses,
]"
>
- <VIcon v-show="isIcon" :icon-path="searchIcon" />
+ <VIcon v-show="isIcon" name="search" />
<span v-show="!isIcon">{{ $t("search.search") }}</span>
</VButton>
</template>
@@ -29,8 +29,6 @@ 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 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.
@@ -74,7 +72,7 @@ export default defineComponent({
: undefined
)
- return { searchIcon, sizeClasses, isIcon }
+ return { sizeClasses, isIcon }
},
})
</script>
diff --git a/frontend/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue b/frontend/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue
index a1b89b0d0..77ff75aff 100644
--- a/frontend/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue
+++ b/frontend/src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue
@@ -39,7 +39,7 @@
!isHomeRoute,
}"
>
- <VIcon :icon-path="searchIcon" />
+ <VIcon name="search" />
</VButton>
</form>
</template>
@@ -52,8 +52,6 @@ import { defineEvent } from "~/types/emits"
import VButton from "~/components/VButton.vue"
import VIcon from "~/components/VIcon/VIcon.vue"
-import searchIcon from "~/assets/icons/search.svg"
-
/**
* Displays a search input for a search query and is attached to an action button
* that fires a search request. Can contain other elements like the search type
@@ -97,8 +95,6 @@ export default defineComponent({
inputRef,
handleSearch,
isHomeRoute,
-
- searchIcon,
}
},
})
diff --git a/frontend/src/components/VHeader/meta/VSearchBarButton.stories.mdx b/frontend/src/components/VHeader/meta/VSearchBarButton.stories.mdx
index 8171cbab3..40b3e10e7 100644
--- a/frontend/src/components/VHeader/meta/VSearchBarButton.stories.mdx
+++ b/frontend/src/components/VHeader/meta/VSearchBarButton.stories.mdx
@@ -8,10 +8,6 @@ import {
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"
-
<Meta
title="Components/VHeader/VHeaderMobile/VSearchBarButton"
component={VSearchBarButton}
@@ -19,8 +15,8 @@ import sourceIcon from "~/assets/icons/source.svg"
iconPath: {
control: {
type: "select",
- options: [closeIcon, chevronLeftIcon, sourceIcon],
- default: closeIcon,
+ options: ["close-small", "chevron-left", "source"],
+ default: "close-small",
},
},
innerSize: {
@@ -49,10 +45,10 @@ export const Template = (args) => ({
template: `<div class="bg-white"><VSearchBarButton label="VSearchBarButton" v-bind="args" v-on="args" /></div>`,
components: { VSearchBarButton },
setup() {
- if (!args.iconPath) {
- args.iconPath = closeIcon
+ if (!args.icon) {
+ args.icon = "close"
}
- return { args, closeIcon, chevronLeftIcon, sourceIcon }
+ return { args }
},
})
@@ -95,21 +91,21 @@ corner.
export const activeButtonsTemplate = (args) => ({
template: `<div class="wrapper rounded-sm bg-white flex justify-between ring ring-pink">
<VSearchBarButton
- :icon-path="chevronLeftIcon"
+ icon="chevron-left"
:inner-size="8"
:label="$t('header.back-button')"
inner-area-classes="hover:bg-dark-charcoal hover:text-white"
:rtl-flip="true"
/>
<VSearchBarButton
- :icon-path="closeIcon"
+ icon="close-small"
:label="$t('browse-page.search-form.clear')"
inner-area-classes="bg-white hover:bg-dark-charcoal-10"
/>
</div>`,
components: { VContentSettingsButton },
setup() {
- return { args, closeIcon, chevronLeftIcon }
+ return { args }
},
})
diff --git a/frontend/src/components/VIcon/VIcon.vue b/frontend/src/components/VIcon/VIcon.vue
index 64ba19c5a..fa526251f 100644
--- a/frontend/src/components/VIcon/VIcon.vue
+++ b/frontend/src/components/VIcon/VIcon.vue
@@ -1,24 +1,18 @@
<template>
- <svg
+ <SvgIcon
class="v-icon flex-shrink-0 flex-grow-0"
:class="[`w-${size}`, `h-${size}`, { 'rtl-flip': rtlFlip }]"
- xmlns="http://www.w3.org/2000/svg"
- :viewBox="viewBox"
+ :name="name"
aria-hidden="true"
focusable="false"
- >
- <use :href="`${iconPath}#${gId}`" />
- </svg>
+ />
</template>
<script lang="ts">
import { defineComponent } from "vue"
-import { isTest } from "~/utils/node-env"
-
-export type IconPath = string
export type IconProps = {
- iconPath: IconPath
+ name: string
viewBox?: string
gId?: string
size?: number
@@ -42,11 +36,11 @@ export default defineComponent({
* the path to the icon SVG; In a bundled application like Openverse,
* importing an SVG should give us the path to the file.
*/
- iconPath: {
+ name: {
/**
* In `jest` our icons get transformed to Vue components
*/
- type: isTest ? Object : String,
+ type: String,
required: true,
},
/**
diff --git a/frontend/src/components/VIcon/meta/VIcon.stories.mdx b/frontend/src/components/VIcon/meta/VIcon.stories.mdx
index b747633dd..8b889bb29 100644
--- a/frontend/src/components/VIcon/meta/VIcon.stories.mdx
+++ b/frontend/src/components/VIcon/meta/VIcon.stories.mdx
@@ -8,11 +8,17 @@ import {
import VIcon from "~/components/VIcon/VIcon.vue"
-import replayIcon from "~/assets/icons/replay.svg"
-import externalLinkIcon from "~/assets/icons/external-link.svg"
+import spriteData from "~svgsprite/sprites.json"
<Meta title="Components/VIcon" component={VIcon} />
+export const iconNames = spriteData.reduce((accumulator, sprite) => {
+ const iconsWithNamespace = sprite.symbols.map((symbol) =>
+ sprite.defaultSprite ? symbol : `${sprite.name}/${symbol}`
+ )
+ return accumulator.concat(iconsWithNamespace)
+}, [])
+
export const Template = (args) => ({
template: `<VIcon v-bind="args" />`,
components: { VIcon },
@@ -27,35 +33,30 @@ export const Template = (args) => ({
<ArgsTable of={VIcon} />
-To display the icon, the path to the SVG must be specified. When using a bundler
-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
-```
-
-You can then pass this imported value as the `iconPath` prop.
+To display the icon, pass the name of the icon as a prop.
```html
-<VIcon :iconPath="iconSvg" />
+<VIcon name="icon-name" />
```
<Canvas>
<Story
name="Default"
args={{
- iconPath: replayIcon,
+ name: "replay",
+ }}
+ argTypes={{
+ name: {
+ options: iconNames,
+ control: { type: "select" },
+ defaultValue: "replay",
+ },
}}
>
{Template.bind({})}
</Story>
</Canvas>
-Each icon SVG must have a `<g>` element right below the top-level `<svg>`
-element. This element should have the `id` attribute equal to `"icon"`. If not,
-pass the attribute value as the `gId` prop.
-
## RTL
`VIcon` can flip the icon for RTL languages. This is useful for certain icons
@@ -69,7 +70,7 @@ using the 🌐 button.
name="RTL"
args={{
rtlFlip: true,
- iconPath: externalLinkIcon,
+ name: "external-link",
}}
>
{Template.bind({})}
diff --git a/frontend/src/components/VIconButton/meta/VIconButton.stories.mdx b/frontend/src/components/VIconButton/meta/VIconButton.stories.mdx
index c213589e6..7a4fdd5c6 100644
--- a/frontend/src/components/VIconButton/meta/VIconButton.stories.mdx
+++ b/frontend/src/components/VIconButton/meta/VIconButton.stories.mdx
@@ -8,8 +8,6 @@ import {
import VIconButton from "~/components/VIconButton/VIconButton.vue"
-import replayIcon from "~/assets/icons/replay.svg"
-
<Meta
title="Components/VIconButton"
component={VIconButton}
@@ -61,7 +59,7 @@ export const sizesTemplate = (args) => ({
name="Default"
args={{
iconProps: {
- iconPath: replayIcon,
+ name: "replay",
},
}}
>
@@ -76,7 +74,7 @@ export const sizesTemplate = (args) => ({
name="Sizes"
args={{
iconProps: {
- iconPath: replayIcon,
+ name: "replay",
},
}}
>
diff --git a/frontend/src/components/VItemGroup/VItem.vue b/frontend/src/components/VItemGroup/VItem.vue
index 0766a1aea..46326f4f8 100644
--- a/frontend/src/components/VItemGroup/VItem.vue
+++ b/frontend/src/components/VItemGroup/VItem.vue
@@ -56,7 +56,7 @@
"
class="absolute"
:class="contextProps.size === 'small' ? 'end-3' : 'end-5'"
- :icon-path="itemIndicator"
+ name="item-indicator"
/>
</VButton>
</div>
@@ -76,8 +76,6 @@ import VButton from "~/components/VButton.vue"
import VIcon from "~/components/VIcon/VIcon.vue"
import { VPopoverContentContextKey } from "~/components/VPopover/VPopoverContent.vue"
-import itemIndicator from "~/assets/icons/item-indicator.svg"
-
export default defineComponent({
name: "VItem",
components: { VButton, VIcon },
@@ -159,7 +157,6 @@ export default defineComponent({
})
return {
- itemIndicator,
contextProps,
isInPopover,
isFocused,
diff --git a/frontend/src/components/VItemGroup/meta/VItemGroup.stories.mdx b/frontend/src/components/VItemGroup/meta/VItemGroup.stories.mdx
index 8d8ce7636..b1e699487 100644
--- a/frontend/src/components/VItemGroup/meta/VItemGroup.stories.mdx
+++ b/frontend/src/components/VItemGroup/meta/VItemGroup.stories.mdx
@@ -13,10 +13,6 @@ 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 pause from "~/assets/icons/pause.svg"
-import play from "~/assets/icons/play.svg"
-import close from "~/assets/icons/close.svg"
<Meta
title="Components/VItemGroup"
@@ -43,7 +39,7 @@ export const DefaultStory = (args) => ({
@click="selectedItem = item"
size="medium"
>
- <VIcon :icon-path="item.icon" /> {{ item.label }}
+ <VIcon :name="item.id" /> {{ item.label }}
</VItem>
</VItemGroup>
</div>
@@ -51,7 +47,7 @@ export const DefaultStory = (args) => ({
`,
components: { VItemGroup, VItem, VIcon },
setup() {
- const icons = [close, pause, play, replay]
+ const icons = ["close", "pause", "play", "replay"]
const items = new Array(icons.length).fill(null).map((_, i) => ({
id: i,
label: `Item ${i}`,
@@ -78,7 +74,7 @@ export const MenuStory = (args) => ({
@click="toggleItem(item)"
size="medium"
>
- <VIcon :icon-path="item.icon" /> {{ item.label }}
+ <VIcon :name="item.icon" /> {{ item.label }}
</VItem>
</VItemGroup>
</div>
@@ -86,7 +82,7 @@ export const MenuStory = (args) => ({
`,
components: { VItemGroup, VItem, VIcon },
setup() {
- const icons = [close, pause, play, replay]
+ const icons = ["close", "pause", "play", "replay"]
const items = new Array(icons.length).fill(null).map((_, i) => ({
id: i,
label: `Item ${i}`,
@@ -119,14 +115,14 @@ export const PopoverStory = (args) => ({
@click="toggleItem(item)"
size="medium"
>
- <VIcon :icon-path="item.icon" /><span :class="{ 'pe-2': args.direction === 'vertical' }">{{ item.label }}</span>
+ <VIcon :name="item.icon" /><span :class="{ 'pe-2': args.direction === 'vertical' }">{{ item.label }}</span>
</VItem>
</VItemGroup>
</VPopover>
`,
components: { VButton, VPopover, VItem, VItemGroup, VIcon },
setup() {
- const icons = [close, pause, play, replay]
+ const icons = ["close", "pause", "play", "replay"]
const items = new Array(icons.length).fill(null).map((_, i) => ({
id: i,
label: `Item ${i}`,
diff --git a/frontend/src/components/VLanguageSelect/VLanguageSelect.vue b/frontend/src/components/VLanguageSelect/VLanguageSelect.vue
index afb792b44..0467b96ff 100644
--- a/frontend/src/components/VLanguageSelect/VLanguageSelect.vue
+++ b/frontend/src/components/VLanguageSelect/VLanguageSelect.vue
@@ -8,7 +8,7 @@
:label-text="$t('language.language')"
>
<template #start>
- <VIcon :icon-path="globeIcon" />
+ <VIcon name="globe" />
</template>
</VSelectField>
</template>
@@ -25,8 +25,6 @@ import VSelectField, {
import type { LocaleObject } from "@nuxtjs/i18n"
-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.
@@ -55,8 +53,6 @@ export default defineComponent({
return {
locale,
choices,
-
- globeIcon,
}
},
})
diff --git a/frontend/src/components/VLicense/VLicense.vue b/frontend/src/components/VLicense/VLicense.vue
index 6676e6cb9..b8f516e02 100644
--- a/frontend/src/components/VLicense/VLicense.vue
+++ b/frontend/src/components/VLicense/VLicense.vue
@@ -2,11 +2,11 @@
<div class="license flex flex-row items-center gap-2">
<div class="flex gap-1">
<VIcon
- v-for="(name, index) in iconNames"
- :key="index"
- :class="['icon', bgFilled ? 'bg-filled text-black' : '']"
+ v-for="name in iconNames"
+ :key="name"
+ :class="{ 'bg-filled text-black': bgFilled }"
view-box="0 0 30 30"
- :icon-path="icons[name]"
+ :name="`licenses/${name}`"
:size="4"
/>
</div>
@@ -19,7 +19,7 @@
<script lang="ts">
import { computed, defineComponent, PropType } from "vue"
-import { License, LICENSE_ICONS } from "~/constants/license"
+import type { License } from "~/constants/license"
import { getFullLicenseName, getElements } from "~/utils/license"
import { useI18n } from "~/composables/use-i18n"
@@ -68,7 +68,6 @@ export default defineComponent({
})
return {
- icons: LICENSE_ICONS,
iconNames,
licenseName,
}
diff --git a/frontend/src/components/VLicense/VLicenseElements.vue b/frontend/src/components/VLicense/VLicenseElements.vue
index f79d677e7..a1317402f 100644
--- a/frontend/src/components/VLicense/VLicenseElements.vue
+++ b/frontend/src/components/VLicense/VLicenseElements.vue
@@ -8,7 +8,7 @@
<VIcon
view-box="0 0 30 30"
:size="isSmall || isMobile ? 5 : 6"
- :icon-path="icons[element]"
+ :name="`licenses/${element}`"
/>
<span v-if="elementNames.length > 1" class="sr-only">{{
element.toUpperCase()
@@ -24,7 +24,6 @@
import { computed, defineComponent, PropType } from "vue"
import type { License } from "~/constants/license"
-import { LICENSE_ICONS } from "~/constants/license"
import { useUiStore } from "~/stores/ui"
import { getElements } from "~/utils/license"
@@ -60,7 +59,6 @@ export default defineComponent({
const isMobile = computed(() => !uiStore.isDesktopLayout)
return {
- icons: LICENSE_ICONS,
elementNames,
isSmall,
isMobile,
diff --git a/frontend/src/components/VLink.vue b/frontend/src/components/VLink.vue
index 0f7ebfe50..f96dcfc1b 100644
--- a/frontend/src/components/VLink.vue
+++ b/frontend/src/components/VLink.vue
@@ -21,7 +21,7 @@
>
<slot /><VIcon
v-if="showExternalIcon && !isInternal"
- :icon-path="externalLinkIcon"
+ name="external-link"
class="inline-block"
:size="externalIconSize"
rtl-flip
@@ -44,8 +44,6 @@ import { useContext } from "@nuxtjs/composition-api"
import VIcon from "~/components/VIcon/VIcon.vue"
-import externalLinkIcon from "~/assets/icons/external-link.svg"
-
export default defineComponent({
name: "VLink",
components: { VIcon },
@@ -98,7 +96,6 @@ export default defineComponent({
linkTo,
isNuxtLink,
isInternal,
- externalLinkIcon,
}
},
})
diff --git a/frontend/src/components/VModal/VModalContent.vue b/frontend/src/components/VModal/VModalContent.vue
index 1a1b3c6ba..b81956cd3 100644
--- a/frontend/src/components/VModal/VModalContent.vue
+++ b/frontend/src/components/VModal/VModalContent.vue
@@ -40,7 +40,7 @@
@click="hide()"
>
{{ $t("modal.close") }}
- <VIcon :icon-path="closeIcon" class="ms-2" :size="5" />
+ <VIcon name="close" class="ms-2" :size="5" />
</VButton>
</div>
</slot>
@@ -71,8 +71,6 @@ import type { ModalColorMode, ModalVariant } from "~/types/modal"
import VButton from "~/components/VButton.vue"
import VIcon from "~/components/VIcon/VIcon.vue"
-import closeIcon from "~/assets/icons/close.svg"
-
/**
* Renders the inner content of a modal and manages focus.
*/
@@ -164,7 +162,6 @@ export default defineComponent({
dialogRef,
onKeyDown,
onBlur,
- closeIcon,
closeButton,
deactivateFocusTrap,
}
diff --git a/frontend/src/components/VRadio/VRadio.vue b/frontend/src/components/VRadio/VRadio.vue
index 09ecd3bb3..243baf3b4 100644
--- a/frontend/src/components/VRadio/VRadio.vue
+++ b/frontend/src/components/VRadio/VRadio.vue
@@ -24,7 +24,7 @@
<script lang="ts">
import { computed, defineComponent } from "vue"
-import Radiomark from "~/assets/icons/radiomark.svg?inline"
+import Radiomark from "~/assets/radiomark.svg?inline"
/**
* Renders a radio input field, useful for choosing one of a few options that
diff --git a/frontend/src/components/VSelectField/VSelectField.vue b/frontend/src/components/VSelectField/VSelectField.vue
index 14b444afc..345c5e380 100644
--- a/frontend/src/components/VSelectField/VSelectField.vue
+++ b/frontend/src/components/VSelectField/VSelectField.vue
@@ -6,7 +6,7 @@
<slot name="start" />
</div>
<div class="pointer-events-none absolute inset-y-0 end-2 my-auto h-fit">
- <VIcon :icon-path="caretDownIcon" />
+ <VIcon name="caret-down" />
</div>
<select
:id="fieldId"
@@ -34,8 +34,6 @@ import { ProperlyExtractPropTypes } from "~/types/prop-extraction"
import VIcon from "~/components/VIcon/VIcon.vue"
-import caretDownIcon from "~/assets/icons/caret-down.svg"
-
/**
* Represents a singular valid option of the dropdown.
*/
@@ -119,7 +117,6 @@ const VSelectField = defineComponent({
fieldName,
modelMedium,
hasStartContent,
- caretDownIcon,
}
},
})
diff --git a/frontend/src/components/VSelectField/meta/VSelectField.stories.mdx b/frontend/src/components/VSelectField/meta/VSelectField.stories.mdx
index 5184305f7..cf0c97cee 100644
--- a/frontend/src/components/VSelectField/meta/VSelectField.stories.mdx
+++ b/frontend/src/components/VSelectField/meta/VSelectField.stories.mdx
@@ -10,8 +10,6 @@ import { ref } from "vue"
import VIcon from "~/components/VIcon/VIcon.vue"
import VSelectField from "~/components/VSelectField/VSelectField.vue"
-import radioIcon from "~/assets/icons/radiomark.svg"
-
<Meta
title="Components/VSelectField"
component={VSelectField}
@@ -86,13 +84,13 @@ export const SlotTemplate = (args) => ({
template: `
<VSelectField v-bind="args">
<template #start>
- <VIcon :icon-path="radioIcon" />
+ <VIcon name="radiomark" />
</template>
</VSelectField>
`,
components: { VSelectField, VIcon },
setup() {
- return { args, radioIcon }
+ return { args }
},
})
diff --git a/frontend/src/components/VSourcesTable.vue b/frontend/src/components/VSourcesTable.vue
index 9b134a7cb..4fd59510c 100644
--- a/frontend/src/components/VSourcesTable.vue
+++ b/frontend/src/components/VSourcesTable.vue
@@ -68,8 +68,6 @@ import type { MediaProvider } from "~/types/media-provider"
import TableSortIcon from "~/components/TableSortIcon.vue"
import VLink from "~/components/VLink.vue"
-import externalLinkIcon from "~/assets/icons/external-link.svg"
-
export default defineComponent({
name: "VSourcesTable",
components: {
@@ -130,7 +128,6 @@ export default defineComponent({
return {
getLocaleFormattedNumber,
- externalLinkIcon,
sortedProviders,
sorting,
sortTable,
diff --git a/frontend/src/components/meta/VButton.stories.mdx b/frontend/src/components/meta/VButton.stories.mdx
index 7dc8d377a..541b532db 100644
--- a/frontend/src/components/meta/VButton.stories.mdx
+++ b/frontend/src/components/meta/VButton.stories.mdx
@@ -14,9 +14,6 @@ import VButton from "~/components/VButton.vue"
import VIcon from "~/components/VIcon/VIcon.vue"
import { capital } from "case"
-import replayIcon from "~/assets/icons/replay.svg"
-import externalLinkIcon from "~/assets/icons/external-link.svg"
-
<Meta title="Components/VButton" components={VButton} />
export const buttonVariants = allButtonVariants.filter(
@@ -54,18 +51,18 @@ export const TemplateWithIcons = (args) => ({
template: `
<div class="flex flex-col items-center gap-4 flex-wrap">
<VButton :variant="args.variant" :size="args.size" :has-icon-start="true">
- <VIcon :icon-path="replayIcon" />Button
+ <VIcon name="replay" />Button
</VButton>
<VButton :variant="args.variant" :size="args.size" has-icon-end>
- Button<VIcon :icon-path="externalLinkIcon" />
+ Button<VIcon name="external-link" />
</VButton>
<VButton :variant="args.variant" :size="args.size" has-icon-start has-icon-end>
- <VIcon :icon-path="replayIcon" />Button<VIcon :icon-path="externalLinkIcon" />
+ <VIcon name="replay" />Button<VIcon name="external-link" />
</VButton>
</div>`,
components: { VButton, VIcon },
setup() {
- return { args, replayIcon, externalLinkIcon }
+ return { args }
},
})
diff --git a/frontend/src/composables/use-search-type.ts b/frontend/src/composables/use-search-type.ts
index 22a37314c..be3ba1e95 100644
--- a/frontend/src/composables/use-search-type.ts
+++ b/frontend/src/composables/use-search-type.ts
@@ -16,18 +16,12 @@ import { useFeatureFlagStore } from "~/stores/feature-flag"
import { useI18n } from "~/composables/use-i18n"
-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,
- [AUDIO]: audioIcon,
- [IMAGE]: imageIcon,
- [VIDEO]: videoIcon,
- [MODEL_3D]: model3dIcon,
+ [ALL_MEDIA]: "all",
+ [AUDIO]: "audio",
+ [IMAGE]: "image",
+ [VIDEO]: "video",
+ [MODEL_3D]: "model-3d",
} as const
const labels = {
diff --git a/frontend/src/constants/license.ts b/frontend/src/constants/license.ts
index 48ead5ab2..97e42bcb0 100644
--- a/frontend/src/constants/license.ts
+++ b/frontend/src/constants/license.ts
@@ -1,13 +1,3 @@
-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",
@@ -35,24 +25,24 @@ export const LICENSE_VERSIONS = ["", "1.0", "2.0", "2.5", "3.0", "4.0"] as const
export type LicenseVersion = typeof LICENSE_VERSIONS[number]
/**
- * Each key of this mapping can be constructed into an SVG in Creative Commons'
- * press-kit assets using the following URL.
+ * Each element of this array can be constructed into an SVG in Creative Commons'
+ * press-kit asset using the following URL.
* ```
* https://mirrors.creativecommons.org/presskit/icons/{licenseElement}.svg
* ```
*/
-export const LICENSE_ICONS = Object.freeze({
- cc,
- by,
- nc,
- nd,
- sa,
- pd,
- zero,
- sampling,
- "sampling-plus": samplingPlus,
- remix: undefined,
- share: undefined,
-} as const)
-
-export type LicenseElement = keyof typeof LICENSE_ICONS
+export const LICENSE_ICONS = [
+ "cc",
+ "by",
+ "nc",
+ "nd",
+ "sa",
+ "pd",
+ "zero",
+ "sampling",
+ "sampling-plus",
+ "remix",
+ "share",
+] as const
+
+export type LicenseElement = typeof LICENSE_ICONS[number]
diff --git a/frontend/src/pages/image/_id/index.vue b/frontend/src/pages/image/_id/index.vue
index 531609cd9..a22a5d329 100644
--- a/frontend/src/pages/image/_id/index.vue
+++ b/frontend/src/pages/image/_id/index.vue
@@ -103,7 +103,6 @@ import VSketchFabViewer from "~/components/VSketchFabViewer.vue"
import VSkipToContentContainer from "~/components/VSkipToContentContainer.vue"
import errorImage from "~/assets/image_not_available_placeholder.png"
-import externalIcon from "~/assets/icons/external-link.svg"
export default defineComponent({
name: "VImageDetailsPage",
@@ -237,7 +236,6 @@ export default defineComponent({
onImageLoaded,
onImageError,
backToSearchPath,
- externalIcon,
sendGetMediaEvent,
}
diff --git a/frontend/test/unit/setup.js b/frontend/test/unit/setup.js
index f6720c7b4..a74fa1ee6 100644
--- a/frontend/test/unit/setup.js
+++ b/frontend/test/unit/setup.js
@@ -13,6 +13,7 @@ Vue.config.productionTip = false
Vue.config.devtools = false
Vue.use(VueI18n)
+/* eslint-disable vue/one-component-per-file */
/**
* Simplified mock of a NuxtLink component.
*/
@@ -21,6 +22,12 @@ config.stubs["nuxt-link"] = Vue.component("NuxtLink", {
template: '<a :href="to" v-on="$listeners"><slot /></a>',
})
+config.stubs["svg-icon"] = Vue.component("SvgIcon", {
+ props: ["name"],
+ template: '<svg title="name" />',
+})
+/* eslint-enable vue/one-component-per-file */
+
config.mocks.$t = (key) => key
config.mocks.localePath = (i) => i
global.matchMedia =
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 09b1771bd..e80070fab 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -43,6 +43,7 @@ importers:
'@nuxtjs/storybook': ^4.3.2
'@nuxtjs/style-resources': ^1.0.0
'@nuxtjs/svg': ^0.4.0
+ '@nuxtjs/svg-sprite': 0.5.2
'@pinia/nuxt': 0.2.1
'@pinia/testing': ^0.0.15
'@playwright/test': 1.30.0
@@ -141,6 +142,7 @@ importers:
'@nuxtjs/sentry': [email protected]
'@nuxtjs/sitemap': 2.4.0
'@nuxtjs/svg': 0.4.0_jjogt4bliw5zkzgrcodkvsva3y
+ '@nuxtjs/svg-sprite': 0.5.2
'@popperjs/core': 2.11.2
'@tailwindcss/typography': [email protected]
@@ -4351,6 +4353,17 @@ packages:
sass-resources-loader: 2.2.4
dev: true
+ /@nuxtjs/svg-sprite/0.5.2:
+ resolution: {integrity: sha512-zxNQbLHUMrKZjW80w0i0SONAqGF5BLUvNYx+j7dnuzUh0pxolJ0a2DIIfjxFs1hUxLk4dHTsclzl/vvV3mU+vA==}
+ dependencies:
+ chalk: 4.1.2
+ chokidar: 3.5.3
+ consola: 2.15.3
+ fs-extra: 9.1.0
+ svgo: 1.3.2
+ vue-functional-data-merge: 3.1.0
+ dev: false
+
/@nuxtjs/svg/0.4.0_jjogt4bliw5zkzgrcodkvsva3y:
resolution: {integrity: sha512-XF8uvV5YKBPAJr52SFRVkhltAsjCBTwwTc4GTysSm8WPYB2utJLY48qXdVC/J9dNQiMd7NHo1xmEYEqQfzqpqg==}
dependencies:
@@ -19209,6 +19222,10 @@ packages:
- supports-color
dev: true
+ /vue-functional-data-merge/3.1.0:
+ resolution: {integrity: sha512-leT4kdJVQyeZNY1kmnS1xiUlQ9z1B/kdBFCILIjYYQDqZgLqCLa0UhjSSeRX6c3mUe6U5qYeM8LrEqkHJ1B4LA==}
+ dev: false
+
/vue-hot-reload-api/2.3.4:
resolution: {integrity: sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==}