Optimize header layout performance with flexbox mixins#5
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThe pull request introduces four new flexbox-related Sass mixins for cross-browser compatibility and refactors four existing stylesheets to use these mixins instead of float-based layouts and direct CSS properties for alignment and spacing control. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/assets/stylesheets/common/foundation/mixins.scss (1)
117-123: Legacy flexbox prefixes require value mapping foralign-items.The legacy
-webkit-box-alignand-ms-flex-alignproperties use different keyword values than the standardalign-items. For example:
flex-start→startflex-end→endcenter→center(same)baseline→baseline(same)stretch→stretch(same)Passing values like
centerorbaselinedirectly works, butflex-start/flex-endwould fail in legacy browsers.Additionally,
-ms-align-itemson line 121 is not a valid IE property—IE10 uses-ms-flex-alignwhich is already present on line 120.♻️ Suggested fix
@mixin align-items($alignment) { -webkit-box-align: $alignment; -webkit-align-items: $alignment; - -ms-flex-align: $alignment; - -ms-align-items: $alignment; - align-items:$alignment; + -ms-flex-align: $alignment; + align-items: $alignment; }If you need to support
flex-start/flex-endvalues in legacy browsers, consider adding value mapping logic or documenting that onlycenter,baseline, andstretchare safe to use.app/assets/stylesheets/common/base/topic-post.scss (1)
263-277: Consider removing redundantfloatdeclarations.With
@include flexbox()applied to.small-action, thefloat: lefton.topic-avatar(line 270) andfloat: rightonbutton(line 309) are ignored by the browser. These declarations are now dead code.Keeping them doesn't cause harm but creates confusion about the actual layout mechanism.
♻️ Optional cleanup
.topic-avatar { padding: 5px 0; border-top: none; - float: left; i { font-size: 35px;And for the button at line 309:
button { background: transparent; border: 0; - float: right; }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
app/assets/stylesheets/common/base/header.scssapp/assets/stylesheets/common/base/topic-post.scssapp/assets/stylesheets/common/base/topic.scssapp/assets/stylesheets/common/components/badges.css.scssapp/assets/stylesheets/common/foundation/mixins.scss
🔇 Additional comments (9)
app/assets/stylesheets/common/foundation/mixins.scss (3)
125-131: Legacy box ordinal properties are 1-indexed.The
-webkit-box-ordinal-groupand-moz-box-ordinal-groupproperties expect 1-based values, while the modernorderproperty is 0-based. Iforder(0)ororder(1)is called, the behavior will be inconsistent across browsers.Consider whether your use cases always use positive integers where the off-by-one difference is acceptable, or add an offset for legacy properties:
♻️ Suggested fix with offset
@mixin order($val) { - -webkit-box-ordinal-group: $val; - -moz-box-ordinal-group: $val; + -webkit-box-ordinal-group: $val + 1; + -moz-box-ordinal-group: $val + 1; -ms-flex-order: $val; -webkit-order: $val; order: $val; }
100-106: LGTM!The
flexbox()mixin correctly includes all necessary vendor prefixes for cross-browser flex container support.
108-114: LGTM!The
inline-flex()mixin correctly includes all necessary vendor prefixes for inline flex containers.app/assets/stylesheets/common/components/badges.css.scss (1)
54-58: LGTM!Good use of the new mixins for the bullet category style. The
baselinevalue works correctly across all vendor prefixes.app/assets/stylesheets/common/base/topic-post.scss (1)
279-284: LGTM!The updated padding and color styling look appropriate for the flexbox layout.
app/assets/stylesheets/common/base/header.scss (3)
14-19: LGTM!The flexbox implementation on
.contentscorrectly centers items vertically and establishes the flex container for header layout.
35-40: Good use ofmargin-left: autowith flexbox ordering.Using
margin-left: autoto push.panelto the right edge is the idiomatic flexbox approach. Theorder(3)ensures proper visual ordering.
42-47: Verify iffloat: leftis still needed on login/sign-up buttons.With the parent
.contentsnow using flexbox,float: lefton these buttons may be redundant. However, if these buttons are within.panel(which is a flex item but not itself a flex container), the float may still apply for internal layout.Please verify the DOM structure to confirm whether these floats are intentional for internal panel layout or are now dead code.
app/assets/stylesheets/common/base/topic.scss (1)
29-36: The parent container.contentsalready has@include flexbox()applied inapp/assets/stylesheets/common/base/header.scss, so theorder(2)property will work correctly. No action needed.Likely an incorrect or invalid review comment.
Test 5
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.
Replicated from ai-code-review-evaluation/discourse-coderabbit#5