Skip to content

Commit

Permalink
HDS-3945 Fix some type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinLBradley committed Nov 7, 2024
1 parent 320d380 commit ad252b4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
18 changes: 9 additions & 9 deletions packages/components/src/components/hds/time/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}}

{{! @glint-nocheck }}
{{! TODO: format-date & display have type errors, fix }}
{{! TODO: isoUtcStringInner has a type errors, fix }}
{{#let this.display as |display|}}
{{#if this.hasTooltip}}
{{#if this.isValidDate}}
Expand All @@ -20,8 +20,8 @@
>
<Hds::Time::Inner
@date={{this.date}}
@isoUtcString={{this.isoUtcString}}
@display={{this.display}}
@isoUtcStringInner={{this.isoUtcString}}
@displayInner={{this.display}}
@register={{this.register}}
@unregister={{this.unregister}}
@isValidDate={{this.isValidDate}}
Expand All @@ -35,8 +35,8 @@
@text={{if
display.options.tooltipFormat
(concat
(hds-format-date this.dateStart display.options.tooltipFormat)
(hds-format-date this.dateEnd display.options.tooltipFormat)
(hds-format-date this.startDate display.options.tooltipFormat)
(hds-format-date this.endDate display.options.tooltipFormat)
)
this.isoUtcString
}}
Expand All @@ -46,8 +46,8 @@
<Hds::Time::Inner
@startDate={{this.startDate}}
@endDate={{this.endDate}}
@isoUtcString={{this.isoUtcString}}
@display={{this.display}}
@isoUtcStringInner={{this.isoUtcString}}
@displayInner={{this.display}}
@register={{this.register}}
@unregister={{this.unregister}}
@isValidDate={{this.isValidDate}}
Expand All @@ -61,8 +61,8 @@
@date={{this.date}}
@startDate={{this.startDate}}
@endDate={{this.endDate}}
@isoUtcString={{this.isoUtcString}}
@display={{this.display}}
@isoUtcStringInner={{this.isoUtcString}}
@displayInner={{this.display}}
@register={{this.register}}
@unregister={{this.unregister}}
@isValidDate={{this.isValidDate}}
Expand Down
34 changes: 19 additions & 15 deletions packages/components/src/components/hds/time/inner.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,49 @@
SPDX-License-Identifier: MPL-2.0
}}

{{! @glint-nocheck: not typesafe yet }}
{{! TODO: format-date & format-relative have type errors, fix }}
{{#if @isValidDate}}
<time class="hds-time" datetime={{@isoUtcString}} ...attributes {{did-insert @register}} {{will-destroy @unregister}}>
{{#if @display.options.showFriendly}}
{{#if @display.options.displayFormat}}
{{hds-format-date @date @display.options.displayFormat}}
<time
class="hds-time"
datetime={{@isoUtcStringInner}}
...attributes
{{did-insert @register}}
{{will-destroy @unregister}}
>
{{#if @displayInner.options.showFriendly}}
{{#if @displayInner.options.displayFormat}}
{{hds-format-date @date @displayInner.options.displayFormat}}
{{else}}
{{@isoUtcString}}
{{@isoUtcStringInner}}
{{/if}}
{{#if @display.options.showRelative}}
({{hds-format-relative @display.relative.value @display.relative.unit}})
{{#if @displayInner.options.showRelative}}
({{hds-format-relative @displayInner.relative.value @displayInner.relative.unit}})
{{/if}}
{{else}}
{{#if @display.options.showRelative}}
{{hds-format-relative @display.relative.value @display.relative.unit}}
{{#if @displayInner.options.showRelative}}
{{hds-format-relative @displayInner.relative.value @displayInner.relative.unit}}
{{/if}}
{{/if}}
</time>
{{else if @isValidDateRange}}
<span class="hds-time-range-contents">
<time
class="hds-time"
datetime={{@isoUtcString}}
datetime={{@isoUtcStringInner}}
...attributes
{{did-insert @register}}
{{will-destroy @unregister}}
>
{{hds-format-date @startDate @display.options.displayFormat}}
{{hds-format-date @startDate @displayInner.options.displayFormat}}
</time>
<time
class="hds-time"
datetime={{@isoUtcString}}
datetime={{@isoUtcStringInner}}
...attributes
{{did-insert @register}}
{{will-destroy @unregister}}
>
{{hds-format-date @endDate @display.options.displayFormat}}
{{hds-format-date @endDate @displayInner.options.displayFormat}}
</time>
</span>
{{else}}
Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/components/hds/time/inner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import type { DefaultDisplayType } from './types.ts';

export interface HdsTimeInnerSignature {
Args: {
isValid: boolean;
date: unknown;
isValidDate: boolean;
isValidDateRange: boolean;
date?: Date;
startDate?: Date;
endDate?: Date;
displayInner: {
options: DefaultDisplayType | undefined;
difference: { absValueInMs: number; valueInMs: number };
relative: { value: number; unit: string };
};
isoUtcString: string;
isoUtcStringInner: string;
register: () => void;
unregister: () => void;
};
Element: HTMLTimeElement;
}
Expand Down

0 comments on commit ad252b4

Please sign in to comment.