fix(docs): center copy icons and wrap full-width tables

This commit is contained in:
maoyingjie
2026-10-21 13:16:57 +08:00
parent 630963c652
commit 56b1ef11d8
4 changed files with 56 additions and 26 deletions
+12 -1
View File
@@ -9,7 +9,18 @@ export default defineConfig({
appearance: true,
cleanUrls: true,
head: [["meta", { name: "theme-color", content: "#f5f5f5" }]],
markdown: { headers: { level: [2, 3] } },
markdown: {
codeCopyButtonTitle: "复制代码",
headers: { level: [2, 3] },
config(md) {
const fence = md.renderer.rules.fence!;
md.renderer.rules.fence = (...args) =>
fence(...args).replace(
/(<button\b[^>]*class="copy"[^>]*>)(<\/button>)/g,
'$1<DocsCopyIcon class="copy-icon" aria-hidden="true" :size="16" /><DocsCheckIcon class="copied-icon" aria-hidden="true" :size="16" />$2',
);
},
},
vite: {
plugins: [
tailwindcss(),
+3
View File
@@ -1,4 +1,5 @@
import type { Theme } from "vitepress";
import { IconCopy, IconCheck } from "@tabler/icons-vue";
import Layout from "./Layout.vue";
import Demo from "./Demo.vue";
import "@heroui-vue/styles/css";
@@ -8,5 +9,7 @@ export default {
Layout,
enhanceApp({ app }) {
app.component("ComponentPreview", Demo);
app.component("DocsCopyIcon", IconCopy);
app.component("DocsCheckIcon", IconCheck);
},
} satisfies Theme;
+33 -25
View File
@@ -286,9 +286,6 @@ h1 {
font-size: 11px;
color: var(--muted);
}
.docs-content div[class*="language-"] > .copy {
display: none;
}
.docs-content pre {
overflow: auto;
padding: 22px;
@@ -310,8 +307,8 @@ h1 {
background-color: transparent !important;
}
.docs-content table:not(:where(.not-prose, .not-prose *)) {
display: block;
overflow: auto;
display: table;
table-layout: fixed;
width: 100%;
border-collapse: collapse;
font-size: 12px;
@@ -321,21 +318,22 @@ h1 {
text-align: left;
font-weight: 500;
color: var(--muted);
white-space: nowrap;
white-space: normal;
}
.docs-content th,
.docs-content th:not(:where(.not-prose, .not-prose *)),
.docs-content td:not(:where(.not-prose, .not-prose *)) {
padding: 13px 12px;
border-bottom: 1px solid var(--docs-border);
vertical-align: top;
min-width: 88px;
overflow-wrap: anywhere;
}
.docs-content th:first-child,
.docs-content td:first-child {
.docs-content th:first-child:not(:where(.not-prose, .not-prose *)),
.docs-content td:first-child:not(:where(.not-prose, .not-prose *)) {
padding-left: 0;
}
.docs-content td code {
white-space: nowrap;
.docs-content :is(th, td):not(:where(.not-prose, .not-prose *)) code {
white-space: normal;
overflow-wrap: anywhere;
}
.docs-content .custom-block {
border: 1px solid var(--docs-border);
@@ -609,17 +607,13 @@ a:focus-visible {
font-size: 17px;
margin-top: 30px;
}
.docs-content th {
.docs-content th:not(:where(.not-prose, .not-prose *)) {
color: var(--foreground);
background: var(--default-soft);
}
.docs-content td {
.docs-content td:not(:where(.not-prose, .not-prose *)) {
line-height: 1.75;
}
.docs-content table {
scrollbar-width: thin;
overscroll-behavior-inline: contain;
}
.docs-content pre {
font-size: 13px;
line-height: 1.7;
@@ -712,25 +706,39 @@ a:focus-visible {
overflow: visible;
}
.docs-content div[class*="language-"] > .copy {
display: block;
display: grid;
place-items: center;
position: absolute;
z-index: 1;
top: 6px;
right: 8px;
width: 30px;
height: 30px;
padding: 0;
border: 1px solid var(--docs-border);
border-radius: 6px;
background: var(--surface);
color: var(--muted);
line-height: 1;
}
.docs-content div[class*="language-"] > .copy::before {
content: "⧉";
font-size: 19px;
.docs-content div[class*="language-"] > .copy:hover {
color: var(--foreground);
background: var(--default-soft);
}
.docs-content div[class*="language-"] > .copy.copied::before {
content: "✓";
font-size: 15px;
.docs-content div[class*="language-"] > .copy:focus-visible {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
.docs-content div[class*="language-"] > .copy svg {
display: block;
grid-area: 1 / 1;
}
.docs-content div[class*="language-"] > .copy .copied-icon,
.docs-content div[class*="language-"] > .copy.copied .copy-icon {
display: none;
}
.docs-content div[class*="language-"] > .copy.copied .copied-icon {
display: block;
}
.docs-content div[class*="language-"] > .lang {
right: 48px;
+8
View File
@@ -81,3 +81,11 @@
- Link:`underline` / `no-underline` / `underline-offset-1..4` 计算值正确;默认图标 `data-default-icon` 与内置 SVG;自定义图标为 Tabler 且无 default 标记;asChild 渲染 `span[data-custom=foo]` 并合并 href 与 link 类。修复文档全局 `a { text-decoration: none }` 未入层导致 utility 下划线被覆盖的问题(改入 `@layer base`)。
- Spinner:尺寸 sm/md/lg/xl = 16/24/32/40px;颜色 current/accent/success/warning/danger 映射主题变量;`role="status"`、`aria-label="Loading"`、内部 SVG `aria-hidden` 与 viewBox;动画 `spin 0.75s`。Button 加载示例内 Spinner 为 16px,按钮 `data-pending` / `aria-busy`。
- Card 页面三处链接已改为 Link/LinkIcon。IAB 截图接口超时,未能保存本轮位图证据;以上为 DOM/计算样式记录,不等同于逐像素视觉验收。
## 文档复制按钮与表格排版修正(2026-10-21)
- Markdown 代码块沿用 VitePress 的复制逻辑,按钮内统一渲染 Tabler IconCopy / IconCheck,移除字符符号。30px 按钮以 grid 居中 16px 图标,保留悬停、键盘焦点和复制成功状态。
- 正文表格统一使用 width:100% 与 table-layout:fixed;表头、单元格和行内代码允许换行,长标识符可断行。移除滚动块和最小列宽,不缩小字号;样式排除 not-prose 演示区。
- 实际 IAB 浏览器检查(1280×720):Button、Card、Input、Link、Spinner、Surface、Switch、主题、安装共 9 页的 13 张表格均铺满 736px 正文宽度,无表格及单元格水平溢出;Button 的 API 表与作用域插槽状态表宽度一致。
- 安装页浅色、深色复制图标中心偏差均为 0px;点击复制后出现“代码已复制”反馈。检查了 Button API 长类型换行的实际页面外观。本轮未新增移动视口与自动视觉验收。
- pnpm test(67 项)、vue-tsc --noEmit、pnpm build:docs、Prettier 与 git diff --check 通过。