Skip to content

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

Update the Box image and Large image cell component hover state (#2714)

Zack Krida4781fcdb9f3d
diff --git a/frontend/src/components/VSearchResultsGrid/VImageCell.vue b/frontend/src/components/VImageCell/VImageCell.vue
similarity index 97%
rename from frontend/src/components/VSearchResultsGrid/VImageCell.vue
rename to frontend/src/components/VImageCell/VImageCell.vue
index 809d8fd9e..a7969cf81 100644
--- a/frontend/src/components/VSearchResultsGrid/VImageCell.vue
+++ b/frontend/src/components/VImageCell/VImageCell.vue
@@ -37,7 +37,7 @@
@error="onImageLoadError($event)"
/>
<figcaption
- class="invisible absolute bottom-0 left-0 bg-white p-1 text-dark-charcoal group-hover:visible group-focus:visible"
+ class="invisible absolute bottom-2 left-2 rounded-sm bg-white p-2 text-dark-charcoal group-hover:visible group-focus:visible"
>
<h2 class="sr-only">
{{
diff --git a/frontend/src/components/VImageCell/meta/VImageCell.stories.mdx b/frontend/src/components/VImageCell/meta/VImageCell.stories.mdx
new file mode 100644
index 000000000..a79f0f9f1
--- /dev/null
+++ b/frontend/src/components/VImageCell/meta/VImageCell.stories.mdx
@@ -0,0 +1,56 @@
+import {
+ ArgsTable,
+ Canvas,
+ Description,
+ Meta,
+ Story,
+} from "@storybook/addon-docs"
+import VImageCell from "~/components/VImageCell/VImageCell.vue"
+import { image } from "~~/test/unit/fixtures/image"
+
+<Meta title="Components/VImageCell" components={VImageCell} />
+
+export const Template = (args, { argTypes }) => ({
+ components: { VImageCell },
+ props: Object.keys(argTypes),
+ template: `
+ <ol class="flex flex-wrap gap-4">
+ <VImageCell
+ :image="image"
+ searchTerm="test"
+ :aspect-ratio="aspectRatio"
+ relatedTo="fake-uuid"
+ />
+ </ol>
+ `,
+})
+
+# VImageCell
+
+<Description of={VImageCell} />
+
+<ArgsTable of={VImageCell} />
+
+<Canvas>
+ <Story
+ name="VImageCell"
+ parameters={{
+ viewport: { defaultViewport: "sm" },
+ }}
+ args={{
+ aspectRatio: "intrinsic",
+ image: image,
+ }}
+ argTypes={{
+ aspectRatio: {
+ options: ["square", "intrinsic"],
+ control: { type: "radio" },
+ },
+ image: {
+ control: { type: "object" },
+ },
+ }}
+ >
+ {Template.bind({})}
+ </Story>
+</Canvas>
diff --git a/frontend/src/components/VSearchResultsGrid/VAllResultsGrid.vue b/frontend/src/components/VSearchResultsGrid/VAllResultsGrid.vue
index a3e319522..1cbfa7795 100644
--- a/frontend/src/components/VSearchResultsGrid/VAllResultsGrid.vue
+++ b/frontend/src/components/VSearchResultsGrid/VAllResultsGrid.vue
@@ -74,7 +74,7 @@ import { useI18n } from "~/composables/use-i18n"
import type { SupportedMediaType } from "~/constants/media"
import VSnackbar from "~/components/VSnackbar.vue"
-import VImageCell from "~/components/VSearchResultsGrid/VImageCell.vue"
+import VImageCell from "~/components/VImageCell/VImageCell.vue"
import VAudioCell from "~/components/VSearchResultsGrid/VAudioCell.vue"
import VLoadMore from "~/components/VLoadMore.vue"
import VContentLink from "~/components/VContentLink/VContentLink.vue"
diff --git a/frontend/src/components/VSearchResultsGrid/VImageGrid.vue b/frontend/src/components/VSearchResultsGrid/VImageGrid.vue
index 31d61de5d..03e3cc7f0 100644
--- a/frontend/src/components/VSearchResultsGrid/VImageGrid.vue
+++ b/frontend/src/components/VSearchResultsGrid/VImageGrid.vue
@@ -41,7 +41,7 @@ import type { ImageDetail } from "~/types/media"
import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue"
import VLoadMore from "~/components/VLoadMore.vue"
-import VImageCell from "~/components/VSearchResultsGrid/VImageCell.vue"
+import VImageCell from "~/components/VImageCell/VImageCell.vue"
import type { NuxtError } from "@nuxt/types"
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts
new file mode 100644
index 000000000..6f29b1e19
--- /dev/null
+++ b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts
@@ -0,0 +1,55 @@
+import { expect, test } from "@playwright/test"
+
+import { makeGotoWithArgs } from "~~/test/storybook/utils/args"
+
+import type { AspectRatio } from "~/types/media"
+
+const imageCell = "a[itemprop='contentUrl']"
+// Necessary to make sure we can capture the focus state, which
+// exceeds the bounds of the actual component
+const screenshotEl = ".sb-main-padded"
+
+test.describe.configure({ mode: "parallel" })
+
+test.describe("VImageCell", () => {
+ const gotoWithArgs = makeGotoWithArgs("components-vimagecell--v-image-cell")
+ const aspectRatios: AspectRatio[] = ["square", "intrinsic"]
+
+ for (const ratio of aspectRatios) {
+ test(`${ratio} loaded`, async ({ page }) => {
+ await gotoWithArgs(page, { aspectRatio: ratio })
+ const mainEl = page.locator(imageCell)
+ await expect(mainEl).toBeVisible()
+ expect(await page.locator(screenshotEl).screenshot()).toMatchSnapshot({
+ name: `v-image-cell-${ratio}-loaded.png`,
+ })
+ })
+
+ test(`${ratio} focused`, async ({ page }) => {
+ await gotoWithArgs(page, { aspectRatio: ratio })
+ await page.focus(imageCell)
+ await page.locator(imageCell).click()
+ expect(await page.locator(screenshotEl).screenshot()).toMatchSnapshot({
+ name: `v-image-cell-${ratio}-focused.png`,
+ })
+ })
+
+ test(`${ratio} hovered`, async ({ page }) => {
+ await gotoWithArgs(page, { aspectRatio: ratio })
+ await page.hover(imageCell)
+ expect(await page.locator(screenshotEl).screenshot()).toMatchSnapshot({
+ name: `v-image-cell-${ratio}-hovered.png`,
+ })
+ })
+
+ test(`${ratio} focused hovered`, async ({ page }) => {
+ await gotoWithArgs(page, { aspectRatio: ratio })
+ await page.focus(imageCell)
+ await page.hover(imageCell)
+ await page.locator(imageCell).click()
+ expect(await page.locator(screenshotEl).screenshot()).toMatchSnapshot({
+ name: `v-image-cell-${ratio}-focused-hovered.png`,
+ })
+ })
+ }
+})
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-focused-hovered-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-focused-hovered-linux.png
new file mode 100644
index 000000000..4a21e4557
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-focused-hovered-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-focused-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-focused-linux.png
new file mode 100644
index 000000000..4a21e4557
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-focused-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-hovered-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-hovered-linux.png
new file mode 100644
index 000000000..9b10edae2
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-hovered-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-loaded-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-loaded-linux.png
new file mode 100644
index 000000000..d31c863ee
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-intrinsic-loaded-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-focused-hovered-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-focused-hovered-linux.png
new file mode 100644
index 000000000..30b261001
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-focused-hovered-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-focused-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-focused-linux.png
new file mode 100644
index 000000000..30b261001
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-focused-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-hovered-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-hovered-linux.png
new file mode 100644
index 000000000..5485a3ea8
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-hovered-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-loaded-linux.png b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-loaded-linux.png
new file mode 100644
index 000000000..22ac8df25
Binary files /dev/null and b/frontend/test/storybook/visual-regression/v-image-cell.spec.ts-snapshots/v-image-cell-square-loaded-linux.png differ
diff --git a/frontend/test/unit/specs/components/VSearchResultsGrid/v-image-cell.spec.js b/frontend/test/unit/specs/components/v-image-cell.spec.js
similarity index 94%
rename from frontend/test/unit/specs/components/VSearchResultsGrid/v-image-cell.spec.js
rename to frontend/test/unit/specs/components/v-image-cell.spec.js
index e3d02ba5f..8fc416104 100644
--- a/frontend/test/unit/specs/components/VSearchResultsGrid/v-image-cell.spec.js
+++ b/frontend/test/unit/specs/components/v-image-cell.spec.js
@@ -3,7 +3,7 @@ import { image } from "~~/test/unit/fixtures/image"
import { useAnalytics } from "~/composables/use-analytics"
-import VImageCell from "~/components/VSearchResultsGrid/VImageCell.vue"
+import VImageCell from "~/components/VImageCell/VImageCell.vue"
jest.mock("~/composables/use-analytics", () => ({
useAnalytics: jest.fn(),