提交 f708aec4 编写于 作者: C codecalm

docs improvements

上级 76aedb83
...@@ -8,7 +8,7 @@ bootstrapLink: components/alerts/ ...@@ -8,7 +8,7 @@ bootstrapLink: components/alerts/
Depending on the information you need to convey, you can use one of the following types of alert messages - **success**, **info**, **warning** or **danger**. Using the right type of alert modal will help draw users' attention to the message and prompt them to take action. Depending on the information you need to convey, you can use one of the following types of alert messages - **success**, **info**, **warning** or **danger**. Using the right type of alert modal will help draw users' attention to the message and prompt them to take action.
```html example ```html example vertical
<div class="alert alert-success" role="alert"> <div class="alert alert-success" role="alert">
<h4 class="alert-title">Wow! Everything worked!</h4> <h4 class="alert-title">Wow! Everything worked!</h4>
<div class="text-secondary">Your account has been saved!</div> <div class="text-secondary">Your account has been saved!</div>
...@@ -38,18 +38,12 @@ Depending on the information you need to convey, you can use one of the followin ...@@ -38,18 +38,12 @@ Depending on the information you need to convey, you can use one of the followin
Add a link to your alert message to redirect users to the details they need to complete or additional information they should read. Add a link to your alert message to redirect users to the details they need to complete or additional information they should read.
```html example ```html example vertical code
<div class="alert alert-danger m-0"> <div class="alert alert-danger m-0">
This is a danger alert — <a href="#" class="alert-link">check it out</a>! This is a danger alert — <a href="#" class="alert-link">check it out</a>!
</div> </div>
``` ```
```html
<div class="alert alert-danger" role="alert">
This is a danger alert — <a href="#" class="alert-link">check it out</a>!
</div>
```
## Dismissible alerts ## Dismissible alerts
Add the `x` close button to make an alert modal dismissible. Thanks to that, your alert modal will disappear only once the user closes it. Add the `x` close button to make an alert modal dismissible. Thanks to that, your alert modal will disappear only once the user closes it.
...@@ -351,7 +345,7 @@ Add primary and secondary buttons to your alert modals if you want users to take ...@@ -351,7 +345,7 @@ Add primary and secondary buttons to your alert modals if you want users to take
If you want your alert to be really eye-catching, you can add a class `alert-important`. If you want your alert to be really eye-catching, you can add a class `alert-important`.
```html example ```html example vertical height="20rem"
<div class="alert alert-important alert-success alert-dismissible" role="alert"> <div class="alert alert-important alert-success alert-dismissible" role="alert">
<div class="d-flex"> <div class="d-flex">
<div> <div>
......
...@@ -72,55 +72,62 @@ export default async function DocPage({ params }: DocPageProps) { ...@@ -72,55 +72,62 @@ export default async function DocPage({ params }: DocPageProps) {
{/*<input type="search" className="form-control w-100 mb-5" placeholder="Search&hellip;" />*/} {/*<input type="search" className="form-control w-100 mb-5" placeholder="Search&hellip;" />*/}
<DocsMenu /> <DocsMenu />
</div> </div>
<div className="md:col"> <div className="col">
<div className="py-6 md:pl-6"> <div className="row">
<nav aria-label="breadcrumbs" className="breadcrumb mb-6"> <div className="md:col">
<ul className="breadcrumb-list"> <div className="py-6 md:pl-6">
<li className="breadcrumb-item"> <nav aria-label="breadcrumbs" className="breadcrumb mb-6">
<Link href="/" className="breadcrumb-link"> <ul className="breadcrumb-list">
Home <li className="breadcrumb-item">
</Link> <Link href="/" className="breadcrumb-link">
</li> Home
<li className="breadcrumb-item"> </Link>
<Link href="/docs" className="breadcrumb-link"> </li>
Documentation <li className="breadcrumb-item">
</Link> <Link href="/docs" className="breadcrumb-link">
</li> Documentation
<li className="breadcrumb-item"> </Link>
<Link href={`/docs/${params.slug.join('/')}`} className="breadcrumb-link"> </li>
{doc.title} <li className="breadcrumb-item">
</Link> <Link href={`/docs/${params.slug.join('/')}`} className="breadcrumb-link">
</li> {doc.title}
</ul> </Link>
</nav> </li>
<div className="markdown"> </ul>
{/* {category && ( </nav>
<div className="markdown">
{/* {category && (
<div className="h-subheader text-primary">{category}</div> <div className="h-subheader text-primary">{category}</div>
)} */} )} */}
{doc.title && <h1>{doc.title}</h1>} {doc.title && <h1>{doc.title}</h1>}
{doc.description && <p className="lead">{doc.description}</p>} {doc.description && <p className="lead">{doc.description}</p>}
<Mdx code={doc.body.code} /> <Mdx code={doc.body.code} />
</div>
</div>
</div> </div>
<div className="docs-side-toc">
<TablerSponsorsBanner className="mt-7" /> <div className="pl-6 font-h6 pt-6">
</div> <div className="h6 mb-3">On this page</div>
</div> <div>
<div className="docs-side-toc"> <TOC toc={toc} />
<div className="pl-6 font-h6 pt-6"> </div>
<div className="h6 mb-3">On this page</div> <div className="mt-4 border-top pt-4">
<div> <a href={`https://github.com/tabler/tabler/blob/main/docs/${doc.slugAsParams.split(',').join('/')}.mdx`} className="link-muted">
<TOC toc={toc} /> Improve this page
<Icon name="edit" className="icon-inline ml-2" />
</a>
</div>
<div className="mt-5">
<Ad />
</div>
</div>
</div> </div>
<div className="mt-4 border-top pt-4"> <div className="col-12">
<a href={`https://github.com/tabler/tabler/blob/main/docs/${doc.slugAsParams.split(',').join('/')}.mdx`} className="link-muted"> <div className="pl-6 mt-7">
Improve this page <TablerSponsorsBanner />
<Icon name="edit" className="icon-inline ml-2" /> </div>
</a>
</div>
<div className="mt-5">
<Ad />
</div> </div>
</div> </div>
</div> </div>
......
...@@ -7,7 +7,7 @@ export default function Ad({ className, horizontal }: { className?: string; hori ...@@ -7,7 +7,7 @@ export default function Ad({ className, horizontal }: { className?: string; hori
const ad = useRef<any>(null); const ad = useRef<any>(null);
useEffect(() => { useEffect(() => {
if (ad.current) { if (ad.current && process.env.NODE_ENV !== 'development') {
ad.current.innerHTML = ''; ad.current.innerHTML = '';
const script = document.createElement('script'); const script = document.createElement('script');
......
...@@ -3,14 +3,8 @@ ...@@ -3,14 +3,8 @@
import { useState } from 'react'; import { useState } from 'react';
import clsx from 'clsx'; import clsx from 'clsx';
import { uiCdnUrl, uiUrl } from '@/config/site'; import { uiCdnUrl, uiUrl } from '@/config/site';
const previewHtml = ( const previewHtml = (
example, example,
{ {
...@@ -27,46 +21,32 @@ const previewHtml = ( ...@@ -27,46 +21,32 @@ const previewHtml = (
plugins = [], plugins = [],
libs = [], libs = [],
}: { }: {
vertical?: boolean vertical?: boolean;
background?: string background?: string;
scrollable?: boolean scrollable?: boolean;
columns?: number columns?: number;
centered?: boolean centered?: boolean;
vcentered?: boolean vcentered?: boolean;
separated?: boolean separated?: boolean;
vendors?: boolean vendors?: boolean;
overview?: boolean overview?: boolean;
fullpage?: boolean fullpage?: boolean;
plugins?: string[] plugins?: string[];
libs?: string[] libs?: string[];
} },
) => { ) => {
let assetsUrl = uiCdnUrl; let assetsUrl = uiCdnUrl;
if (process.env.TABLER_LOCAL) { if (process.env.TABLER_LOCAL) {
assetsUrl = uiUrl; assetsUrl = 'http://localhost:3000';
} }
let content = example; let content = example;
if (!fullpage) { if (!fullpage) {
content = `<main class="min-vh-100 ${vertical ? 'p-4' : 'py-4 px-4'}${ content = `<main class="min-vh-100 ${vertical ? 'p-4' : 'py-4 px-4'}${centered ? ' d-flex justify-content-center align-items-center flex-wrap' : ''}${vcentered ? ' d-flex justify-content-center flex-column' : ''}">
centered
? ' d-flex justify-content-center align-items-center flex-wrap'
: ''
}${vcentered ? ' d-flex justify-content-center flex-column' : ''}">
${ ${columns ? `<div class="mx-auto w-100" style="max-width: ${columns * 20}rem">` : ''}
columns ${separated ? (vertical ? '<div class="space-y">' : '<div class="space-x">') : ''}
? `<div class="mx-auto w-100" style="max-width: ${columns * 20}rem">`
: ''
}
${
separated
? vertical
? '<div class="space-y">'
: '<div class="space-x">'
: ''
}
${example} ${example}
...@@ -75,32 +55,17 @@ const previewHtml = ( ...@@ -75,32 +55,17 @@ const previewHtml = (
</main>`; </main>`;
} }
example = example example = example.replace(/a href="[^"]+"/g, 'a href="javascript:void(0)"').replace(/action="[^"]+"/g, 'action="javascript:void(0)"');
.replace(/a href="[^"]+"/g, 'a href="javascript:void(0)"')
.replace(/action="[^"]+"/g, 'action="javascript:void(0)"');
return `<html lang="en"> return `<html lang="en">
<head> <head>
<title>Example</title> <title>Example</title>
<link rel="stylesheet" href="${assetsUrl}/dist/css/tabler.css"> <link rel="stylesheet" href="${assetsUrl}/dist/css/tabler.css">
${ ${plugins ? plugins.map((plugin) => ` <link rel="stylesheet" href="${assetsUrl}/dist/css/tabler-${plugin}.css" />`) : ''}
plugins
? plugins.map(
(plugin) =>
` <link rel="stylesheet" href="${assetsUrl}/dist/css/tabler-${plugin}.css" />`
)
: ''
}
</head> </head>
<body class="h-100${background ? ` bg-${background}` : ''}${ <body class="h-100${background ? ` bg-${background}` : ''}${scrollable || fullpage ? ' auto-scroll' : ' no-scroll'}"${!background && ' style="--tblr-body-bg: #fbfcfd"'}>
scrollable || fullpage ? ' auto-scroll' : ' no-scroll'
}"${!background && ' style="--tblr-body-bg: #fbfcfd"'}>
${content} ${content}
${ ${vendors ? `<link rel="stylesheet" href="${assetsUrl}/dist/css/tabler-vendors.css" />` : ''}
vendors
? `<link rel="stylesheet" href="${assetsUrl}/dist/css/tabler-vendors.css" />`
: ''
}
<script src="${assetsUrl}/dist/js/tabler.js"></script> <script src="${assetsUrl}/dist/js/tabler.js"></script>
</body> </body>
</html>`; </html>`;
...@@ -141,9 +106,13 @@ export default function Example({ ...@@ -141,9 +106,13 @@ export default function Example({
return ( return (
<div className="example"> <div className="example">
<iframe className={clsx('example-frame', { <iframe
'example-frame-resizable': resizable, className={clsx('example-frame', {
})} srcDoc={srcDoc} style={{ height: iframeHeight }} /> 'example-frame-resizable': resizable,
})}
srcDoc={srcDoc}
style={{ height: iframeHeight }}
/>
</div> </div>
); );
} }
...@@ -31,7 +31,7 @@ export default function TOC({ toc }: TocProps) { ...@@ -31,7 +31,7 @@ export default function TOC({ toc }: TocProps) {
return mounted ? ( return mounted ? (
<Tree tree={toc} activeItem={activeHeading} /> <Tree tree={toc} activeItem={activeHeading} />
) : null; ) : <Tree tree={toc} />;
} }
function useActiveItem(itemIds: (string | undefined)[]) { function useActiveItem(itemIds: (string | undefined)[]) {
......
...@@ -2,7 +2,11 @@ import { sponsorsUrl } from '@/config/site'; ...@@ -2,7 +2,11 @@ import { sponsorsUrl } from '@/config/site';
import clsx from 'clsx'; import clsx from 'clsx';
import Icon from './Icon'; import Icon from './Icon';
export default function TablerSponsorsBanner({ className }) { export default function TablerSponsorsBanner({
className
}: {
className?: string;
}) {
return <a href={sponsorsUrl} target="_blank" className={clsx('sponsors', className )}> return <a href={sponsorsUrl} target="_blank" className={clsx('sponsors', className )}>
<div <div
className="logo logo-gray mb-5" className="logo logo-gray mb-5"
......
...@@ -241,7 +241,7 @@ pre { ...@@ -241,7 +241,7 @@ pre {
color: $color-white; color: $color-white;
border-radius: $border-radius; border-radius: $border-radius;
padding: $gap-3 $gap-4; padding: $gap-3 $gap-4;
font-size: 14px; font-size: 13px;
word-break: break-word; word-break: break-word;
tab-size: 2; tab-size: 2;
overflow: auto; overflow: auto;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册