framework/less/lib/layout.less
Toby Zerner e466dcc626 Significantly improve mobile UX
Most of #137 done.

- Use FastClick to make everything feel more responsive
- Use transforms for animations to make them silky smooth
- Style the drawer the same as the header to keep things simple
- Revert to fixed composer, but allow it to be minimised
- Add a separate notifications page for mobile so it’s easy to go back
- Add indicator to the menu button when there are unread notifications
- Close the drawer when navigating away
- Make dropdowns/modals scrollable
- Many other mobile tweaks and bug fixes

Didn’t take much care to keep CSS clean, due to #103
2015-06-24 11:44:53 +09:30

453 lines
8.8 KiB
Plaintext

body {
background: @fl-body-bg;
color: @fl-body-color;
overflow-y: scroll;
}
.container-narrow {
max-width: 600px;
margin: 0 auto;
}
.global-page {
overflow-x: hidden;
min-height: 100vh;
}
#assets-loading {
color: @fl-body-muted-color;
font-size: 16px;
padding: 20px;
}
// ------------------------------------
// Page Toolbar
.toolbar() {
background: fade(@fl-hdr-bg, 98%);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: @zindex-navbar-fixed;
border-bottom: 1px solid @fl-body-control-bg;
.translate3d(0, 0, 0);
.transition(~"box-shadow 0.2s, -webkit-transform 0.2s");
@media @phone {
height: @mobile-header-height;
}
@media @tablet, @desktop, @desktop-hd {
height: @header-height;
}
}
// Fix a solid white box to the top of the viewport. This toolbar's contents
// will differ depending on the device: on phones it will be content
// controls, whereas on desktops it will be the header. We will overlay
// these things on top of it later.
.global-page:before {
content: " ";
.toolbar();
border-bottom: 0;
.scrolled & {
.box-shadow(0 2px 6px @fl-shadow-color);
}
// PHONES: Push the toolbar to the right when the drawer is open.
@media @phone {
.drawer-open & {
.translate3d(@drawer-width, 0, 0);
}
}
}
// PHONES: Somewhere on the page there will be a .back-button, a .primary-
// control, and a .title-control. We will position these on the left, right,
// and center of the header respectively.
@media @phone {
.primary-control, .title-control, .back-control {
position: fixed;
z-index: @zindex-navbar-fixed + 1;
top: 0;
margin: 0;
visibility: visible;
.transition(visibility 0s 0.4s);
& .btn {
float: none;
background: transparent !important;
.box-shadow(~"none !important");
height: @mobile-header-height;
width: auto;
padding: 13px !important;
&:active {
opacity: 0.5;
}
}
}
.primary-control, .title-control {
.drawer-open .global-page & {
visibility: hidden;
transition-delay: 0s;
}
}
.primary-control {
width: auto;
right: 0;
&.dropdown-split {
& .btn, & .icon-caret {
display: none;
}
& .dropdown-toggle {
display: block;
}
}
}
.primary-control, .back-control {
& .btn {
color: @fl-hdr-control-color !important;
& .icon {
display: block;
font-size: 20px;
}
& .label {
display: none;
}
}
}
.title-control {
width: 200px;
left: 50%;
margin-left: -100px;
text-align: center;
color: @fl-body-muted-color;
&, & .btn {
font-size: 16px;
}
& .btn {
color: @fl-hdr-color;
}
}
h3.title-control, h4.title-control {
line-height: 46px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.back-control {
left: 0;
.transition-transform(0.2s);
.drawer-open .global-page & {
.translate3d(@drawer-width, 0, 0);
}
& .pin {
display: none;
}
}
}
// ------------------------------------
// Drawer
// This is a mixin which styles components (buttons, inputs, etc.) for use on
// dark backgrounds.
.inverted-components() {
.header-title {
&, & a {
color: #fff;
}
}
&, & a, & .btn-link {
color: #fff;
}
& .form-control {
background: fade(#000, 10%);
border: 0;
color: #fff;
.placeholder(fade(#fff, 50%));
&:focus {
background: fade(#000, 15%);
}
}
& .btn-default:not(.btn-naked), & .btn-default:hover {
background: fade(#000, 10%);
color: #fff;
}
& .btn-default.active, .open > .dropdown-toggle.btn-default {
background: fade(#000, 15%);
color: #fff;
}
}
// On phones, the drawer is displayed in its semantic sense: as a drawer on
// the left side of the screen. On other devices, the drawer has no specific
// appearance.
@media @phone {
.drawer-open {
overflow: hidden;
}
.global-drawer {
background: @fl-hdr-bg;
width: @drawer-width;
position: fixed;
left: 0;
top: 0;
bottom: 0;
visibility: hidden;
.transition(visibility 0s 0.2s);
.box-shadow(inset -6px 0 6px -6px @fl-shadow-color);
& when (@fl-colored-hdr = true) {
.inverted-components();
}
.drawer-open & {
visibility: visible;
transition-delay: 0s;
}
& .dropdown-menu {
width: @drawer-width !important;
}
}
}
// ------------------------------------
// Header
.header-controls {
margin: 0;
padding: 0;
list-style: none;
}
// On phones, the header is displayed inside of the drawer. We lay its
// contents out vertically.
@media @phone {
.global-header {
& .container {
padding: 0;
}
& .back-button {
display: none;
}
}
.header-title {
border-bottom: 1px solid @fl-drawer-control-bg;
font-size: 16px;
font-weight: normal;
margin: 0;
line-height: @mobile-header-height;
white-space: nowrap;
text-align: center;
}
.header-controls {
& > li {
padding: 10px 10px 0;
}
& .form-control, & .btn-group, & .btn {
width: 100%;
text-align: left;
}
& .dropdown-menu {
& .btn-group, & .btn {
width: auto;
}
}
}
}
// On other devices, we stick the header up the top of the page, overlaying
// the page toolbar that we styled earlier. We lay its contents out
// horizontally.
@media @tablet, @desktop, @desktop-hd {
.back-button.back-control {
display: none;
}
.global-header {
padding: 10px;
height: @header-height;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: @zindex-navbar-fixed;
.clearfix();
& when (@fl-colored-hdr = true) {
.inverted-components();
}
& .back-button {
float: left;
margin-right: 25px;
}
}
.header-controls {
&, & > li {
display: inline-block;
vertical-align: middle;
}
}
.header-primary {
float: left;
}
.header-title {
float: left;
vertical-align: top;
font-size: 18px;
font-weight: normal;
margin: 0;
line-height: 36px;
&, & a {
color: @fl-hdr-color;
}
}
.header-secondary {
float: right;
& .search-box {
margin-right: 10px;
}
}
}
// ------------------------------------
// Content Area
.global-content {
border-top: 1px solid @fl-body-control-bg;
}
// On phones, the content area overlays the drawer, so we must give it a
// background and min-height so it cannot be seen through. When the drawer is
// meant to be open, we slide the content to the right to reveal the drawer.
@media @phone {
.global-content {
background: @fl-body-bg;
position: relative;
width: 100%;
min-height: 100vh;
padding-bottom: 50px;
margin-top: @mobile-header-height;
.transition-transform(0.2s);
.drawer-open & {
.translate3d(@drawer-width, 0, 0);
// Disable all interaction with the content when the drawer is open. When
// .global-content is touched, the drawer will be closed.
& * {
pointer-events: none;
}
}
}
}
@media @tablet, @desktop, @desktop-hd {
.global-content {
margin-top: @header-height;
}
}
// ------------------------------------
// Footer
.footer-controls {
margin: 0;
padding: 0;
list-style: none;
& > li {
display: inline-block;
vertical-align: middle;
}
}
// On phones, the footer is displayed at the bottom of the drawer. The
// footer's primary controls don't display, but the secondary ones do.
// @todo Maybe we should reverse the naming of primary/secondary then?
@media @phone {
.global-footer {
position: fixed;
left: 15px;
bottom: 15px;
width: @drawer-width;
margin: 0;
z-index: 1;
& .container {
padding: 0;
}
}
.footer-primary {
display: none;
}
.footer-secondary {
float: none;
& > li {
margin-right: 15px;
}
}
}
// On other devices, we put the footer at the bottom of the page by absolutely
// positioning it, relative to the page which we pad out at the bottom. We
// show the primary controls on the left, and the secondary controls on the
// right.
@media @tablet, @desktop, @desktop-hd {
.global-page {
padding-bottom: 100px;
position: relative;
}
.global-footer {
position: absolute;
bottom: 20px;
left: 0;
right: 0;
&, & a {
color: @fl-body-muted-more-color;
}
& a {
&:hover,
&:focus {
text-decoration: none;
color: @link-hover-color;
}
}
}
.footer-primary {
display: inline-block;
& > li {
margin-right: 15px;
}
}
.footer-secondary {
float: right;
& > li {
margin-left: 15px;
}
}
}
// ------------------------------------
// Miscellaneous
// On phones, we disregard "affixed" elements and make them static.
@media @phone {
.affix {
position: static;
}
}