Repository navigation
Releases: feildmaster/SimpleToast
Releases · feildmaster/SimpleToast
Release list
3.0.0
A rewrite built around a stylesheet, templates and events. Toasts are still created with SimpleToast(...).
New
- Styling by classes. SimpleToast never sets inline styles. The default look is
dist/simpletoast.css, with custom properties for colors, spacing and position. - Four builds in
dist/:simpletoast.js(everything, injects its stylesheet),simpletoast.core.js(toasts only),simpletoast.timers.js(timeouts add-on for the core build) andsimpletoast.css. Type definitions come with each. - Templates. A
<template id="simpletoast-template">controls a toast's structure. It can have one root element or several top-level elements. - Handle:
toast.element,setTitleandsetFooter, next tosetText,existsandclose. - Events:
simpletoast:addandsimpletoast:closebubble todocument. Dispatchsimpletoast:dismisson a toast's element to close it with a reason. - Timers. Each toast has its own timer, exact to the millisecond. It pauses while hovered or focused, while the tab is hidden or unfocused, and after
idlemilliseconds without input (pauseOnHoverandidlecontrol this). - Options:
signal(anAbortSignal),html: falsefor plain text,dismissOnClick: false,roleanddata. - Accessibility. The root is a polite live region, toasts have
role="status"and are focusable, and Escape, Enter and Space dismiss them. - TypeScript types, checked against the source.
- Title-only toasts work.
Breaking changes
- The builds moved to
dist/, and the rootsimpletoast.jsis gone. Load a tagged file, for examplehttps://raw.githubusercontent.com/feildmaster/SimpleToast/3.0.0/dist/simpletoast.js, not one from the default branch. - The
cssoption is removed. Use classes, custom properties ortoast.element. - Buttons no longer dismiss the toast. Call
toast.close()from the handler. - Timeouts only run while the tab is visible and focused and the user is not idle. The core build alone ignores
timeout.
Notes
- The default build injects its stylesheet as a
<style>element, which a strictstyle-srcContent Security Policy blocks. On such pages usesimpletoast.core.js(plussimpletoast.timers.js) and loadsimpletoast.cssyourself. - To manage the styles yourself with the default build, add your own
<style data-simpletoast-stylesheet>without adata-version, and SimpleToast will not inject or change a stylesheet. - Only the top frame gets SimpleToast. Nothing is defined in iframes.
See the readme for the full option list.
2.0.5
Changes
- Buttons take
onClick, matching the casing used everywhere else.onclickstill works.
2.0.4
Fixes
setText('')now clears the text. Empty strings used to be ignored.close()no longer needs the toast to still be inside#AlertToast, so it works if something else removed or replaced the root.
2.0.3
2.0.2
2.0.1
2.0.0
Breaking changes
onCloseis now called with(reason, toast)instead of(toast, reason), andthisis the toast.toast.close(reason)accepts a close reason. Toasts close with'timeout'when they time out and'dismissed'when clicked, and'unknown'is the default.
Fixes
- The toast handle given to callers no longer exposes the library's internal object.