-
-
Notifications
You must be signed in to change notification settings - Fork 78.6k
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
Add the ability to create elements using Bootstrap modules. #35749
Comments
It's very hard to complex components like as card. const bsToast = content => `<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">${content}</div>`;
const bsBasicToast = (header, body) => bsToast(`<div class="toast-header">${header}</div><div class="toast-body">${body}</div>`);
const bsShortToast = body => bsToast(`<div class="toast-body">${body}</div>`); or create custom HTML elements: <bs-toast>
<bs-toast-header>...</bs-toast-header>
<bs-toast-body>...</bs-toast-body>
</bs-toast> |
Just a note. https://github.com/twbs/bootstrap/blob/main/js/src/util/template-factory.js was extracted from tooltip functionality, for this cause. Just waiting to be utilized :) |
what you mean? BS5 not support legacy browsers, then why not use custom elements? or something like Mithril components |
Although I love the idea (and it is been suggested in another issue), sure a am not the right person to take a big decision like this Until we decide to make a radical change like this, on #34519 , I tried to prepare a base for future usage, that gives the ability to use templates on BS components. |
@GeoSot don't think what this is good solution. need wrap current classes in custom elements. |
Custom elements would be a breaking change, thus this would probably be the first step for V6. But that's not possible for v5, whereas the template factory already exists. |
not BC, I'm mean something like proxy pattern |
Probably you may try to propose your ideas, making a PR as a proof of concept. You never know, it may be liked out there. |
Prerequisites
Proposal
I would like the ability to create Bootstrap elements from the modules, for example, with the toast element:
Auto-Destruction
This is not a requirement but would be a great feature if all modules implemented it so that we could specify that the element should be removed after so many milliseconds. By default, the element would live forever. I believe a very basic implementation would be something like:
Motivation and context
In Electron apps, it would be nice to generate elements such as toasts, list items, modals, etc within the preload and other renderer scripts. Currently, elements must be generated manually in a rather verbose way.
The text was updated successfully, but these errors were encountered: