✨ Add Toast notification component#14
Merged
Merged
Conversation
Introduce a Bootstrap 5 toast component for non-intrusive notifications (flash messages, status updates). Features: - Bootstrap color types: primary, secondary, success, danger, warning, info, light, dark (mapped via `text-bg-*`) - Optional dismiss button, with `btn-close-white` applied automatically except on light backgrounds (warning, light) - Configurable auto-hide via Bootstrap's `data-bs-autohide` and `data-bs-delay` (default 5s) - Configurable `politeness` (`polite` or `assertive`) mapped to `aria-live` so consumers can pick the appropriate level for non-urgent confirmations vs urgent errors - Renders the markup only — Bootstrap's toast must be initialized client-side, exactly like the native Bootstrap toast. Documentation includes a Stimulus snippet covering all toasts inside a container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
Enabel:Ux:ToastTwig component wrapping Bootstrap 5's toast pattern, designed for non-intrusive notifications (flash messages, status updates, async operation results).Why
The existing
Enabel:Ux:Alertcomponent renders an inline alert in the document flow, which is fine for inline forms feedback but not ideal for transient notifications: it pushes content around, doesn't auto-dismiss, doesn't stack natively, and isn't tuned for screen reader politeness levels.The Toast component renders Bootstrap's native toast markup with the right ARIA attributes and configurable behaviors, so consumers can drop it into a
.toast-containerand forget about the boilerplate.API
{{ component('Enabel:Ux:Toast', { text: 'Saved successfully', type: 'success', autohide: true, delay: 5000, dismissible: true, politeness: 'polite', }) }}text?stringnulltypestring'info'dismissiblebooltrueautohidebooltruedelayint5000politenessstring'polite'Accessibility
role=\"alert\"+aria-live=\"{politeness}\"+aria-atomic=\"true\"on the toast rootpoliteness: 'polite'for non-urgent messages (default),assertivefor errors / urgent feedbackbtn-close-whiteapplied automatically except onwarningandlightbackgrounds (dark text on light fill)Initialization
Like the native Bootstrap toast, the component renders the markup but does not display it. Bootstrap's JS must be invoked to show it. The doc includes a one-method Stimulus controller covering all toasts inside a container:
Test plan
Notes