FIX: vertical centering of header, using display: table

This commit is contained in:
Neil Lalonde 2016-03-08 17:50:06 -05:00
parent 213950e4cf
commit 1b4e0f3300
6 changed files with 222 additions and 172 deletions

View file

@ -1,6 +1,7 @@
import DiscourseURL from 'discourse/lib/url'; import DiscourseURL from 'discourse/lib/url';
const TopicCategoryComponent = Ember.Component.extend({ const TopicCategoryComponent = Ember.Component.extend({
classNames: ['extra-info-cell'],
needsSecondRow: Ember.computed.gt('secondRowItems.length', 0), needsSecondRow: Ember.computed.gt('secondRowItems.length', 0),
secondRowItems: function() { return []; }.property(), secondRowItems: function() { return []; }.property(),

View file

@ -2,7 +2,7 @@ import DiscourseURL from 'discourse/lib/url';
import { setting } from 'discourse/lib/computed'; import { setting } from 'discourse/lib/computed';
export default Ember.Component.extend({ export default Ember.Component.extend({
classNames: ["title"], classNameBindings: [":title", "minimized"],
targetUrl: function() { targetUrl: function() {
// For overriding by customizations // For overriding by customizations

View file

@ -1,8 +1,13 @@
<div class='wrap'> <div {{bind-attr class=":wrap :d-header-wrap showExtraInfo:minimized:not-minimized"}}>
<div class='contents clearfix'> <div class='d-header-table contents clearfix'>
<div class="d-header-row">
{{home-logo minimized=showExtraInfo}} {{home-logo minimized=showExtraInfo}}
{{plugin-outlet "header-after-home-logo"}} {{plugin-outlet "header-after-home-logo"}}
{{#if showExtraInfo}}
{{header-extra-info topic=topic}}
{{/if}}
<div class='panel clearfix'> <div class='panel clearfix'>
{{#unless currentUser}} {{#unless currentUser}}
{{#if showSignUpButton}} {{#if showSignUpButton}}
@ -10,6 +15,7 @@
{{/if}} {{/if}}
{{d-button action="showLogin" class="btn-primary btn-small login-button" icon="user" label="log_in"}} {{d-button action="showLogin" class="btn-primary btn-small login-button" icon="user" label="log_in"}}
{{/unless}} {{/unless}}
<div class="d-header-nav">
<ul class='icons clearfix' role='navigation'> <ul class='icons clearfix' role='navigation'>
{{#if currentUser}} {{#if currentUser}}
{{plugin-outlet "header-before-notifications"}} {{plugin-outlet "header-before-notifications"}}
@ -57,10 +63,8 @@
{{hamburger-menu visible=hamburgerVisible showKeyboardAction="showKeyboardShortcutsHelp"}} {{hamburger-menu visible=hamburgerVisible showKeyboardAction="showKeyboardShortcutsHelp"}}
{{search-menu visible=searchVisible}} {{search-menu visible=searchVisible}}
</div> </div>
</div>
{{#if showExtraInfo}} </div>
{{header-extra-info topic=topic}}
{{/if}}
</div> </div>
</div> </div>
{{plugin-outlet "header-under-content"}} {{plugin-outlet "header-under-content"}}

View file

@ -11,12 +11,49 @@
backface-visibility: hidden; /** do magic for scrolling performance **/ backface-visibility: hidden; /** do magic for scrolling performance **/
} }
.contents { .d-header-table {
margin: 8px 0; display: table;
table-layout: fixed; /* or else long topic titles break everything */
width: 100%;
margin: 8px auto;
}
.d-header-row {
display: table-header-group; /* table-row doesn't work on mobile */
}
.d-header-wrap {
padding: 0;
}
.title, .extra-info-cell, .panel {
display: table-cell;
}
.title {
vertical-align: middle;
padding-left: 8px;
overflow: hidden;
width: 65%;
}
.extra-info-cell {
vertical-align: middle;
padding-left: 8px;
}
.panel {
width:35%;
text-align: right;
position: relative;
.menu-panel {
text-align: left;
}
} }
.title { .not-minimized {
float: left; .title { width: 65%; }
.panel { width: 35%; }
}
/* .minimized is different for desktop and mobile */
.d-header-nav {
position: relative;
float: right;
} }
#site-logo { #site-logo {
@ -27,13 +64,8 @@
font-size: 1.643em; font-size: 1.643em;
} }
.panel {
float: right;
position: relative;
}
.login-button, button.sign-up-button { .login-button, button.sign-up-button {
float: left; float: none;
margin-top: 7px; margin-top: 7px;
padding: 6px 10px; padding: 6px 10px;
.fa { margin-right: 3px; } .fa { margin-right: 3px; }
@ -44,7 +76,6 @@
} }
.icons { .icons {
float: left;
text-align: center; text-align: center;
margin: 0 0 0 5px; margin: 0 0 0 5px;
list-style: none; list-style: none;

View file

@ -11,6 +11,11 @@
padding:8px; padding:8px;
font-size: 2.1em; font-size: 2.1em;
} }
.minimized {
.title { width: 40px; vertical-align: baseline; }
.extra-info-cell { width: 74%; }
.panel { width: 25%; }
}
} }
@media all @media all

View file

@ -17,6 +17,10 @@
text-overflow: clip; text-overflow: clip;
} }
.extra-info-cell {
display: none;
}
.icons { .icons {
.badge-notification { .badge-notification {
top: -5px; top: -5px;
@ -31,6 +35,11 @@
button.sign-up-button { button.sign-up-button {
display:none; display:none;
} }
.not-minimized, .minimized {
.title { width: auto; }
.panel { width: auto; }
}
} }
#main-outlet { #main-outlet {