diff --git a/src/Page/Title/index.tsx b/src/Page/Title/index.tsx new file mode 100644 index 0000000..ab83917 --- /dev/null +++ b/src/Page/Title/index.tsx @@ -0,0 +1,11 @@ +import React from 'react'; + +import { useStyles } from './style'; + +export interface PageTitleProps extends React.HTMLAttributes { + children: React.ReactNode; +} +export const PageTitle: React.FC = ({ className, ...otherProps }) => { + const { cx, styles } = useStyles(); + return

; +}; diff --git a/src/Page/Title/style.ts b/src/Page/Title/style.ts new file mode 100644 index 0000000..06dd22b --- /dev/null +++ b/src/Page/Title/style.ts @@ -0,0 +1,18 @@ +import { createStyles } from 'antd-style'; + +export const useStyles = createStyles( + ({ css, token }) => { + return { + root: css` + margin: 0; + + font-family: ${token.fontFamily}; + font-size: 16px; + font-weight: ${token.fontWeightStrong}; + line-height: ${token.lineHeight}; + color: ${token.colorText}; + `, + }; + }, + { hashPriority: 'low' } +); diff --git a/src/Page/demos/List.tsx b/src/Page/demos/List.tsx index a1d96c3..c4cb706 100644 --- a/src/Page/demos/List.tsx +++ b/src/Page/demos/List.tsx @@ -1,86 +1,41 @@ -import { Space, Table, Tag } from 'antd'; -import type { TableProps } from 'antd'; -import React from 'react'; +/** + * compact: true + */ -interface DataType { - key: string; - name: string; - age: number; - address: string; - tags: string[]; -} +/* eslint-disable no-console */ +import { PlusOutlined, ReloadOutlined } from '@ant-design/icons'; +import { Button, Input, Page, Space } from '@yuntijs/ui'; +import { useEffect, useState } from 'react'; -const columns: TableProps['columns'] = [ - { - title: '姓名', - dataIndex: 'name', - key: 'name', - render: text => {text}, - }, - { - title: '年龄', - dataIndex: 'age', - key: 'age', - }, - { - title: '地址', - dataIndex: 'address', - key: 'address', - }, - { - title: '标签', - key: 'tags', - dataIndex: 'tags', - render: (_, { tags }) => ( - <> - {tags.map(tag => { - let color = tag.length > 5 ? 'geekblue' : 'green'; - if (tag === 'loser') { - color = 'volcano'; - } - return ( - - {tag.toUpperCase()} - - ); - })} - - ), - }, - { - title: '操作', - key: 'action', - render: (_, record) => ( - - Invite {record.name} - Delete - - ), - }, -]; +import { Table } from './Table'; +import { useStyles } from './style'; -const data: DataType[] = [ - { - key: '1', - name: 'John Brown', - age: 32, - address: 'New York No. 1 Lake Park', - tags: ['nice', 'developer'], - }, - { - key: '2', - name: 'Jim Green', - age: 42, - address: 'London No. 1 Lake Park', - tags: ['loser'], - }, - { - key: '3', - name: 'Joe Black', - age: 32, - address: 'Sydney No. 1 Lake Park', - tags: ['cool', 'teacher'], - }, -]; +const { Title, Content } = Page; -export const List: React.FC = () => ; +const ListPageDemo = () => { + const { styles } = useStyles(); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const timeout = setTimeout(() => setLoading(false), 1500); + return () => clearTimeout(timeout); + }, []); + + return ( + + 插件 + + + + + + +
+ + + ); +}; + +export default ListPageDemo; diff --git a/src/Page/demos/Table.tsx b/src/Page/demos/Table.tsx new file mode 100644 index 0000000..42dc920 --- /dev/null +++ b/src/Page/demos/Table.tsx @@ -0,0 +1,86 @@ +import { Table as AntTable, Space, Tag } from 'antd'; +import type { TableProps } from 'antd'; +import React from 'react'; + +interface DataType { + key: string; + name: string; + age: number; + address: string; + tags: string[]; +} + +const columns: TableProps['columns'] = [ + { + title: '姓名', + dataIndex: 'name', + key: 'name', + render: text => {text}, + }, + { + title: '年龄', + dataIndex: 'age', + key: 'age', + }, + { + title: '地址', + dataIndex: 'address', + key: 'address', + }, + { + title: '标签', + key: 'tags', + dataIndex: 'tags', + render: (_, { tags }) => ( + <> + {tags.map(tag => { + let color = tag.length > 5 ? 'geekblue' : 'green'; + if (tag === 'loser') { + color = 'volcano'; + } + return ( + + {tag.toUpperCase()} + + ); + })} + + ), + }, + { + title: '操作', + key: 'action', + render: (_, record) => ( + + Invite {record.name} + Delete + + ), + }, +]; + +const data: DataType[] = [ + { + key: '1', + name: 'John Brown', + age: 32, + address: 'New York No. 1 Lake Park', + tags: ['nice', 'developer'], + }, + { + key: '2', + name: 'Jim Green', + age: 42, + address: 'London No. 1 Lake Park', + tags: ['loser'], + }, + { + key: '3', + name: 'Joe Black', + age: 32, + address: 'Sydney No. 1 Lake Park', + tags: ['cool', 'teacher'], + }, +]; + +export const Table: React.FC = () => ; diff --git a/src/Page/demos/index.tsx b/src/Page/demos/index.tsx index fd8b806..1a39618 100644 --- a/src/Page/demos/index.tsx +++ b/src/Page/demos/index.tsx @@ -13,12 +13,12 @@ import { import { Button, Input, Page, Space } from '@yuntijs/ui'; import { useEffect, useState } from 'react'; -import { List } from './List'; +import { Table } from './Table'; import { useStyles } from './style'; const { Breadcrumb, Header, Content } = Page; -const PageDemo = () => { +const DetailPageDemo = () => { const { styles } = useStyles(); const [loading, setLoading] = useState(true); @@ -89,10 +89,10 @@ const PageDemo = () => { - +
); }; -export default PageDemo; +export default DetailPageDemo; diff --git a/src/Page/index.md b/src/Page/index.md index 79ceeb2..66c7343 100644 --- a/src/Page/index.md +++ b/src/Page/index.md @@ -63,10 +63,14 @@ const IndexPage = () => { export default IndexPage; ``` -### Simple usage +### Detail page +### List page + + + ### Loading sample diff --git a/src/Page/index.ts b/src/Page/index.ts index 80ee03d..96fa037 100644 --- a/src/Page/index.ts +++ b/src/Page/index.ts @@ -3,6 +3,7 @@ import { PageContent } from './Content'; import { PageFooter } from './Footer'; import { PageHeader } from './Header'; import { Page as InternalPage } from './Page'; +import { PageTitle } from './Title'; export type { PageBreadcrumbProps } from './Breadcrumb'; export type { PageContentProps } from './Content'; @@ -11,14 +12,17 @@ export { HeaderButtonGroup } from './Header/ButtonGroup'; export type { PageHeaderProps } from './Header'; export type { HeaderButtonGroupProps } from './Header/ButtonGroup'; export type { PageProps } from './Page'; +export type { PageTitleProps } from './Title'; export const Page = InternalPage as typeof InternalPage & { Breadcrumb: typeof PageBreadcrumb; + Title: typeof PageTitle; Header: typeof PageHeader; Content: typeof PageContent; Footer: typeof PageFooter; }; Page.Breadcrumb = PageBreadcrumb; +Page.Title = PageTitle; Page.Header = PageHeader; Page.Content = PageContent; Page.Footer = PageFooter;