Add error state styles to date picker field

This commit is contained in:
Andrew Kingston 2021-02-01 19:01:43 +00:00
parent cf43cf765c
commit 8789d576af
1 changed files with 15 additions and 3 deletions

View File

@ -57,7 +57,8 @@
<div <div
id={`${$fieldState.fieldId}-wrapper`} id={`${$fieldState.fieldId}-wrapper`}
aria-disabled="false" aria-disabled="false"
aria-invalid="false" aria-invalid={!$fieldState.valid}
class:is-invalid={!$fieldState.valid}
class="flatpickr spectrum-InputGroup spectrum-Datepicker" class="flatpickr spectrum-InputGroup spectrum-Datepicker"
class:is-focused={open} class:is-focused={open}
aria-readonly="false" aria-readonly="false"
@ -65,12 +66,21 @@
aria-haspopup="true"> aria-haspopup="true">
<div <div
on:click={flatpickr?.open} on:click={flatpickr?.open}
class="spectrum-Textfield spectrum-InputGroup-textfield"> class="spectrum-Textfield spectrum-InputGroup-textfield"
class:is-invalid={!$fieldState.valid}>
{#if !$fieldState.valid}
<svg
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-validationIcon"
focusable="false"
aria-hidden="true">
<use xlink:href="#spectrum-icon-18-Alert" />
</svg>
{/if}
<input <input
data-input data-input
type="text" type="text"
class="spectrum-Textfield-input spectrum-InputGroup-input" class="spectrum-Textfield-input spectrum-InputGroup-input"
aria-invalid="false" aria-invalid={!$fieldState.valid}
{placeholder} {placeholder}
id={$fieldState.fieldId} id={$fieldState.fieldId}
value={$fieldState.value} /> value={$fieldState.value} />
@ -79,6 +89,7 @@
type="button" type="button"
class="spectrum-Picker spectrum-InputGroup-button" class="spectrum-Picker spectrum-InputGroup-button"
tabindex="-1" tabindex="-1"
class:is-invalid={!$fieldState.valid}
on:click={flatpickr?.open}> on:click={flatpickr?.open}>
<svg <svg
class="spectrum-Icon spectrum-Icon--sizeM" class="spectrum-Icon spectrum-Icon--sizeM"
@ -108,6 +119,7 @@
--spectrum-alias-single-line-width, --spectrum-alias-single-line-width,
var(--spectrum-global-dimension-size-2400) var(--spectrum-global-dimension-size-2400)
); );
overflow: hidden;
} }
.flatpickr .spectrum-Textfield { .flatpickr .spectrum-Textfield {
width: auto; width: auto;