Add cross browser style improvements for datepicker
This commit is contained in:
parent
93630b36e2
commit
e758582822
|
@ -61,6 +61,10 @@
|
|||
onChange(base.year(date.year()).month(date.month()).date(date.date()))
|
||||
}
|
||||
|
||||
export const setDate = date => {
|
||||
calendarDate = date
|
||||
}
|
||||
|
||||
const cleanYear = cleanInput({ max: 9999, pad: 0, fallback: now.year() })
|
||||
</script>
|
||||
|
||||
|
@ -85,6 +89,7 @@
|
|||
value={calendarDate.year()}
|
||||
min={0}
|
||||
max={9999}
|
||||
width={64}
|
||||
on:change={handleCalendarYearChange}
|
||||
on:input={cleanYear}
|
||||
/>
|
||||
|
@ -173,6 +178,9 @@
|
|||
.spectrum-Calendar {
|
||||
width: auto;
|
||||
}
|
||||
.spectrum-Calendar-header {
|
||||
width: auto;
|
||||
}
|
||||
.spectrum-Calendar-title {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
|
@ -196,12 +204,11 @@
|
|||
background: var(--spectrum-global-color-blue-400);
|
||||
}
|
||||
.spectrum-Calendar tr {
|
||||
box-sizing: content-box;
|
||||
height: 40px;
|
||||
}
|
||||
.spectrum-Calendar-tableCell {
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
padding: 4px;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.spectrum-Calendar-nextMonth,
|
||||
.spectrum-Calendar-prevMonth {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
let isOpen = false
|
||||
let anchor
|
||||
let popover
|
||||
let calendar
|
||||
|
||||
$: parsedValue = parseValue(value)
|
||||
$: showCalendar = !timeOnly
|
||||
|
@ -107,6 +108,12 @@
|
|||
|
||||
dispatch("change", newValue)
|
||||
}
|
||||
|
||||
const setToNow = () => {
|
||||
const now = dayjs()
|
||||
calendar?.setDate(now)
|
||||
handleChange(now)
|
||||
}
|
||||
</script>
|
||||
|
||||
<DateTimeInput
|
||||
|
@ -133,7 +140,11 @@
|
|||
{#if isOpen}
|
||||
<div class="date-time-popover">
|
||||
{#if showCalendar}
|
||||
<Calendar value={parsedValue} onChange={handleChange} />
|
||||
<Calendar
|
||||
value={parsedValue}
|
||||
onChange={handleChange}
|
||||
bind:this={calendar}
|
||||
/>
|
||||
{/if}
|
||||
<div class="footer" class:spaced={showCalendar}>
|
||||
{#if showTime}
|
||||
|
@ -147,7 +158,7 @@
|
|||
>
|
||||
Clear
|
||||
</ActionButton>
|
||||
<ActionButton size="S" on:click={() => handleChange(dayjs())}>
|
||||
<ActionButton size="S" on:click={setToNow}>
|
||||
{showTime ? "Now" : "Today"}
|
||||
</ActionButton>
|
||||
</div>
|
||||
|
@ -164,7 +175,7 @@
|
|||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 32px;
|
||||
gap: 60px;
|
||||
}
|
||||
.footer.spaced {
|
||||
padding-top: 14px;
|
||||
|
@ -175,6 +186,5 @@
|
|||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
font-weight: bold;
|
||||
font-family: var(--font-sans);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
input:focus,
|
||||
input:hover {
|
||||
|
|
Loading…
Reference in New Issue