Skip to content

Commit 32c74a4

Browse files
committed
fix: move sidebar element to right position
1 parent 4b5cb3f commit 32c74a4

File tree

4 files changed

+50
-74
lines changed

4 files changed

+50
-74
lines changed

src/date-picker.vue

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@
4343
:append-to-body="appendToBody"
4444
@clickoutside="handleClickOutSide"
4545
>
46-
<div v-if="hasSlot('header')" class="mx-datepicker-header">
47-
<slot name="header" :value="currentValue" :emit="emitValue"></slot>
46+
<div v-if="hasSlot('sidebar') || shortcuts.length" class="mx-datepicker-sidebar">
47+
<slot name="sidebar" :value="currentValue" :emit="emitValue"></slot>
48+
<button
49+
v-for="(v, i) in shortcuts"
50+
:key="i"
51+
type="button"
52+
class="mx-btn mx-btn-text mx-btn-shortcut"
53+
@click="handleSelectShortcut(v)"
54+
>
55+
{{ v.text }}
56+
</button>
4857
</div>
49-
<div class="mx-datepicker-content-wrapper">
50-
<div v-if="hasSlot('sidebar') || shortcuts.length" class="mx-datepicker-sidebar">
51-
<slot name="sidebar" :value="currentValue" :emit="emitValue"></slot>
52-
<button
53-
v-for="(v, i) in shortcuts"
54-
:key="i"
55-
type="button"
56-
class="mx-btn mx-btn-text mx-btn-shortcut"
57-
@click="handleSelectShortcut(v)"
58-
>
59-
{{ v.text }}
60-
</button>
58+
<div class="mx-datepicker-content">
59+
<div v-if="hasSlot('header')" class="mx-datepicker-header">
60+
<slot name="header" :value="currentValue" :emit="emitValue"></slot>
6161
</div>
62-
<div class="mx-datepicker-content">
62+
<div class="mx-datepicker-body">
6363
<slot name="content" :value="currentValue" :emit="emitValue">
6464
<component
6565
:is="currentComponent"
@@ -69,17 +69,17 @@
6969
></component>
7070
</slot>
7171
</div>
72-
</div>
73-
<div v-if="hasSlot('footer') || confirm" class="mx-datepicker-footer">
74-
<slot name="footer" :value="currentValue" :emit="emitValue"></slot>
75-
<button
76-
v-if="confirm"
77-
type="button"
78-
class="mx-btn mx-datepicker-btn-confirm"
79-
@click="handleConfirmDate"
80-
>
81-
{{ confirmText }}
82-
</button>
72+
<div v-if="hasSlot('footer') || confirm" class="mx-datepicker-footer">
73+
<slot name="footer" :value="currentValue" :emit="emitValue"></slot>
74+
<button
75+
v-if="confirm"
76+
type="button"
77+
class="mx-btn mx-datepicker-btn-confirm"
78+
@click="handleConfirmDate"
79+
>
80+
{{ confirmText }}
81+
</button>
82+
</div>
8383
</div>
8484
</Popup>
8585
</div>

src/popup.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,15 @@ export default {
9191
},
9292
render() {
9393
if (this.inline) {
94-
return <div>{this.$slots.default}</div>;
94+
return <div class="mx-datepicker-main">{this.$slots.default}</div>;
9595
}
9696
return (
9797
<transition name="mx-zoom-in-down">
9898
{this.visible && (
99-
<div class="mx-datepicker-popup" style={{ top: this.top, left: this.left }}>
99+
<div
100+
class="mx-datepicker-main mx-datepicker-popup"
101+
style={{ top: this.top, left: this.left }}
102+
>
100103
{this.$slots.default}
101104
</div>
102105
)}

src/style/index.scss

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
position: relative;
99
display: inline-block;
1010
width: 210px;
11-
color: $default-color;
12-
font: 14px/1.5 'Helvetica Neue', Helvetica, Arial, 'Microsoft Yahei', sans-serif;
1311
svg {
1412
width: 1em;
1513
height: 1em;
@@ -29,8 +27,6 @@
2927

3028
.mx-datepicker-inline {
3129
width: auto;
32-
border: 1px solid $border-color;
33-
background-color: #fff;
3430
}
3531

3632
.mx-input-wrapper {
@@ -101,27 +97,22 @@
10197
}
10298
}
10399

104-
.mx-datepicker-popup {
105-
color: $default-color;
100+
.mx-datepicker-main {
106101
font: 14px/1.5 'Helvetica Neue', Helvetica, Arial, 'Microsoft Yahei', sans-serif;
102+
color: $default-color;
103+
background-color: #fff;
104+
border: 1px solid $border-color;
105+
display: flex;
106+
}
107+
108+
.mx-datepicker-popup {
107109
position: absolute;
108110
margin-top: 1px;
109111
margin-bottom: 1px;
110-
border: 1px solid $border-color;
111-
background-color: #fff;
112112
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
113113
z-index: 1000;
114114
}
115115

116-
.mx-datepicker-content-wrapper {
117-
display: flex;
118-
}
119-
120-
.mx-datepicker-content {
121-
position: relative;
122-
user-select: none;
123-
}
124-
125116
.mx-datepicker-sidebar {
126117
box-sizing: border-box;
127118
width: 100px;
@@ -130,6 +121,11 @@
130121
border-right: 1px solid $border-color;
131122
}
132123

124+
.mx-datepicker-body {
125+
position: relative;
126+
user-select: none;
127+
}
128+
133129
.mx-btn-shortcut {
134130
display: block;
135131
padding: 0 6px;
@@ -152,6 +148,8 @@
152148
}
153149

154150
.mx-calendar {
151+
box-sizing: border-box;
152+
width: 248px;
155153
padding: 6px 12px;
156154
& + & {
157155
border-left: 1px solid $border-color;
@@ -166,17 +164,13 @@
166164
overflow: hidden;
167165
}
168166

169-
.mx-btn-icon-left {
170-
float: left;
171-
}
172-
.mx-btn-icon-right {
173-
float: right;
174-
}
167+
.mx-btn-icon-left,
175168
.mx-btn-icon-double-left {
176-
@extend .mx-btn-icon-left;
169+
float: left;
177170
}
171+
.mx-btn-icon-right,
178172
.mx-btn-icon-double-right {
179-
@extend .mx-btn-icon-right;
173+
float: right;
180174
}
181175

182176
.mx-calendar-header-label {
@@ -192,7 +186,6 @@
192186

193187
.mx-calendar-content {
194188
position: relative;
195-
width: 224px;
196189
height: 224px;
197190
box-sizing: border-box;
198191
.cell {

src/style/mixins.scss

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)