Skip to content

Commit

Permalink
feat: add live alert type selection
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadSalman11 committed Feb 3, 2025
1 parent 5708adc commit 31aec5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion site/assets/js/partials/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ export default () => {
}

const alertTrigger = document.getElementById('liveAlertBtn')
const selectAlertType = document.getElementById('liveAlertType')
if (alertTrigger) {
alertTrigger.addEventListener('click', () => {
appendAlert('Nice, you triggered this alert message!', 'success')
const alertType = selectAlertType.value
appendAlert('Nice, you triggered this alert message!', alertType)
})
}
// js-docs-end live-alert
Expand Down
12 changes: 12 additions & 0 deletions site/content/docs/5.3/components/alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,19 @@ Click the button below to show an alert (hidden with inline styles to start), th

{{< example stackblitz_add_js="true" >}}
<div id="liveAlertPlaceholder"></div>
<div class="d-flex align-items-center gap-2">
<button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button>
<select id="liveAlertType" class="form-select w-auto d-inline-block">
<option value="primary">Primary</option>
<option value="secondary">Secondary</option>
<option value="success" selected>Success</option>
<option value="danger">Danger</option>
<option value="warning">Warning</option>
<option value="info">Info</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</div>
{{< /example >}}

We use the following JavaScript to trigger our live alert demo:
Expand Down

0 comments on commit 31aec5c

Please sign in to comment.