Skip to content

Commit 7690969

Browse files
committed
update component preview layout
1 parent bb5285f commit 7690969

File tree

7 files changed

+60
-42
lines changed

7 files changed

+60
-42
lines changed

www/content/docs/components/buttons/button.mdx

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ links:
1212
href: https://github.com/mehdibha/dotUI/tree/main/content/components/buttons/button.mdx?plain=1
1313
---
1414

15-
<ComponentPreview name="button/default" preview={`<Button>button</Button>`} />
15+
<ComponentPreview
16+
name="button/default"
17+
preview={`<Button>button</Button>`}
18+
/>
1619

1720
## Installation
1821

www/public/og.jpg

461 KB
Loading

www/src/components/docs/code-block-client.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ const CodeBlockClient = ({
8080
<div className="flex items-center gap-2">
8181
{(preview || expandable) && (
8282
<Button
83-
variant="default"
83+
variant="outline"
8484
size="sm"
85-
className="h-7 text-xs"
85+
className="bg-bg-inverse/5 h-7 text-xs"
8686
onPress={handleExpand}
8787
>
8888
{isExpanded ? "Collapse" : "Expand"} code
@@ -152,9 +152,9 @@ const CodeBlockCopyButton = ({ code, ...props }: CodeBlockCopyButtonProps) => {
152152
<Button
153153
size="sm"
154154
shape="square"
155-
variant="default"
155+
variant="outline"
156156
onPress={handleCopy}
157-
className="size-7 [&_svg]:size-3"
157+
className="bg-bg-inverse/5 size-7 [&_svg]:size-3"
158158
{...props}
159159
>
160160
{copied ? (

www/src/components/docs/component-preview.tsx

+43-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import React from "react";
22
import { ScrollArea } from "@radix-ui/react-scroll-area";
3-
import { PaintBucket } from "lucide-react";
3+
import {
4+
PaintBucket,
5+
Settings2Icon,
6+
SlidersHorizontalIcon,
7+
} from "lucide-react";
48
import { getFileSource } from "@/lib/get-file-source";
59
import { cn } from "@/lib/utils";
610
import { Button } from "@/components/core/button";
@@ -25,6 +29,7 @@ export interface ComponentPreviewProps {
2529
fullWidth?: boolean;
2630
resizable?: boolean;
2731
suspense?: boolean;
32+
primary?: boolean;
2833
}
2934

3035
export const ComponentPreview = async ({
@@ -35,6 +40,7 @@ export const ComponentPreview = async ({
3540
fullWidth = false,
3641
resizable = false,
3742
suspense = false,
43+
primary = false,
3844
}: ComponentPreviewProps) => {
3945
const demoItem = Index[name];
4046

@@ -55,33 +61,49 @@ export const ComponentPreview = async ({
5561
<div
5662
className={cn("overflow-hidden rounded-md border", containerClassName)}
5763
>
64+
{/* <div className="bg-bg-muted flex items-center justify-between rounded-t-[inherit] border-b p-2">
65+
<StyleSwitcher
66+
// @ts-expect-error TODO fix later
67+
componentName={getComponentName(name)}
68+
variant="outline"
69+
className="bg-bg-inverse/5 h-7 text-xs font-normal"
70+
/>
71+
<ThemeCustomizerDialog>
72+
<Tooltip
73+
content={
74+
<span>
75+
<span className="text-fg-muted">Theme:</span> dotUI
76+
</span>
77+
}
78+
>
79+
<Button
80+
variant="outline"
81+
shape="square"
82+
size="sm"
83+
className="bg-bg-inverse/5 size-7 text-sm font-normal"
84+
>
85+
<PaintBucket />
86+
</Button>
87+
</Tooltip>
88+
</ThemeCustomizerDialog>
89+
</div> */}
5890
<div className="bg-bg-muted">
5991
<ResizableContainer resizable={resizable}>
6092
<Loader>
6193
<ThemeOverride className="relative duration-300">
62-
{/* @ts-expect-error fix later */}
63-
<StyleSwitcher componentName={getComponentName(name)} />
64-
<ThemeCustomizerDialog>
65-
<Tooltip
66-
content={
67-
<span>
68-
<span className="text-fg-muted">Theme:</span> dotUI
69-
</span>
70-
}
71-
>
72-
<Button
73-
shape="square"
74-
size="sm"
75-
className="border-border absolute right-2 top-2 z-10 font-normal"
76-
>
77-
<PaintBucket />
78-
</Button>
79-
</Tooltip>
80-
</ThemeCustomizerDialog>
94+
<Button
95+
variant="quiet"
96+
shape="square"
97+
size="sm"
98+
className="absolute right-2 top-2 z-10"
99+
>
100+
<SlidersHorizontalIcon />
101+
</Button>
81102
<ScrollArea className="bg-bg text-fg">
82103
<div
83104
className={cn(
84-
"flex min-h-52 py-20",
105+
"flex py-10",
106+
primary && "min-h-48 py-20",
85107
fullWidth
86108
? "px-8 lg:px-12"
87109
: "flex items-center justify-center px-4"

www/src/components/docs/style-switcher.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ import React from "react";
44
import { ChevronDownIcon } from "lucide-react";
55
import { useComponentsVariants } from "@/lib/create-dynamic-component";
66
import { useThemes } from "@/hooks/use-themes";
7-
import { Button } from "@/components/core/button";
7+
import { Button, ButtonProps } from "@/components/core/button";
88
import { ListBox, ListBoxItem } from "@/components/core/list-box";
99
import { Popover } from "@/components/core/popover";
1010
import { SelectRoot, SelectValue } from "@/components/core/select";
1111
import { core } from "@/registry/registry-core";
1212

13-
export function StyleSwitcher({ componentName }: { componentName: string }) {
13+
export function StyleSwitcher({
14+
componentName,
15+
...props
16+
}: {
17+
componentName: string;
18+
} & ButtonProps) {
1419
const primitiveInfo = getPrimitiveInfo(componentName);
1520
const { variants: contextVariants, setVariants } = useComponentsVariants();
1621
const { currentTheme } = useThemes();
@@ -35,11 +40,7 @@ export function StyleSwitcher({ componentName }: { componentName: string }) {
3540
}}
3641
className="w-auto"
3742
>
38-
<Button
39-
size="sm"
40-
suffix={<ChevronDownIcon />}
41-
className="border-border absolute left-2 top-2 z-10 text-xs font-normal"
42-
>
43+
<Button size="sm" suffix={<ChevronDownIcon />} {...props}>
4344
<span className="font-bold">{primitiveName}:</span> <SelectValue />
4445
</Button>
4546
<Popover>

www/src/components/header.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,6 @@ const Logo = () => {
8585
href="/"
8686
className="flex items-center gap-2 rounded opacity-100 transition-[opacity,transform] duration-300 ease-out"
8787
>
88-
{/* <Avatar
89-
src={siteConfig.global.logo}
90-
alt={siteConfig.global.name}
91-
width={24}
92-
height={24}
93-
loading="lazy"
94-
className="m-1 size-6 rounded-sm"
95-
/> */}
9688
<svg
9789
xmlns="http://www.w3.org/2000/svg"
9890
width={20}

www/src/components/mobile-nav.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const MobileNav = ({
6161
<div className="font-josefin group-data-collapsed/sidebar:opacity-0 mt-[5px] font-bold leading-normal tracking-tighter transition-colors">
6262
{siteConfig.global.name}
6363
</div>
64-
</Link>
64+
</Link>
6565
<Button size="sm" shape="square" onPress={close}>
6666
<PanelLeftCloseIcon />
6767
</Button>

0 commit comments

Comments
 (0)