Skip to content

Commit 7b0c37c

Browse files
committed
Merge branch 'main' into fix-layout
2 parents dd0b402 + f94d4d6 commit 7b0c37c

File tree

7 files changed

+45
-16
lines changed

7 files changed

+45
-16
lines changed

apps/landing/src/app/(detail)/components/button/demo/Colors.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Box, css, Flex } from '@devup-ui/react'
55
* **Colors**
66
* Pass in an object containing color tokens into `colors` prop. You can change color of border, background, danger color and more using `primary`, `error`, `text`, and so on.
77
*/
8-
export function Colors() {
8+
export default function Colors() {
99
return (
1010
<Box w="100%">
1111
<Flex flexWrap="wrap" gap="12px" mb="16px">

apps/landing/src/app/(detail)/components/button/demo/Danger.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Box, css } from '@devup-ui/react'
55
* **Danger**
66
* Use `danger` prop to signal caution.
77
*/
8-
export function Danger() {
8+
export default function Danger() {
99
return (
1010
<Box w="100%">
1111
<Box display="flex" flexWrap="wrap" gap="12px" marginBottom="16px">

apps/landing/src/app/(detail)/components/button/demo/Disabled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Box, css, Flex } from '@devup-ui/react'
55
* **Disabled**
66
* Use `disabled` prop to show disabled UI of the button.
77
*/
8-
export function Disabled() {
8+
export default function Disabled() {
99
return (
1010
<Box w="100%">
1111
<Flex flexWrap="wrap" gap="12px" mb="16px">

apps/landing/src/app/(detail)/components/button/demo/Icon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import IconDelete from '../IconDelete'
77
* **Icon**
88
* Pass in an svg icon component into `icon` prop. If props like `stroke` and `fill` have `"currentColor"` value, the svg icon will follow the text color of the button.
99
*/
10-
export function Icon() {
10+
export default function Icon() {
1111
return (
1212
<Box w="100%">
1313
<Flex flexWrap="wrap" gap="12px" mb="16px">

apps/landing/src/app/(detail)/components/button/demo/Variants.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { css, Flex } from '@devup-ui/react'
55
* **Variant & Size**
66
* `Button` components has `default` and `primary` variants. `Size` prop determines the paddings of the button.
77
*/
8-
export function Variants() {
8+
export default function Variants() {
99
return (
1010
<>
1111
<Flex flexWrap="wrap" gap="12px" mb="16px">

apps/landing/src/app/(detail)/components/button/page.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ import { CustomH6 } from '@/components/mdx/components/CustomH6'
77
import { CustomParagraph } from '@/components/mdx/components/CustomParagraph'
88
import { CustomPre } from '@/components/mdx/components/CustomPre'
99
import { CustomStrong } from '@/components/mdx/components/CustomStrong'
10+
import { getDemos } from '@/utils/get-demos'
1011

1112
import MdxCard from '../MdxCard'
1213
import Api from './Api.mdx'
1314
import Button from './Button.mdx'
14-
import { Colors } from './demo/Colors'
15-
import { Danger } from './demo/Danger'
16-
import { Disabled } from './demo/Disabled'
17-
import { Icon } from './demo/Icon'
18-
import { Variants } from './demo/Variants'
1915

2016
export const metadata: Metadata = {
2117
title: 'Devup UI - Button',
@@ -32,7 +28,10 @@ export const metadata: Metadata = {
3228
},
3329
}
3430

35-
export default function Page() {
31+
export default async function Page() {
32+
const c = await getDemos(__dirname.split(/[\\/]/).pop()!)
33+
const m = Math.ceil(c.length / 2)
34+
3635
return (
3736
<VStack gap="16px" maxW="100%" overflow="hidden">
3837
<Button
@@ -50,13 +49,14 @@ export default function Page() {
5049
</Text>
5150
<Flex flexWrap="wrap" gap="16px">
5251
<Box flex="1" minW="300px" w="calc(50% - 8px)">
53-
<MdxCard demo={<Variants />} src="button/demo/Variants.tsx" />
54-
<MdxCard demo={<Danger />} src="button/demo/Danger.tsx" />
55-
<MdxCard demo={<Disabled />} src="button/demo/Disabled.tsx" />
52+
{c.slice(0, m).map(([Demo, src]) => (
53+
<MdxCard key={src} demo={<Demo />} src={src} />
54+
))}
5655
</Box>
5756
<Box flex="1" minW="300px" w="calc(50% - 8px)">
58-
<MdxCard demo={<Icon />} src="button/demo/Icon.tsx" />
59-
<MdxCard demo={<Colors />} src="button/demo/Colors.tsx" />
57+
{c.slice(m).map(([Demo, src]) => (
58+
<MdxCard key={src} demo={<Demo />} src={src} />
59+
))}
6060
</Box>
6161
</Flex>
6262
</VStack>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { readdir } from 'node:fs/promises'
2+
import { join, relative } from 'node:path'
3+
4+
export async function getDemos(
5+
dir: string,
6+
): Promise<[React.ComponentType, string][]> {
7+
const dirPath = join(
8+
process.cwd(),
9+
'src',
10+
'app',
11+
'(detail)',
12+
'components',
13+
dir,
14+
'demo',
15+
)
16+
const demos = await readdir(dirPath)
17+
18+
return Promise.all(
19+
demos.map<Promise<[React.ComponentType, string]>>((item) =>
20+
import(
21+
'./../' +
22+
relative(process.cwd(), `${dirPath}/${item}`)
23+
.replace('.tsx', '')
24+
.replaceAll('\\', '/')
25+
.slice(4)
26+
).then((m) => [m.default, `${dir}/demo/${item}`]),
27+
),
28+
)
29+
}

0 commit comments

Comments
 (0)