Skip to content
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 Bootstrap5 template then set it to default #25

Merged
merged 5 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ The Config file consists of two properties.

The `$template` property sets the path to the View file which will be used to format your
alerts. The default template has HTML tags and classes designed for use with
[Bootstrap 4 Alerts](https://getbootstrap.com/docs/4.6/components/alerts/), but the library
[Bootstrap 5 Alerts](https://getbootstrap.com/docs/5.2/components/alerts/), but the library
includes additional templates for you to choose:
* `Tatter\Alerts\Views\Bootstrap4`: Compatible with the Bootstrap 4 CSS Framework
* `Tatter\Alerts\Views\Foundation`: Compatible with the Foundation CSS Framework
* `Tatter\Alerts\Views\Vanilla`: A framework-free implementation, with classes available for your own CSS styling

Expand Down
2 changes: 1 addition & 1 deletion src/Config/Alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Alerts extends BaseConfig
/**
* Template to use for HTML output.
*/
public string $template = 'Tatter\Alerts\Views\Bootstrap4';
public string $template = 'Tatter\Alerts\Views\Bootstrap5';

/**
* Mapping of Session keys to their CSS classes.
Expand Down
9 changes: 9 additions & 0 deletions src/Views/Bootstrap5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

<?php foreach ($alerts as $alert): ?>
<?php [$class, $content] = $alert; ?>
<div role="alert" class="alert alert-<?= $class ?> alert-dismissible fade show">
<?= $content ?>

<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php endforeach; ?>