Skip to content

Commit a3f1722

Browse files
committed
fix(@clayui/css): Mixins Alerts adds clay-alert-variant mixin and deprecate Bootstrap's alert-variant mixin
1 parent fca2ea2 commit a3f1722

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

packages/clay-css/src/scss/mixins/_alerts.scss

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/// This is Bootstrap 4's Alert Variant Mixin.
2+
/// @deprecated use the mixin `clay-alert-variant` instead
3+
/// @param {Color} $background
4+
/// @param {Color} $border
5+
/// @param {Color} $color
6+
17
@mixin alert-variant($background, $border, $color) {
28
@include gradient-bg($background);
39

@@ -12,3 +18,120 @@
1218
color: darken($color, 10%);
1319
}
1420
}
21+
22+
/// A mixin to create alert variants.
23+
/// @param {Map} $map - A map of `key: value` pairs. The keys and value types are listed below:
24+
/// @example
25+
/// enabled: {Bool}, // Set to false to prevent mixin styles from being output. Default: true
26+
/// hr: {Map | Null}, // See mixin `clay-css`
27+
/// alert-btn: {Map | Null}, // See mixin `clay-button-variant`
28+
/// btn-group: {Map | Null}, // See mixin `clay-container`
29+
/// btn-group-item: {Map | Null}, // See mixin `clay-container`
30+
/// close: {Map | Null}, // See mixin `clay-close`
31+
/// lead: {Map | Null}, // See mixin `clay-css`
32+
/// alert-link: {Map | Null}, // See mixin `clay-link`
33+
/// component-title: {Map | Null}, // See mixin `clay-text-typography`
34+
/// component-subtitle: {Map | Null}, // See mixin `clay-text-typography`
35+
36+
@mixin clay-alert-variant($map) {
37+
$enabled: setter(map-get($map, enabled), true);
38+
39+
$base: map-merge(
40+
$map,
41+
(
42+
background-color:
43+
setter(map-get($map, bg), map-get($map, background-color)),
44+
)
45+
);
46+
47+
$hr: setter(map-get($map, hr), ());
48+
49+
$alert-btn: setter(map-get($map, alert-btn), ());
50+
51+
$btn-group: setter(map-get($map, btn-group), ());
52+
53+
$btn-group-item: setter(map-get($map, btn-group-item), ());
54+
55+
$close: setter(map-get($map, close), ());
56+
$close: map-deep-merge(
57+
$close,
58+
(
59+
color: setter(map-get($map, close-color), map-get($close, color)),
60+
hover: (
61+
color:
62+
setter(
63+
map-get($map, close-hover-color),
64+
map-deep-get($close, hover, color)
65+
),
66+
),
67+
)
68+
);
69+
70+
$lead: setter(map-get($map, lead), ());
71+
$lead: map-deep-merge(
72+
$lead,
73+
(
74+
color: setter(map-get($map, lead-color), map-get($lead, color)),
75+
)
76+
);
77+
78+
$alert-link: setter(map-get($map, alert-link), ());
79+
$alert-link: map-deep-merge(
80+
$alert-link,
81+
(
82+
color:
83+
setter(map-get($map, link-color), map-get($alert-link, color)),
84+
hover: (
85+
color:
86+
setter(
87+
map-get($map, link-hover-color),
88+
map-deep-get($alert-link, hover, color)
89+
),
90+
),
91+
)
92+
);
93+
94+
$component-title: setter(map-get($map, component-title), ());
95+
96+
$component-subtitle: setter(map-get($map, component-subtitle), ());
97+
98+
@if ($enabled) {
99+
@include clay-css($base);
100+
101+
hr {
102+
@include clay-css($hr);
103+
}
104+
105+
.alert-btn {
106+
@include clay-button-variant($alert-btn);
107+
}
108+
109+
.btn-group {
110+
@include clay-container($btn-group);
111+
}
112+
113+
.btn-group-item {
114+
@include clay-container($btn-group-item);
115+
}
116+
117+
.close {
118+
@include clay-close($close);
119+
}
120+
121+
.lead {
122+
@include clay-css($lead);
123+
}
124+
125+
.alert-link {
126+
@include clay-link($alert-link);
127+
}
128+
129+
.component-title {
130+
@include clay-text-typography($component-title);
131+
}
132+
133+
.component-subtitle {
134+
@include clay-text-typography($component-subtitle);
135+
}
136+
}
137+
}

0 commit comments

Comments
 (0)