Skip to content

Commit a31e652

Browse files
authored
Merge pull request #1319 from roland04/devdocs-bootstrap5-compatibility-data-fix
[docs] Documentation for MDL-85127
2 parents 2a9fe5b + f93d19b commit a31e652

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

docs/guides/bs5migration/index.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Some of the Bootstrap 4 classes will be deprecated or dropped in its version 5.
3838

3939
### Badges
4040

41-
- Badge colour class helpers `.badge-*` have been replaced with background utilities (use `.bg-primary` instead of `.badge-primary`) combined with the corresponding text colour classes (`.text-dark` or `.text-white`) to meet accessibility contrast.
41+
- Badge colour class helpers `.badge-*` have been replaced with background utilities (use `.bg-primary` instead of `.badge-primary`) combined with the corresponding text colour classes (`.text-dark` or `.text-white`) to meet accessibility contrast. Or use the new `.text-bg-*` classes.
4242
- The `.badge-pill` class has been replaced with `.rounded-pill`
4343

4444
<InvalidExample title="Don't">
@@ -52,7 +52,7 @@ Some of the Bootstrap 4 classes will be deprecated or dropped in its version 5.
5252
<ValidExample title="Do">
5353

5454
```html
55-
<span class="badge bg-danger text-white rounded-pill">Error badge</span>
55+
<span class="badge text-bg-danger rounded-pill">Error badge</span>
5656
```
5757

5858
</ValidExample>
@@ -83,7 +83,7 @@ The `.media` component has been replaced with utility classes.
8383
<div class="flex-shrink-0">
8484
[...]
8585
</div>
86-
<div class="flex-grow-1 ml-3">
86+
<div class="flex-grow-1 ms-3">
8787
[...]
8888
</div>
8989
</div>
@@ -735,15 +735,15 @@ As per Bootstrap's migration guide "*Data attributes for all JavaScript plugins
735735
This feature can be used to translate old data attributes to their Bootstrap 5 equivalents, allowing existing markup to function without requiring immediate updates.
736736

737737
```js title="Example of bs4-compat silent replacement in amd module"
738-
import initBootstrap4Compatibility from 'theme_boost/bs4-compat';
738+
import * as BS4compat from 'theme_boost/bs4-compat';
739739

740740
[...]
741741

742742
// Init Bootstrap 4 compatibility giving an specific element to look into.
743-
initBootstrap4Compatibility(document.querySelector('[data-region="my-plugin-region"]'));
743+
BS4compat.init(document.querySelector('[data-region="my-plugin-region"]'));
744744

745745
// Init Bootstrap 4 compatibility in the entire document.
746-
initBootstrap4Compatibility();
746+
BS4compat.init();
747747
```
748748

749749
```mustache title="Example of bs4-compat silent replacement in a template"
@@ -752,11 +752,15 @@ initBootstrap4Compatibility();
752752
{{#js}}
753753
// Init Bootstrap 4 compatibility in the entire document.
754754
require(['theme_boost/bs4-compat'], function(BS4Compat) {
755-
BS4Compat();
755+
BS4Compat.init();
756756
});
757757
{{/js}}
758758
```
759759

760+
```php title="Example of bs4-compat silent replacement in a php file"
761+
$PAGE->requires->js_call_amd('theme_boost/bs4-compat', 'init');
762+
```
763+
760764
This will replace for example `data-toggle="tooltip"` with `data-bs-toggle="tooltip"`, or `data-target="#collapsableContent"` with `data-bs-target="#collapsableContent"`.
761765

762766
:::warning

0 commit comments

Comments
 (0)