-
Notifications
You must be signed in to change notification settings - Fork 48
Optimize header layout performance with flexbox mixins #5
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
base: header-layout-optimization-pre
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,10 +13,9 @@ | |
|
|
||
| .contents { | ||
| margin: 8px 0; | ||
| } | ||
|
|
||
| .title { | ||
| float: left; | ||
| @include flexbox(); | ||
| @include align-items(center); | ||
| } | ||
|
|
||
| .valign-helper { | ||
|
|
@@ -34,8 +33,10 @@ | |
| } | ||
|
|
||
| .panel { | ||
| float: right; | ||
| position: relative; | ||
| margin-left: auto; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking — logged-out / no-JS visitors lose right-alignment of the header login button. .panel {
position: relative;
float: right; // right-aligns in block-flow .row (no-JS/anonymous header)
margin-left: auto; // right-aligns as a flex item in the JS header (float ignored there)
@include order(3);
}There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking — logged-out / no-JS visitors lose right-alignment of the login panel. .panel {
position: relative;
float: right; /* fallback for server-rendered .row path */
margin-left: auto; /* flex path: push to the right edge */
@include order(3);
} |
||
|
|
||
| @include order(3); | ||
| } | ||
|
|
||
| .login-button, button.sign-up-button { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -261,6 +261,9 @@ table.md-table { | |
| } | ||
|
|
||
| .small-action { | ||
| @include flexbox(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — .topic-avatar {
padding: 5px 0;
border-top: none;
/* float: left removed — inert on a flex item */
i { ... }
}``` |
||
| @include align-items(center); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — dead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — .topic-avatar {
padding: 5px 0;
border-top: none;
i {
font-size: 35px;
width: 45px;
text-align: center;
color: lighten($primary, 75%);
}
} |
||
|
|
||
| .topic-avatar { | ||
| padding: 5px 0; | ||
| border-top: none; | ||
|
|
@@ -274,8 +277,7 @@ table.md-table { | |
| } | ||
|
|
||
| .small-action-desc { | ||
| padding: 0.5em 0 0.5em 4em; | ||
| margin-top: 5px; | ||
| padding: 0 1.5%; | ||
| text-transform: uppercase; | ||
| font-weight: bold; | ||
| font-size: 0.9em; | ||
|
|
@@ -287,7 +289,7 @@ table.md-table { | |
| font-weight: normal; | ||
| font-size: 14px; | ||
| p { | ||
| margin: 5px 0; | ||
| margin: 0; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -298,7 +300,6 @@ table.md-table { | |
|
|
||
| > p { | ||
| margin: 0; | ||
| padding-top: 4px; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,11 +27,11 @@ | |
| } | ||
|
|
||
| .extra-info-wrapper { | ||
| @include order(2); | ||
|
|
||
| line-height: 1.5; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — bullet badge loses its top margin. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — bullet badge loses its 5px top offset; the replacement is not equivalent. The |
||
| .badge-wrapper { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — bullet badge lost its 5px top offset; the replacement is not equivalent. The .extra-info-wrapper {
@include order(2);
line-height: 1.5;
.badge-wrapper {
float: left;
&.bullet {
margin-top: 5px; // restore if alignment regressed
}
}
}``` |
||
| float: left; | ||
| &.bullet { | ||
| margin-top: 5px; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,3 +92,40 @@ | |
| -moz-user-select: none; | ||
| -ms-user-select: none; | ||
| } | ||
|
|
||
| // --------------------------------------------------- | ||
|
|
||
| //Flexbox | ||
|
|
||
| @mixin flexbox() { | ||
| display: -webkit-box; | ||
| display: -moz-box; | ||
| display: -ms-flexbox; | ||
| display: -webkit-flex; | ||
| display: flex; | ||
| } | ||
|
|
||
| @mixin inline-flex() { | ||
| display: -webkit-inline-box; | ||
| display: -webkit-inline-flex; | ||
| display: -moz-inline-box; | ||
| display: -ms-inline-flexbox; | ||
| display: inline-flex; | ||
| } | ||
|
|
||
|
|
||
| @mixin align-items($alignment) { | ||
| -webkit-box-align: $alignment; | ||
| -webkit-align-items: $alignment; | ||
| -ms-flex-align: $alignment; | ||
| -ms-align-items: $alignment; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — invalid CSS property. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — @mixin align-items($alignment) {
-webkit-box-align: $alignment;
-webkit-align-items: $alignment;
-ms-flex-align: $alignment;
align-items: $alignment;
}```There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Non-blocking — @mixin align-items($alignment) {
-webkit-box-align: $alignment;
-webkit-align-items: $alignment;
-ms-flex-align: $alignment;
align-items: $alignment;
} |
||
| align-items:$alignment; | ||
| } | ||
|
|
||
| @mixin order($val) { | ||
| -webkit-box-ordinal-group: $val; | ||
| -moz-box-ordinal-group: $val; | ||
| -ms-flex-order: $val; | ||
| -webkit-order: $val; | ||
| order: $val; | ||
| } | ||
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.
🟡 Non-blocking — anonymous/no-JS header loses panel right-alignment.
.panellost itsfloat: rightand now relies onmargin-left: auto+order(3)to sit on the right. That works for the JS header, where.panelis a direct flex item of.contents. But the server-rendered anonymous header (app/views/application/_header.html.erb) wraps the title and panel in an intervening.row:.d-header > .contents > .row > (.title.span13 + .panel.clearfix). There.rowis the flex item, not.panel, somargin-left: auto/order(3)are inert andfloat: rightis gone — the panel is no longer right-aligned for logged-out / no-JS visitors. Either keepfloat: righton.panelfor the non-flex path, or make.rowitself a flex container for the anon header.