Skip to content

Commit a98740a

Browse files
committed
🎨 🔥 Removed default color on input (#38)
Input color will be active only when menu is visible
1 parent 2cad04d commit a98740a

File tree

6 files changed

+43
-23
lines changed

6 files changed

+43
-23
lines changed

Diff for: dist/vue-datepicker.esm.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/vue-datepicker.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/vue-datepicker.umd.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/components/DatePicker/DatePicker.vue

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ export default {
320320
disabled: this.disabled,
321321
id: this.componentId,
322322
isDateDefined: this.isDateDefined,
323+
isMenuActive: this.isMenuActive,
323324
name: this.name,
324325
noCalendarIcon: this.noCalendarIcon,
325326
noInput: this.noInput,

Diff for: src/components/DatePicker/DatePickerCustomInput.vue

+28-9
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,31 @@ export default {
1313
mixins: [colorable],
1414
directives: { ClickOutside },
1515
props: {
16-
id: { type: String },
17-
name: { type: String },
1816
clearable: { type: Boolean },
17+
closeOnClickOutside: { type: Boolean, default: true },
18+
color: { type: String },
1919
date: { type: [Object, Date, String] },
20+
disabled: { type: Boolean, default: false },
21+
id: { type: String },
2022
isDateDefined: { type: Boolean, default: false },
23+
isMenuActive: { type: Boolean, default: false },
24+
name: { type: String },
25+
noCalendarIcon: { type: Boolean, default: false },
26+
noInput: { type: Boolean, default: false },
2127
placeholder: { type: String },
22-
color: { type: String },
23-
disabled: { type: Boolean, default: false },
2428
tabindex: { type: [String, Number] },
25-
noInput: { type: Boolean, default: false },
26-
noCalendarIcon: { type: Boolean, default: false },
27-
closeOnClickOutside: { type: Boolean, default: true },
2829
},
2930
computed: {
31+
classes () {
32+
return {
33+
'datepicker__input--disabled': this.disabled,
34+
'datepicker__input--is-active': this.isMenuActive,
35+
'datepicker__input--no-date': !this.isDateDefined,
36+
};
37+
},
3038
computedColor () {
31-
return this.isDateDefined && !this.disabled ? this.color : 'rgba(93, 106, 137, 0.5)';
39+
if (this.disabled) return '';
40+
return this.isMenuActive ? this.color : '';
3241
},
3342
isDirty () {
3443
return this.isDateDefined;
@@ -158,6 +167,7 @@ export default {
158167
render (h) {
159168
return h('div', this.setTextColor(this.computedColor, {
160169
staticClass: 'datepicker__input',
170+
class: this.classes,
161171
directives: [{
162172
name: 'click-outside',
163173
value: {
@@ -183,10 +193,19 @@ export default {
183193
justify-content: flex-start;
184194
align-items: center;
185195
width: 100%;
196+
color: currentColor;
186197
187198
&--disabled {
188199
cursor: not-allowed;
189200
pointer-events: none;
201+
202+
input {
203+
opacity: .38;
204+
}
205+
}
206+
207+
&--no-date:not(.datepicker__input--is-active) {
208+
opacity: .6;
190209
}
191210
192211
.datepicker__wrapper--rtl & {
@@ -236,7 +255,7 @@ export default {
236255
}
237256
238257
@include input-placeholder {
239-
color: transparentize(black, .6);
258+
opacity: .6;
240259
}
241260
}
242261
}

Diff for: tests/unit/components/datepicker/DatePickerCustonInput.spec.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ describe('DatePickerCustomInput', () => {
3333
describe('computed', () => {
3434
describe('computedColor', () => {
3535
[{
36-
description: 'return disabled color if there is no color',
36+
description: 'return empty by default',
3737
props: {},
38-
expectedResult: 'rgba(93, 106, 137, 0.5)',
38+
expectedResult: '',
3939
}, {
40-
description: 'return disabled color if date isnt defined',
41-
props: { color: '#ffffff' },
42-
expectedResult: 'rgba(93, 106, 137, 0.5)',
40+
description: 'return empty if disabled',
41+
props: { disabled: true, color: '#ffffff', isMenuActive: true },
42+
expectedResult: '',
4343
}, {
44-
description: 'return color if date is defined',
45-
props: { color: '#ffffff', isDateDefined: true },
46-
expectedResult: '#ffffff',
44+
description: 'return empty if menu is not active',
45+
props: { color: '#ffffff', isMenuActive: false },
46+
expectedResult: '',
4747
}, {
48-
description: 'return disabled color if disabled',
49-
props: { color: '#ffffff', disabled: true },
50-
expectedResult: 'rgba(93, 106, 137, 0.5)',
48+
description: 'return color if menu is active',
49+
props: { color: '#ffffff', isMenuActive: true },
50+
expectedResult: '#ffffff',
5151
}].forEach(({ description, props, expectedResult }) => {
5252
it(`should ${description}`, () => {
5353
const wrapper = mountComponent({ props });

0 commit comments

Comments
 (0)