client/css: improve mobile styling

This commit is contained in:
Michael Serajnik 2017-12-16 03:45:51 +01:00 committed by rr-
parent c770ad8f28
commit 26a1451ff6
18 changed files with 170 additions and 24 deletions

View file

@ -3,7 +3,6 @@ $comment-header-background-color = $top-navigation-color
$comment-border-color = #DDD $comment-border-color = #DDD
.comment-container .comment-container
margin: 0 0 1em 0
padding: 0 0 0 60px padding: 0 0 0 60px
.avatar .avatar

View file

@ -2,3 +2,8 @@
list-style-type: none list-style-type: none
margin: 0 margin: 0
padding: 0 padding: 0
>li
margin-bottom: 1em
&:last-child
margin-bottom: 0

View file

@ -1,15 +1,24 @@
@import colors
$comment-border-color = $top-navigation-color
.global-comment-list .global-comment-list
text-align: left text-align: left
&>ul &>ul
list-style-type: none list-style-type: none
margin: 1em 0 margin: 1em 0 0
padding: 0 padding: 0
@media (max-width: 700px)
&>li &>li
margin-bottom: 5em margin-top: 2em
padding: 1vw padding-top: 2em
border-top: 3px solid $comment-border-color
&:first-child
margin-top: 0
padding-top: 0
border-top: none
@media (max-width: 700px)
.post-thumbnail .post-thumbnail
margin-bottom: 1em margin-bottom: 1em
.thumbnail .thumbnail
@ -19,7 +28,6 @@
@media (min-width: 700px) @media (min-width: 700px)
&>li &>li
padding-left: 13em padding-left: 13em
margin-bottom: 2em
.post-thumbnail .post-thumbnail
float: left float: left
margin: 0 0 1em -13em margin: 0 0 1em -13em

View file

@ -31,13 +31,22 @@ form.horizontal
margin-bottom: 1em margin-bottom: 1em
.input, .buttons, ul .input, .buttons, ul
display: inline-block display: inline-block
vertical-align: middle vertical-align: top
margin: 0 margin: 0
padding: 0 padding: 0
input input
vertical-align: middle vertical-align: top
.buttons .buttons
margin-right: 0.5em margin-right: 0.5em
@media (max-width: 1000px)
display: block
.input, .buttons, ul
display: block
margin-top: 0.5em
&:first-child
margin-top: 0
.buttons
margin-right: 0
@ -213,10 +222,13 @@ input[type=submit]
cursor: pointer cursor: pointer
font-size: 100% font-size: 100%
padding: 0.2em 0.7em padding: 0.2em 0.7em
border-radius: 0
border: 2px solid $button-enabled-background-color border: 2px solid $button-enabled-background-color
background: $button-enabled-background-color background: $button-enabled-background-color
color: $button-enabled-text-color color: $button-enabled-text-color
outline: 0 /* something on Chrome */ outline: 0 /* something on Chrome */
-moz-appearance: none
-webkit-appearance: none
&:disabled &:disabled
cursor: default cursor: default

View file

@ -125,6 +125,37 @@ nav
li li
display: inline-block display: inline-block
float: left float: left
#mobile-navigation-toggle
display: none
width: 100%
padding: 0 1.5vw
line-height: 2.3em
font-family: inherit
border: none
background: none
color: $active-tab-text-color
.site-name
display: block
float: left
max-width: 50vw
overflow: hidden
text-overflow: ellipsis
.toggle-icon
display: block
float: right
@media (max-width: 1000px)
text-align: left
li
display: none
float: none
a
display: block
padding: 0 1.5vw
#mobile-navigation-toggle
display: block
&.opened
li
display: block
ul li[data-name=account], ul li[data-name=account],
ul li[data-name=register], ul li[data-name=register],
ul li[data-name=login], ul li[data-name=login],
@ -141,6 +172,8 @@ nav
margin-right: 0.6em margin-right: 0.6em
margin-left: calc(0.6em - 1.2em) margin-left: calc(0.6em - 1.2em)
float: left float: left
@media (max-width: 1000px)
display: none
a .access-key a .access-key
text-decoration: underline text-decoration: underline
@ -194,6 +227,9 @@ a .access-key
margin-top: 0 !important margin-top: 0 !important
margin-bottom: 0 !important margin-bottom: 0 !important
.table-wrap
overflow-x: scroll
/* hack to prevent text from being copied */ /* hack to prevent text from being copied */
[data-pseudo-content]:before { [data-pseudo-content]:before {
content: attr(data-pseudo-content) content: attr(data-pseudo-content)

View file

@ -15,6 +15,7 @@
margin: 0 auto 2em auto margin: 0 auto 2em auto
form form
display: inline-block
width: auto width: auto
vertical-align: middle vertical-align: middle
margin: 0 0 2em 0 margin: 0 0 2em 0
@ -52,6 +53,8 @@
li li
display: inline display: inline
white-space: nowrap white-space: nowrap
@media (max-width: 800px)
display: block
.sep .sep
word-spacing: 1.1em word-spacing: 1.1em
background-repeat: no-repeat background-repeat: no-repeat

View file

@ -8,7 +8,7 @@
.page .page
position: relative position: relative
.page-header .page-header
margin: 0.5em 0.5em 0.5em 0 margin: 0.5em 0
position: relative position: relative
&:before &:before
display: block display: block

View file

@ -145,12 +145,19 @@
margin-bottom: 0.75em margin-bottom: 0.75em
* *
vertical-align: top vertical-align: top
@media (max-width: 1000px)
display: block
input input
margin-bottom: 0.25em margin-bottom: 0.25em
margin-right: 0.25em margin-right: 0.25em
input[name=search-text] input[name=search-text]
width: 25em width: 25em
@media (max-width: 1000px)
display: block
width: 100%
margin-bottom: 0.5em
.append .append
vertical-align: middle
font-size: 0.95em font-size: 0.95em
color: $inactive-link-color color: $inactive-link-color
.bulk-edit .bulk-edit
@ -163,6 +170,11 @@
&.hidden &.hidden
display: none display: none
.bulk-edit-tags .bulk-edit-tags
&.opened
.hint
@media (max-width: 1000px)
display: block
margin-bottom: 0.5em
&:not(.opened) &:not(.opened)
[type=text], [type=text],
.start .start
@ -171,8 +183,21 @@
display: none display: none
input[name=tag] input[name=tag]
width: 12em width: 12em
@media (max-width: 1000px)
display: block
width: 100%
margin-bottom: 0.5em
.append
&.open,
&.hint
@media (max-width: 1000px)
margin-left: 0
.hint .hint
margin-right: 1em margin-right: 1em
.bulk-edit-safety
.append
@media (max-width: 1000px)
margin-left: 0
.safety .safety
margin-right: 0.25em margin-right: 0.25em

View file

@ -138,6 +138,9 @@
margin: 0 margin: 0
padding: 0 padding: 0
form
width: auto
label:not(.file-dropper) label:not(.file-dropper)
margin-bottom: 0.3em margin-bottom: 0.3em
display: block display: block

View file

@ -8,11 +8,16 @@ $snapshot-merged-background-color = #FEC
ul ul
margin: 0 auto margin: 0 auto
padding: 0
width: 100% width: 100%
max-width: 35em max-width: 35em
list-style-type: none list-style-type: none
li li
margin-bottom: 1em
&:last-child
margin-bottom: 0
.time .time
float: right float: right
@ -39,6 +44,3 @@ $snapshot-merged-background-color = #FEC
background: $snapshot-merged-background-color background: $snapshot-merged-background-color
&+.details &+.details
background: lighten($snapshot-merged-background-color, 50%) background: lighten($snapshot-merged-background-color, 50%)
div.details
margin-bottom: 2em

View file

@ -17,6 +17,12 @@
text-align: center text-align: center
&.remove, &.set-default &.remove, &.set-default
white-space: pre white-space: pre
th
white-space: nowrap
&:first-child
padding-left: 0
&:last-child
padding-right: 0
tfoot tfoot
display: none display: none
form form

View file

@ -11,6 +11,7 @@
th, td th, td
padding: 0.1em 0.5em padding: 0.1em 0.5em
th th
white-space: nowrap
background: $top-navigation-color background: $top-navigation-color
.names .names
width: 28% width: 28%
@ -47,6 +48,9 @@
width: auto width: auto
input[name=search-text] input[name=search-text]
width: 25em width: 25em
@media (max-width: 1000px)
width: 100%
.append .append
vertical-align: middle
font-size: 0.95em font-size: 0.95em
color: $inactive-link-color color: $inactive-link-color

View file

@ -34,6 +34,9 @@
width: auto width: auto
input[name=search-text] input[name=search-text]
width: 25em width: 25em
@media (max-width: 1000px)
width: 100%
.append .append
vertical-align: middle
font-size: 0.95em font-size: 0.95em
color: $inactive-link-color color: $inactive-link-color

View file

@ -1,6 +1,7 @@
<div class='content-wrapper tag-categories'> <div class='content-wrapper tag-categories'>
<form> <form>
<h1>Tag categories</h1> <h1>Tag categories</h1>
<div class="table-wrap">
<table> <table>
<thead> <thead>
<tr> <tr>
@ -12,6 +13,7 @@
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
</div>
<% if (ctx.canCreate) { %> <% if (ctx.canCreate) { %>
<p><a href class='add'>Add new category</a></p> <p><a href class='add'>Add new category</a></p>

View file

@ -1,4 +1,4 @@
<div class='tag-list'> <div class='tag-list table-wrap'>
<% if (ctx.response.results.length) { %> <% if (ctx.response.results.length) { %>
<table> <table>
<thead> <thead>

View file

@ -1,5 +1,9 @@
<nav id='top-navigation' class='buttons'><!-- <nav id='top-navigation' class='buttons'><!--
--><ul><!-- --><ul><!--
--><button id="mobile-navigation-toggle"><!--
--><span class="site-name"><%- ctx.name %></span><!--
--><span class="toggle-icon"><i class="fa fa-bars"></i></span><!--
--></button><!--
--><% for (let item of ctx.items) { %><!-- --><% for (let item of ctx.items) { %><!--
--><% if (item.available) { %><!-- --><% if (item.available) { %><!--
--><li data-name='<%- item.key %>'><!-- --><li data-name='<%- item.key %>'><!--

View file

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const api = require('../api.js'); const api = require('../api.js');
const config = require('../config.js');
const topNavigation = require('../models/top_navigation.js'); const topNavigation = require('../models/top_navigation.js');
const TopNavigationView = require('../views/top_navigation_view.js'); const TopNavigationView = require('../views/top_navigation_view.js');
@ -64,6 +65,7 @@ class TopNavigationController {
this._updateNavigationFromPrivileges(); this._updateNavigationFromPrivileges();
this._topNavigationView.render({ this._topNavigationView.render({
items: topNavigation.getAll(), items: topNavigation.getAll(),
name: config.name
}); });
this._topNavigationView.activate( this._topNavigationView.activate(
topNavigation.activeItem ? topNavigation.activeItem.key : ''); topNavigation.activeItem ? topNavigation.activeItem.key : '');

View file

@ -9,8 +9,22 @@ class TopNavigationView {
this._hostNode = document.getElementById('top-navigation-holder'); this._hostNode = document.getElementById('top-navigation-holder');
} }
get _mobileNavigationToggleNode() {
return this._hostNode.querySelector('#mobile-navigation-toggle');
}
get _navigationListNode() {
return this._hostNode.querySelector('nav > ul');
}
get _navigationLinkNodes() {
return this._navigationListNode.querySelectorAll('li > a');
}
render(ctx) { render(ctx) {
views.replaceContent(this._hostNode, template(ctx)); views.replaceContent(this._hostNode, template(ctx));
this._bindMobileNavigationEvents();
} }
activate(key) { activate(key) {
@ -19,6 +33,24 @@ class TopNavigationView {
'active', itemNode.getAttribute('data-name') === key); 'active', itemNode.getAttribute('data-name') === key);
} }
} }
_bindMobileNavigationEvents() {
this._mobileNavigationToggleNode.addEventListener(
'click', e => this._mobileNavigationToggleClick(e));
for (let navigationLinkNode of this._navigationLinkNodes) {
navigationLinkNode.addEventListener(
'click', e => this._navigationLinkClick(e));
}
}
_mobileNavigationToggleClick(e) {
this._navigationListNode.classList.toggle('opened');
}
_navigationLinkClick(e) {
this._navigationListNode.classList.remove('opened');
}
} }
module.exports = TopNavigationView; module.exports = TopNavigationView;