Skip to content

Commit 94a2148

Browse files
committed
docs: Add blink case
1 parent 4aa2b89 commit 94a2148

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

examples/blink.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react';
2+
import Overflow from '../src';
3+
import '../assets/index.less';
4+
import './common.less';
5+
6+
interface ItemType {
7+
value: string | number;
8+
label: string;
9+
}
10+
11+
function createData(count: number): ItemType[] {
12+
const data: ItemType[] = new Array(count).fill(undefined).map((_, index) => ({
13+
value: index,
14+
label: `Label ${index}`,
15+
}));
16+
17+
return data;
18+
}
19+
20+
const sharedStyle: React.CSSProperties = {
21+
padding: '4px 8px',
22+
width: 90,
23+
overflow: 'hidden',
24+
background: 'rgba(255, 0, 0, 0.2)',
25+
};
26+
27+
function renderItem(item: ItemType) {
28+
return <div style={sharedStyle}>{item.label}</div>;
29+
}
30+
31+
function renderRest(items: ItemType[]) {
32+
if (items.length === 3) {
33+
return items.length;
34+
}
35+
36+
return <div style={sharedStyle}>+{items.length}...</div>;
37+
}
38+
39+
const data = createData(5);
40+
41+
const Demo = () => {
42+
return (
43+
<div style={{ padding: 32 }}>
44+
<div
45+
style={{
46+
boxShadow: '0 0 1px green',
47+
maxWidth: 300,
48+
marginTop: 32,
49+
}}
50+
>
51+
<Overflow<ItemType>
52+
data={data}
53+
renderItem={renderItem}
54+
renderRest={renderRest}
55+
maxCount="responsive"
56+
/>
57+
</div>
58+
</div>
59+
);
60+
};
61+
62+
export default Demo;

0 commit comments

Comments
 (0)