126 lines
3.0 KiB
Vue
126 lines
3.0 KiB
Vue
<script setup lang="ts">
|
||
// Adapted from HeroUI ce90ea3 related-showcases/showcase-item and registry/navigation,
|
||
// Apache-2.0. Cards link to the upstream React examples; no local showcase runtime.
|
||
import { computed } from "vue";
|
||
|
||
const props = defineProps<{ component: string }>();
|
||
const cdn =
|
||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/showcases";
|
||
const showcases = [
|
||
{
|
||
name: "apple-iphone-disclosure",
|
||
title: "Apple iPhone 17 Pro Disclosure",
|
||
components: ["DisclosureGroup", "Disclosure", "Button"],
|
||
asset: 1,
|
||
},
|
||
{
|
||
name: "apple-iphone-camera-zoom",
|
||
title: "Apple iPhone 17 Pro Camera Zoom",
|
||
components: ["Tabs"],
|
||
asset: 2,
|
||
},
|
||
];
|
||
const items = computed(() =>
|
||
showcases.filter((item) =>
|
||
item.components.some(
|
||
(name) => name.toLowerCase() === props.component.toLowerCase(),
|
||
),
|
||
),
|
||
);
|
||
</script>
|
||
|
||
<template>
|
||
<div v-if="items.length" class="docs-related-showcases not-prose">
|
||
<a
|
||
v-for="item in items"
|
||
:key="item.name"
|
||
class="showcase-card"
|
||
:href="`https://heroui.com/cn/showcase/${item.name}`"
|
||
target="_blank"
|
||
rel="noopener noreferrer"
|
||
:aria-label="`${item.title}(上游 React 案例,新窗口)`"
|
||
>
|
||
<div class="showcase-media">
|
||
<span class="showcase-status">new</span>
|
||
<video
|
||
autoplay
|
||
loop
|
||
muted
|
||
playsinline
|
||
preload="none"
|
||
:poster="`${cdn}/${item.asset}.jpg`"
|
||
>
|
||
<source :src="`${cdn}/${item.asset}.mp4`" type="video/mp4" />
|
||
</video>
|
||
</div>
|
||
<span class="showcase-title">{{ item.title }}</span>
|
||
</a>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.docs-related-showcases {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 250px));
|
||
gap: 16px;
|
||
padding: 8px;
|
||
margin: 0 -8px;
|
||
}
|
||
.showcase-card {
|
||
position: relative;
|
||
display: flex;
|
||
flex-direction: column;
|
||
height: 180px;
|
||
max-width: 250px;
|
||
min-width: 0;
|
||
color: var(--foreground);
|
||
text-decoration: none;
|
||
}
|
||
.showcase-media {
|
||
position: relative;
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow: hidden;
|
||
border: 1px solid transparent;
|
||
border-radius: 12px;
|
||
box-shadow: var(--surface-shadow);
|
||
transition: transform 250ms ease-out;
|
||
}
|
||
.showcase-card:hover .showcase-media {
|
||
transform: scale(1.02);
|
||
}
|
||
.showcase-card:focus-visible {
|
||
outline: 2px solid var(--focus);
|
||
outline-offset: 4px;
|
||
border-radius: 12px;
|
||
}
|
||
.showcase-media video {
|
||
width: 100%;
|
||
height: 100%;
|
||
object-fit: cover;
|
||
}
|
||
.showcase-status {
|
||
position: absolute;
|
||
z-index: 1;
|
||
top: 6px;
|
||
right: 8px;
|
||
padding: 2px 6px;
|
||
border: 1px solid rgb(255 255 255 / 10%);
|
||
border-radius: 999px;
|
||
background: rgb(255 255 255 / 10%);
|
||
color: rgb(255 255 255 / 80%);
|
||
font-size: 11px;
|
||
}
|
||
.showcase-title {
|
||
margin-top: 12px;
|
||
padding: 0 4px;
|
||
font-size: 14px;
|
||
color: color-mix(in oklab, var(--foreground) 50%, transparent);
|
||
}
|
||
@media (prefers-reduced-motion: reduce) {
|
||
.showcase-media {
|
||
transition: none;
|
||
}
|
||
}
|
||
</style>
|