1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 08:27:42 +02:00

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
This commit is contained in:
Toby Zerner
2015-06-24 11:44:53 +09:30
parent b4dcc02520
commit e466dcc626
33 changed files with 538 additions and 292 deletions

View File

@@ -4,23 +4,39 @@
.composer {
pointer-events: auto;
.box-shadow(0 2px 6px @fl-shadow-color);
&.minimized {
height: 50px;
cursor: pointer;
}
}
.composer-controls {
list-style: none;
padding: 0;
margin: 0;
}
.composer-content {
.minimized & {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.composer-header {
list-style: none;
padding: 1px 0;
margin: 0;
margin: 0 0 10px;
.minimized & {
pointer-events: none;
}
& > li {
display: inline-block;
margin-right: -4px;
}
& h3 {
margin: 0 0 10px;
margin: 0;
line-height: 1.5em;
&, & input, & a {
@@ -41,6 +57,9 @@
}
}
}
.fa-minus.minimize {
vertical-align: -5px;
}
.composer-controls {
position: absolute;
right: 10px;
@@ -71,27 +90,85 @@
pointer-events: auto;
}
}
.composer-editor {
.minimized & {
visibility: hidden;
}
}
// On phones, show the composer as a fixed overlay that covers the whole
// screen. The controls are hidden (except for the 'x', which is the back-
// control), and the avatar hidden.
@media @phone {
.composer {
position: absolute;
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: @zindex-composer;
background: @fl-body-bg;
&:not(.minimized) {
top: 0;
height: 100vh !important;
padding-top: @mobile-header-height;
&:before {
content: " ";
.toolbar();
opacity: 0;
.visible& {
opacity: 1;
}
}
& .composer-controls {
z-index: @zindex-navbar-fixed + 1;
& li:not(.back-control) {
display: none;
}
}
}
}
.composer-content {
padding: 15px 15px 0;
}
.composer-controls {
& li:not(:last-child) {
display: none;
.minimized & {
margin-right: 50px;
}
}
.composer-avatar {
display: none;
}
.composer-header {
margin-bottom: 0;
& > li {
display: block;
border-bottom: 1px solid @fl-body-secondary-color;
padding: 10px 15px;
.minimized & {
border-bottom: 0;
padding: 15px;
}
}
& h3 {
&, & a, & input {
font-size: 14px;
}
& input {
width: 100% !important;
}
}
}
.composer-editor {
padding: 15px;
& textarea {
height: 50vh !important;
}
}
}
// On larger screens, show the composer as a window at the bottom of the
@@ -120,10 +197,6 @@
&.active:not(.full-screen) {
box-shadow: 0 0 0 2px @fl-body-primary-color, 0 2px 6px @fl-shadow-color;
}
&.minimized {
height: 50px;
cursor: pointer;
}
&.full-screen {
position: fixed;
left: 0;
@@ -144,9 +217,6 @@
}
}
.composer-header {
.minimized & {
pointer-events: none;
}
.full-screen & {
margin-bottom: 20px;
}
@@ -172,9 +242,6 @@
display: none;
}
}
.fa-minus.minimize {
vertical-align: -5px;
}
.composer-avatar {
float: left;
.avatar-size(64px);
@@ -191,10 +258,6 @@
}
}
.composer-editor {
.minimized & {
visibility: hidden;
}
.full-screen & textarea {
font-size: 16px;
}

View File

@@ -72,6 +72,11 @@
& .item {
&:not(:last-child) {
border-bottom: 1px solid @fl-body-secondary-color;
@media @phone {
margin: 0 -15px;
padding: 0 15px;
}
}
}
}
@@ -85,6 +90,8 @@
animation-iteration-count: infinite;
}
.fake-text {
display: inline-block;
vertical-align: middle;
background: @fl-body-secondary-color;
height: 12px;
width: 100%;
@@ -94,6 +101,10 @@
.post-header & {
height: 16px;
width: 150px;
@media @phone {
margin-bottom: 0;
}
}
}
@@ -135,6 +146,11 @@
background: @fl-primary-color;
}
}
@-webkit-keyframes pulsate {
0% {-webkit-transform: scale(1)}
50% {-webkit-transform: scale(1.02)}
100% {-webkit-transform: scale(1)}
}
@keyframes pulsate {
0% {transform: scale(1)}
50% {transform: scale(1.02)}
@@ -143,10 +159,14 @@
.item.pulsate {
animation: pulsate 1s ease-in-out;
animation-iteration-count: infinite;
-webkit-animation: pulsate 1s ease-in-out;
-webkit-animation-iteration-count: infinite;
}
.item.flash {
animation: pulsate 0.2s ease-in-out;
animation-iteration-count: 1;
-webkit-animation: pulsate 0.2s ease-in-out;
-webkit-animation-iteration-count: 1;
}
.post-header {
margin-bottom: 10px;
@@ -356,10 +376,13 @@
}
.post-actions {
margin-top: 10px;
margin-bottom: -10px;
opacity: 0;
.transition(opacity 0.2s);
@media @tablet, @desktop, @desktop-hd {
margin-bottom: -10px;
opacity: 0;
}
& > ul {
& > li {
margin-right: 10px;
@@ -377,6 +400,11 @@
padding: 20px 20px 20px 90px;
background: @fl-body-secondary-color;
font-size: 12px;
@media @phone {
margin: 0 -15px;
padding: 20px 15px;
}
}
.post-preview {
@@ -415,8 +443,8 @@
& h3 .badges {
position: absolute;
top: -7px;
left: 5px;
top: -12px;
left: 6px;
width: 32px;
& .badge {
@@ -469,26 +497,39 @@
font-size: 22px;
}
}
.reply-post {
font-size: 15px;
cursor: text;
overflow: hidden;
margin: 50px -20px 0;
border: 2px dashed transparent;
margin-top: 50px;
border: 2px dashed @fl-body-secondary-color;
color: @fl-body-muted-color;
border-radius: 10px;
padding: 20px 20px 20px 110px;
transition: border-color 0.2s;
padding: 20px;
& .post-header {
padding-top: 18px;
margin: 0;
color: inherit;
}
& .avatar {
margin-top: -18px;
}
&:hover {
border-color: @fl-body-secondary-color;
}
@media @tablet, @desktop, @desktop-hd {
.reply-post {
margin-left: -20px;
margin-right: -20px;
padding-left: 110px;
border-color: transparent;
transition: border-color 0.2s;
& .post-header {
padding-top: 18px;
}
& .avatar {
margin-top: -18px;
}
&:hover {
border-color: @fl-body-secondary-color;
}
}
}

View File

@@ -146,11 +146,13 @@
}
@media @phone {
.discussion-list > ul > li {
padding-right: 45px;
.discussion-list {
margin: 0 -15px;
& .contextual-controls {
display: none;
& > ul > li {
& .contextual-controls {
display: none;
}
}
}
}
@@ -271,8 +273,12 @@
@media @phone {
.discussion-summary {
padding-left: 45px;
padding-right: 45px;
padding-left: 15px + 45px;
padding-right: 15px + 35px;
&:active {
background: @fl-body-secondary-color;
}
& .author {
margin-left: -45px;
@@ -294,9 +300,10 @@
}
& .title {
font-size: 14px;
text-decoration: none !important;
}
& .count {
margin-right: -45px;
margin-right: -35px;
background: @fl-body-control-bg;
color: @fl-body-control-color;
border-radius: @border-radius-base;

View File

@@ -2,14 +2,22 @@
& .dropdown-menu {
padding: 0;
overflow: hidden;
}
& .loading-indicator {
height: 100px;
& .notifications-content {
max-height: 600px;
overflow: auto;
padding-bottom: 10px;
}
}
& .dropdown-toggle .label {
margin-left: 5px;
}
}
.notification-list {
& .loading-indicator {
height: 100px;
}
}
@media @tablet, @desktop, @desktop-hd {
.notifications {
& .dropdown-menu {
@@ -36,26 +44,23 @@
color: #fff;
}
.notifications-header {
padding: 12px 15px;
border-bottom: 1px solid @fl-body-secondary-color;
@media @tablet, @desktop, @desktop-hd {
padding: 12px 15px;
border-bottom: 1px solid @fl-body-secondary-color;
& h4 {
font-size: 12px;
text-transform: uppercase;
font-weight: bold;
margin: 0;
color: @fl-body-muted-color;
& h4 {
font-size: 12px;
text-transform: uppercase;
font-weight: bold;
margin: 0;
color: @fl-body-muted-color;
}
& .btn {
float: right;
margin-top: -5px;
margin-right: -5px;
}
}
& .btn {
float: right;
margin-top: -5px;
margin-right: -5px;
}
}
.notifications-content {
max-height: 600px;
overflow: auto;
padding-bottom: 10px;
}
.no-notifications {
color: @fl-body-muted-color;
@@ -80,7 +85,7 @@
overflow: hidden;
text-overflow: ellipsis;
}
.notifications-list {
.notification-group-list {
list-style: none;
margin: 0;
padding: 0;
@@ -123,14 +128,20 @@
text-transform: uppercase;
}
}
@media @phone {
.notification {
& > a {
padding-left: 60px;
}
& .avatar {
margin-left: -45px;
.avatar-size(32px);
}
.drawer-toggle.unread-notifications {
position: relative;
&:after {
content: ' ';
display: block;
position: absolute;
background: @fl-body-primary-color;
top: 4px;
right: 2px;
width: 14px;
height: 14px;
border-radius: 7px;
border: 2px solid @fl-body-bg;
}
}

View File

@@ -10,7 +10,7 @@
color: #fff;
font-size: 14px;
.drawer-components();
.inverted-components();
& .avatar {
.avatar-size(96px);

View File

@@ -1,5 +1,5 @@
.user-card {
.drawer-components();
.inverted-components();
background-size: 100% 100%;
&, & .container {
@@ -44,6 +44,11 @@
padding-left: 130px;
max-width: 800px;
@media @phone {
padding-left: 0;
text-align: center;
}
& .user-identity {
display: inline;
vertical-align: middle;
@@ -51,16 +56,30 @@
& .user-avatar {
float: left;
margin-left: -130px;
@media @phone {
float: none;
margin: 0 auto 20px;
width: 64px + 8px;
}
}
& .avatar-editor .dropdown-toggle {
margin: 4px;
line-height: 96px;
font-size: 26px;
@media @phone {
line-height: 64px;
}
}
& .avatar {
.avatar-size(96px);
border: 4px solid @fl-body-bg;
.box-shadow(0 2px 6px @fl-shadow-color);
@media @phone {
.avatar-size(64px);
}
}
& .badges {
margin-left: 10px;
@@ -126,6 +145,10 @@
& > li {
margin-bottom: 30px;
padding-left: 32px;
@media @phone {
padding-left: 24px;
}
}
& .activity-icon {
.avatar-size(32px);
@@ -133,6 +156,10 @@
margin-left: -50px;
.box-shadow(0 0 0 3px #fff);
margin-top: -5px;
@media @phone {
margin-left: -42px;
}
}
}
.activity-info {
@@ -213,8 +240,10 @@
right: 0;
bottom: 0;
}
& .dropdown-menu {
left: 35%;
top: 65%;
@media @tablet, @desktop, @desktop-hd {
& .dropdown-menu {
left: 35%;
top: 65%;
}
}
}

View File

@@ -81,59 +81,73 @@
}
}
// PHONES
@media @phone {
.dropdown-open {
overflow: hidden;
}
.dropdown-menu {
margin: 0;
position: fixed;
left: 0 !important;
right: 0 !important;
width: auto !important;
bottom: -100vh;
top: auto;
padding: 0;
.dropdown.open {
z-index: @zindex-modal;
display: block;
max-height: 100vh;
border-radius: 0;
.box-shadow(0 2px 6px @fl-shadow-color);
.translate3d(0, 0, 0);
visibility: hidden;
.transition(~"bottom 0.3s, visibility 0s 0.3s");
}
.dropdown {
& .dropdown-menu {
margin: 0;
position: fixed;
left: 0 !important;
right: 0 !important;
width: auto !important;
bottom: 0;
top: auto;
padding: 0;
padding-bottom: 40px !important;
display: block;
max-height: 70vh;
border-radius: 0;
.box-shadow(0 2px 6px @fl-shadow-color);
visibility: hidden;
overflow: auto;
-webkit-overflow-scrolling: touch;
.translate3d(0, 70vh, 0);
.transition-transform(~" 0.3s, visibility 0s 0.3s");
& > li > a {
background: #fff;
font-size: 16px;
padding: 15px 20px 15px 50px;
& .icon {
& > li > a {
background: #fff;
font-size: 16px;
margin-left: -30px;
padding: 15px 20px;
&.has-icon {
padding-left: 50px;
}
& .icon {
font-size: 16px;
margin-left: -30px;
}
&:hover {
background: @fl-body-secondary-color;
}
}
& .divider {
margin: 0;
}
& > .active > a {
&, &:hover {
background: @fl-body-primary-color !important;
color: #fff !important;
}
}
.open& {
-webkit-transform: none;
transform: none;
visibility: visible;
transition-delay: 0s;
}
}
& .divider {
margin: 0;
}
& > .active > a {
color: #fff !important;
}
& .dropdown-backdrop {
background: fade(@fl-secondary-color, 90%);
opacity: 0;
.transition(~"opacity 0.3s");
.translate3d(0, 0, 0);
.open & {
bottom: 0;
visibility: visible;
transition-delay: 0s;
}
}
.dropdown-backdrop {
background: fade(@fl-body-primary-color, 90%);
opacity: 0;
.transition(~"opacity 0.3s");
.open & {
opacity: 1;
.open& {
opacity: 1;
}
}
}
}

View File

@@ -4,6 +4,7 @@
.form-control {
.box-shadow(none);
border-width: 2px;
-webkit-appearance: none;
&:focus,
&.focus {

View File

@@ -22,14 +22,14 @@ body {
.toolbar() {
background: fade(@fl-hdr-bg, 98%);
transform: translateZ(0); // Fix for Chrome bug where a transparent white background is actually gray
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: @zindex-navbar-fixed;
border-bottom: 1px solid @fl-body-control-bg;
.transition(~"box-shadow 0.2s, left 0.2s");
.translate3d(0, 0, 0);
.transition(~"box-shadow 0.2s, -webkit-transform 0.2s");
@media @phone {
height: @mobile-header-height;
@@ -55,7 +55,7 @@ body {
// PHONES: Push the toolbar to the right when the drawer is open.
@media @phone {
.drawer-open & {
left: @drawer-width;
.translate3d(@drawer-width, 0, 0);
}
}
}
@@ -67,29 +67,35 @@ body {
.primary-control, .title-control, .back-control {
position: fixed;
z-index: @zindex-navbar-fixed + 1;
top: 5px;
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: 5px;
.transition(right 0.2s);
right: 0;
.drawer-open .global-page & {
right: -@drawer-width;
}
& .dropdown-split {
&.dropdown-split {
& .btn, & .icon-caret {
display: none;
}
@@ -101,12 +107,10 @@ body {
.primary-control, .back-control {
& .btn {
color: @fl-hdr-control-color !important;
padding-left: 5px;
padding-right: 5px;
& .icon {
display: block;
font-size: 18px;
font-size: 20px;
}
& .label {
display: none;
@@ -118,24 +122,27 @@ body {
left: 50%;
margin-left: -100px;
text-align: center;
line-height: 33px;
.transition(margin-left 0.2s);
.drawer-open .global-page & {
margin-left: -100px + @drawer-width;
}
color: @fl-body-muted-color;
&, & .btn {
color: @fl-hdr-color;
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: 5px;
.transition(left 0.2s);
left: 0;
.transition-transform(0.2s);
.drawer-open .global-page & {
left: @drawer-width + 10px;
.translate3d(@drawer-width, 0, 0);
}
& .pin {
@@ -147,41 +154,34 @@ body {
// ------------------------------------
// Drawer
// This is a mixin which styles components (buttons, inputs, etc.) for use in
// the drawer. We define it as a mixin because it is also pulled in when
// styling a "colored header".
.drawer-components() {
// This is a mixin which styles components (buttons, inputs, etc.) for use on
// dark backgrounds.
.inverted-components() {
.header-title {
&, & a {
color: @fl-drawer-color;
color: #fff;
}
}
&, & a, & .btn-link {
color: @fl-drawer-control-color;
color: #fff;
}
& .form-control {
background: @fl-drawer-control-bg;
background: fade(#000, 10%);
border: 0;
color: @fl-drawer-control-color;
.placeholder(@fl-drawer-control-color);
color: #fff;
.placeholder(fade(#fff, 50%));
&:focus {
background: fadein(@fl-drawer-control-bg, 5%);
background: fade(#000, 15%);
}
}
& .search-input {
color: @fl-drawer-control-color;
}
& .btn-default, & .btn-default:hover {
background: @fl-drawer-control-bg;
color: @fl-drawer-control-color;
& .btn-default:not(.btn-naked), & .btn-default:hover {
background: fade(#000, 10%);
color: #fff;
}
& .btn-default.active, .open > .dropdown-toggle.btn-default {
background: fadein(@fl-drawer-control-bg, 5%);
color: @fl-drawer-control-color;
}
& .btn-naked {
background: transparent;
background: fade(#000, 15%);
color: #fff;
}
}
@@ -193,8 +193,7 @@ body {
overflow: hidden;
}
.global-drawer {
background: @fl-drawer-bg;
color: @fl-drawer-color;
background: @fl-hdr-bg;
width: @drawer-width;
position: fixed;
left: 0;
@@ -202,8 +201,11 @@ body {
bottom: 0;
visibility: hidden;
.transition(visibility 0s 0.2s);
.box-shadow(inset -6px 0 6px -6px @fl-shadow-color);
.drawer-components();
& when (@fl-colored-hdr = true) {
.inverted-components();
}
.drawer-open & {
visibility: visible;
@@ -279,7 +281,7 @@ body {
.clearfix();
& when (@fl-colored-hdr = true) {
.drawer-components();
.inverted-components();
}
& .back-button {
@@ -333,13 +335,12 @@ body {
position: relative;
width: 100%;
min-height: 100vh;
padding-bottom: 15px;
padding-bottom: 50px;
margin-top: @mobile-header-height;
.box-shadow(0 0 6px @fl-shadow-color);
.transition(margin-left 0.2s);
.transition-transform(0.2s);
.drawer-open & {
margin-left: @drawer-width;
.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.

View File

@@ -83,33 +83,32 @@
.modal.fade {
opacity: 1;
}
.modal-backdrop.in {
opacity: 0;
}
.modal-dialog {
.modal {
position: fixed;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
.modal-dialog {
margin: 0;
overflow: auto;
.modal.fade & {
.transition(top 0.3s);
top: 100%;
.translate(0, 0);
&.fade {
.transition-transform(0.3s);
.translate3d(0, 100vh, 0);
}
.modal.in & {
top: 0;
&.in {
-webkit-transform: none !important;
transform: none !important;
}
&:before {
content: " ";
.toolbar();
}
}
.modal-dialog {
margin: 0;
-webkit-transform: none !important;
transform: none !important;
}
.modal-content {
border-radius: 0;
border: 0;
@@ -121,10 +120,6 @@
padding: 0;
border: 0;
min-height: 0;
& h3 {
line-height: 36px;
}
}
}

View File

@@ -1,6 +1,8 @@
.search-box {
& input:focus, &.active input, & .search-results {
width: 400px;
@media @tablet, @desktop, @desktop-hd {
.search-box {
& input:focus, &.active input, & .search-results {
width: 400px;
}
}
}
.search-results {