1
0
mirror of https://github.com/tabler/tabler.git synced 2026-06-17 12:50:03 +04:00

Refactor alert component styles and markup, remove Bootstrap styles (#2141)

This commit is contained in:
Paweł Kuna
2025-02-28 00:04:50 +01:00
committed by GitHub
parent 309ff40a48
commit f3c409ffc2
5 changed files with 125 additions and 96 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"@tabler/core": patch
"preview": patch
---
Refactor alert component styles and markup, remove Bootstrap styles
-1
View File
@@ -17,7 +17,6 @@
// @import "bootstrap/scss/accordion"; // @import "bootstrap/scss/accordion";
@import "bootstrap/scss/breadcrumb"; @import "bootstrap/scss/breadcrumb";
@import "bootstrap/scss/pagination"; @import "bootstrap/scss/pagination";
@import "bootstrap/scss/alert";
@import "bootstrap/scss/progress"; @import "bootstrap/scss/progress";
@import "bootstrap/scss/list-group"; @import "bootstrap/scss/list-group";
@import "bootstrap/scss/close"; @import "bootstrap/scss/close";
+74 -43
View File
@@ -1,40 +1,86 @@
.alert { .alert {
--#{$prefix}alert-color: #{var(--#{$prefix}secondary)}; --#{$prefix}alert-bg: transparent;
--#{$prefix}alert-bg: #{var(--#{$prefix}bg-surface)}; --#{$prefix}alert-padding-x: #{$alert-padding-x};
border: $alert-border-width var(--#{$prefix}border-style) $alert-border-color; --#{$prefix}alert-padding-y: #{$alert-padding-y};
border-left: .25rem var(--#{$prefix}border-style) var(--#{$prefix}alert-color); --#{$prefix}alert-margin-bottom: #{$alert-margin-bottom};
box-shadow: $alert-shadow; --#{$prefix}alert-color: inherit;
--#{$prefix}alert-border-color: var(--#{$prefix}border-color);
--#{$prefix}alert-border: var(--#{$prefix}border-width) solid var(--#{$prefix}alert-border-color);
--#{$prefix}alert-border-radius: var(--#{$prefix}border-radius);
--#{$prefix}alert-link-color: inherit;
--#{$prefix}alert-heading-font-weight: var(--#{$prefix}font-weight-medium);
>:last-child { position: relative;
margin-bottom: 0; padding: var(--#{$prefix}alert-padding-y) var(--#{$prefix}alert-padding-x);
margin-bottom: var(--#{$prefix}alert-margin-bottom);
background-color: var(--#{$prefix}alert-bg);
border-radius: var(--#{$prefix}alert-border-radius);
border: var(--#{$prefix}border-width) var(--#{$prefix}border-style) var(--#{$prefix}alert-border-color);
display: flex;
flex-direction: row;
gap: 1rem;
}
.alert-heading {
color: inherit;
margin-bottom: .25rem; // todo: use variable
font-weight: var(--#{$prefix}alert-heading-font-weight);
}
.alert-description {
color: var(--#{$prefix}secondary);
}
.alert-icon {
color: var(--#{$prefix}alert-color);
width: 1.25rem !important; // todo: use variable
height: 1.25rem !important;
}
.alert-action {
color: var(--#{$prefix}alert-color);
text-decoration: underline;
&:hover {
text-decoration: none;
}
}
.alert-list {
margin: 0;
}
.alert-link {
font-weight: $alert-link-font-weight;
color: var(--#{$prefix}alert-link-color);
&,
&:hover {
color: var(--#{$prefix}alert-color);
}
}
.alert-dismissible {
padding-right: 3rem; //todo: use variable
.btn-close {
position: absolute;
top: 0;
right: 0;
z-index: 1;
padding: calc(var(--#{$prefix}alert-padding-y) * 1.25) var(--#{$prefix}alert-padding-x);
} }
} }
.alert-important { .alert-important {
border-color: transparent; border-color: var(--#{$prefix}alert-color);
background: var(--#{$prefix}alert-color); color: var(--#{$prefix}alert-color);
color: #fff;
.alert-icon, .btn-close,
.alert-link, .alert-description {
.alert-title {
color: inherit; color: inherit;
} }
.alert-link:hover {
color: inherit;
}
.btn-close {
filter: var(--#{$prefix}btn-close-white-filter);
}
}
.alert-link, {
&,
&:hover {
color: var(--#{$prefix}alert-color);
}
} }
@each $name, $color in $theme-colors { @each $name, $color in $theme-colors {
@@ -42,18 +88,3 @@
--#{$prefix}alert-color: var(--#{$prefix}#{$name}); --#{$prefix}alert-color: var(--#{$prefix}#{$name});
} }
} }
.alert-icon {
color: var(--#{$prefix}alert-color);
width: 1.5rem !important;
height: 1.5rem !important;
margin: -.125rem $alert-padding-x -.125rem 0;
}
.alert-title {
font-size: $h4-font-size;
line-height: $h4-line-height;
font-weight: var(--#{$prefix}font-weight-bold);
margin-bottom: .25rem;
color: var(--#{$prefix}alert-color);
}
+24 -27
View File
@@ -2,43 +2,44 @@
{% unless icon %} {% unless icon %}
{% if include.type == 'success' %} {% if include.type == 'success' %}
{% assign icon = 'check' %} {% assign icon = 'check' %}
{% assign title = 'Wow! Everything worked!' %}
{% assign description = 'Your account has been saved!' %}
{% elsif include.type == 'warning' %} {% elsif include.type == 'warning' %}
{% assign icon = 'alert-triangle' %} {% assign icon = 'alert-triangle' %}
{% assign title = 'Uh oh, something went wrong' %}
{% assign description = 'Sorry! There was a problem with your request.' %}
{% elsif include.type == 'danger' %} {% elsif include.type == 'danger' %}
{% assign icon = 'alert-circle' %} {% assign icon = 'alert-circle' %}
{% assign title = "I'm so sorry…" %}
{% assign description = 'Something went wrong. Please try again.' %}
{% elsif include.type == 'info' %} {% elsif include.type == 'info' %}
{% assign icon = 'info-circle' %} {% assign icon = 'info-circle' %}
{% assign title = 'Did you know?' %}
{% assign description = 'Here is something that you might like to know.' %}
{% endif %} {% endif %}
{% endunless %} {% endunless %}
<div class="alert{% if include.important %} alert-important{% endif %} alert-{{ include.type | default: 'primary'}}{%if include.show-close %} alert-dismissible{% endif %}{% if include.avatar %} alert-avatar{% endif %}" role="alert"> <div class="alert{% if include.important %} alert-important{% endif %} alert-{{ include.type | default: 'primary'}}{%if include.show-close %} alert-dismissible{% endif %}{% if include.avatar %} alert-avatar{% endif %}" role="alert">
{% if include.show-icon or include.person-id %} <div class="alert-icon">
<div class="d-flex"> {% include "ui/icon.html" icon=icon class="alert-icon" %}
<div> </div>
{% if include.person-id %}{% include "ui/avatar.html" person-id=include.person-id class="float-start me-3" %}{% endif %}
{% if include.show-icon %} {% if include.description or include.list %}
{% include "ui/icon.html" icon=icon class="alert-icon" %} <div>
{% endif %} <h4 class="alert-heading">{{ include.title | default: "This is a custom alert box!" }}</h4>
<div class="alert-description">
{{ include.description | default: description }}
{% if include.list %}
{% assign items = include.list | split: ',' %}
<ul class="alert-list">
{% for item in items %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div> </div>
<div>
{% endif %}
{% if include.show-description or include.description %}
<h4 class="alert-title">{{ include.text | default: "This is a custom alert box!" }}</h4>
<div class="text-secondary">{{ include.description | default: description }}</div>
{% else %} {% else %}
{{ include.title | default: title }} {{ include.title | default: "This is a custom alert box!" }}
{% if include.action %}
<a href="#" class="alert-action">
Link
</a>
{% endif %}
{% endif %} {% endif %}
{% if include.buttons %} {% if include.buttons %}
@@ -48,10 +49,6 @@
</div> </div>
{% endif %} {% endif %}
{% if include.show-icon or include.person-id %}
</div>
</div>
{% endif %}
{% if include.show-close %}<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>{% endif %} {% if include.show-close %}<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>{% endif %}
</div> </div>
+21 -25
View File
@@ -11,23 +11,21 @@ permalink: alerts.html
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h2 class="card-title">Basic alerts</h2> <h2 class="card-title">Basic alerts</h2>
<p class="text-secondary">Wrap any text and an optional dismiss button in <code>.alert</code> and one of the four contextual classes (e.g., <code>.alert-success</code>) for basic alert messages.</p> {% include "ui/alert.html" type="danger" title="An error occurred!" %}
{% include "ui/alert.html" type="success" %} {% include "ui/alert.html" type="warning" title="Some information is missing!" %}
{% include "ui/alert.html" type="warning" %} {% include "ui/alert.html" type="success" title="Completed successfully!" %}
{% include "ui/alert.html" type="danger" %} {% include "ui/alert.html" type="info" title="Just a quick note!" %}
{% include "ui/alert.html" type="info" %}
</div> </div>
</div> </div>
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h2 class="card-title">Alerts with icon</h2> <h2 class="card-title">Alerts with action</h2>
<p class="text-secondary">Build on any alert by adding an optional icon.</p> {% include "ui/alert.html" show-close action="Link" type="danger" title="An error occurred!" %}
{% include "ui/alert.html" type="success" show-icon=true %} {% include "ui/alert.html" show-close action="Link" type="warning" title="Some information is missing!" %}
{% include "ui/alert.html" type="warning" show-icon=true %} {% include "ui/alert.html" show-close action="Link" type="success" title="Completed successfully!" %}
{% include "ui/alert.html" type="danger" show-icon=true %} {% include "ui/alert.html" show-close action="Link" type="info" title="Just a quick note!" %}
{% include "ui/alert.html" type="info" show-icon=true %}
</div> </div>
</div> </div>
</div> </div>
@@ -35,11 +33,10 @@ permalink: alerts.html
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h2 class="card-title">Dismissible alerts</h2> <h2 class="card-title">Dismissible alerts</h2>
<p class="text-secondary">Build on any alert by adding an optional <code>.alert-dismissible</code> and close button.</p> {% include "ui/alert.html" show-close type="danger" title="An error occurred!" %}
{% include "ui/alert.html" type="success" show-icon=true show-close=true %} {% include "ui/alert.html" show-close type="warning" title="Some information is missing!" %}
{% include "ui/alert.html" type="warning" show-icon=true show-close=true %} {% include "ui/alert.html" show-close type="success" title="Completed successfully!" %}
{% include "ui/alert.html" type="danger" show-icon=true show-close=true %} {% include "ui/alert.html" show-close type="info" title="Just a quick note!" %}
{% include "ui/alert.html" type="info" show-icon=true show-close=true %}
</div> </div>
</div> </div>
</div> </div>
@@ -47,11 +44,10 @@ permalink: alerts.html
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h2 class="card-title">Alert with a description</h2> <h2 class="card-title">Alert with a description</h2>
<p class="text-secondary">Add a description to the alert to provide additional information.</p> {% include "ui/alert.html" show-close type="danger" title="Password does not meet requirements:" list="Minimum 8 characters,Include a special character" %}
{% include "ui/alert.html" type="success" show-description=true show-icon=true %} {% include "ui/alert.html" show-close type="warning" title="Some information is missing!" description="This is a custom alert box with a description." %}
{% include "ui/alert.html" type="warning" show-description=true show-icon=true %} {% include "ui/alert.html" show-close type="success" title="Completed successfully!" description="This is a custom alert box with a description." %}
{% include "ui/alert.html" type="danger" show-description=true show-icon=true %} {% include "ui/alert.html" show-close type="info" title="Just a quick note!" description="This is a custom alert box with a description." %}
{% include "ui/alert.html" type="info" show-description=true show-icon=true %}
</div> </div>
</div> </div>
</div> </div>
@@ -59,10 +55,10 @@ permalink: alerts.html
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h2 class="card-title">Important alerts</h2> <h2 class="card-title">Important alerts</h2>
{% include "ui/alert.html" important=true type="success" show-icon=true show-close=true %} {% include "ui/alert.html" show-close important=true type="danger" title="Password does not meet requirements:" list="Minimum 8 characters,Include a special character" %}
{% include "ui/alert.html" important=true type="warning" show-icon=true show-close=true %} {% include "ui/alert.html" show-close important=true type="success" description="This is a custom alert box with a description." %}
{% include "ui/alert.html" important=true type="danger" show-icon=true show-close=true %} {% include "ui/alert.html" show-close important=true type="warning" description="This is a custom alert box with a description." %}
{% include "ui/alert.html" important=true type="info" show-icon=true show-close=true %} {% include "ui/alert.html" show-close important=true type="info" description="This is a custom alert box with a description." %}
</div> </div>
</div> </div>
</div> </div>