Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions apps/landing/src/app/(detail)/components/[component]/button/Api.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
import { PropsTable } from '@/components/PropsTable'

###### API

`Button` props extends the button HTML attributes.

<div style={{ width: '100%', overflow: 'auto'}}>
| Property | Description | Type | Default |
| --- | --- | --- | --- |
| **variant** | The variant of the button | `'primary' \| 'default'` | `'default'` |
| **colors** | The color variables of the button, i.e. `var(--primary)` | ```{<br> primary?: string<br> error?: string<br> text?: string<br> border?: string<br> inputBackground?: string<br> primaryFocus?: string<br>}``` | `undefined` |
| **danger** | Signals that it should be used with caution. It is often used in a delete button or to show the error status. | `boolean` | `false` |
| **size** | The size of the button | `'sm' \| 'md' \| 'lg'` | `'md'` |
| **icon** | Icon of the button passed in as a form of ReactNode | `React.ReactNode` | `undefined` |
| **ellipsis** | Whether the button text should be truncated with an ellipsis. The button should have a width to be able to truncate the text. | `boolean` | `false` |
</div>
<PropsTable
componentProps={[
{
property: 'variant',
description: 'The variant of the button',
type: "`'primary' | 'default'`",
default: "`'default'`",
},
{
property: 'colors',
description: 'The color variables of the button, i.e. `var(--primary)`',
type: '```{<br> primary?: string<br> error?: string<br> text?: string<br> border?: string<br> inputBackground?: string<br> primaryFocus?: string<br>}```',
default: '`undefined`',
},
{
property: 'danger',
description:
'Signals that it should be used with caution. It is often used in a delete button or to show the error status.',
type: '`boolean`',
default: '`false`',
},
{
property: 'size',
description: 'The size of the button',
type: "`'sm' | 'md' | 'lg'`",
default: "`'md'`",
},
{
property: 'icon',
description: 'Icon of the button passed in as a form of ReactNode',
type: '`React.ReactNode`',
default: '`undefined`',
},
{
property: 'ellipsis',
description:
'Whether the button text should be truncated with an ellipsis. The button should have a width to be able to truncate the text.',
type: '`boolean`',
default: '`false`',
},
]}
/>
2 changes: 2 additions & 0 deletions apps/landing/src/app/(detail)/components/[component]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CustomH6 } from '@/components/mdx/components/CustomH6'
import { CustomParagraph } from '@/components/mdx/components/CustomParagraph'
import { CustomPre } from '@/components/mdx/components/CustomPre'
import { CustomStrong } from '@/components/mdx/components/CustomStrong'
import { PropsTable } from '@/components/PropsTable'
import { COMPONENT_GROUPS } from '@/constants'
import { getDemos } from '@/utils/get-demos'

Expand Down Expand Up @@ -102,6 +103,7 @@ export default async function Page({
h6: CustomH6,
pre: CustomPre,
p: CustomParagraph,
PropsTable,
}}
/>
</VStack>
Expand Down
18 changes: 1 addition & 17 deletions apps/landing/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ export const metadata: Metadata = {
resetCss()

globalCss({
table: {
borderCollapse: 'collapse',
borderSpacing: 0,
border: '1px solid var(--text)',
color: 'var(--text, #2F2F2F)',
fontFamily: 'Pretendard',
fontSize: '16px',
fontStyle: 'normal',
fontWeight: 400,
lineHeight: '150%',
letterSpacing: '-0.48px',
},
code: {
fontFamily: 'D2Coding',
fontSize: ['13px', '15px'],
Expand All @@ -47,10 +35,6 @@ globalCss({
lineHeight: '1.5',
letterSpacing: '-0.03em',
},
'th, td': {
border: '1px solid var(--text)',
padding: '6px 13px',
},
pre: {
borderRadius: '10px',
},
Expand Down Expand Up @@ -117,7 +101,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
width="0"
/>
</noscript>
<ReactLenis options={{ duration: 1.4 }} root>
<ReactLenis options={{ duration: 1.4, allowNestedScroll: true }} root>
<SearchModal />
<Box bg="$background">
<Header />
Expand Down
90 changes: 90 additions & 0 deletions apps/landing/src/components/PropsTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Text, VStack } from '@devup-ui/react'
import Markdown from 'react-markdown'

import { _components } from '@/mdx-components'

import { CustomCodeBlock } from './mdx/components/CustomCodeBlock'
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeaderCell,
TableRow,
} from './mdx/components/Table'

interface ComponentProp {
property: string
description?: string
type?: string
default?: string
}

const MdxComponentsWithCodeBlock = ({ children }: { children?: string }) => {
return (
<Markdown
components={{
...(_components as any),
code: CustomCodeBlock,
}}
>
{children}
</Markdown>
)
}

interface PropTableProps {
componentProps: ComponentProp[]
}

export const PropsTable = async (props: PropTableProps) => {
const { componentProps } = props

return (
<Table border={0}>
<TableHead>
<TableRow>
<TableHeaderCell>Prop</TableHeaderCell>
<TableHeaderCell>description</TableHeaderCell>
<TableHeaderCell>Type</TableHeaderCell>
<TableHeaderCell>Default</TableHeaderCell>
</TableRow>
</TableHead>
<TableBody>
{componentProps.length === 0 && (
<TableRow>
<TableCell colSpan={3}>
<Text>No props to display</Text>
</TableCell>
</TableRow>
)}
{componentProps.map(
({ property, description, type, default: defaultValue }) => (
<TableRow key={property}>
<TableCell>
<Text typography="bodyBold">{property}</Text>
</TableCell>
<TableCell>
<MdxComponentsWithCodeBlock>
{description}
</MdxComponentsWithCodeBlock>
</TableCell>
<TableCell>
<VStack>
<MdxComponentsWithCodeBlock>
{type?.replaceAll('"', "'")}
</MdxComponentsWithCodeBlock>
</VStack>
</TableCell>
<TableCell>
<MdxComponentsWithCodeBlock>
{defaultValue}
</MdxComponentsWithCodeBlock>
</TableCell>
</TableRow>
),
)}
</TableBody>
</Table>
)
}
21 changes: 21 additions & 0 deletions apps/landing/src/components/mdx/components/CustomCodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Box, Text } from '@devup-ui/react'

export function CustomCodeBlock({ children }: { children: string }) {
return (
<Box
as="code"
bg="$containerBackground"
borderRadius="0.25rem"
color="$text"
padding="0.25rem"
whiteSpace="pre-wrap"
>
{children.split('<br>').map((line, index) => (
<Text key={index.toString()} whiteSpace="pre">
{index > 0 && <br />}
{line}
</Text>
))}
</Box>
)
}
51 changes: 51 additions & 0 deletions apps/landing/src/components/mdx/components/Table/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Box } from '@devup-ui/react'
import { type ComponentProps } from 'react'

export const Table = ({ ...props }: ComponentProps<'table'>) => {
return (
<Box borderRadius="0.5rem" overflow="hidden">
<Box {...props} as="table" borderCollapse="collapse" borderSpacing={0} />
</Box>
)
}

export const TableBody = ({ ...props }: ComponentProps<'tbody'>) => {
return <Box {...props} as="tbody" />
}

export const TableCell = ({ ...props }: ComponentProps<'th'>) => {
return <Box {...props} as="td" padding="0.5rem 1rem" />
}

export const TableHead = ({ ...props }: ComponentProps<'thead'>) => {
return (
<Box
{...props}
as="thead"
selectors={{
'& tr': {
bg: '$cardBg',
},
}}
/>
)
}

export const TableHeaderCell = ({ ...props }: ComponentProps<'th'>) => {
return <Box {...props} as="th" padding="0.5rem 1rem" textAlign="left" />
}

export const TableRow = ({ ...props }: ComponentProps<'tr'>) => {
return (
<Box
{...props}
as="tr"
borderBottom="1px solid var(--border, #E4E4E4)"
selectors={{
'& + &:last-of-type': {
borderBottom: 'none',
},
}}
/>
)
}