Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(toast): add Toast.useToastTime #375

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MariusDoe
Copy link
Contributor

Adds Toast.useToastTime, which can be used to access the elapsed and remaining time (or fraction of the duration) that a toast has been / will stay open for.

The code is extracted from/inspired by Toast.ProgressFill and I adjusted Toast.ProgressFill to use the new API.

Motivation

I use daisyUI to style kobalte components. daisyUI provides a progress component (component means set of css classes here), that i would like to use with kobalte's toast system.

The problem is that daisyUI uses a native progress element, while kobalte uses two divs (Toast.ProgressTrack and Toast.ProgressFill) and relies on a css variable to show the current value. Sadly, I don't think there is a direct way to use the css variable to populate the value attribute of the progress element. I could try to use a hidden Toast.ProgressFill, listen to changes of its --kb-toast-progress-fill-width variable and apply the value to the value property of the progress element, but that sounds like ugly code and poor performance.

Since I see no other way to get the value I need from kobalte, I propose to add this API. If there is a way I didn't see, please let me know :)

Docs

The custom progress element in the new example for Toast.useToastTime is currently unstyled, which doesn't fit nicely into the rest of the docs. I'm unsure whether we should add some styles to make it fit better or leave it as-is to show that it really is a raw/native progress element.

Copy link

netlify bot commented Mar 21, 2024

👷 Deploy request for kobalte pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b21625e

@jer3m01
Copy link
Member

jer3m01 commented Mar 29, 2024

We plan to expose all component context for custom use cases. We want to finish a few tasks before we tackle this.

Thanks for the work, will definitely merge once ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants