Skip to content

Commit

Permalink
Disable relative vs absolute inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
laurakwhit committed Sep 7, 2023
1 parent 8b0aa42 commit 48f83ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@
error={error(relativeTime)}
unroundRight
class="h-10"
disabled={type !== 'relative'}
/>
<Select
unroundLeft
bind:value={timeUnit}
id="relative-datetime-unit-input"
label={translate('time-unit')}
labelHidden
disabled={type !== 'relative'}
>
{#each TIME_UNIT_OPTIONS as unit}
<Option value={unit}>{unit} {translate('ago')}</Option>
Expand Down Expand Up @@ -248,12 +250,14 @@
todayLabel={translate('today')}
closeLabel={translate('close')}
clearLabel={translate('clear-input-button-label')}
disabled={type !== 'absolute'}
/>
<TimePicker
bind:hour={startHour}
bind:minute={startMinute}
bind:second={startSecond}
twelveHourClock={false}
disabled={type !== 'absolute'}
/>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/holocene/date-picker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export let todayLabel: string;
export let closeLabel: string;
export let clearLabel: string;
export let disabled = false;
let month: number | undefined;
let year: number | undefined;
Expand Down Expand Up @@ -88,6 +89,7 @@
value={selected.toDateString()}
clearable
clearButtonLabel={clearLabel}
{disabled}
/>
{#if showDatePicker}
<div
Expand Down
4 changes: 4 additions & 0 deletions src/lib/holocene/time-picker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export let second = '';
export let half: 'AM' | 'PM' = 'AM';
export let twelveHourClock = true;
export let disabled = false;
</script>

<div class="flex gap-2">
Expand All @@ -20,6 +21,7 @@
suffix="hrs"
maxLength={2}
error={twelveHourClock ? parseInt(hour) > 12 : parseInt(hour) > 23}
{disabled}
/>
<Input
id="minute"
Expand All @@ -31,6 +33,7 @@
suffix="min"
maxLength={2}
error={Boolean(parseInt(hour) > 59)}
{disabled}
/>
<Input
id="second"
Expand All @@ -41,6 +44,7 @@
suffix="sec"
maxLength={2}
error={Boolean(parseInt(hour) > 59)}
{disabled}
/>
{#if twelveHourClock}
<ToggleButtons>
Expand Down

0 comments on commit 48f83ab

Please sign in to comment.