-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
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
Docs: group together reusable CSS for examples in a single stylesheet #35649
Docs: group together reusable CSS for examples in a single stylesheet #35649
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds OK to me but it needs some more testing. I think CSS @import
is still considered a bad practice regarding performances, isn't it?
BTW I think some examples' styles could be replaced with new utilities. Another topic 😄
.bi { | ||
vertical-align: -.125em; | ||
pointer-events: none; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leftover could be dropped by using the pointer-events utility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed via 045faaf. I'll look into the main feedback about @import
asap.
bootstrap/site/layouts/_default/examples.html Lines 20 to 35 in f7a1b18
As it already has a shared style, maybe is fine to move it there |
I've just tested 2 different approaches by disabling cache and enabling throttling (Regular 2G). The When removing the
both the CSS files are loaded at the same time and the global downloaded time of the CSS files is 8.34s. It seems that the 2nd approach would be better for the 1st load of the With cache enabled it doesn't make any difference after the 1st load. |
Definitely not import. It's bad practice. We can instead inline it on build timel |
@GeoSot 's suggestion is good but could lead to side effects in other examples if those classes are used without such styles. Could worth a try 🙂 |
We already inline some stuff: https://github.com/twbs/bootstrap/blob/main/site/layouts/_default/examples.html#L20 |
@@ -31,6 +31,28 @@ | |||
font-size: 3.5rem; | |||
} | |||
} | |||
|
|||
.b-example-divider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ffoodd I didn't see it at first but the sidebars example displays vertical separators. So I've created here a common class grouping together color, box shadow and border. And then 2 separator classes allowing to have an horizontal one and a vertical one.
There are several ways of doing it: only use 2 classes, only put the .b-example-divider
horizontal in this file and let examples like sidebars overwrite it to make a vertical one, etc. I'd like your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think .b-example-hr
could be dropped. Its height
can be the default, and only .b-example-vr
would override it.
Apart from this suggestion, it looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 1b51e6d
.opacity-50 { opacity: .5; } | ||
.opacity-75 { opacity: .75; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess those should be dropped since utilities exist already. Maybe another PR later to refactor such styles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I will create another branch + PR to try to refactor it after the merge of this one 👌
@@ -31,6 +31,28 @@ | |||
font-size: 3.5rem; | |||
} | |||
} | |||
|
|||
.b-example-divider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think .b-example-hr
could be dropped. Its height
can be the default, and only .b-example-vr
would override it.
Apart from this suggestion, it looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too, thanks!
Description
site/layouts/_default/examples.html
.b-example-divider
,.b-example-vr
and.bi
used in several examples.Motivation & Context
This change could help the maintenance of the examples by gathering in a single place some CSS definitions reused several times in Bootstrap examples.
Types of changes
Checklist
npm run lint
)Related issues
Live previews
For non-regression testing: