Coder Social home page Coder Social logo

pablen / toasty Goto Github PK

View Code? Open in Web Editor NEW
40.0 40.0 12.0 50 KB

A notification package for Elm apps.

Home Page: http://package.elm-lang.org/packages/pablen/toasty/latest

License: BSD 3-Clause "New" or "Revised" License

Elm 94.63% CSS 5.37%
elm notifications toasts

toasty's People

Contributors

mdevlamynck avatar pablen avatar razzeee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

toasty's Issues

Ability to conditionally show toasts

We're using toasty to notify the user whenever API requests are slower than a given threshold. Using the current version of toasty there isn't a way to figure out if a toast is visible or not. If multiple API's are slow and hit the threshold at or around the same time, multiple toasts (in our case with the same contents) are shown.

The most pressing issue we have is to figure out if a given toast is visible or not. If it's the case that one already is visible, we don't want to show another toast as we've already told the user that one or more of the API's are slow.

Currently we've forked Toasty and exposed the Stack constructors so we can poke around in the toasty internals and figure out if we should show a new toast or not. Simply exposing the constructors as we have, doesn't seem like a good idea for the library to do. I'm not sure what the best approach would be to solve this? I'm happy to submit a MR given I can wrap my head around what a good approach would be.

Further enhancements is to be able to prolong the duration of a given toast, as well as change the contents of the visible toast. Then we can make sure the relevant toast stays visible as new API requests hit the threshold. And we could update the message with the number of pending API requests. But these are enhancements, not strictly needed for us to use Toasty.

Accessibility

I know it's possible to pass a11y attributes in via the config, but I think they should be the default. I think Twitter Bootstrap's toasts are a good starting point. This would possibly also include giving it a tabindex and keyboard shortcuts for Enter and Escape to dismiss.

I wouldn't mind doing a PR for this.

Elm 0.19

Hello, could you bump the version to support elm 0.19?

Remove toasts

I understand that it's not really what this library is trying to do, but, I have a use case. I want to show a toast for the user being offline and it's persistent until the user comes back online (or they choose to close it). There's no mechanism for removing this as Remove msg isn't exposed and everything is related to add*.

Demo does not work on mobile

In your demo i am forced to hit a keyboard key to create the toasts.
But that is a hard thing to do on mobile.

Can the demo additionally get some buttons that spawn the toasts?

Cheers

Toasts can close prematurely due to ID collision

Steps to reproduce:

  1. Open the demo
  2. Press the 's' key to create a success toast
  3. Wait 3 seconds
  4. Click on the toast to dismiss it
  5. Press the 's' key again to create a new success toast
  6. The newly created toast will close after 2 seconds instead of 5. This happens because the newly created toast has the same Id as the dismissed toast, and the dismissed toast's Process.sleep was never killed.

Possible solutions:

  • When a toast is added, use Process.spawn to keep track of the Process.sleep process ID. If the user manually dismisses a toast, kill the sleep process with Process.kill.
  • Use a random number generator to assign a unique ID to each toast. It won't prevent all collisions but the chance of collision will be extremely small.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.