Skip to content

Commit fe323df

Browse files
committed
refactor: decade separator can replace by css
1 parent 6f70ffb commit fe323df

File tree

3 files changed

+49
-36
lines changed

3 files changed

+49
-36
lines changed

__test__/__snapshots__/calendar-panel.test.js.snap

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,51 @@ exports[`CalendarPanel prop: type=date 1`] = `
1414
class="mx-icon-double-left"
1515
/>
1616
</button>
17-
17+
1818
<button
1919
class="mx-btn mx-btn-text mx-btn-icon-left"
2020
>
2121
<i
2222
class="mx-icon-left"
2323
/>
2424
</button>
25-
25+
2626
<button
2727
class="mx-btn mx-btn-text mx-btn-icon-double-right"
2828
>
2929
<i
3030
class="mx-icon-double-right"
3131
/>
3232
</button>
33-
33+
3434
<button
3535
class="mx-btn mx-btn-text mx-btn-icon-right"
3636
>
3737
<i
3838
class="mx-icon-right"
3939
/>
4040
</button>
41-
41+
4242
<span
4343
class="mx-calendar-header-label"
4444
>
4545
<button
4646
class="mx-btn mx-btn-text mx-btn-current-month"
4747
>
48-
48+
4949
Oct
50-
50+
5151
</button>
5252
<button
5353
class="mx-btn mx-btn-text mx-btn-current-year"
5454
>
55-
55+
5656
2019
57-
57+
5858
</button>
5959
</span>
6060
</div>
61-
61+
6262
<div
6363
class="mx-calendar-content"
6464
>
@@ -67,12 +67,12 @@ exports[`CalendarPanel prop: type=date 1`] = `
6767
getcellclasses="function () { [native code] }"
6868
style="display: none;"
6969
/>
70-
70+
7171
<table-month-stub
7272
getcellclasses="function () { [native code] }"
7373
style="display: none;"
7474
/>
75-
75+
7676
<table-date-stub
7777
calendarmonth="9"
7878
calendaryear="2019"
@@ -98,7 +98,7 @@ exports[`CalendarPanel prop: type=month 1`] = `
9898
class="mx-icon-double-left"
9999
/>
100100
</button>
101-
101+
102102
<button
103103
class="mx-btn mx-btn-text mx-btn-icon-left"
104104
style="display: none;"
@@ -107,15 +107,15 @@ exports[`CalendarPanel prop: type=month 1`] = `
107107
class="mx-icon-left"
108108
/>
109109
</button>
110-
110+
111111
<button
112112
class="mx-btn mx-btn-text mx-btn-icon-double-right"
113113
>
114114
<i
115115
class="mx-icon-double-right"
116116
/>
117117
</button>
118-
118+
119119
<button
120120
class="mx-btn mx-btn-text mx-btn-icon-right"
121121
style="display: none;"
@@ -124,20 +124,20 @@ exports[`CalendarPanel prop: type=month 1`] = `
124124
class="mx-icon-right"
125125
/>
126126
</button>
127-
127+
128128
<span
129129
class="mx-calendar-header-label"
130130
>
131131
<button
132132
class="mx-btn mx-btn-text"
133133
>
134-
134+
135135
2019
136-
136+
137137
</button>
138138
</span>
139139
</div>
140-
140+
141141
<div
142142
class="mx-calendar-content"
143143
>
@@ -146,11 +146,11 @@ exports[`CalendarPanel prop: type=month 1`] = `
146146
getcellclasses="function () { [native code] }"
147147
style="display: none;"
148148
/>
149-
149+
150150
<table-month-stub
151151
getcellclasses="function () { [native code] }"
152152
/>
153-
153+
154154
<!---->
155155
</div>
156156
</div>
@@ -170,7 +170,7 @@ exports[`CalendarPanel prop: type=year 1`] = `
170170
class="mx-icon-double-left"
171171
/>
172172
</button>
173-
173+
174174
<button
175175
class="mx-btn mx-btn-text mx-btn-icon-left"
176176
style="display: none;"
@@ -179,15 +179,15 @@ exports[`CalendarPanel prop: type=year 1`] = `
179179
class="mx-icon-left"
180180
/>
181181
</button>
182-
182+
183183
<button
184184
class="mx-btn mx-btn-text mx-btn-icon-double-right"
185185
>
186186
<i
187187
class="mx-icon-double-right"
188188
/>
189189
</button>
190-
190+
191191
<button
192192
class="mx-btn mx-btn-text mx-btn-icon-right"
193193
style="display: none;"
@@ -196,26 +196,34 @@ exports[`CalendarPanel prop: type=year 1`] = `
196196
class="mx-icon-right"
197197
/>
198198
</button>
199-
199+
200200
<span
201201
class="mx-calendar-header-label"
202202
>
203203
<span>
204-
2010 ~ 2019
204+
2010
205+
</span>
206+
207+
<span
208+
class="mx-calendar-decade-separator"
209+
/>
210+
211+
<span>
212+
2019
205213
</span>
206214
</span>
207215
</div>
208-
216+
209217
<div
210218
class="mx-calendar-content"
211219
>
212220
<table-year-stub
213221
decade="2010"
214222
getcellclasses="function () { [native code] }"
215223
/>
216-
224+
217225
<!---->
218-
226+
219227
<!---->
220228
</div>
221229
</div>

src/calendar/calendar-panel.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@
3636
<i class="mx-icon-right"></i>
3737
</button>
3838
<span class="mx-calendar-header-label">
39-
<span v-if="panel === 'year'">{{ yearHeader }}</span>
39+
<template v-if="panel === 'year'">
40+
<span>{{ calendarDecade }}</span>
41+
<span class="mx-calendar-decade-separator"></span>
42+
<span>{{ calendarDecade + 9 }}</span>
43+
</template>
4044
<button
4145
v-else-if="panel === 'month'"
4246
class="mx-btn mx-btn-text"
4347
@click="handelPanelChange('year')"
4448
>
45-
{{ monthHeader }}
49+
{{ calendarYear }}
4650
</button>
4751
<template v-else-if="panel === 'date'">
4852
<button
@@ -177,12 +181,6 @@ export default {
177181
showIconArrow() {
178182
return this.panel === 'date';
179183
},
180-
yearHeader() {
181-
return `${this.calendarDecade} ~ ${this.calendarDecade + 9}`;
182-
},
183-
monthHeader() {
184-
return this.calendarYear;
185-
},
186184
dateHeader() {
187185
const monthBeforeYear = this.t('monthBeforeYear');
188186
const yearFormat = this.t('yearFormat');

src/style/index.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@
183183
font-size: 14px;
184184
}
185185

186+
.mx-calendar-decade-separator {
187+
margin: 0 2px;
188+
&:after {
189+
content: '~';
190+
}
191+
}
192+
186193
.mx-calendar-content {
187194
position: relative;
188195
width: 224px;

0 commit comments

Comments
 (0)