Skip to content

Commit fd9d47a

Browse files
committed
Add properties
1 parent 33cde64 commit fd9d47a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/relative-time-element.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
198198
month: this.month,
199199
year: this.year,
200200
timeZoneName: this.timeZoneName,
201+
dateStyle: this.dateStyle,
202+
timeStyle: this.timeStyle,
201203
})
202204
return `${this.prefix} ${formatter.format(date)}`.trim()
203205
}
@@ -326,6 +328,30 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
326328
this.setAttribute('time-zone-name', value || '')
327329
}
328330

331+
get dateStyle() {
332+
const dateStyle = this.getAttribute('date-style')
333+
334+
if (dateStyle === 'short' || dateStyle === 'long' || dateStyle === 'full' || dateStyle === 'medium') {
335+
return dateStyle
336+
}
337+
}
338+
339+
set dateStyle(value: 'short' | 'long' | 'full' | 'medium' | undefined) {
340+
this.setAttribute('date-style', value ?? '')
341+
}
342+
343+
get timeStyle() {
344+
const timeStyle = this.getAttribute('time-style')
345+
346+
if (timeStyle === 'short' || timeStyle === 'long' || timeStyle === 'full' || timeStyle === 'medium') {
347+
return timeStyle
348+
}
349+
}
350+
351+
set timeStyle(value: 'short' | 'long' | 'full' | 'medium' | undefined) {
352+
this.setAttribute('time-style', value ?? '')
353+
}
354+
329355
/** @deprecated */
330356
get prefix(): string {
331357
return this.getAttribute('prefix') ?? (this.format === 'datetime' ? '' : 'on')

0 commit comments

Comments
 (0)