Skip to content

Commit c102f04

Browse files
authored
feat: Support prefix (#54)
* chore: support prefix * test: add test case * chore: ci
1 parent 9b000f1 commit c102f04

File tree

9 files changed

+560
-11
lines changed

9 files changed

+560
-11
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
node-version: '18'
1919

2020
- name: cache package-lock.json
21-
uses: actions/cache@v2
21+
uses: actions/cache@v3
2222
with:
2323
path: package-temp-dir
2424
key: lock-${{ github.sha }}
@@ -35,7 +35,7 @@ jobs:
3535
3636
- name: cache node_modules
3737
id: node_modules_cache_id
38-
uses: actions/cache@v2
38+
uses: actions/cache@v3
3939
with:
4040
path: node_modules
4141
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
@@ -51,13 +51,13 @@ jobs:
5151
uses: actions/checkout@master
5252

5353
- name: restore cache from package-lock.json
54-
uses: actions/cache@v2
54+
uses: actions/cache@v3
5555
with:
5656
path: package-temp-dir
5757
key: lock-${{ github.sha }}
5858

5959
- name: restore cache from node_modules
60-
uses: actions/cache@v2
60+
uses: actions/cache@v3
6161
with:
6262
path: node_modules
6363
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
@@ -74,13 +74,13 @@ jobs:
7474
uses: actions/checkout@master
7575

7676
- name: restore cache from package-lock.json
77-
uses: actions/cache@v2
77+
uses: actions/cache@v3
7878
with:
7979
path: package-temp-dir
8080
key: lock-${{ github.sha }}
8181

8282
- name: restore cache from node_modules
83-
uses: actions/cache@v2
83+
uses: actions/cache@v3
8484
with:
8585
path: node_modules
8686
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
@@ -97,13 +97,13 @@ jobs:
9797
uses: actions/checkout@master
9898

9999
- name: restore cache from package-lock.json
100-
uses: actions/cache@v2
100+
uses: actions/cache@v3
101101
with:
102102
path: package-temp-dir
103103
key: lock-${{ github.sha }}
104104

105105
- name: restore cache from node_modules
106-
uses: actions/cache@v2
106+
uses: actions/cache@v3
107107
with:
108108
path: node_modules
109109
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

docs/demo/prefix-suffix.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: prefix-suffix
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
# Prefix & Suffix Demo
9+
10+
This demo shows how to use `prefix` and `suffix` props with the Overflow component.
11+
12+
<code src="../../examples/prefix-demo.tsx"></code>

examples/basic.tsx

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function renderRest(items: ItemType[]) {
4848
const Demo = () => {
4949
const [responsive, setResponsive] = React.useState(true);
5050
const [data, setData] = React.useState(createData(1));
51+
const [showPrefix, setShowPrefix] = React.useState(true);
52+
const [showSuffix, setShowSuffix] = React.useState(true);
5153

5254
return (
5355
<div style={{ padding: 32 }}>
@@ -59,6 +61,26 @@ const Demo = () => {
5961
>
6062
{responsive ? 'Responsive' : 'MaxCount: 6'}
6163
</button>
64+
65+
<button
66+
type="button"
67+
onClick={() => {
68+
setShowPrefix(!showPrefix);
69+
}}
70+
style={{ marginLeft: 8 }}
71+
>
72+
{showPrefix ? 'Hide Prefix' : 'Show Prefix'}
73+
</button>
74+
75+
<button
76+
type="button"
77+
onClick={() => {
78+
setShowSuffix(!showSuffix);
79+
}}
80+
style={{ marginLeft: 8 }}
81+
>
82+
{showSuffix ? 'Hide Suffix' : 'Show Suffix'}
83+
</button>
6284
<select
6385
style={{ width: 200, height: 32 }}
6486
value={data.length}
@@ -98,7 +120,30 @@ const Demo = () => {
98120
renderItem={renderItem}
99121
renderRest={renderRest}
100122
maxCount={responsive ? 'responsive' : 6}
101-
// suffix={<span>1</span>}
123+
prefix={showPrefix ? (
124+
<div
125+
style={{
126+
margin: '0 8px 0 0',
127+
padding: '4px 8px',
128+
background: 'rgba(0, 255, 0, 0.3)',
129+
border: '1px solid green',
130+
}}
131+
>
132+
前缀:
133+
</div>
134+
) : undefined}
135+
suffix={showSuffix ? (
136+
<div
137+
style={{
138+
margin: '0 0 0 8px',
139+
padding: '4px 8px',
140+
background: 'rgba(0, 0, 255, 0.3)',
141+
border: '1px solid blue',
142+
}}
143+
>
144+
后缀
145+
</div>
146+
) : undefined}
102147
/>
103148
</div>
104149
</div>

0 commit comments

Comments
 (0)