Skip to content

Commit 538ff1c

Browse files
Used fixed positioning for Alert component (#2044)
1 parent cf44a17 commit 538ff1c

File tree

5 files changed

+58
-16
lines changed

5 files changed

+58
-16
lines changed

.changeset/fuzzy-singers-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Fixed positioning, bottom-alignment for Alert component

src/components/alert/alert.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@
6868
@include theme.styles {
6969
--theme-color-shadow-inner: #{sass-color.change(
7070
color.$brand-primary-darker,
71-
$alpha: 0.2
71+
$alpha: 0.4
7272
)};
7373
--theme-color-shadow-outer: #{sass-color.change(
7474
color.$brand-primary-darker,
75-
$alpha: 0.1
75+
$alpha: 0.2
7676
)};
7777
}
7878
@include theme.styles(dark) {

src/mixins/_spacing.scss

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@ $fluid-gap: fluid.fluid-clamp(
3636
$fluid-spacing-breakpoint-max
3737
);
3838

39-
@mixin fluid-padding-block() {
40-
padding-block: $fluid-spacing-block;
39+
@mixin fluid-padding-block($factor: 1) {
40+
padding-block: fluid.fluid-clamp(
41+
$fluid-spacing-block-min * $factor,
42+
$fluid-spacing-block-max * $factor,
43+
$fluid-spacing-breakpoint-min,
44+
$fluid-spacing-breakpoint-max
45+
);
4146
}
4247

43-
@mixin fluid-padding-inline() {
44-
padding-inline: $fluid-spacing-inline;
48+
@mixin fluid-padding-inline($factor: 1) {
49+
padding-inline: fluid.fluid-clamp(
50+
$fluid-spacing-inline-min * $factor,
51+
$fluid-spacing-inline-max * $factor,
52+
$fluid-spacing-breakpoint-min,
53+
$fluid-spacing-breakpoint-max
54+
);
4555
}
4656

4757
@mixin fluid-margin-inline-negative() {

src/objects/page/demo/example-with-alert.twig

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,34 @@
1313
</p>
1414
{% endblock %}
1515
{% block content %}
16-
<p class="u-pad-1">
17-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu ex
18-
enim. Nunc efficitur scelerisque dolor et sollicitudin. Donec finibus
19-
lorem elit, eu consectetur quam pellentesque sed. Pellentesque habitant
20-
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
21-
</p>
16+
{% embed '@cloudfour/objects/container/container.twig' with {
17+
class: 'o-container--pad'
18+
} only %}
19+
{% block content %}
20+
{% embed '@cloudfour/objects/rhythm/rhythm.twig' only %}
21+
{% block content %}
22+
<p>
23+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu ex
24+
enim. Nunc efficitur scelerisque dolor et sollicitudin. Donec finibus
25+
lorem elit, eu consectetur quam pellentesque sed. Pellentesque habitant
26+
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
27+
</p>
28+
<p>
29+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu ex
30+
enim. Nunc efficitur scelerisque dolor et sollicitudin. Donec finibus
31+
lorem elit, eu consectetur quam pellentesque sed. Pellentesque habitant
32+
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
33+
</p>
34+
<p>
35+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eu ex
36+
enim. Nunc efficitur scelerisque dolor et sollicitudin. Donec finibus
37+
lorem elit, eu consectetur quam pellentesque sed. Pellentesque habitant
38+
morbi tristique senectus et netus et malesuada fames ac turpis egestas.
39+
</p>
40+
{% endblock %}
41+
{% endembed %}
42+
{% endblock %}
43+
{% endembed %}
2244
{% endblock %}
2345
{% block footer %}
2446
<p class="u-pad-1 t-dark">

src/objects/page/page.scss

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,21 @@
3232
/**
3333
* An optional `alert` block can be used to pass an Alert component
3434
*
35-
* 1. The alert should overlap the content above slightly
35+
* 1. Use a $factor of 0.5 to allow the alert to bleed more into the
36+
* content margins instead of aligning with the content itself.
37+
* 2. Match the padding-inline for visual balance.
3638
*/
3739

3840
.o-page__alert {
39-
@include spacing.fluid-padding-inline;
41+
@include spacing.fluid-padding-inline($factor: 0.5); // 1
42+
@include spacing.fluid-padding-block($factor: 0.5); // 2
43+
4044
display: grid;
4145
grid-row: 2;
42-
inset-block-start: calc(size.$overlap-large * -1); // 1
46+
inline-size: 100%;
47+
inset-block-end: 0;
4348
justify-content: center;
44-
position: relative;
49+
position: fixed;
4550
z-index: z-index.$alert;
4651
}
4752

0 commit comments

Comments
 (0)