Skip to content

Commit f68cda9

Browse files
dlouhakliterat
authored andcommitted
Feat(web): Add feature flag to suppress margin-collapsing when using Container #DS-1905
1 parent 6eaf018 commit f68cda9

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

packages/web/src/scss/components/Container/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,22 @@ Responsive values can be defined using the `tablet` and `desktop` infixes.
5252
```html
5353
<div class="Container text-center text-tablet-right text-desktop-left">Content with responsive text alignment</div>
5454
```
55+
56+
## Feature Flag: Block Formatting Context
57+
58+
This feature is behind the `enable-v5-container-block-formatting-context` feature flag.
59+
60+
When the feature flag is enabled, the Container root element will create a new block formatting context
61+
by applying `flow-root` display property. This helps to manage the layout of floated children elements
62+
inside the Container or prevent margin collapsing issues.
63+
64+
For more info, see main [README][readme-feature-flags].
65+
66+
### ⚠️ DEPRECATION NOTICE
67+
68+
The property which sets a new block formatting context to Container root element will be part of the next major release.
69+
70+
[What are deprecations?][readme-deprecations]
71+
72+
[readme-feature-flags]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web/README.md#feature-flags
73+
[readme-deprecations]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web/README.md#deprecations

packages/web/src/scss/components/Container/_Container.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
// 1. Establishes a new block formatting context,
2+
// which contains its floats and prevents margin collapsing.
3+
14
@use '@tokens' as tokens;
5+
@use '../../settings/feature-flags';
26
@use '../../tools/dictionaries';
37
@use 'theme';
48
@use 'tools';
@@ -9,6 +13,12 @@
913
width: 100%;
1014
padding-inline: var(--container-padding-inline);
1115
margin-inline: auto;
16+
17+
// @deprecated The feature flag will be removed in the next major version.
18+
// Migration: delete this feature flag and apply the flow-root display property by default.
19+
@if feature-flags.$enable-v5-container-block-formatting-context {
20+
display: flow-root; // 1.
21+
}
1222
}
1323

1424
@include dictionaries.generate-sizes(
@@ -20,3 +30,9 @@
2030
.Container:not(.Container--fluid) {
2131
max-width: var(--#{tokens.$css-variable-prefix}container-max-width, #{theme.$container-max-width});
2232
}
33+
34+
// @deprecated The feature flag will be removed in the next major version.
35+
// Migration: delete this feature flag and apply the flow-root display property by default.
36+
.spirit-feature-enable-v5-container-block-formatting-context .Container {
37+
display: flow-root; // 1.
38+
}

packages/web/src/scss/components/Container/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,17 @@ <h2 class="docs-Heading">Text Alignment</h2>
6464
</div>
6565
</section>
6666

67+
<section class="py-900 py-tablet-1000">
68+
<div class="Container">
69+
<h2 class="docs-Heading">Feature Flag: Block Formatting Context</h2>
70+
</div>
71+
<div class="spirit-feature-enable-v5-container-block-formatting-context">
72+
<div class="Container">
73+
<div class="docs-Box">
74+
Container
75+
</div>
76+
</div>
77+
</div>
78+
</section>
79+
6780
{{/web/layout/default }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$enable-v5-container-block-formatting-context: false !default;

0 commit comments

Comments
 (0)