Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Cuppens <martijn.cuppens@gmail.com>2020-11-29 17:58:44 +0300
committerXhmikosR <xhmikosr@gmail.com>2020-12-04 17:15:51 +0300
commit6c069b697614a4ab9053c4f6d4a3aad75fbcaf97 (patch)
treed958f6914726b0089fa18a3d6fe0d7bab6d6c61e
parent5b0dcf8ffe6ae121722c9db571294e715b7ec52a (diff)
Add interactive positioning widget
-rw-r--r--site/assets/js/application.js11
-rw-r--r--site/content/docs/5.0/components/toasts.md44
2 files changed, 42 insertions, 13 deletions
diff --git a/site/assets/js/application.js b/site/assets/js/application.js
index 58f4e23bf2..7f6752d2cd 100644
--- a/site/assets/js/application.js
+++ b/site/assets/js/application.js
@@ -28,6 +28,17 @@
new bootstrap.Popover(popover)
})
+ var toastPlacement = document.getElementById('toastPlacement')
+ if (toastPlacement) {
+ document.getElementById('selectToastPlacement').addEventListener('change', function () {
+ if (!toastPlacement.dataset.originalClass) {
+ toastPlacement.dataset.originalClass = toastPlacement.className
+ }
+
+ toastPlacement.className = toastPlacement.dataset.originalClass + ' ' + this.value
+ })
+ }
+
document.querySelectorAll('.toast')
.forEach(function (toastNode) {
var toast = new bootstrap.Toast(toastNode, {
diff --git a/site/content/docs/5.0/components/toasts.md b/site/content/docs/5.0/components/toasts.md
index ecee0ecdf4..740a926f95 100644
--- a/site/content/docs/5.0/components/toasts.md
+++ b/site/content/docs/5.0/components/toasts.md
@@ -135,17 +135,35 @@ Building on the above example, you can create different toast color schemes with
Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you're only ever going to show one toast at a time, put the positioning styles right on the `.toast`.
-{{< example class="bg-dark bd-example-toasts p-0">}}
-<div aria-live="polite" aria-atomic="true" class="position-relative">
- <div class="toast position-absolute top-0 end-0 m-3">
- <div class="toast-header">
- {{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
- <strong class="me-auto">Bootstrap</strong>
- <small>11 mins ago</small>
- <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
- </div>
- <div class="toast-body">
- Hello, world! This is a toast message.
+{{< example >}}
+<form>
+ <div class="form-group mb-3">
+ <label for="selectToastPlacement">Toast placement</label>
+ <select class="form-select mt-2" id="selectToastPlacement">
+ <option value="" selected>Select a position...</option>
+ <option value="top-0 start-0">Top left</option>
+ <option value="top-0 start-50 translate-middle-x">Top center</option>
+ <option value="top-0 end-0">Top right</option>
+ <option value="top-50 start-0 translate-middle-y">Middle left</option>
+ <option value="top-50 start-50 translate-middle">Middle center</option>
+ <option value="top-50 end-0 translate-middle-y">Middle right</option>
+ <option value="bottom-0 start-0">Bottom left</option>
+ <option value="bottom-0 start-50 translate-middle-x">Bottom center</option>
+ <option value="bottom-0 end-0">Bottom right</option>
+ </select>
+ </div>
+</form>
+<div aria-live="polite" aria-atomic="true" class="bg-dark position-relative bd-example-toasts">
+ <div class="toast-container position-absolute p-3" id="toastPlacement">
+ <div class="toast">
+ <div class="toast-header">
+ {{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
+ <strong class="me-auto">Bootstrap</strong>
+ <small>11 mins ago</small>
+ </div>
+ <div class="toast-body">
+ Hello, world! This is a toast message.
+ </div>
</div>
</div>
</div>
@@ -158,8 +176,8 @@ For systems that generate more notifications, consider using a wrapping element
<!-- Position it: -->
<!-- - `.toast-container` for spacing between toasts -->
<!-- - `.position-absolute`, `top-0` & `end-0` to position the toasts in the upper right corner -->
- <!-- - `.m-3` to prevent the toasts from sticking to the edge of the container -->
- <div class="toast-container position-absolute top-0 end-0 m-3">
+ <!-- - `.p-3` to prevent the toasts from sticking to the edge of the container -->
+ <div class="toast-container position-absolute top-0 end-0 p-3">
<!-- Then put toasts within -->
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">