Skip to content

Commit a7641ad

Browse files
authored
Merge pull request #9 from react-component/new-range
New range
2 parents 8d4d62d + dcabc7b commit a7641ad

25 files changed

+1374
-616
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
'react/sort-comp': 0,
1111
'@typescript-eslint/no-explicit-any': 0,
1212
'default-case': 0,
13+
'no-confusing-arrow': 0,
1314
'jsx-a11y/no-autofocus': 0,
1415
'import/no-extraneous-dependencies': [
1516
'error',

assets/index.less

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
@prefix-cls: rc-picker;
22

3+
@background-color: rgb(255, 240, 255);
4+
35
.@{prefix-cls} {
46
display: inline-flex;
57

68
&-panel {
79
border: 1px solid #666;
8-
background: rgb(255, 240, 255);
10+
background: @background-color;
911
display: inline-block;
1012
vertical-align: top;
1113

@@ -33,6 +35,7 @@
3335

3436
table {
3537
text-align: center;
38+
border-collapse: collapse;
3639
}
3740
}
3841

@@ -91,9 +94,36 @@
9194
&-in-range > &-inner {
9295
background: fade(blue, 5%);
9396
}
97+
&-range-hover-start,
98+
&-range-hover-end,
99+
&-range-hover {
100+
position: relative;
101+
&::after {
102+
content: '';
103+
position: absolute;
104+
top: 3px;
105+
bottom: 0;
106+
left: 0;
107+
right: 0;
108+
border: 1px solid green;
109+
border-left: 0;
110+
border-right: 0;
111+
pointer-events: none;
112+
}
113+
}
114+
115+
&-range-hover-start::after {
116+
border-left: 1px solid green!important;
117+
}
118+
&-range-hover-end::after {
119+
border-right: 1px solid green!important;
120+
}
121+
94122
&-today > &-inner {
95123
border: 1px solid blue;
96124
}
125+
&-range-start > &-inner,
126+
&-range-end > &-inner,
97127
&-selected > &-inner {
98128
background: fade(blue, 20%);
99129
}
@@ -179,6 +209,7 @@
179209
> li {
180210
padding: 0;
181211
margin: 0;
212+
cursor: pointer;
182213

183214
.@{prefix-cls}-time-panel-cell-inner {
184215
color: #333;
@@ -245,17 +276,58 @@
245276
// ======================= Dropdown =======================
246277
&-dropdown {
247278
position: absolute;
248-
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
279+
box-shadow: 0 0 1px red;
249280

250281
&-hidden {
251282
display: none;
252283
}
284+
285+
// Panel
286+
@arrow-size: 10px;
287+
.@{prefix-cls}-range-arrow {
288+
position: absolute;
289+
width: @arrow-size;
290+
height: @arrow-size;
291+
z-index: 1;
292+
transform: rotate(-45deg);
293+
top: @arrow-size / 2 + 1px;
294+
left: @arrow-size;
295+
296+
&::before,
297+
&::after {
298+
content: '';
299+
position: absolute;
300+
box-sizing: border-box;
301+
top: 50%;
302+
left: 50%;
303+
transform: translate(-50%, -50%);
304+
}
305+
306+
&::before {
307+
width: @arrow-size;
308+
height: @arrow-size;
309+
border: @arrow-size / 2 solid blue;
310+
border-color: blue blue transparent transparent;
311+
}
312+
&::after {
313+
width: @arrow-size - 2px;
314+
height: @arrow-size - 2px;
315+
border: (@arrow-size - 2px) / 2 solid blue;
316+
border-color: @background-color @background-color transparent
317+
transparent;
318+
}
319+
}
320+
321+
.@{prefix-cls}-panel {
322+
margin: 10px 0;
323+
}
253324
}
254325

255326
// ========================================================
256327
// = Range Picker =
257328
// ========================================================
258329
&-range {
259330
display: inline-flex;
331+
position: relative;
260332
}
261333
}

examples/common.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
h1,
2+
h2,
3+
h3,
4+
h4 {
5+
margin: 0;
6+
line-height: 200%;
7+
}

examples/range.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import RangePicker from '../src/RangePicker';
44
import momentGenerateConfig from '../src/generate/moment';
55
import zhCN from '../src/locale/zh_CN';
66
import '../assets/index.less';
7+
import './common.less';
78

89
const defaultStartValue = moment('2019-09-03 05:02:03');
910
const defaultEndValue = moment('2019-11-28 01:02:03');
@@ -43,19 +44,38 @@ export default () => {
4344

4445
return (
4546
<div>
46-
<h1>
47+
<h2>
4748
Value:{' '}
4849
{value ? `${formatDate(value[0])} ~ ${formatDate(value[1])}` : 'null'}
49-
</h1>
50+
</h2>
5051

5152
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
53+
<div style={{ margin: '0 8px' }}>
54+
<h3>Basic</h3>
55+
<RangePicker<Moment>
56+
{...sharedProps}
57+
value={undefined}
58+
locale={zhCN}
59+
allowClear
60+
ref={rangePickerRef}
61+
/>
62+
<RangePicker<Moment>
63+
{...sharedProps}
64+
locale={zhCN}
65+
allowClear
66+
ref={rangePickerRef}
67+
showTime
68+
/>
69+
</div>
70+
5271
<div style={{ margin: '0 8px' }}>
5372
<h3>Basic</h3>
5473
<RangePicker<Moment>
5574
{...sharedProps}
5675
locale={zhCN}
5776
allowClear
5877
ref={rangePickerRef}
78+
// style={{ width: 500 }}
5979
/>
6080
<button
6181
type="button"
@@ -78,7 +98,25 @@ export default () => {
7898
locale={zhCN}
7999
allowClear
80100
allowEmpty={[true, true]}
81-
selectable={[true, false]}
101+
/>
102+
</div>
103+
104+
<div style={{ margin: '0 8px' }}>
105+
<h3>Start disabled</h3>
106+
<RangePicker<Moment>
107+
{...sharedProps}
108+
locale={zhCN}
109+
allowClear
110+
disabled={[true, false]}
111+
/>
112+
</div>
113+
<div style={{ margin: '0 8px' }}>
114+
<h3>End disabled</h3>
115+
<RangePicker<Moment>
116+
{...sharedProps}
117+
locale={zhCN}
118+
allowClear
119+
disabled={[false, true]}
82120
/>
83121
</div>
84122

src/PanelContext.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export interface PanelContextProps {
1010
/** Only work with time panel */
1111
hideHeader?: boolean;
1212
panelRef?: React.Ref<HTMLDivElement>;
13+
hidePrevBtn?: boolean;
14+
hideNextBtn?: boolean;
15+
onDateMouseEnter?: (date: any) => void;
16+
onDateMouseLeave?: (date: any) => void;
1317
}
1418

1519
const PanelContext = React.createContext<PanelContextProps>({});

0 commit comments

Comments
 (0)