ant-design/components/descriptions/demo/style.tsx
红果汁 ecb36840bf
feat: Descriptions implement items API (#43483)
* feat: descriptions implement items api

* docs: add jsx debug demo

* refactor: add useRow hook

* Update components/descriptions/index.tsx

Co-authored-by: Wuxh <wxh1220@gmail.com>
Signed-off-by: 红果汁 <pingfj77@gmail.com>

* Update components/descriptions/index.zh-CN.md

Co-authored-by: Wuxh <wxh1220@gmail.com>
Signed-off-by: 红果汁 <pingfj77@gmail.com>

* Update components/descriptions/index.en-US.md

Co-authored-by: Wuxh <wxh1220@gmail.com>
Signed-off-by: 红果汁 <pingfj77@gmail.com>

* fix: decrease in coverage

* refactor: enhancement code

---------

Signed-off-by: 红果汁 <pingfj77@gmail.com>
Co-authored-by: Wuxh <wxh1220@gmail.com>
2023-07-17 14:48:03 +08:00

83 lines
1.9 KiB
TypeScript

import { Descriptions, Divider, Radio, Switch } from 'antd';
import type { DescriptionsProps } from 'antd/es/descriptions';
import React, { useState } from 'react';
const labelStyle: React.CSSProperties = { background: 'red' };
const contentStyle: React.CSSProperties = { background: 'green' };
type LayoutType = 'horizontal' | 'vertical' | undefined;
const items: DescriptionsProps['items'] = [
{
key: '1',
label: 'Product',
children: 'Cloud Database',
labelStyle,
contentStyle,
},
{
key: '2',
label: 'Billing Mode',
children: 'Prepaid',
},
{
key: '3',
label: 'Automatic Renewal',
children: 'YES',
},
];
const rootStyleItems: DescriptionsProps['items'] = [
{
key: '1',
label: 'Product',
children: 'Cloud Database',
},
{
key: '2',
label: 'Billing Mode',
children: 'Prepaid',
},
{
key: '3',
label: 'Automatic Renewal',
children: 'YES',
labelStyle: { color: 'orange' },
contentStyle: { color: 'blue' },
},
];
const App: React.FC = () => {
const [border, setBorder] = useState(true);
const [layout, setLayout] = useState('horizontal' as LayoutType);
return (
<>
<Switch
checkedChildren="Border"
unCheckedChildren="No Border"
checked={border}
onChange={(e) => setBorder(e)}
/>
<Divider />
<Radio.Group onChange={(e) => setLayout(e.target.value)} value={layout}>
<Radio value="horizontal">horizontal</Radio>
<Radio value="vertical">vertical</Radio>
</Radio.Group>
<Divider />
<Descriptions title="User Info" bordered={border} layout={layout} items={items} />
<Divider />
<Descriptions
title="Root style"
labelStyle={labelStyle}
contentStyle={contentStyle}
bordered={border}
layout={layout}
items={rootStyleItems}
/>
</>
);
};
export default App;