Skip to content

Commit 119c727

Browse files
committed
docs: add demos for back-top, carousel, collapse, list, select, tabs, transfer
Add missing prop demos: custom BackTop trigger, carousel ref methods, collapse panel extra, list pagination, select custom rendering, tabs extra content with icons, and transfer custom renderItem.
1 parent 97a3b4d commit 119c727

14 files changed

Lines changed: 261 additions & 0 deletions

File tree

components/back-top/demo/custom.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<demo>
2+
3+
### Custom Trigger
4+
5+
Use custom children to replace the default button.
6+
7+
```jsx live
8+
() => {
9+
return (
10+
<BackTop visibilityHeight={100}>
11+
<div style={{
12+
width: 40,
13+
height: 40,
14+
borderRadius: 4,
15+
backgroundColor: '#6e41bf',
16+
color: '#fff',
17+
textAlign: 'center',
18+
lineHeight: '40px',
19+
fontSize: 14,
20+
}}>
21+
UP
22+
</div>
23+
</BackTop>
24+
);
25+
}
26+
```
27+
28+
</demo>

components/back-top/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Basic from './demo/basic.md'
2+
import Custom from './demo/custom.md'
23

34
# BackTop
45

@@ -22,6 +23,7 @@ import { BackTop } from 'tiny-ui';
2223
<Basic/>
2324
</column>
2425
<column>
26+
<Custom/>
2527
</column>
2628
</layout>
2729

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<demo>
2+
3+
### Ref Methods
4+
5+
Use `ref` to access `goTo`, `next`, and `prev` methods for programmatic control.
6+
7+
```jsx live
8+
() => {
9+
const ref = React.useRef();
10+
const style = {
11+
height: 160,
12+
display: 'flex',
13+
alignItems: 'center',
14+
justifyContent: 'center',
15+
color: '#fff',
16+
fontSize: 24,
17+
};
18+
19+
return (
20+
<div>
21+
<Space style={{ marginBottom: 16 }}>
22+
<Button onClick={() => ref.current.prev()}>Prev</Button>
23+
<Button onClick={() => ref.current.next()}>Next</Button>
24+
<Button onClick={() => ref.current.goTo(2)}>Go to Slide 3</Button>
25+
</Space>
26+
<Carousel ref={ref} dots>
27+
<div style={{ ...style, background: '#364d79' }}>Slide 1</div>
28+
<div style={{ ...style, background: '#6b8e23' }}>Slide 2</div>
29+
<div style={{ ...style, background: '#8b4513' }}>Slide 3</div>
30+
<div style={{ ...style, background: '#483d8b' }}>Slide 4</div>
31+
</Carousel>
32+
</div>
33+
);
34+
}
35+
```
36+
37+
</demo>

components/carousel/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Basic from './demo/basic.md'
22
import Arrows from './demo/arrows.md'
33
import Fade from './demo/fade.md'
4+
import Methods from './demo/methods.md'
45

56
# Carousel
67

@@ -21,6 +22,7 @@ import { Carousel } from 'tiny-ui';
2122
</column>
2223
<column>
2324
<Arrows/>
25+
<Methods/>
2426
</column>
2527
</layout>
2628

components/collapse/demo/extra.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<demo>
2+
3+
### Extra Content
4+
5+
Add extra elements in the panel header corner with the `extra` prop.
6+
7+
```jsx live
8+
() => {
9+
const { Panel } = Collapse;
10+
11+
return (
12+
<Collapse defaultActiveKey={['1']}>
13+
<Panel
14+
itemKey="1"
15+
header="Panel with action"
16+
extra={
17+
<Button
18+
size="sm"
19+
onClick={(e) => {
20+
e.stopPropagation();
21+
alert('Settings clicked');
22+
}}
23+
>
24+
Settings
25+
</Button>
26+
}
27+
>
28+
Panel content with an extra action button.
29+
</Panel>
30+
<Panel
31+
itemKey="2"
32+
header="Panel with badge"
33+
extra={<Badge count={5} />}
34+
>
35+
Panel content with a badge indicator.
36+
</Panel>
37+
<Panel
38+
itemKey="3"
39+
header="Panel with tag"
40+
extra={<Tag color="#6e41bf">New</Tag>}
41+
>
42+
Panel content with a tag.
43+
</Panel>
44+
</Collapse>
45+
);
46+
}
47+
```
48+
49+
</demo>

components/collapse/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Accordion from './demo/accordion.md'
22
import Basic from './demo/basic.md'
33
import Borderless from './demo/borderless.md'
44
import Deletable from './demo/deletable.md'
5+
import Extra from './demo/extra.md'
56
import Nested from './demo/nested.md'
67

78
# Collapse
@@ -33,6 +34,7 @@ const { Panel } = Collapse;
3334
<column>
3435
<Borderless/>
3536
<Deletable/>
37+
<Extra/>
3638
</column>
3739
</layout>
3840

components/list/demo/pagination.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<demo>
2+
3+
### Pagination
4+
5+
Use `pagination` to add a pager to the list.
6+
7+
```jsx live
8+
() => {
9+
const data = Array.from({ length: 25 }, (_, i) => `Item ${i + 1}`);
10+
11+
return (
12+
<List
13+
bordered
14+
header="Paginated List"
15+
dataSource={data}
16+
pagination={{ pageSize: 5 }}
17+
renderItem={(item) => <List.Item>{item}</List.Item>}
18+
/>
19+
);
20+
}
21+
```
22+
23+
</demo>

components/list/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Sizes from './demo/sizes.md'
33
import Actions from './demo/actions.md'
44
import Grid from './demo/grid.md'
55
import Loading from './demo/loading.md'
6+
import Pagination from './demo/pagination.md'
67
import Virtual from './demo/virtual.md'
78

89
# List
@@ -31,6 +32,7 @@ import { List } from 'tiny-ui';
3132
<Sizes/>
3233
<Loading/>
3334
<Virtual/>
35+
<Pagination/>
3436
</column>
3537
</layout>
3638

components/select/demo/render.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<demo>
2+
3+
### Custom Rendering
4+
5+
Use `optionRender` to customize dropdown items and `labelRender` to customize the selected label.
6+
7+
```jsx live
8+
() => {
9+
const options = [
10+
{ value: 'red', label: 'Red' },
11+
{ value: 'green', label: 'Green' },
12+
{ value: 'blue', label: 'Blue' },
13+
{ value: 'purple', label: 'Purple' },
14+
];
15+
16+
const colors = { red: '#f5222d', green: '#52c41a', blue: '#1890ff', purple: '#722ed1' };
17+
18+
return (
19+
<Select
20+
defaultValue="blue"
21+
style={{ width: 200 }}
22+
options={options}
23+
optionRender={(option) => (
24+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
25+
<span style={{
26+
width: 12,
27+
height: 12,
28+
borderRadius: '50%',
29+
backgroundColor: colors[option.value],
30+
display: 'inline-block',
31+
}} />
32+
{option.label}
33+
</div>
34+
)}
35+
labelRender={({ label, value }) => (
36+
<span style={{ color: colors[value] }}>{label}</span>
37+
)}
38+
/>
39+
);
40+
}
41+
```
42+
43+
</demo>

components/select/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Basic from './demo/basic.md'
22
import Search from './demo/search.md'
33
import Multiple from './demo/multiple.md'
4+
import Render from './demo/render.md'
45
import Sizes from './demo/sizes.md'
56
import Groups from './demo/groups.md'
67
import Custom from './demo/custom.md'
@@ -35,6 +36,7 @@ const { Option, OptGroup } = Select;
3536
<Sizes/>
3637
<Groups/>
3738
<Custom/>
39+
<Render/>
3840
</column>
3941
</layout>
4042

0 commit comments

Comments
 (0)