Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | 39x 39x 39x 38x 38x 39x 33x 33x 25x 8x 13x 8x 5x 3x 39x 39x 39x 5x 39x 6x 33x 3x 39x 5x 39x 1x 39x 38x 39x | <script setup lang="ts">
import { computed } from "vue";
import type { SkeletonBaseProps } from "../types";
interface ImageOptions {
ratio?: string;
icon?: boolean;
iconSize?: number | string;
iconColor?: string;
}
const props = defineProps<SkeletonBaseProps & { options?: ImageOptions }>();
const showIcon = computed(() => props.options?.icon ?? true);
const normalizedIconSize = computed(() => {
const value = props.options?.iconSize ?? "40%";
return typeof value === "number"
? `${value}px`
: value;
});
const aspectRatio = computed(() => {
const ratio = props.options?.ratio;
if (!ratio) {
return undefined;
}
const [width, height] = ratio
.split(":")
.map((value) => Number(value));
if (!width || !height) {
return undefined;
}
return `${width} / ${height}`;
});
const containerStyle = computed<Record<string, string>>(() => {
const styles: Record<string, string> = {};
if (props.width != null && props.width !== "") {
styles.width =
typeof props.width === "number"
? `${props.width}px`
: props.width;
}
if (props.height != null && props.height !== "") {
styles.height =
typeof props.height === "number"
? `${props.height}px`
: props.height;
} else if (aspectRatio.value) {
styles.aspectRatio = aspectRatio.value;
}
if (props.radius != null && props.radius !== "") {
styles.borderRadius =
typeof props.radius === "number"
? `${props.radius}px`
: props.radius;
}
if (props.options?.iconColor) {
styles["--vslk-sk-icon-color"] = props.options.iconColor;
}
return styles;
});
</script>
<template>
<div
class="vslk-sk-shape vslk-sk-image"
:style="containerStyle"
>
<svg
v-if="showIcon"
class="vslk-sk-image__icon"
:style="{
width: normalizedIconSize,
height: normalizedIconSize,
}"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
focusable="false"
>
<rect
x="3"
y="3"
width="18"
height="18"
rx="2"
ry="2"
stroke="currentColor"
stroke-width="1.5"
/>
<circle
cx="8.5"
cy="8.5"
r="1.5"
stroke="currentColor"
stroke-width="1.5"
/>
<polyline
points="21 15 16 10 5 21"
stroke="currentColor"
stroke-width="1.5"
stroke-linejoin="round"
stroke-linecap="round"
/>
</svg>
</div>
</template>
<style scoped>
.vslk-sk-image {
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.vslk-sk-image__icon {
display: block;
color: var(--vslk-sk-icon-color, #94a3b8);
opacity: 0.6;
flex-shrink: 0;
}
</style>
|