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