2
0
mirror of https://github.com/frappe/books.git synced 2025-01-26 00:28:25 +00:00

fix(ux): shifting chevrons on date picker, formatting

This commit is contained in:
18alantom 2021-11-24 16:20:02 +05:30
parent 95735a91e8
commit 7ebbddd307

View File

@ -18,7 +18,14 @@
</span> </span>
<span class="flex"> <span class="flex">
<div <div
class="w-5 h-5 hover:bg-gray-100 rounded-md flex-center cursor-pointer" class="
w-5
h-5
hover:bg-gray-100
rounded-md
flex-center
cursor-pointer
"
> >
<feather-icon <feather-icon
@click="prevMonth" @click="prevMonth"
@ -27,7 +34,15 @@
/> />
</div> </div>
<div <div
class="ml-2 w-5 h-5 hover:bg-gray-100 rounded-md flex-center cursor-pointer" class="
ml-2
w-5
h-5
hover:bg-gray-100
rounded-md
flex-center
cursor-pointer
"
> >
<feather-icon <feather-icon
@click="nextMonth" @click="nextMonth"
@ -52,12 +67,21 @@
<div <div
v-for="date in week" v-for="date in week"
:key="toValue(date)" :key="toValue(date)"
class="w-6 h-6 mr-1 last:mr-0 flex-center cursor-pointer rounded-md hover:bg-blue-100 hover:text-blue-500" class="
w-6
h-6
mr-1
last:mr-0
flex-center
cursor-pointer
rounded-md
hover:bg-blue-100 hover:text-blue-500
"
:class="{ :class="{
'text-gray-600': date.getMonth() !== currentMonth - 1, 'text-gray-600': date.getMonth() !== currentMonth - 1,
'text-blue-500': toValue(date) === toValue(today), 'text-blue-500': toValue(date) === toValue(today),
'bg-blue-100 font-semibold text-blue-500': 'bg-blue-100 font-semibold text-blue-500':
toValue(date) === value toValue(date) === value,
}" }"
@click=" @click="
selectDate(date); selectDate(date);
@ -81,12 +105,12 @@ export default {
name: 'DatePicker', name: 'DatePicker',
props: ['value', 'placeholder', 'readonly', 'formatValue', 'inputClass'], props: ['value', 'placeholder', 'readonly', 'formatValue', 'inputClass'],
components: { components: {
Popover Popover,
}, },
data() { data() {
return { return {
currentYear: null, currentYear: null,
currentMonth: null currentMonth: null,
}; };
}, },
created() { created() {
@ -122,17 +146,25 @@ export default {
let daysInMonth = this.getDaysInMonth(monthIndex, year); let daysInMonth = this.getDaysInMonth(monthIndex, year);
let datesInMonth = this.getDatesAfter(firstDayOfMonth, daysInMonth - 1); let datesInMonth = this.getDatesAfter(firstDayOfMonth, daysInMonth - 1);
return [ let dates = [
...leftPadding, ...leftPadding,
firstDayOfMonth, firstDayOfMonth,
...datesInMonth, ...datesInMonth,
...rightPadding ...rightPadding,
]; ];
if (dates.length < 42) {
const finalPadding = this.getDatesAfter(
dates.at(-1),
42 - dates.length
);
dates = dates.concat(...finalPadding)
}
return dates;
}, },
formatMonth() { formatMonth() {
let date = this.getDate(this.currentYear, this.currentMonth - 1, 1); let date = this.getDate(this.currentYear, this.currentMonth - 1, 1);
return date.toLocaleString('en-US', { month: 'short', year: 'numeric' }); return date.toLocaleString('en-US', { month: 'short', year: 'numeric' });
} },
}, },
methods: { methods: {
selectDate(date) { selectDate(date) {
@ -212,7 +244,7 @@ export default {
getDate(...args) { getDate(...args) {
let d = new Date(...args); let d = new Date(...args);
return d; return d;
} },
} },
}; };
</script> </script>