Skip to content

Commit fb45ee1

Browse files
Hufe921claude
andcommitted
feat: add year and month picker for date control #1256
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1d403ea commit fb45ee1

5 files changed

Lines changed: 474 additions & 37 deletions

File tree

src/editor/assets/css/date/datePicker.css

Lines changed: 129 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
display: block;
2828
}
2929

30+
.ce-date-wrap.year-mode .ce-date-week,
31+
.ce-date-wrap.year-mode .ce-date-day,
32+
.ce-date-wrap.month-mode .ce-date-week,
33+
.ce-date-wrap.month-mode .ce-date-day {
34+
display: none;
35+
}
36+
3037
.ce-date-title {
3138
display: flex;
3239
justify-content: center;
@@ -36,17 +43,17 @@
3643
font-size: 16px;
3744
}
3845

39-
.ce-date-title>span {
46+
.ce-date-title > span {
4047
display: inline-block;
4148
}
4249

43-
.ce-date-title>span:not(.ce-date-title__now) {
50+
.ce-date-title > span:not(.ce-date-title__now) {
4451
font-family: cursive;
4552
cursor: pointer;
4653
}
4754

48-
.ce-date-title>span:not(.ce-date-title__now):hover {
49-
color: #5175F4;
55+
.ce-date-title > span:not(.ce-date-title__now):hover {
56+
color: #5175f4;
5057
}
5158

5259
.ce-date-title .ce-date-title__pre-year {
@@ -61,6 +68,17 @@
6168
width: 40%;
6269
}
6370

71+
.ce-date-title .ce-date-title__year-label,
72+
.ce-date-title .ce-date-title__month-label {
73+
cursor: pointer;
74+
white-space: nowrap;
75+
}
76+
77+
.ce-date-title .ce-date-title__year-label:hover,
78+
.ce-date-title .ce-date-title__month-label:hover {
79+
color: #5175f4;
80+
}
81+
6482
.ce-date-title .ce-date-title__next-year {
6583
width: 15%;
6684
}
@@ -78,9 +96,9 @@
7896
border-bottom: 1px solid #e4e7ed;
7997
}
8098

81-
.ce-date-week>span {
99+
.ce-date-week > span {
82100
list-style: none;
83-
width: calc(100%/7);
101+
width: calc(100% / 7);
84102
text-align: center;
85103
color: #606266;
86104
font-size: 14px;
@@ -94,8 +112,8 @@
94112
margin-top: 5px;
95113
}
96114

97-
.ce-date-day>div {
98-
width: calc(100%/7);
115+
.ce-date-day > div {
116+
width: calc(100% / 7);
99117
height: 40px;
100118
text-align: center;
101119
color: #606266;
@@ -105,23 +123,103 @@
105123
border-radius: 4px;
106124
}
107125

108-
.ce-date-day>div:hover {
109-
color: #5175F4;
110-
opacity: .8;
126+
.ce-date-day > div:hover {
127+
color: #5175f4;
128+
opacity: 0.8;
111129
}
112130

113-
.ce-date-day>div.active {
114-
color: #5175F4;
131+
.ce-date-day > div.active {
132+
color: #5175f4;
115133
font-weight: 700;
116134
}
117135

118-
.ce-date-day>div.disable {
136+
.ce-date-day > div.disable {
119137
color: #c0c4cc;
120138
}
121139

122-
.ce-date-day>div.select {
140+
.ce-date-day > div.select {
141+
color: #fff;
142+
background-color: #5175f4;
143+
}
144+
145+
/* year picker */
146+
.ce-year-wrap {
147+
display: none;
148+
width: 100%;
149+
flex-wrap: wrap;
150+
align-items: center;
151+
margin-top: 15px;
152+
min-height: 280px;
153+
}
154+
155+
.ce-year-wrap.active {
156+
display: flex;
157+
}
158+
159+
.ce-year-wrap > div {
160+
width: calc(100% / 3);
161+
height: 60px;
162+
text-align: center;
163+
color: #606266;
164+
font-size: 14px;
165+
cursor: pointer;
166+
line-height: 60px;
167+
border-radius: 4px;
168+
}
169+
170+
.ce-year-wrap > div:hover {
171+
color: #5175f4;
172+
opacity: 0.8;
173+
}
174+
175+
.ce-year-wrap > div.active {
176+
color: #5175f4;
177+
font-weight: 700;
178+
}
179+
180+
.ce-year-wrap > div.select {
181+
color: #fff;
182+
background-color: #5175f4;
183+
}
184+
185+
/* month picker */
186+
.ce-month-wrap {
187+
display: none;
188+
width: 100%;
189+
flex-wrap: wrap;
190+
align-items: center;
191+
margin-top: 15px;
192+
min-height: 280px;
193+
}
194+
195+
.ce-month-wrap.active {
196+
display: flex;
197+
}
198+
199+
.ce-month-wrap > div {
200+
width: calc(100% / 3);
201+
height: 60px;
202+
text-align: center;
203+
color: #606266;
204+
font-size: 14px;
205+
cursor: pointer;
206+
line-height: 60px;
207+
border-radius: 4px;
208+
}
209+
210+
.ce-month-wrap > div:hover {
211+
color: #5175f4;
212+
opacity: 0.8;
213+
}
214+
215+
.ce-month-wrap > div.active {
216+
color: #5175f4;
217+
font-weight: 700;
218+
}
219+
220+
.ce-month-wrap > div.select {
123221
color: #fff;
124-
background-color: #5175F4;
222+
background-color: #5175f4;
125223
}
126224

127225
.ce-time-wrap {
@@ -142,45 +240,45 @@
142240
list-style: none;
143241
}
144242

145-
.ce-time-wrap>li {
243+
.ce-time-wrap > li {
146244
width: 33.3%;
147245
height: 100%;
148246
text-align: center;
149247
}
150248

151-
.ce-time-wrap>li>span {
249+
.ce-time-wrap > li > span {
152250
transform: translateY(-5px);
153251
display: inline-block;
154252
}
155253

156-
.ce-time-wrap>li>ol {
254+
.ce-time-wrap > li > ol {
157255
height: calc(100% - 20px);
158256
overflow-y: auto;
159257
border: 1px solid #e2e2e2;
160258
position: relative;
161259
}
162260

163-
.ce-time-wrap>li:first-child>ol {
261+
.ce-time-wrap > li:first-child > ol {
164262
border-right: 0;
165263
}
166264

167-
.ce-time-wrap>li:last-child>ol {
265+
.ce-time-wrap > li:last-child > ol {
168266
border-left: 0;
169267
}
170268

171-
.ce-time-wrap>li>ol>li {
269+
.ce-time-wrap > li > ol > li {
172270
line-height: 30px;
173271
cursor: pointer;
174-
transition: all .3s;
272+
transition: all 0.3s;
175273
}
176274

177-
.ce-time-wrap>li>ol>li:hover {
275+
.ce-time-wrap > li > ol > li:hover {
178276
background-color: #eaeaea;
179277
}
180278

181-
.ce-time-wrap>li>ol>li.active {
279+
.ce-time-wrap > li > ol > li.active {
182280
color: #ffffff;
183-
background: #5175F4;
281+
background: #5175f4;
184282
}
185283

186284
.ce-date-menu {
@@ -207,7 +305,7 @@
207305
box-sizing: border-box;
208306
outline: none;
209307
margin: 0;
210-
transition: .1s;
308+
transition: 0.1s;
211309
font-weight: 500;
212310
user-select: none;
213311
padding: 7px 15px;
@@ -217,8 +315,8 @@
217315
}
218316

219317
.ce-date-menu button:hover {
220-
color: #5175F4;
221-
border-color: #5175F4;
318+
color: #5175f4;
319+
border-color: #5175f4;
222320
}
223321

224322
.ce-date-menu button.ce-date-menu__time {
@@ -229,5 +327,5 @@
229327
}
230328

231329
.ce-date-menu button.ce-date-menu__time:hover {
232-
color: #5175F4;
233-
}
330+
color: #5175f4;
331+
}

0 commit comments

Comments
 (0)