Improved calendar day styling. Large numbers, now today marker and other tweaks.
This commit is contained in:
@@ -1,8 +1,16 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { formatDateCompact, fromLocalString } from '@/utils/date'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
day: Object,
|
day: Object,
|
||||||
dragging: { type: Boolean, default: false },
|
dragging: { type: Boolean, default: false },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const formattedDate = computed(() => {
|
||||||
|
const date = fromLocalString(props.day.date)
|
||||||
|
return formatDateCompact(date)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -21,6 +29,7 @@ const props = defineProps({
|
|||||||
]"
|
]"
|
||||||
:data-date="props.day.date"
|
:data-date="props.day.date"
|
||||||
>
|
>
|
||||||
|
<span class="compact-date">{{ formattedDate }}</span>
|
||||||
<h1 class="day-number">{{ props.day.displayText }}</h1>
|
<h1 class="day-number">{{ props.day.displayText }}</h1>
|
||||||
<span v-if="props.day.lunarPhase" class="lunar-phase">{{ props.day.lunarPhase }}</span>
|
<span v-if="props.day.lunarPhase" class="lunar-phase">{{ props.day.lunarPhase }}</span>
|
||||||
<div v-if="props.day.holiday" class="holiday-info" dir="auto" :title="props.day.holiday.name">
|
<div v-if="props.day.holiday" class="holiday-info" dir="auto" :title="props.day.holiday.name">
|
||||||
@@ -32,59 +41,68 @@ const props = defineProps({
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.cell {
|
.cell {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
background: var(--panel);
|
||||||
border-inline-end: 1px solid var(--border-color);
|
border-inline-end: 1px solid var(--border-color);
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
display: grid;
|
display: grid;
|
||||||
/* 3 columns: day number, flexible space, lunar phase */
|
/* Updated grid for centered day number */
|
||||||
grid-template-columns: min-content 1fr min-content;
|
grid-template-columns: 1fr;
|
||||||
/* 3 rows: header, flexible filler, holiday label */
|
grid-template-rows: 1fr auto;
|
||||||
grid-template-rows: auto 1fr auto;
|
/* Named grid areas */
|
||||||
/* Named grid areas (only ones actually used) */
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
'day-number . lunar-phase'
|
'day-number'
|
||||||
'day-number . lunar-phase'
|
'holiday-info';
|
||||||
'holiday-info holiday-info holiday-info';
|
|
||||||
/* Explicit areas mainly for clarity */
|
|
||||||
grid-auto-flow: row;
|
|
||||||
padding: 0.25em;
|
padding: 0.25em;
|
||||||
overflow: hidden;
|
overflow: visible;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: var(--row-h);
|
height: var(--row-h);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
transition: background-color 0.15s ease;
|
transition: background-color 0.15s ease;
|
||||||
align-items: start;
|
align-items: center;
|
||||||
|
justify-items: center;
|
||||||
}
|
}
|
||||||
.cell h1.day-number {
|
.cell h1.day-number {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
min-width: 1.5em;
|
position: absolute;
|
||||||
font-size: 1em;
|
inset-block: 1.5rem;
|
||||||
font-weight: 700;
|
inset-inline: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 5vmin;
|
||||||
|
font-weight: 600;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
transition: background-color 0.15s ease;
|
opacity: 0.8;
|
||||||
grid-area: day-number;
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
.cell.firstday h1.day-number {
|
||||||
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
.cell.weekend h1.day-number {
|
.cell.weekend h1.day-number {
|
||||||
color: var(--weekend);
|
color: var(--weekend);
|
||||||
}
|
}
|
||||||
.cell.firstday h1.day-number {
|
.cell.firstday h1.day-number {
|
||||||
color: var(--firstday);
|
color: var(--firstday);
|
||||||
text-shadow: 0 0 0.1em var(--strong);
|
|
||||||
}
|
}
|
||||||
.cell.today h1.day-number {
|
.cell.today::before {
|
||||||
border-radius: 2em;
|
content: '';
|
||||||
background: var(--today);
|
position: absolute;
|
||||||
border: 0.2em solid var(--today);
|
top: 50%;
|
||||||
margin: -0.2em;
|
left: 50%;
|
||||||
color: var(--strong);
|
transform: translate(-50%, -50%);
|
||||||
font-weight: bold;
|
width: calc(100% + .3rem);
|
||||||
}
|
height: calc(100% + .3rem);
|
||||||
.cell.selected {
|
border-radius: 1rem;
|
||||||
filter: hue-rotate(180deg);
|
background: transparent;
|
||||||
|
border: 0.1em solid var(--today);
|
||||||
|
z-index: 15;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.cell.selected h1.day-number {
|
.cell.selected h1.day-number {
|
||||||
color: var(--strong);
|
opacity: 0.3;
|
||||||
|
filter: brightness(1.2);
|
||||||
}
|
}
|
||||||
.cell.holiday {
|
.cell.holiday {
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(
|
||||||
@@ -102,32 +120,50 @@ const props = defineProps({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.cell.holiday h1.day-number {
|
|
||||||
/* Slight emphasis without forcing a specific hue */
|
|
||||||
color: var(--holiday);
|
|
||||||
text-shadow: 0 0 0.3em rgba(255, 255, 255, 0.4);
|
|
||||||
}
|
|
||||||
.lunar-phase {
|
.lunar-phase {
|
||||||
grid-area: lunar-phase;
|
grid-area: lunar-phase;
|
||||||
align-self: start;
|
position: absolute;
|
||||||
justify-self: end;
|
inset-block-start: 0.5em;
|
||||||
margin-top: 0.5em;
|
inset-inline-end: 0.2em;
|
||||||
margin-inline-end: 0.2em;
|
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.compact-date {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.25em;
|
||||||
|
left: 0.25em;
|
||||||
|
inset-inline-end: 1rem; /* Space for lunar phase */
|
||||||
|
font-weight: 400;
|
||||||
|
color: var(--ink);
|
||||||
|
line-height: 1;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cell.weekend .compact-date {
|
||||||
|
color: var(--weekend);
|
||||||
|
}
|
||||||
|
.cell.firstday .compact-date {
|
||||||
|
color: var(--firstday);
|
||||||
|
}
|
||||||
|
.cell.today .compact-date {
|
||||||
|
color: var(--strong);
|
||||||
|
}
|
||||||
|
.cell.selected .compact-date {
|
||||||
|
color: var(--strong);
|
||||||
|
}
|
||||||
|
|
||||||
.holiday-info {
|
.holiday-info {
|
||||||
grid-area: holiday-info;
|
grid-area: holiday-info;
|
||||||
align-self: end;
|
align-self: end;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
max-width: 100%;
|
||||||
white-space: nowrap;
|
color: var(--holiday);
|
||||||
color: var(--holiday-label);
|
font-size: 1em;
|
||||||
font-size: clamp(1.2vw, 0.6em, 1em);
|
font-weight: 400;
|
||||||
line-height: 1;
|
line-height: 1.0;
|
||||||
padding-inline: 0.15em;
|
padding-inline: 0.15em;
|
||||||
padding-block-end: 0.05em;
|
padding-block: 0;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -192,6 +192,17 @@ function formatTodayString(date) {
|
|||||||
return formatted.charAt(0).toUpperCase() + formatted.slice(1)
|
return formatted.charAt(0).toUpperCase() + formatted.slice(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format date as compact string for day cell corner (e.g., "Mon 15 Jan")
|
||||||
|
*/
|
||||||
|
function formatDateCompact(date) {
|
||||||
|
return date.toLocaleDateString(undefined, {
|
||||||
|
weekday: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'short'
|
||||||
|
}).replace(", ", " ")
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
// constants
|
// constants
|
||||||
monthAbbr,
|
monthAbbr,
|
||||||
@@ -218,6 +229,7 @@ export {
|
|||||||
formatDateRange,
|
formatDateRange,
|
||||||
formatDateShort,
|
formatDateShort,
|
||||||
formatDateLong,
|
formatDateLong,
|
||||||
|
formatDateCompact,
|
||||||
formatTodayString,
|
formatTodayString,
|
||||||
lunarPhaseSymbol,
|
lunarPhaseSymbol,
|
||||||
// iso helpers re-export
|
// iso helpers re-export
|
||||||
|
|||||||
Reference in New Issue
Block a user