metonym / svelte-time

Svelte component and action to format a timestamp using day.js
https://metonym.github.io/svelte-time
MIT License
137 stars 8 forks source link

How to NOT render the title global attribute. #43

Closed shyakadavis closed 4 months ago

shyakadavis commented 4 months ago

Hello, ๐Ÿ‘‹

First off, I really love the lib and use it often for its simplicity. ๐Ÿ™‚

From MDN, I understand the title attribute is basically a tooltip for representing advisory information related to the element it belongs to. In our case, the time element. (Thanks for making this semantic.)

But here is my issue; I wanted to provide my own tooltip, but trying to override the rendered title doesn't seem to work.

I tried passing null and an empty string '' to the title prop, but nothing seemed to work.

                        <Time
                            relative
                            format="D MMMM, YYYY"
                            timestamp={created_at}
                            class="text-sm text-muted-foreground"
                            title={null}
                        />

The result, in my case, is repetitive information and I would like to avoid this:

Screenshot 2024-04-18 at 19 54 25

Do you know of a way to:

  1. disable the tooltip, but retain the element title in the DOM (for accessibility's sake?) 2) forego on adding the title altogether

I appreciate the help.

metonym commented 4 months ago

Hey โ€“ thank you for the feedback and taking the time to open this issue. I'm working on a PR that will allow the title attribute to be overridden.

metonym commented 4 months ago

Released in v0.9.0.

You can now specify a custom title or omit it altogether by setting title={undefined}.

<Time relative title="Custom title" />

Set the value to undefined to omit the title altogether.

<Time relative title={undefined} />
shyakadavis commented 4 months ago

Hello, @metonym

Thank you very much for the release. It works splendidly.

I appreciate the help.

Be safe. ๐Ÿ™‚