Fixes client vs server side
Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import { MDXRemote } from 'next-mdx-remote-client/rsc';
|
||||
import { formattedMDXComponents } from '@/mdx-components';
|
||||
import type {
|
||||
ComponentDefinition,
|
||||
DataAttributeValues,
|
||||
} from '../../../../packages/ui/src/types';
|
||||
'use client';
|
||||
|
||||
export function Theming({ definition }: { definition: ComponentDefinition }) {
|
||||
import { formattedMDXComponents } from '@/mdx-components';
|
||||
import type { DataAttributeValues } from '../../../../packages/ui/src/types';
|
||||
|
||||
interface ThemingProps {
|
||||
definition: {
|
||||
classNames: Record<string, string>;
|
||||
dataAttributes?: Record<string, string[]>;
|
||||
};
|
||||
}
|
||||
|
||||
export function Theming({ definition }: ThemingProps) {
|
||||
const classNames = definition.classNames;
|
||||
const dataAttributes = definition.dataAttributes;
|
||||
|
||||
@@ -33,15 +38,28 @@ export function Theming({ definition }: { definition: ComponentDefinition }) {
|
||||
...Object.values(classNames).slice(1),
|
||||
];
|
||||
|
||||
// Use the same styled components from MDX
|
||||
const H2 = formattedMDXComponents.h2!;
|
||||
const P = formattedMDXComponents.p!;
|
||||
const Ul = formattedMDXComponents.ul!;
|
||||
const Li = formattedMDXComponents.li!;
|
||||
const Code = formattedMDXComponents.code!;
|
||||
|
||||
return (
|
||||
<MDXRemote
|
||||
components={formattedMDXComponents}
|
||||
source={`## Theming
|
||||
|
||||
Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
|
||||
|
||||
${classNamesArray.map(selector => `- \`${selector}\``).join('\n')}
|
||||
`}
|
||||
/>
|
||||
<div>
|
||||
<H2>Theming</H2>
|
||||
<P>
|
||||
Our theming system is based on a mix between CSS classes, CSS variables
|
||||
and data attributes. If you want to customise this component, you can
|
||||
use one of these class names below.
|
||||
</P>
|
||||
<Ul>
|
||||
{classNamesArray.map((selector, index) => (
|
||||
<Li key={index}>
|
||||
<Code>{selector}</Code>
|
||||
</Li>
|
||||
))}
|
||||
</Ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* Client-side re-export of UI component definitions.
|
||||
*
|
||||
* The 'use client' directive here creates a boundary that prevents Next.js
|
||||
* from analyzing the transitive dependencies (hooks) during SSR/SSG.
|
||||
*
|
||||
* This allows the UI package to remain pure and free of Next.js-specific
|
||||
* directives while still working correctly in the Next.js App Router.
|
||||
*/
|
||||
export * from '../../../packages/ui/src/definitions';
|
||||
|
||||
Reference in New Issue
Block a user