Skip to content

Commit d1d5606

Browse files
julien-deramondmdo
andauthored
Wrap alert text content in <p> to fix flex gap issue and improve semantics (#42175)
* Wrap alert text content in `<p>` to fix flex gap issue and improve semantics * bump --------- Co-authored-by: Mark Otto <markdotto@gmail.com>
1 parent 339f94d commit d1d5606

8 files changed

Lines changed: 21 additions & 19 deletions

File tree

.bundlewatch.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
},
2323
{
2424
"path": "./dist/css/bootstrap-utilities.min.css",
25-
"maxSize": "14.0 kB"
25+
"maxSize": "14.25 kB"
2626
},
2727
{
2828
"path": "./dist/css/bootstrap.css",
2929
"maxSize": "43.0 kB"
3030
},
3131
{
3232
"path": "./dist/css/bootstrap.min.css",
33-
"maxSize": "39.5 kB"
33+
"maxSize": "40.0 kB"
3434
},
3535
{
3636
"path": "./dist/js/bootstrap.bundle.js",

js/tests/visual/alert.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h1>Alert <small>Bootstrap Visual Test</small></h1>
1212

1313
<div class="alert theme-warning alert-dismissible fade show" role="alert">
1414
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
15-
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
15+
<p><strong>Holy guacamole!</strong> You should check in on some of those fields below.</p>
1616
</div>
1717

1818
<div class="alert theme-danger alert-dismissible fade show" role="alert">
@@ -39,7 +39,7 @@ <h1>Alert <small>Bootstrap Visual Test</small></h1>
3939

4040
<div class="alert theme-warning alert-dismissible fade show" role="alert" style="transition-duration: 5s;">
4141
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
42-
This alert will take 5 seconds to fade out.
42+
<p>This alert will take 5 seconds to fade out.</p>
4343
</div>
4444
</div>
4545

scss/_alert.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ $alert-tokens: defaults(
3838
@include border-radius(var(--alert-border-radius));
3939
}
4040

41+
.alert > p {
42+
margin-bottom: 0;
43+
}
44+
4145
.alert-heading {
4246
// Specified to prevent conflicts of changing $headings-color
4347
color: inherit;

site/src/assets/examples/cheatsheet/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ export const body_class = 'bg-body-tertiary'
652652
<div>
653653
<Example showMarkup={false} code={getData('theme-colors').map((themeColor) => `
654654
<div class="alert theme-${themeColor.name} alert-dismissible fade show mb-3" role="alert">
655-
A simple ${themeColor.name} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
655+
<p>A simple ${themeColor.name} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.</p>
656656
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
657657
</div>
658658
`)} />

site/src/assets/partials/snippets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default () => {
8686
const wrapper = document.createElement('div')
8787
wrapper.innerHTML = [
8888
`<div class="alert theme-${type} alert-dismissible" role="alert">`,
89-
` <div>${message}</div>`,
89+
` <p>${message}</p>`,
9090
' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
9191
'</div>'
9292
].join('')

site/src/content/docs/components/alert.mdx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import { getData } from '@libs/data'
1313
Alerts are available for any length of text, as well as an optional close button. Alerts are designed to be used with theme colors, but have neutral fallback colors for when no theme color is applied. For inline dismissal, use the [alerts JavaScript plugin](#dismiss).
1414

1515
<Example code={`<div class="alert" role="alert">
16-
A simple alert—check it out!
16+
<p>A simple alert—check it out!</p>
1717
</div>`} />
1818

1919
## Variants
2020

2121
Use any of our variant theme classes for color mode adaptive, contextual styling.
2222

2323
<Example class="vstack gap-3" code={getData('theme-colors').map((themeColor) => `<div class="alert theme-${themeColor.name}" role="alert">
24-
A simple ${themeColor.name} alert—check it out!
24+
<p>A simple ${themeColor.name} alert—check it out!</p>
2525
</div>`)} />
2626

2727
<Details name="warning-color-assistive-technologies" />
@@ -42,7 +42,7 @@ We use the following JavaScript to trigger our live alert demo:
4242
Use the `.alert-link` utility class to quickly provide matching colored links within any alert.
4343

4444
<Example class="vstack gap-3" code={getData('theme-colors').map((themeColor) => `<div class="alert theme-${themeColor.name}" role="alert">
45-
A simple ${themeColor.name} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
45+
<p>A simple ${themeColor.name} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.</p>
4646
</div>`)} />
4747

4848
## Additional content
@@ -66,9 +66,7 @@ Similarly, you can use [flexbox utilities]([[docsref:/utilities/flex]]) and [Boo
6666
<svg xmlns="http://www.w3.org/2000/svg" class="bi flex-shrink-0" viewBox="0 0 16 16" role="img" aria-label="Warning:">
6767
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
6868
</svg>
69-
<div>
70-
An example alert with an icon
71-
</div>
69+
<p>An example alert with an icon</p>
7270
</div>`} />
7371

7472
## Dismiss
@@ -83,7 +81,7 @@ Using the alert JavaScript plugin, it’s possible to dismiss any alert inline.
8381
You can see this in action with a live demo:
8482

8583
<Example code={`<div class="alert theme-warning alert-dismissible fade show" role="alert">
86-
Something’s wrong, check the fields below and try again.
84+
<p>Something’s wrong, check the fields below and try again.</p>
8785
<CloseButton dismiss="alert" class="ms-auto" />
8886
</div>`} />
8987

site/src/content/docs/components/offcanvas.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ To make a responsive offcanvas, replace the `.offcanvas` base class with a respo
169169

170170
<Example code={`<button class="btn-solid theme-primary d-lg-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasResponsive" aria-controls="offcanvasResponsive">Toggle offcanvas</button>
171171
172-
<div class="alert theme-info d-none d-lg-block">Resize your browser to show the responsive offcanvas toggle.</div>
172+
<div class="alert theme-info d-none d-lg-block"><p>Resize your browser to show the responsive offcanvas toggle.</p></div>
173173
174174
<div class="offcanvas-lg offcanvas-end" tabindex="-1" id="offcanvasResponsive" aria-labelledby="offcanvasResponsiveLabel">
175175
<div class="offcanvas-header">

site/src/content/docs/customize/theme.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Here's the same set of components rendered in both light and dark modes side by
211211
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
212212
</div>
213213
</div>
214-
<div class="alert theme-primary">This is a primary alert.</div>
214+
<div class="alert theme-primary"><p>This is a primary alert.</p></div>
215215
<input type="text" class="form-control" placeholder="Form control">
216216
<div class="checkgroup">
217217
<div class="check">
@@ -236,7 +236,7 @@ Here's the same set of components rendered in both light and dark modes side by
236236
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
237237
</div>
238238
</div>
239-
<div class="alert theme-primary">This is a primary alert.</div>
239+
<div class="alert theme-primary"><p>This is a primary alert.</p></div>
240240
<input type="text" class="form-control" placeholder="Form control">
241241
<div class="checkgroup">
242242
<div class="check">
@@ -271,7 +271,7 @@ We generate theme utility classes from the `$theme-colors` Sass map that make al
271271

272272
With theme utilities, you can apply a theme color to an element with a single class.
273273

274-
<Example class="vstack gap-3" code={`<div class="alert theme-primary">Primary alert</div>
274+
<Example class="vstack gap-3" code={`<div class="alert theme-primary"><p>Primary alert</p></div>
275275
<div>
276276
<button type="button" class="btn-solid theme-primary">Primary button</button>
277277
<button type="button" class="btn-outline theme-primary">Primary outline button</button>
@@ -286,7 +286,7 @@ With theme utilities, you can apply a theme color to an element with a single cl
286286
And you can apply a theme color utility to a container and any theme-aware children will inherit the theme color.
287287

288288
<Example code={`<div class="vstack gap-3 theme-primary">
289-
<div class="alert">Primary alert</div>
289+
<div class="alert"><p>Primary alert</p></div>
290290
<div>
291291
<button type="button" class="btn-solid">Primary button</button>
292292
<button type="button" class="btn-outline">Primary outline button</button>
@@ -302,7 +302,7 @@ And you can apply a theme color utility to a container and any theme-aware child
302302
This also means you can override a container's theme color with another theme color on specific components.
303303

304304
<Example code={`<div class="vstack gap-3 theme-primary">
305-
<div class="alert">Primary alert</div>
305+
<div class="alert"><p>Primary alert</p></div>
306306
<div>
307307
<button type="button" class="btn-solid theme-emphasis">Emphasis button</button>
308308
<button type="button" class="btn-outline">Primary outline button</button>

0 commit comments

Comments
 (0)