Skip to content

Commit 216fbb3

Browse files
committed
adds accordion logic
1 parent fbbe1bd commit 216fbb3

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

docs/starter-template/components/DevDocsAccordion.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ Accordion returns a React component that renders an accordion UI element.
3434
</Accordion>
3535
```
3636

37+
<Accordion title="Click me to expand">
38+
This is the content that will be shown when the accordion is expanded.
39+
40+
You can include any markdown content here.
41+
- List items
42+
- More items
43+
44+
Or even code blocks!
45+
</Accordion>
46+
3747
## Notes or Considerations
3848

3949
* The accordion is collapsible by default, meaning it can be opened and closed by clicking on the title.

src/components/ui/accordion.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import { unified } from 'unified';
55
import markdown from 'remark-parse';
66
import remark2rehype from 'remark-rehype';
77
import rehype2react from 'rehype-react';
8+
import * as runtime from 'react/jsx-runtime';
89

910
import { cn } from "@site/src/utils"
1011

1112
const processor = unified()
1213
.use(markdown)
1314
.use(remark2rehype)
14-
.use(rehype2react, { createElement: React.createElement });
15+
.use(rehype2react, {
16+
createElement: React.createElement,
17+
Fragment: React.Fragment,
18+
jsx: runtime.jsx,
19+
jsxs: runtime.jsxs
20+
});
1521

1622
const Accordion = AccordionPrimitive.Root
1723

src/theme/MDXComponents/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import React from 'react';
22
import MDXComponents from '@theme-original/MDXComponents';
3-
import Parser from '@site/src/components/Parser';
3+
44
import CodeSnippets from '@site/src/components/CodeSnippets';
55
import InfoBox from '@site/src/components/InfoBox';
66

7+
import { DevDocsCard } from '@site/src/components/ui/card';
8+
import { DevDocsAccordion } from '@site/src/components/ui/accordion';
9+
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@site/src/components/ui/tabs.jsx';
10+
711
export default {
812
...MDXComponents,
913
CodeSnippets,
1014
InfoBox,
11-
Parser,
15+
Card: DevDocsCard,
16+
Accordion: DevDocsAccordion,
17+
Tabs,
18+
TabsList,
19+
TabsTrigger,
20+
TabsContent,
1221
};

0 commit comments

Comments
 (0)