mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
refactor(frontend): rename RImg to RImage (#5387)
Spells the primitive out like every other one in src/lib (RIcon, RTextField, RSegmentedControl). Renames the component, its folder, story, story stylesheet, and the r-img CSS classes. No behaviour change. Claude-Session: https://claude.ai/code/session_01NH5s4h1gm17cCYTX1t7BQX Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@ function scrollWindowTo(y: number) {
|
||||
function mountNav() {
|
||||
return mount(AppNav, {
|
||||
global: {
|
||||
stubs: { RouterLink: true, RImg: true, RSegmentedControl: true },
|
||||
stubs: { RouterLink: true, RImage: true, RSegmentedControl: true },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import NowPlayingPill from "@/components/Soundtrack/NowPlayingPill.vue";
|
||||
import { useBreakpoint } from "@/composables/useBreakpoint";
|
||||
import { useNavDestinations } from "@/composables/useNavDestinations";
|
||||
import { useNavGlass } from "@/composables/useNavGlass";
|
||||
import { RSegmentedControl, RImg } from "@/lib";
|
||||
import { RSegmentedControl, RImage } from "@/lib";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
@@ -54,14 +54,14 @@ const scrolled = computed(
|
||||
>
|
||||
<nav class="r-nav">
|
||||
<router-link to="/" class="r-nav__logo" :aria-label="t('common.home')">
|
||||
<RImg
|
||||
<RImage
|
||||
src="/assets/isotipo.svg"
|
||||
alt="RomM isotipo"
|
||||
aria-hidden="true"
|
||||
class="r-nav__logo-mark"
|
||||
:width="32"
|
||||
/>
|
||||
<RImg
|
||||
<RImage
|
||||
src="/assets/logotipo.svg"
|
||||
alt="RomM logotipo"
|
||||
aria-hidden="true"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// (falls back to a generic key if the icon can't be found).
|
||||
import { ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { RBtn, RIcon, RImg } from "@/lib";
|
||||
import { RBtn, RIcon, RImage } from "@/lib";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
@@ -34,7 +34,7 @@ defineExpose({ login, loading });
|
||||
>
|
||||
<template v-if="provider" #prepend>
|
||||
<RIcon size="20">
|
||||
<RImg
|
||||
<RImage
|
||||
:src="`/assets/dashboard-icons/${provider
|
||||
.toLowerCase()
|
||||
.replace(/ /g, '-')}.png`"
|
||||
@@ -42,7 +42,7 @@ defineExpose({ login, loading });
|
||||
<template #error>
|
||||
<RIcon icon="mdi-key" size="20" />
|
||||
</template>
|
||||
</RImg>
|
||||
</RImage>
|
||||
</RIcon>
|
||||
</template>
|
||||
{{ t("login.login-oidc", { oidc: provider || "OIDC" }) }}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useEmitterEvent } from "@/composables/useEmitterEvent";
|
||||
import { useVersionDisplay } from "@/composables/useVersionDisplay";
|
||||
import { RDialog, RIcon, RImg, RTooltip } from "@/lib";
|
||||
import { RDialog, RIcon, RImage, RTooltip } from "@/lib";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
@@ -96,7 +96,7 @@ watch(() => links.value.map((link) => link.value), measure, { flush: "post" });
|
||||
class="r-about__tile"
|
||||
>
|
||||
<div class="r-about__icon">
|
||||
<RImg
|
||||
<RImage
|
||||
v-if="link.isotipo"
|
||||
src="/assets/isotipo.svg"
|
||||
alt="RomM"
|
||||
|
||||
@@ -22,7 +22,7 @@ describe("ScanPlatformRow", () => {
|
||||
global: {
|
||||
stubs: {
|
||||
RouterLink: { template: "<a><slot /></a>" },
|
||||
RImg: true,
|
||||
RImage: true,
|
||||
RTooltip,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useWebpSupport } from "@/composables/useWebpSupport";
|
||||
import { RImg, RTag, RTooltip } from "@/lib";
|
||||
import { RImage, RTag, RTooltip } from "@/lib";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import type { SimpleRom } from "@/stores/roms";
|
||||
import { getMissingCoverImage, getUnmatchedCoverImage } from "@/utils/covers";
|
||||
@@ -77,7 +77,7 @@ function coverFor(rom: SimpleRom): string {
|
||||
:to="{ name: ROUTES.ROM, params: { rom: props.rom.id } }"
|
||||
class="r-scan-platform__rom"
|
||||
>
|
||||
<RImg
|
||||
<RImage
|
||||
:src="coverFor(props.rom)"
|
||||
:alt="displayName"
|
||||
:width="36"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// (Login / Register / ResetPassword / Setup). Wraps RCard, the logo,
|
||||
// and the padded inner column. Views drop their form content into the
|
||||
// default slot.
|
||||
import { RCard, RImg } from "@/lib";
|
||||
import { RCard, RImage } from "@/lib";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
</script>
|
||||
@@ -11,7 +11,7 @@ defineOptions({ inheritAttrs: false });
|
||||
<template>
|
||||
<RCard v-bind="$attrs" class="auth-card" variant="elevated" elevation="4">
|
||||
<div class="auth-card__inner">
|
||||
<RImg
|
||||
<RImage
|
||||
src="/assets/isotipo.svg"
|
||||
:width="80"
|
||||
class="auth-card__logo"
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
getCachedPlatformIcon,
|
||||
invalidatePlatformIcon,
|
||||
} from "@/composables/usePlatformIconCache";
|
||||
import { RImg } from "@/lib";
|
||||
import { RImage } from "@/lib";
|
||||
import { DEFAULT_PLATFORM_ICON, platformIconUrl } from "@/utils/platformIcons";
|
||||
|
||||
interface Props {
|
||||
@@ -43,7 +43,7 @@ function onError() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RImg
|
||||
<RImage
|
||||
:src="src"
|
||||
:alt="name || slug"
|
||||
:title="name || slug"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// setup / caveat pills; the status chip joins the pill row.
|
||||
// Surface-specific state styling (e.g. the wizard's "available" tint)
|
||||
// stays in the consumer, keyed on a data-* attr it passes through.
|
||||
import { RIcon, RImg, RTag } from "@/lib";
|
||||
import { RIcon, RImage, RTag } from "@/lib";
|
||||
import type { ProviderCardStatus } from "./types";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
@@ -64,7 +64,7 @@ defineSlots<{
|
||||
<header class="r-provider-card__header">
|
||||
<div class="r-provider-card__logo">
|
||||
<!-- Decorative: the name sits right next to it. -->
|
||||
<RImg :src="logo" alt="" width="100%" height="100%" contain />
|
||||
<RImage :src="logo" alt="" width="100%" height="100%" contain />
|
||||
</div>
|
||||
<div class="r-provider-card__head-text">
|
||||
<component :is="nameTag" class="r-provider-card__name">
|
||||
|
||||
@@ -20,7 +20,7 @@ export * from "./primitives/RChip";
|
||||
export * from "./primitives/RDivider";
|
||||
export * from "./primitives/REmptyState";
|
||||
export * from "./primitives/RIcon";
|
||||
export * from "./primitives/RImg";
|
||||
export * from "./primitives/RImage";
|
||||
export * from "./primitives/RLetterHeading";
|
||||
export * from "./primitives/RMarquee";
|
||||
export * from "./primitives/RProgressCircular";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/* Demo-only styles for RImg stories. Imported by RImg.stories.ts so
|
||||
/* Demo-only styles for RImage stories. Imported by RImage.stories.ts so
|
||||
Storybook + Vite handles them as a normal CSS module. Inline <style>
|
||||
blocks inside template strings get parsed inconsistently and the
|
||||
keyframes stop animating: keep the demo CSS in a real file. */
|
||||
|
||||
/* Loading-slot shimmer: three-stop gradient sliding across the
|
||||
container. Visible only while RImg is in `loading` state. */
|
||||
@keyframes r-img-story-shimmer {
|
||||
container. Visible only while RImage is in `loading` state. */
|
||||
@keyframes r-image-story-shimmer {
|
||||
0% {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.r-img-story-shimmer {
|
||||
.r-image-story-shimmer {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(
|
||||
@@ -24,10 +24,10 @@
|
||||
var(--r-color-surface) 100%
|
||||
);
|
||||
background-size: 200% 100%;
|
||||
animation: r-img-story-shimmer 1.4s ease-in-out infinite;
|
||||
animation: r-image-story-shimmer 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.r-img-story-reload-btn {
|
||||
.r-image-story-reload-btn {
|
||||
padding: 6px 12px;
|
||||
background: var(--r-color-brand-primary);
|
||||
color: white;
|
||||
@@ -36,6 +36,6 @@
|
||||
font: 12px/1 sans-serif;
|
||||
cursor: pointer;
|
||||
}
|
||||
.r-img-story-reload-btn:hover {
|
||||
.r-image-story-reload-btn:hover {
|
||||
background: var(--r-color-brand-primary-hover);
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
||||
import { onMounted, onUnmounted, ref } from "vue";
|
||||
import { CONTRAST_TODO_PARAMETERS } from "@/utils/storyA11y";
|
||||
import "./RImg.stories.css";
|
||||
import RImg from "./RImg.vue";
|
||||
import "./RImage.stories.css";
|
||||
import RImage from "./RImage.vue";
|
||||
|
||||
const meta: Meta<typeof RImg> = {
|
||||
title: "Primitives/RImg",
|
||||
component: RImg,
|
||||
const meta: Meta<typeof RImage> = {
|
||||
title: "Primitives/RImage",
|
||||
component: RImage,
|
||||
parameters: CONTRAST_TODO_PARAMETERS,
|
||||
argTypes: {
|
||||
width: { control: "text" },
|
||||
@@ -17,7 +17,7 @@ const meta: Meta<typeof RImg> = {
|
||||
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<typeof RImg>;
|
||||
type Story = StoryObj<typeof RImage>;
|
||||
|
||||
// A small known-good image we can use without network access in
|
||||
// Storybook. The local logo ships at /assets/isotipo.svg.
|
||||
@@ -43,19 +43,19 @@ export const NaturalSize: Story = {
|
||||
export const WidthOnly: Story = {
|
||||
name: "Width only — auto height",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
template: `
|
||||
<div style="display:flex;align-items:flex-end;gap:24px;font:11px/1.2 sans-serif;color:var(--r-color-fg-muted)">
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:6px">
|
||||
<RImg src="${LOGO}" :width="32" alt="logo" />
|
||||
<RImage src="${LOGO}" :width="32" alt="logo" />
|
||||
<span>width 32</span>
|
||||
</div>
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:6px">
|
||||
<RImg src="${LOGO}" :width="64" alt="logo" />
|
||||
<RImage src="${LOGO}" :width="64" alt="logo" />
|
||||
<span>width 64</span>
|
||||
</div>
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:6px">
|
||||
<RImg src="${LOGO}" :width="128" alt="logo" />
|
||||
<RImage src="${LOGO}" :width="128" alt="logo" />
|
||||
<span>width 128</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -66,15 +66,15 @@ export const WidthOnly: Story = {
|
||||
export const CoverFit: Story = {
|
||||
name: "cover · width × height",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
template: `
|
||||
<div style="display:flex;gap:24px;font:11px/1.2 sans-serif;color:var(--r-color-fg-muted)">
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
|
||||
<RImg src="${PHOTO}" :width="160" :height="100" cover alt="cover" style="border-radius:8px" />
|
||||
<RImage src="${PHOTO}" :width="160" :height="100" cover alt="cover" style="border-radius:8px" />
|
||||
<span>cover · 160×100</span>
|
||||
</div>
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
|
||||
<RImg src="${PHOTO_TALL}" :width="160" :height="100" cover alt="cover tall" style="border-radius:8px" />
|
||||
<RImage src="${PHOTO_TALL}" :width="160" :height="100" cover alt="cover tall" style="border-radius:8px" />
|
||||
<span>cover · tall src → cropped</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,11 +85,11 @@ export const CoverFit: Story = {
|
||||
export const ContainFit: Story = {
|
||||
name: "contain · width × height",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
template: `
|
||||
<div style="display:flex;gap:24px;font:11px/1.2 sans-serif;color:var(--r-color-fg-muted)">
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
|
||||
<RImg
|
||||
<RImage
|
||||
src="${PHOTO}"
|
||||
:width="160"
|
||||
:height="100"
|
||||
@@ -100,7 +100,7 @@ export const ContainFit: Story = {
|
||||
<span>contain · letterboxed</span>
|
||||
</div>
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:8px">
|
||||
<RImg
|
||||
<RImage
|
||||
src="${PHOTO_TALL}"
|
||||
:width="160"
|
||||
:height="100"
|
||||
@@ -118,19 +118,19 @@ export const ContainFit: Story = {
|
||||
export const AspectRatio: Story = {
|
||||
name: "aspectRatio (responsive)",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
template: `
|
||||
<div style="display:flex;flex-direction:column;gap:16px;width:320px;font:11px/1.2 sans-serif;color:var(--r-color-fg-muted)">
|
||||
<div>
|
||||
<RImg src="${PHOTO}" aspect-ratio="16/9" cover style="width:100%;border-radius:8px" alt="16/9" />
|
||||
<RImage src="${PHOTO}" aspect-ratio="16/9" cover style="width:100%;border-radius:8px" alt="16/9" />
|
||||
<div style="margin-top:6px">aspectRatio "16/9" · cover · width 100%</div>
|
||||
</div>
|
||||
<div>
|
||||
<RImg src="${PHOTO}" aspect-ratio="1/1" cover style="width:100%;border-radius:8px" alt="1/1" />
|
||||
<RImage src="${PHOTO}" aspect-ratio="1/1" cover style="width:100%;border-radius:8px" alt="1/1" />
|
||||
<div style="margin-top:6px">aspectRatio "1/1" · cover · width 100%</div>
|
||||
</div>
|
||||
<div>
|
||||
<RImg src="${PHOTO}" aspect-ratio="4/3" cover style="width:100%;border-radius:8px" alt="4/3" />
|
||||
<RImage src="${PHOTO}" aspect-ratio="4/3" cover style="width:100%;border-radius:8px" alt="4/3" />
|
||||
<div style="margin-top:6px">aspectRatio "4/3" · cover · width 100%</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -143,17 +143,17 @@ export const AspectRatio: Story = {
|
||||
export const ErrorSlot: Story = {
|
||||
name: "error slot (fallback)",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
template: `
|
||||
<div style="display:flex;align-items:center;gap:24px;font:12px/1.4 sans-serif;color:var(--r-color-fg-muted)">
|
||||
<RImg src="/does-not-exist.png" :width="64" :height="64" alt="missing">
|
||||
<RImage src="/does-not-exist.png" :width="64" :height="64" alt="missing">
|
||||
<template #error>
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:4px;color:var(--r-color-fg-faint)">
|
||||
<i class="mdi mdi-image-broken-variant" style="font-size:24px"></i>
|
||||
<span style="font-size:10px">missing</span>
|
||||
</div>
|
||||
</template>
|
||||
</RImg>
|
||||
</RImage>
|
||||
<span>The src 404s — the <code>#error</code> slot renders instead.</span>
|
||||
</div>
|
||||
`,
|
||||
@@ -163,10 +163,10 @@ export const ErrorSlot: Story = {
|
||||
export const LoadingSlot: Story = {
|
||||
name: "loading slot (placeholder)",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
setup() {
|
||||
// The story controls how long the loading state lasts:
|
||||
// 1. Start with `src` empty: RImg renders the loading slot.
|
||||
// 1. Start with `src` empty: RImage renders the loading slot.
|
||||
// 2. After `loadingDelay` ms, set a real cache-busted src so
|
||||
// the image fetches and `loaded` takes over.
|
||||
// 3. The "Reload" button restarts the cycle on demand.
|
||||
@@ -185,7 +185,7 @@ export const LoadingSlot: Story = {
|
||||
const myCounter = counter;
|
||||
timer = setTimeout(() => {
|
||||
// Cache-bust each cycle so picsum re-fetches.
|
||||
src.value = `https://picsum.photos/seed/r-img-loading-${myCounter}/400/400`;
|
||||
src.value = `https://picsum.photos/seed/r-image-loading-${myCounter}/400/400`;
|
||||
}, loadingDelay);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ export const LoadingSlot: Story = {
|
||||
},
|
||||
template: `
|
||||
<div style="display:flex;align-items:center;gap:24px;font:12px/1.4 sans-serif;color:var(--r-color-fg-muted)">
|
||||
<RImg
|
||||
<RImage
|
||||
:src="src"
|
||||
:width="120"
|
||||
:height="120"
|
||||
@@ -207,12 +207,12 @@ export const LoadingSlot: Story = {
|
||||
style="border-radius:8px"
|
||||
>
|
||||
<template #loading>
|
||||
<div class="r-img-story-shimmer" />
|
||||
<div class="r-image-story-shimmer" />
|
||||
</template>
|
||||
</RImg>
|
||||
</RImage>
|
||||
<div style="display:flex;flex-direction:column;gap:8px;max-width:240px">
|
||||
<span>The shimmer is forced visible for 2.5s before the image fetches. Click reload to re-trigger.</span>
|
||||
<button class="r-img-story-reload-btn" type="button" @click="reload">Reload</button>
|
||||
<button class="r-image-story-reload-btn" type="button" @click="reload">Reload</button>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
@@ -222,9 +222,9 @@ export const LoadingSlot: Story = {
|
||||
export const DefaultSlotOverlay: Story = {
|
||||
name: "default slot (overlay over loaded image)",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
template: `
|
||||
<RImg
|
||||
<RImage
|
||||
src="${PHOTO}"
|
||||
:width="320"
|
||||
:height="180"
|
||||
@@ -244,7 +244,7 @@ export const DefaultSlotOverlay: Story = {
|
||||
">
|
||||
Overlay caption — composes on top of the image
|
||||
</div>
|
||||
</RImg>
|
||||
</RImage>
|
||||
`,
|
||||
}),
|
||||
};
|
||||
@@ -254,11 +254,11 @@ export const DefaultSlotOverlay: Story = {
|
||||
export const Logo: Story = {
|
||||
name: "Logo (AppNav usage)",
|
||||
render: () => ({
|
||||
components: { RImg },
|
||||
components: { RImage },
|
||||
template: `
|
||||
<div style="display:inline-flex;align-items:center;gap:8px;padding:8px 12px;background:var(--r-color-surface);border-radius:8px">
|
||||
<RImg src="${LOGO}" :width="32" alt="isotipo" />
|
||||
<RImg src="/assets/logotipo.svg" :width="70" alt="logotipo" />
|
||||
<RImage src="${LOGO}" :width="32" alt="isotipo" />
|
||||
<RImage src="/assets/logotipo.svg" :width="70" alt="logotipo" />
|
||||
</div>
|
||||
`,
|
||||
}),
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
// RImg: wraps a native <img> with three slot-driven
|
||||
// RImage: wraps a native <img> with three slot-driven
|
||||
// states: `loading` (while the network fetch is in flight), `error`
|
||||
// (when load fails or src is empty), and `default` (a content overlay
|
||||
// rendered on top of the loaded image: captions, hover CTAs, etc).
|
||||
@@ -95,13 +95,13 @@ const wrapperStyle = computed(() => ({
|
||||
<template>
|
||||
<div
|
||||
v-bind="$attrs"
|
||||
class="r-img"
|
||||
class="r-image"
|
||||
:class="{
|
||||
'r-img--loading': state === 'loading',
|
||||
'r-img--loaded': state === 'loaded',
|
||||
'r-img--error': state === 'error',
|
||||
'r-img--cover': cover,
|
||||
'r-img--contain': contain,
|
||||
'r-image--loading': state === 'loading',
|
||||
'r-image--loaded': state === 'loaded',
|
||||
'r-image--error': state === 'error',
|
||||
'r-image--cover': cover,
|
||||
'r-image--contain': contain,
|
||||
}"
|
||||
:style="wrapperStyle"
|
||||
>
|
||||
@@ -109,34 +109,34 @@ const wrapperStyle = computed(() => ({
|
||||
v-if="src && state !== 'error'"
|
||||
:src="src"
|
||||
:alt="alt ?? ''"
|
||||
class="r-img__image"
|
||||
class="r-image__image"
|
||||
decoding="async"
|
||||
@load="onLoad"
|
||||
@error="onError"
|
||||
/>
|
||||
|
||||
<div v-if="state === 'loading' && slots.loading" class="r-img__layer">
|
||||
<div v-if="state === 'loading' && slots.loading" class="r-image__layer">
|
||||
<slot name="loading" />
|
||||
</div>
|
||||
<div
|
||||
v-else-if="state === 'loading' && slots.placeholder"
|
||||
class="r-img__layer"
|
||||
class="r-image__layer"
|
||||
>
|
||||
<slot name="placeholder" />
|
||||
</div>
|
||||
|
||||
<div v-if="state === 'error'" class="r-img__layer">
|
||||
<div v-if="state === 'error'" class="r-image__layer">
|
||||
<slot name="error" />
|
||||
</div>
|
||||
|
||||
<div v-if="state === 'loaded' && slots.default" class="r-img__overlay">
|
||||
<div v-if="state === 'loaded' && slots.default" class="r-image__overlay">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.r-img {
|
||||
.r-image {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
@@ -149,7 +149,7 @@ const wrapperStyle = computed(() => ({
|
||||
/* Image: defaults to width 100%, height auto so a logo with only
|
||||
`width` set keeps its natural aspect ratio. Adding `cover`/`contain`
|
||||
forces the height to fill the wrapper so object-fit takes effect. */
|
||||
.r-img__image {
|
||||
.r-image__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
@@ -159,25 +159,25 @@ const wrapperStyle = computed(() => ({
|
||||
opacity: 0;
|
||||
transition: opacity var(--r-motion-base) var(--r-motion-ease-out);
|
||||
}
|
||||
.r-img--loaded .r-img__image {
|
||||
.r-image--loaded .r-image__image {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.r-img--cover .r-img__image,
|
||||
.r-img--contain .r-img__image {
|
||||
.r-image--cover .r-image__image,
|
||||
.r-image--contain .r-image__image {
|
||||
height: 100%;
|
||||
}
|
||||
.r-img--cover .r-img__image {
|
||||
.r-image--cover .r-image__image {
|
||||
object-fit: cover;
|
||||
}
|
||||
.r-img--contain .r-img__image {
|
||||
.r-image--contain .r-image__image {
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
/* Loading / error layer: absolutely positioned over the wrapper so
|
||||
it sits where the image would and disappears once the image lands.
|
||||
`inset: 0` works with the inline-block sizing. */
|
||||
.r-img__layer {
|
||||
.r-image__layer {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
@@ -192,7 +192,7 @@ const wrapperStyle = computed(() => ({
|
||||
|
||||
/* Default-slot overlay: sits over the loaded image. Caption /
|
||||
hover-CTA / shimmer-on-top. */
|
||||
.r-img__overlay {
|
||||
.r-image__overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
line-height: 1.4;
|
||||
1
frontend/src/lib/primitives/RImage/index.ts
Normal file
1
frontend/src/lib/primitives/RImage/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as RImage } from "./RImage.vue";
|
||||
@@ -1 +0,0 @@
|
||||
export { default as RImg } from "./RImg.vue";
|
||||
@@ -18,7 +18,7 @@ import { useResizeObserver } from "@vueuse/core";
|
||||
import { computed, nextTick, onMounted, ref, watch } from "vue";
|
||||
import { useReducedMotion } from "@/composables/useReducedMotion";
|
||||
import RIcon from "../../primitives/RIcon/RIcon.vue";
|
||||
import RImg from "../../primitives/RImg/RImg.vue";
|
||||
import RImage from "../../primitives/RImage/RImage.vue";
|
||||
import type { RTabNavItem } from "./types";
|
||||
|
||||
// Width of the faded edge, also the margin kept when scrolling a tab into view
|
||||
@@ -227,7 +227,7 @@ onMounted(async () => {
|
||||
:aria-selected="modelValue === t.id"
|
||||
@click="$emit('update:modelValue', t.id)"
|
||||
>
|
||||
<RImg
|
||||
<RImage
|
||||
v-if="t.image"
|
||||
:src="t.image"
|
||||
alt=""
|
||||
@@ -398,7 +398,7 @@ onMounted(async () => {
|
||||
.r-tab-nav__icon {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/* Image variant: provider logos / brand marks. RImg owns the inner
|
||||
/* Image variant: provider logos / brand marks. RImage owns the inner
|
||||
<img>; we round its outer wrapper and ride opacity from "muted at
|
||||
rest" to "full saturation on hover/active" so the brand mark stands
|
||||
out only when it's the focus of the surface. */
|
||||
|
||||
@@ -36,7 +36,7 @@ vi.mock("@/lib", () => {
|
||||
template: "<div><slot name='toolbar' /><slot name='content' /></div>",
|
||||
}),
|
||||
RIcon: slotHost("i"),
|
||||
RImg: slotHost("span"),
|
||||
RImage: slotHost("span"),
|
||||
RTabNav: defineComponent({ name: "RTabNav", template: "<nav />" }),
|
||||
RTag: slotHost("span"),
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { AdminUserDraft } from "@/components/Auth/SetupStepAdmin.vue";
|
||||
import SetupStepMetadata from "@/components/Auth/SetupStepMetadata.vue";
|
||||
import SetupStepPlatforms from "@/components/Auth/SetupStepPlatforms.vue";
|
||||
import { useSnackbar } from "@/composables/useSnackbar";
|
||||
import { RBtn, RIcon, RImg, RSpinner, RSteps } from "@/lib";
|
||||
import { RBtn, RIcon, RImage, RSpinner, RSteps } from "@/lib";
|
||||
import { refetchCSRFToken } from "@/services/api";
|
||||
import identityApi from "@/services/api/identity";
|
||||
import setupApi from "@/services/api/setup";
|
||||
@@ -205,7 +205,7 @@ onMounted(loadLibraryInfo);
|
||||
<template>
|
||||
<div class="r-setup">
|
||||
<header class="r-setup__header">
|
||||
<RImg
|
||||
<RImage
|
||||
src="/assets/isotipo.svg"
|
||||
:width="56"
|
||||
class="r-setup__logo"
|
||||
|
||||
@@ -22,7 +22,7 @@ vi.mock("@/lib", () => ({
|
||||
}),
|
||||
RBtn: defineComponent({ template: "<button><slot /></button>" }),
|
||||
RIcon: defineComponent({ template: "<i />" }),
|
||||
RImg: defineComponent({
|
||||
RImage: defineComponent({
|
||||
props: { src: { type: String, default: "" } },
|
||||
template: '<img :src="src" />',
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user