Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed Mar 29, 2023
1 parent c5c24a8 commit 5a0833b
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 92 deletions.
8 changes: 0 additions & 8 deletions docs/demo/fragment.md

This file was deleted.

77 changes: 50 additions & 27 deletions docs/examples/custom-icon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Collapse, { Panel } from 'rc-collapse';
import Collapse from 'rc-collapse';
import * as React from 'react';
import '../../assets/index.less';
import type { ItemType } from '../../src/interface';
import motion from './_util/motionUtil';

const initLength = 3;
Expand Down Expand Up @@ -48,31 +49,54 @@ const App: React.FC = () => {

const time = random();

const panelItems = Array.from<object, React.ReactNode>({ length: initLength }, (_, i) => {
const panelItems = Array.from<object, ItemType>({ length: initLength }, (_, i) => {
const key = i + 1;
return (
<Panel header={`This is panel header ${key}`} key={key}>
<p>{text.repeat(time)}</p>
</Panel>
);
return {
key,
header: `This is panel header ${key}`,
children: <p>{text.repeat(time)}</p>,
};
}).concat(
<Panel header={`This is panel header ${initLength + 1}`} key={initLength + 1}>
<Collapse defaultActiveKey="1" expandIcon={expandIcon}>
<Panel header="This is panel nest panel" key="1" id="header-test">
<p>{text}</p>
</Panel>
</Collapse>
</Panel>,
<Panel header={`This is panel header ${initLength + 2}`} key={initLength + 2}>
<Collapse defaultActiveKey="1">
<Panel header="This is panel nest panel" key="1" id="another-test">
<form>
<label htmlFor="test">Name:&nbsp;</label>
<input type="text" id="test" />
</form>
</Panel>
</Collapse>
</Panel>,
{
key: initLength + 1,
header: `This is panel header ${initLength + 1}`,
children: (
<Collapse
defaultActiveKey="1"
expandIcon={expandIcon}
items={[
{
key: '1',
header: 'This is panel nest panel',
id: 'header-test',
children: <p>{text}</p>,
},
]}
/>
),
},
{
key: initLength + 2,
header: `This is panel header ${initLength + 2}`,
children: (
<Collapse
defaultActiveKey="1"
items={[
{
key: '1',
header: 'This is panel nest panel',
id: 'another-test',
children: (
<form>
<label htmlFor="test">Name:&nbsp;</label>
<input type="text" id="test" />
</form>
),
},
]}
/>
),
},
);

const tools = (
Expand Down Expand Up @@ -104,9 +128,8 @@ const App: React.FC = () => {
activeKey={activeKey}
expandIcon={expandIcon}
openMotion={motion}
>
{panelItems}
</Collapse>
items={panelItems}
/>
</>
);
};
Expand Down
23 changes: 0 additions & 23 deletions docs/examples/fragment.tsx

This file was deleted.

90 changes: 56 additions & 34 deletions docs/examples/simple.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { CollapseProps } from 'rc-collapse';
import Collapse, { Panel } from 'rc-collapse';
import Collapse from 'rc-collapse';
import * as React from 'react';
import '../../assets/index.less';
import type { ItemType } from '../../src/interface';
import motion from './_util/motionUtil';

const initLength = 3;
Expand Down Expand Up @@ -50,38 +51,60 @@ const App: React.FC = () => {

const time = random();

const panelItems = Array.from<object, React.ReactNode>({ length: initLength }, (_, i) => {
const panelItems = Array.from<object, ItemType>({ length: initLength }, (_, i) => {
const key = i + 1;
return (
<Panel header={`This is panel header ${key}`} key={key}>
<p>{text.repeat(time)}</p>
</Panel>
);
return {
key,
header: `This is panel header ${key}`,
children: <p>{text.repeat(time)}</p>,
};
}).concat(
<Panel header={`This is panel header ${initLength + 1}`} key={initLength + 1}>
<Collapse defaultActiveKey="1" expandIcon={expandIcon}>
<Panel header="This is panel nest panel" key="1" id="header-test">
<p>{text}</p>
</Panel>
</Collapse>
</Panel>,
<Panel header={`This is panel header ${initLength + 2}`} key={initLength + 2}>
<Collapse defaultActiveKey="1">
<Panel header="This is panel nest panel" key="1" id="another-test">
<form>
<label htmlFor="test">Name:&nbsp;</label>
<input type="text" id="test" />
</form>
</Panel>
</Collapse>
</Panel>,
<Panel
header={`This is panel header ${initLength + 3}`}
key={initLength + 3}
extra={<span>Extra Node</span>}
>
<p>Panel with extra</p>
</Panel>,
{
key: initLength + 1,
header: `This is panel header ${initLength + 1}`,
children: (
<Collapse
defaultActiveKey="1"
expandIcon={expandIcon}
items={[
{
key: '1',
header: 'This is panel nest panel',
id: 'header-test',
children: <p>{text}</p>,
},
]}
/>
),
},
{
key: initLength + 2,
header: `This is panel header ${initLength + 2}`,
children: (
<Collapse
defaultActiveKey="1"
items={[
{
key: '1',
header: 'This is panel nest panel',
id: 'another-test',
children: (
<form>
<label htmlFor="test">Name:&nbsp;</label>
<input type="text" id="test" />
</form>
),
},
]}
/>
),
},
{
key: initLength + 3,
header: `This is panel header ${initLength + 3}`,
extra: <span>Extra Node</span>,
children: <p>Panel with extra</p>,
},
);

const handleCollapsibleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
Expand Down Expand Up @@ -129,9 +152,8 @@ const App: React.FC = () => {
expandIcon={expandIcon}
openMotion={motion}
collapsible={collapsible}
>
{panelItems}
</Collapse>
items={panelItems}
/>
</>
);
};
Expand Down

0 comments on commit 5a0833b

Please sign in to comment.