Skip to content

Commit 28e2cd7

Browse files
committed
more components and new components docs :)
1 parent e7f71b6 commit 28e2cd7

43 files changed

Lines changed: 1614 additions & 151 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/DefinitionList.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default function DefinitionList({ items = [] }) {
2+
return (
3+
<dl className="my-6 space-y-3">
4+
{items.map((item) => (
5+
<div
6+
key={item.term}
7+
className="rounded-lg border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900"
8+
>
9+
<dt className="text-sm font-semibold text-slate-900 dark:text-slate-100">{item.term}</dt>
10+
<dd className="mt-1 text-sm leading-6 text-slate-700 dark:text-slate-200">{item.definition}</dd>
11+
</div>
12+
))}
13+
</dl>
14+
);
15+
}

components/Figure.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default function Figure({ src, alt = '', caption, width = '100%' }) {
2+
return (
3+
<figure className="my-6">
4+
<img
5+
src={src}
6+
alt={alt}
7+
style={{ width }}
8+
className="rounded-xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900"
9+
/>
10+
{caption ? <figcaption className="mt-2 text-sm text-slate-600 dark:text-slate-400">{caption}</figcaption> : null}
11+
</figure>
12+
);
13+
}

components/Infobox.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default function Infobox({ title, image, imageAlt = '', imageCaption, items = [] }) {
2+
return (
3+
<aside className="my-6 rounded-xl border border-slate-200 bg-white p-4 text-sm shadow-sm dark:border-slate-800 dark:bg-slate-900">
4+
{title ? <h3 className="mb-3 text-base font-semibold text-slate-900 dark:text-slate-100">{title}</h3> : null}
5+
6+
{image ? (
7+
<figure className="mb-4 overflow-hidden rounded-lg border border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-800/60">
8+
<img src={image} alt={imageAlt} className="h-auto w-full" />
9+
{imageCaption ? <figcaption className="px-3 py-2 text-xs text-slate-600 dark:text-slate-400">{imageCaption}</figcaption> : null}
10+
</figure>
11+
) : null}
12+
13+
<dl className="divide-y divide-slate-200 dark:divide-slate-800">
14+
{items.map((item) => (
15+
<div key={item.label} className="grid grid-cols-[8rem_1fr] gap-3 py-2">
16+
<dt className="font-medium text-slate-700 dark:text-slate-300">{item.label}</dt>
17+
<dd className="text-slate-900 dark:text-slate-100">{item.value}</dd>
18+
</div>
19+
))}
20+
</dl>
21+
</aside>
22+
);
23+
}

components/WikiTable.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export function Table({ children, className = '' }) {
2+
return (
3+
<div className="my-6 overflow-x-auto rounded-xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-950">
4+
<table className={`min-w-full border-collapse text-left text-sm ${className}`.trim()}>{children}</table>
5+
</div>
6+
);
7+
}
8+
9+
export function THead({ children, className = '' }) {
10+
return <thead className={`bg-slate-100 dark:bg-slate-900/80 ${className}`.trim()}>{children}</thead>;
11+
}
12+
13+
export function TBody({ children, className = '', striped = true }) {
14+
const stripedClass = striped
15+
? '[&>tr:nth-child(even)]:bg-slate-50/80 dark:[&>tr:nth-child(even)]:bg-slate-900/40'
16+
: '';
17+
18+
return <tbody className={`${stripedClass} ${className}`.trim()}>{children}</tbody>;
19+
}
20+
21+
export function TR({ children, className = '' }) {
22+
return <tr className={`border-b border-slate-200 last:border-0 dark:border-slate-800 ${className}`.trim()}>{children}</tr>;
23+
}
24+
25+
export function TH({ children, className = '' }) {
26+
return (
27+
<th className={`px-4 py-2 align-top font-semibold text-slate-900 dark:text-slate-100 ${className}`.trim()}>
28+
{children}
29+
</th>
30+
);
31+
}
32+
33+
export function TD({ children, className = '' }) {
34+
return <td className={`px-4 py-2 align-top text-slate-700 dark:text-slate-200 ${className}`.trim()}>{children}</td>;
35+
}
36+
37+
export function Caption({ children, className = '' }) {
38+
return <caption className={`px-4 py-3 text-left text-xs text-slate-600 dark:text-slate-400 ${className}`.trim()}>{children}</caption>;
39+
}
40+
41+
export default Table;

components/mdx-components.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ import Callout from './Callout';
66
import Card from './Card';
77
import CardGrid from './CardGrid';
88
import CodeBlock from './CodeBlock';
9+
import DarkModeToggle from './DarkModeToggle';
910
import Divider from './Divider';
11+
import DefinitionList from './DefinitionList';
1012
import FeatureList from './FeatureList';
13+
import Figure from './Figure';
14+
import Footer from './Footer';
15+
import Header from './Header';
16+
import Infobox from './Infobox';
1117
import Icon from './Icon';
1218
import Kbd from './Kbd';
19+
import SearchBar from './SearchBar';
20+
import Sidebar from './Sidebar';
1321
import Steps from './Steps';
1422
import Tabs, { TabPanels } from './Tabs';
23+
import Table, { Caption, TBody, TD, TH, THead, TR } from './WikiTable';
1524

1625
const mdxComponents = {
1726
Accordion,
@@ -21,15 +30,37 @@ const mdxComponents = {
2130
Callout,
2231
Card,
2332
CardGrid,
33+
Caption,
2434
CodeBlock,
35+
DarkModeToggle,
36+
DefinitionList,
2537
Divider,
2638
FeatureList,
39+
Figure,
40+
Footer,
41+
Header,
2742
Icon,
43+
Infobox,
2844
Kbd,
45+
SearchBar,
46+
Sidebar,
2947
Steps,
48+
Table,
49+
TBody,
50+
TD,
51+
TH,
52+
THead,
53+
TR,
3054
Tabs,
3155
TabPanels,
56+
caption: (props) => <Caption {...props} />,
3257
pre: (props) => <CodeBlock {...props} />,
58+
table: (props) => <Table {...props} />,
59+
tbody: (props) => <TBody {...props} />,
60+
td: (props) => <TD {...props} />,
61+
th: (props) => <TH {...props} />,
62+
thead: (props) => <THead {...props} />,
63+
tr: (props) => <TR {...props} />,
3364
};
3465

3566
export default mdxComponents;

content/guides/components-and-icons.mdx

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Accordion
3+
description: Collapsible content panels for FAQs and dense docs.
4+
template: default
5+
---
6+
7+
# Accordion
8+
9+
Renders collapsible sections from an `items` array.
10+
11+
## Props
12+
13+
| Prop | Type | Required | Description |
14+
| --- | --- | --- | --- |
15+
| `items` | `Array<{ id: string, title: string, content: ReactNode }>` | Yes | Accordion rows to render. |
16+
17+
## Live examples
18+
19+
<Accordion
20+
items={[
21+
{ id: 'what', title: 'What is MiniWiki?', content: 'A configurable MDX docs site.' },
22+
{ id: 'nest', title: 'Can I nest components?', content: 'Yes, MDX supports composition.' },
23+
]}
24+
/>
25+
26+
<Accordion
27+
items={[
28+
{
29+
id: 'install',
30+
title: 'Install',
31+
content: (
32+
<>
33+
Run <Kbd>npm</Kbd> <Kbd>run</Kbd> <Kbd>dev</Kbd>.
34+
<Callout icon="tool">Use Node 20+ for consistency.</Callout>
35+
</>
36+
),
37+
},
38+
{
39+
id: 'publish',
40+
title: 'Publish',
41+
content: 'Push to main to trigger your GitHub Pages workflow.',
42+
},
43+
]}
44+
/>
45+
46+
## Code
47+
48+
### Basic FAQ
49+
50+
```mdx
51+
<Accordion
52+
items={[
53+
{ id: 'what', title: 'What is MiniWiki?', content: 'A configurable MDX docs site.' },
54+
{ id: 'nest', title: 'Can I nest components?', content: 'Yes, MDX supports composition.' },
55+
]}
56+
/>
57+
```
58+
59+
### Rich content in panels
60+
61+
```mdx
62+
<Accordion
63+
items={[
64+
{
65+
id: 'install',
66+
title: 'Install',
67+
content: (
68+
<>
69+
Run <Kbd>npm</Kbd> <Kbd>run</Kbd> <Kbd>dev</Kbd>.
70+
<Callout icon="tool">Use Node 20+ for consistency.</Callout>
71+
</>
72+
),
73+
},
74+
{
75+
id: 'publish',
76+
title: 'Publish',
77+
content: 'Push to main to trigger your GitHub Pages workflow.',
78+
},
79+
]}
80+
/>
81+
```
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Alert
3+
description: Highlight critical info with semantic variants.
4+
template: default
5+
---
6+
7+
# Alert
8+
9+
Displays a message block with optional title and variant type.
10+
11+
## Props
12+
13+
| Prop | Type | Required | Description |
14+
| --- | --- | --- | --- |
15+
| `type` | `'info' \| 'warning' \| 'success' \| 'danger'` | No | Visual variant. |
16+
| `title` | `string` | No | Optional heading line. |
17+
| `children` | `ReactNode` | No | Alert body content. |
18+
19+
## Examples
20+
21+
### Live examples
22+
23+
<Alert title="Heads up">
24+
JSON edits are reflected immediately after page refresh.
25+
</Alert>
26+
27+
<Alert type="warning" title="Check before deploy">
28+
Confirm all sidebar links point to existing pages.
29+
</Alert>
30+
31+
<Alert type="success" title="Published">
32+
Your docs site deployed successfully.
33+
</Alert>
34+
35+
<Alert type="danger" title="Build failed">
36+
A referenced MDX route is missing. Fix links and redeploy.
37+
</Alert>
38+
39+
### Code
40+
41+
#### Info (default)
42+
43+
```mdx
44+
<Alert title="Heads up">
45+
JSON edits are reflected immediately after page refresh.
46+
</Alert>
47+
```
48+
49+
#### Warning
50+
51+
```mdx
52+
<Alert type="warning" title="Check before deploy">
53+
Confirm all sidebar links point to existing pages.
54+
</Alert>
55+
```
56+
57+
#### Success
58+
59+
```mdx
60+
<Alert type="success" title="Published">
61+
Your docs site deployed successfully.
62+
</Alert>
63+
```
64+
65+
#### Danger
66+
67+
```mdx
68+
<Alert type="danger" title="Build failed">
69+
A referenced MDX route is missing. Fix links and redeploy.
70+
</Alert>
71+
```

0 commit comments

Comments
 (0)