Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS: Add a debugger class. #40976

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .bundlewatch.config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"files": [
{
"path": "./dist/css/bootstrap-debugger.css",
"maxSize": "0.75 kB"
},
{
"path": "./dist/css/bootstrap-debugger.min.css",
"maxSize": "0.75 kB"
},
{
"path": "./dist/css/bootstrap-grid.css",
"maxSize": "6.5 kB"
"maxSize": "7.0 kB"
},
{
"path": "./dist/css/bootstrap-grid.min.css",
"maxSize": "6.0 kB"
"maxSize": "6.25 kB"
},
{
"path": "./dist/css/bootstrap-reboot.css",
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ Within the download you'll find the following directories and files, logically g
```text
bootstrap/
├── css/
│ ├── bootstrap-debugger.css
│ ├── bootstrap-debugger.css.map
│ ├── bootstrap-debugger.min.css
│ ├── bootstrap-debugger.min.css.map
│ ├── bootstrap-debugger.rtl.css
│ ├── bootstrap-debugger.rtl.css.map
│ ├── bootstrap-debugger.rtl.min.css
│ ├── bootstrap-debugger.rtl.min.css.map
│ ├── bootstrap-grid.css
│ ├── bootstrap-grid.css.map
│ ├── bootstrap-grid.min.css
Expand Down
44 changes: 44 additions & 0 deletions scss/_debug.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@if $enable-debugger-classes {
.#{$prefix}grid-debug {
&::before {
position: fixed;
top: 0;
left: 0;
z-index: 2000;
padding: $spacer * .5 $spacer;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this use em unit instead of rem unit for padding? Then it may adjust itself by its font size.

font-family: $font-family-base;
color: $black;
background-color: $white;
border-radius: 0 0 4px; // stylelint-disable-line property-disallowed-list
@include font-size($h1-font-size);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this get font size from css a variable? then we may able to adjust it like <body style="--bs-debug-label-font-size: 15px;">

}

@each $breakpoint, $value in $grid-breakpoints {
@include media-breakpoint-up($breakpoint) {
&::before {
content: "#{$breakpoint}";
}
}
}

[class^="container"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide this functionality as a seperated class name?

Copy link
Member Author

@louismaximepiton louismaximepiton Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not, I don't have strong opinion on this. I did it this way because on my project, we use sometimes .row and sometimes .container-* with .col-* inside. Do you have any cool name to propose ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature looks nice but the developer may want to toggle on/off this option to make the design look more clear and understandable.

You know, design considerations call for pixel-perfect work, and the overlay of this option can become annoying at some point.

.bs-debug-grid-marks, .bs-debug-grid-cols or something else like to understand of the purpose this utility.

It would be better if it does not have any connection with the other class name. The developer can use whatever he/she wants like <body class="bs-debug-grid-breakpoints bs-debug-grid-marks">

&[class^="container"],
.row,
&.row {
position: relative;

&::before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1999;
pointer-events: none;
content: "";
background: repeating-linear-gradient(to right, transparent, transparent calc(var(--#{$prefix}gutter-x) * .5), var(--#{$prefix}primary) calc(var(--#{$prefix}gutter-x) * .5), var(--#{$prefix}primary) calc((100% - 12 * var(--#{$prefix}gutter-x)) / 12 + var(--#{$prefix}gutter-x) * .5), transparent calc((100% - 12 * var(--#{$prefix}gutter-x)) / 12 + var(--#{$prefix}gutter-x) * .5), transparent calc(100% / 12)); // stylelint-disable-line function-disallowed-list
opacity: .3;
}
}
}
}
1 change: 1 addition & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ $enable-validation-icons: true !default;
$enable-negative-margins: false !default;
$enable-deprecation-messages: true !default;
$enable-important-utilities: true !default;
$enable-debugger-classes: true !default;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default value looks true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's done on purpose at the moment to be able to test it on the deploy preview but I think it will go to false before getting merged.


$enable-dark-mode: true !default;
$color-mode-type: data !default; // `data` or `media-query`
Expand Down
7 changes: 7 additions & 0 deletions scss/bootstrap-debugger.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$enable-debugger-classes: true !default;

@import "functions";
@import "variables";
@import "mixins";

@import "debug";
1 change: 1 addition & 0 deletions scss/bootstrap-grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ $utilities: map-get-multiple(
"padding-start",
)
);
@import "debug";

@import "utilities/api";
1 change: 1 addition & 0 deletions scss/bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

// Helpers
@import "helpers";
@import "debug";

// Utilities
@import "utilities/api";
Expand Down
1 change: 1 addition & 0 deletions site/content/docs/5.3/customize/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You can find and customize these variables for key global options in Bootstrap's
| `$enable-caret` | `true` (default) or `false` | Enables pseudo element caret on `.dropdown-toggle`. |
| `$enable-button-pointers` | `true` (default) or `false` | Add "hand" cursor to non-disabled button elements. |
| `$enable-rfs` | `true` (default) or `false` | Globally enables [RFS]({{< docsref "/getting-started/rfs" >}}). |
| `$enable-debugger-classes` | `true` or `false` (default) | Enables the use of `.bs-grid-debug` class. You can use it on any html element and it will highlight its children grids (`.row` and `.container-*`). It also displays the living breakpoint depending on the viewport. |
| `$enable-validation-icons` | `true` (default) or `false` | Enables `background-image` icons within textual inputs and some custom forms for validation states. |
| `$enable-negative-margins` | `true` or `false` (default) | Enables the generation of [negative margin utilities]({{< docsref "/utilities/spacing#negative-margin" >}}). |
| `$enable-deprecation-messages` | `true` (default) or `false` | Set to `false` to hide warnings when using any of the deprecated mixins and functions that are planned to be removed in `v6`. |
Expand Down
9 changes: 9 additions & 0 deletions site/content/docs/5.3/getting-started/contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ Once downloaded, unzip the compressed folder and you'll see something like this:
```text
bootstrap/
├── css/
│ ├── bootstrap-debugger.css
│ ├── bootstrap-debugger.css.map
│ ├── bootstrap-debugger.min.css
│ ├── bootstrap-debugger.min.css.map
│ ├── bootstrap-debugger.rtl.css
│ ├── bootstrap-debugger.rtl.css.map
│ ├── bootstrap-debugger.rtl.min.css
│ ├── bootstrap-debugger.rtl.min.css.map
│ ├── bootstrap-grid.css
│ ├── bootstrap-grid.css.map
│ ├── bootstrap-grid.min.css
Expand Down Expand Up @@ -72,6 +80,7 @@ Bootstrap includes a handful of options for including some or all of our compile
| CSS files | Layout | Content | Components | Utilities |
| --- | --- | --- | --- | --- |
| `bootstrap.css`<br> `bootstrap.min.css`<br> `bootstrap.rtl.css`<br> `bootstrap.rtl.min.css` | Included | Included | Included | Included |
| `bootstrap-debugger.css`<br> `bootstrap-debugger.rtl.css`<br> `bootstrap-debugger.min.css`<br> `bootstrap-debugger.rtl.min.css` | [Only debug classes]({{< docsref "/customize/options" >}}) | — | — | — |
| `bootstrap-grid.css`<br> `bootstrap-grid.rtl.css`<br> `bootstrap-grid.min.css`<br> `bootstrap-grid.rtl.min.css` | [Only grid system]({{< docsref "/layout/grid" >}}) | — | — | [Only flex utilities]({{< docsref "/utilities/flex" >}}) |
| `bootstrap-utilities.css`<br> `bootstrap-utilities.rtl.css`<br> `bootstrap-utilities.min.css`<br> `bootstrap-utilities.rtl.min.css` | — | — | — | Included |
| `bootstrap-reboot.css`<br> `bootstrap-reboot.rtl.css`<br> `bootstrap-reboot.min.css`<br> `bootstrap-reboot.rtl.min.css` | — | [Only Reboot]({{< docsref "/content/reboot" >}}) | — | — |
Expand Down