@tobeofuse/mdx-ui 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +38 -2
  2. package/package.json +1 -2
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Components for MDX
1
+ # MDX UI
2
2
 
3
- This is a simple library built by Vite. It uses plugins to support React and JSX, dynamically build a stylesheet with TailwindCSS, and produce .d.ts files. It has React as a peer dependency. It uses Shadcn components.
3
+ This is a component library intended to be used in [MDX](https://mdxjs.com/) files. It takes the elements that MDX produces and slots them into place in Shadcn components. It makes it very easy to have basic UI in MDX files. Given input like this:
4
+
5
+ ```mdx
6
+ <MdxTabs>
7
+
8
+ # Tab A
9
+
10
+ This tab has content.
11
+
12
+ # Tab B
13
+
14
+ This tab has different content.
15
+
16
+ </MdxTabs>
17
+ ```
18
+
19
+ You'll get a component like this:
20
+
21
+ ![A mouse clicks back and forth between Tab A and Tab B.](tabs.gif)
22
+
23
+ [Here](https://tobeofuse.github.io/mdx-ui) is a demo.
24
+
25
+ ## How It Works
26
+
27
+ When MDX parses the file, it turns Markdown into React elements that correspond to standard DOM elements like `<p>`, `<h1>` and so on. These elements are passed to any actual components you use in your MDX as children. This library uses `React.Children` to inspect the children that are passed in and slot them into Shadcn components. [Radix UI](https://github.com/radix-ui/primitives/blob/22473d16404bfd446305db5b6c9308aece99fdec/packages/react/slot/src/slot.tsx#L50) uses a similar approach to slots internally, and [here](https://sandroroth.com/blog/react-slots/) is a blog post I found that explains the technique in detail. The only thing that this library does differently than those examples is that it looks for normal elements like `<p>` instead of special slot elements like `<CardHeader>`.
28
+
29
+ ## Styles
30
+
31
+ This library does ship with a stylesheet generated by TailwindCSS, meaning that it will add some CSS variables and utility classes to the global CSS namespace. However, it deliberately excludes Tailwind's "Preflight" CSS reset, so it should inherit any global styles that you're using instead of conflicting with them.
32
+
33
+ ### Dark Mode
34
+
35
+ These components will switch into dark mode if they have a container element as an ancestor that has a class called `dark`.
36
+
37
+ ## Development
38
+
39
+ The main repository is a simple monorepo managed with npm workspaces. It has two packages: the main library package (`packages/mdx-ui`), and the static demo site (`packages/demo`). Run `npm run dev` to build the library in watch mode and run a dev server for the demo site.
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@tobeofuse/mdx-ui",
3
- "readme": "../../Readme.md",
4
3
  "private": false,
5
- "version": "0.5.1",
4
+ "version": "0.5.2",
6
5
  "type": "module",
7
6
  "scripts": {
8
7
  "build": "tsc -b ./tsconfig.lib.json && vite build"