fix(docs): restore related showcases and correct CSS customization examples

This commit is contained in:
maoyingjie
2026-10-28 23:06:08 +08:00
parent cfbcb38ec3
commit f9938eea8c
9 changed files with 180 additions and 5 deletions
@@ -0,0 +1,125 @@
<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>
+2
View File
@@ -5,6 +5,7 @@ import DocsComponents from "./DocsComponents.vue";
import DocsColorSection from "./DocsColorSection.vue";
import Layout from "./Layout.vue";
import Demo from "./Demo.vue";
import DocsRelatedShowcases from "./DocsRelatedShowcases.vue";
import "@heroui-vue/styles/css";
import "./utilities.css";
import "./style.css";
@@ -13,6 +14,7 @@ export default {
Layout,
enhanceApp({ app }) {
app.component("ComponentPreview", Demo);
app.component("DocsRelatedShowcases", DocsRelatedShowcases);
app.component("DocsCopyButton", Button);
app.component("DocsComponents", DocsComponents);
app.component("DocsColorSection", DocsColorSection);