Skip to content

Commit

Permalink
chore(doc): replace PreviewComponent by ComponentExample
Browse files Browse the repository at this point in the history
  • Loading branch information
franckgaudin committed Jun 18, 2024
1 parent 95dfea5 commit f7f6906
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ComponentPreviewWrapper from "./ComponentPreviewWrapper.tsx";
import "./componentExample.css";

interface CommonProps {
src: string;
className?: string;
isOpen?: boolean;
}
Expand All @@ -34,6 +35,7 @@ interface BothProps extends CommonProps {
export type ComponentExampleProps = CodeProps | PreviewProps | BothProps;

const ComponentExample = memo(({
src,
type = "both",
className,
isOpen = false,
Expand All @@ -47,6 +49,10 @@ const ComponentExample = memo(({

const toggleShowCode = useCallback(() => setShowCode(prevShowCode => !prevShowCode), []);

if (!src) {
return null;
}

const renderToggleButton = () => {
if (!showBothComponent) {
return null;
Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions apps/docs/app/ui/components/heading/heading.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.hd-heading {
margin-block-end: var(--hd-space-4);
}

.hd-heading__title {
display: flex;
align-items: baseline;
Expand Down
39 changes: 0 additions & 39 deletions apps/docs/app/ui/components/previewComponent/PreviewComponent.tsx

This file was deleted.

This file was deleted.

20 changes: 13 additions & 7 deletions apps/docs/components/mdx/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import PackageInstallation, {

import type { MigrateGuideProps } from "@/app/ui/components/migrateGuide/MigrateGuide.tsx";
import type { PropTableProps } from "@/app/ui/components/propTable/PropTable.tsx";
import type { ComponentExampleWrapperProps } from "@/app/ui/components/componentExample/ComponentExampleWrapper.tsx";
import type { ComponentExampleProps } from "@/app/ui/components/componentExample/ComponentExample.tsx";
import { ComponentCodeWrapper } from "@/app/ui/components/componentExample/ComponentCodeWrapper.tsx";
import ComponentPreview from "@/app/ui/components/componentExample/ComponentPreview.tsx";

const MigrateGuide = dynamic(() => import("@/app/ui/components/migrateGuide/MigrateGuide.tsx"));
const PropTable = dynamic(() => import("@/app/ui/components/propTable/PropTable.tsx"));
const ComponentExampleWrapper = dynamic(() => import("@/app/ui/components/componentExample/ComponentExampleWrapper.tsx"));
const ComponentExample = dynamic(() => import("@/app/ui/components/componentExample/ComponentExample.tsx"));

type HeadingProps = DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;

Expand All @@ -50,11 +52,15 @@ export const components = {
PackageInstallation: (props: PackageInstallationProps) => {
return <PackageInstallation {...props} />;
},
PreviewComponent: (props: ComponentExampleWrapperProps) => {
return <ComponentExampleWrapper type="preview" {...props} />;
},
Example: (props: ComponentExampleWrapperProps) => {
return <ComponentExampleWrapper {...props} />;
Example: (props: ComponentExampleProps) => {
const { src } = props;

return <ComponentExample
{...props}
type="both"
code={<ComponentCodeWrapper src={src} />}
preview={<ComponentPreview src={src} />}
/>;
},
MigrateGuide: (props: MigrateGuideProps) => {
return <MigrateGuide {...props} />;
Expand Down
8 changes: 1 addition & 7 deletions apps/docs/content/components/actions/button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ links:
source: https://github.com/gsoft-inc/wl-hopper/blob/main/packages/components/src/buttons/src/Button.tsx
---

<PreviewComponent src="buttons/docs/button/preview"/>
<Example src="buttons/docs/button/preview" isOpen />

## Usage
```tsx showLineNumbers
import { Button } from "@hopper-ui/components";

<Button>save</Button>
```
## Props

<PropTable component="Button" />
Expand Down

0 comments on commit f7f6906

Please sign in to comment.