Improve back button appearance

This commit is contained in:
Rico Sta. Cruz 2017-09-01 04:23:55 +08:00
parent 6abfb81975
commit b9b3dbbd9b
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
7 changed files with 120 additions and 43 deletions

View File

@ -1,8 +1,10 @@
<nav class='top-nav'> <nav class='top-nav'>
<div class='container'> <div class='container'>
{% unless include.is_home %}
<div class='left'> <div class='left'>
<a class='home' href='{{base}}'></a> <a class='home back-button' href='{{base}}'></a>
</div> </div>
{% endunless %}
<a class='brand' href='{{base}}'> <a class='brand' href='{{base}}'>
Rico's cheatsheets Rico's cheatsheets

View File

@ -9,7 +9,7 @@ type: website
| sort: "updated", "first" | sort: "updated", "first"
%} %}
{% include 2017/head.html %} {% include 2017/head.html %}
{% include 2017/top-nav.html page=page %} {% include 2017/top-nav.html page=page is_home=true %}
<div class='SideAd'> <div class='SideAd'>
<script async src='//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=ricostacruzcom' id="_carbonads_js"></script> <script async src='//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=ricostacruzcom' id="_carbonads_js"></script>

View File

@ -0,0 +1,48 @@
/*
* Home link
*/
.back-button {
text-decoration: none;
width: 48px;
height: 48px;
line-height: 48px - 2px;
text-align: center;
display: inline-block;
border-radius: 50%;
transition: all 100ms linear;
// Smaller on mobile
@media (max-width: 480px) {
width: 32px;
height: 32px;
line-height: 32px - 2;
}
// Colors
&,
&:visited {
color: $base-mute;
}
// Active
&:hover,
&:focus {
color: white;
background: $base-a;
opacity: 1;
}
// Icon
&::before {
@include ion-icon('md-arrow-back');
font-size: 24px;
}
// Icon: smaller on mobile
@media (max-width: 480px) {
&::before {
font-size: 16px;
}
}
}

View File

@ -30,6 +30,7 @@
text-align: right; text-align: right;
} }
// Clearfix
& > div > span::after { & > div > span::after {
content: ''; content: '';
display: table; display: table;
@ -49,6 +50,7 @@
margin-bottom: -0.02em; margin-bottom: -0.02em;
} }
@media (min-width: 481px) {
.carbon-poweredby::before { .carbon-poweredby::before {
display: block; display: block;
content: ''; content: '';
@ -58,3 +60,4 @@
margin: 8px (130px + 16px) 8px auto; margin: 8px (130px + 16px) 8px auto;
} }
} }
}

View File

@ -48,10 +48,12 @@
} }
} }
// Mobile: reorder things
@media (max-width: 540px) { @media (max-width: 540px) {
& { & {
flex-direction: column; flex-direction: column;
flex-wrap: wrap; flex-wrap: wrap;
margin-top: 0;
} }
& > h1, & > h1,

View File

@ -1,12 +1,30 @@
.top-nav { .top-nav {
& { &,
& > .container {
height: 64px; height: 64px;
line-height: 64px; line-height: 64px;
text-align: center; text-align: center;
position: relative; position: relative;
} }
// Smaller on mobile
@media (max-width: 480px) {
& > .container {
height: 32px;
line-height: 32px;
margin-top: 8px;
}
& {
height: 32px + 8px + 8px;
padding: 8px 0;
border-bottom: solid 1px $dark-line-color;
margin-bottom: 8px;
}
}
// Horiz line // Horiz line
@media (min-width: 481px) {
&::after { &::after {
content: ''; content: '';
display: block; display: block;
@ -15,15 +33,20 @@
right: 40%; right: 40%;
bottom: 0; bottom: 0;
height: 1px; height: 1px;
background: $dark-line-color; background: linear-gradient(to right,
transparent,
$dark-line-color 20%,
$dark-line-color 80%,
transparent);
@media (max-width: 480px) { @media (max-width: 480px) {
left: 0; left: 0;
right: 0; right: 0;
} }
} }
}
> .container { & > .container {
@include gutter(padding-left); @include gutter(padding-left);
@include gutter(padding-right); @include gutter(padding-right);
max-width: $area-width; max-width: $area-width;
@ -70,6 +93,18 @@
} }
} }
// Mobile
@media (max-width: 480px) {
& > .brand {
display: none;
}
& > .actions {
margin-left: auto;
}
}
// Desktop: absolute the actions
@media (min-width: 481px) { @media (min-width: 481px) {
& > .actions { & > .actions {
position: absolute; position: absolute;
@ -84,23 +119,9 @@
} }
} }
// Home link // Offset so it doesn't look misasligned
& > .left > .home { & > .left > .home {
text-decoration: none; position: relative;
left: -16px;
&,
&:visited {
color: $base-mute;
}
&:hover,
&:focus {
color: $base-a;
}
}
& > .left > .home::before {
@include ion-icon('md-arrow-back');
font-size: 16px;
} }
} }

View File

@ -15,6 +15,7 @@
@import './markdown/table'; @import './markdown/table';
@import './markdown/ul'; @import './markdown/ul';
@import './components/attribute-peg'; @import './components/attribute-peg';
@import './components/back-button';
@import './components/body-area'; @import './components/body-area';
@import './components/h2-section'; @import './components/h2-section';
@import './components/h3-section'; @import './components/h3-section';