fix(docs): center copy icons and wrap full-width tables
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user