Separate the major variables.

This commit is contained in:
Cotes Chung 2020-02-27 17:36:59 +08:00
parent f3280bc136
commit 4f903b3041
2 changed files with 52 additions and 31 deletions

View file

@ -0,0 +1,22 @@
/*
* Mainly scss variables
*
* v2.1
* https://github.com/cotes2020/jekyll-theme-chirpy
* © 2020 Cotes Chung
* MIT Licensed
*/
$sidebar-width-small: 210px;
$sidebar-width-medium: 260px;
$sidebar-width-large: 350px;
$topbar-height: 3rem;
$footer-height: 5rem;
$main-content-max-width: 1150px;
$panel-max-width: 300px;
$post-extend-min-height: 35rem;

View file

@ -11,6 +11,7 @@
@import "_fonts"; @import "_fonts";
@import "_dark/dark-main"; @import "_dark/dark-main";
@import "_module"; @import "_module";
@import "_variables";
html, body { html, body {
height: 100%; height: 100%;
@ -43,7 +44,7 @@ $tab-count: {{ site.data.tabs | size }};
left: 0; left: 0;
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
width: 260px; width: $sidebar-width-medium;
z-index: 99; z-index: 99;
-webkit-transition: transform 0.4s ease; -webkit-transition: transform 0.4s ease;
transition: transform 0.4s ease; transition: transform 0.4s ease;
@ -253,7 +254,7 @@ $tab-count: {{ site.data.tabs | size }};
/*--- top-bar ---*/ /*--- top-bar ---*/
#topbar-wrapper { #topbar-wrapper {
height: 3rem; height: $topbar-height;
position: fixed; position: fixed;
top: 0; top: 0;
left: 260px; /* same as sidebar width */ left: 260px; /* same as sidebar width */
@ -417,8 +418,6 @@ $tab-count: {{ site.data.tabs | size }};
/*--- main wrapper ---*/ /*--- main wrapper ---*/
$footer-height: 5rem;
#main-wrapper { #main-wrapper {
background-color: var(--main-wrapper-bg, white); background-color: var(--main-wrapper-bg, white);
position: relative; position: relative;
@ -432,17 +431,17 @@ $footer-height: 5rem;
#main>div.row:first-child>div { #main>div.row:first-child>div {
&:nth-child(1), &:nth-child(2) { &:nth-child(1), &:nth-child(2) {
margin-top: 3rem; /* same as the height of topbar */ margin-top: $topbar-height; /* same as the height of topbar */
} }
&:first-child { &:first-child {
/* 3rem for topbar, 6rem for footer */ /* 3rem for topbar, 6rem for footer */
min-height: calc(100vh - 3rem - 6rem); min-height: calc(100vh - #{$topbar-height} - #{$footer-height} - #{$post-extend-min-height});
} }
} }
#post-wrapper { #post-wrapper {
/* 350px for post extended block */ min-height: calc(100vh - #{$topbar-height}
min-height: calc(100vh - 3rem - 6rem - 470px) !important; - #{$footer-height} - #{$post-extend-min-height})!important;
.post-content { .post-content {
a:hover { a:hover {
@extend %link-hover; @extend %link-hover;
@ -923,12 +922,15 @@ table {
@media all and (max-width: 576px) { @media all and (max-width: 576px) {
$footer-height: 6rem; // overwrite
#main>div.row:first-child>div:first-child { #main>div.row:first-child>div:first-child {
min-height: calc(100vh - 3rem - 10rem); /* topbar is 3rem and footer is 10rem */ min-height: calc(100vh - #{$topbar-height} - #{$footer-height});
} }
#post-wrapper { #post-wrapper {
min-height: calc(100vh - 3rem - 10rem - 470px) !important; min-height: calc(100vh - #{$topbar-height}
- #{$footer-height} - #{$post-extend-min-height}) !important;
h1 { h1 {
margin-top: 2.2rem; margin-top: 2.2rem;
font-size: 1.55rem; font-size: 1.55rem;
@ -955,8 +957,6 @@ table {
word-wrap: break-word; word-wrap: break-word;
} }
$footer-height: 6rem;
#main-wrapper { #main-wrapper {
padding-bottom: $footer-height; padding-bottom: $footer-height;
} }
@ -1028,13 +1028,13 @@ table {
.sidebar-expand { .sidebar-expand {
transform: translateX(0) !important; transform: translateX(0) !important;
~#main-wrapper { ~#main-wrapper {
transform: translateX(260px) !important; transform: translateX(#{$sidebar-width-medium}) !important;
} }
} }
#sidebar { #sidebar {
transform: translateX(-260px); // hide transform: translateX(-#{$sidebar-width-medium}); // hide
-webkit-transform: translateX(-260px); -webkit-transform: translateX(-#{$sidebar-width-medium});
.cursor { .cursor {
-webkit-transition: none; -webkit-transition: none;
-moz-transition: none; -moz-transition: none;
@ -1137,7 +1137,7 @@ table {
@media all and (min-width: 832px) and (max-width: 1199px) { @media all and (min-width: 832px) and (max-width: 1199px) {
#sidebar { #sidebar {
width: 210px; width: $sidebar-width-small;
.sidebar-bottom { .sidebar-bottom {
@include ml-mr(1.5rem); @include ml-mr(1.5rem);
.icon-border { .icon-border {
@ -1218,7 +1218,7 @@ table {
} }
#panel-wrapper { #panel-wrapper {
max-width: 300px; max-width: $panel-max-width;
} }
#back-to-top { #back-to-top {
@ -1258,7 +1258,7 @@ table {
@media all and (min-width: 1400px) { @media all and (min-width: 1400px) {
#main>div.row { #main>div.row {
padding-left: calc((100% - 1150px) / 2); padding-left: calc((100% - #{$main-content-max-width}) / 2);
>div.col-xl-8 { >div.col-xl-8 {
max-width: 850px; max-width: 850px;
} }
@ -1297,22 +1297,20 @@ table {
} }
} }
$side-bar-width: 350px;
#main-wrapper { #main-wrapper {
margin-left: $side-bar-width margin-left: $sidebar-width-large;
} }
#panel-wrapper { #panel-wrapper {
margin-left: calc((100% - 1150px) / 10); margin-left: calc((100% - #{$main-content-max-width}) / 10);
} }
#topbar-wrapper { #topbar-wrapper {
left: $side-bar-width left: $sidebar-width-large;
} }
#topbar { #topbar {
max-width: 1150px; max-width: #{$main-content-max-width};
} }
#search-wrapper { #search-wrapper {
@ -1367,7 +1365,7 @@ table {
} }
#sidebar { #sidebar {
width: $side-bar-width; width: $sidebar-width-large;
ul { ul {
margin-left: 5%; margin-left: 5%;
>li>a { >li>a {
@ -1435,9 +1433,9 @@ table {
} }
#search-result-wrapper { #search-result-wrapper {
width: calc(100% - 350px); // 350px is the with of sidebar width: calc(100% - #{$sidebar-width-large});
>div { >div {
max-width: 1150px; max-width: #{$main-content-max-width};
} }
} }
@ -1445,11 +1443,12 @@ table {
@media all and (min-width: 1700px) { @media all and (min-width: 1700px) {
#topbar-wrapper { #topbar-wrapper {
padding-right: calc(100% - 350px - 1570px) /* 100% - 350px - (1920px - 350px); */ padding-right: calc(100% - #{$sidebar-width-large}
- (1920px - #{$sidebar-width-large}) ) /* 100% - 350px - (1920px - 350px); */
} }
#main>div.row { #main>div.row {
padding-left: calc((100% - 1150px - 2%) / 2); padding-left: calc((100% - #{$main-content-max-width} - 2%) / 2);
} }
#panel-wrapper { #panel-wrapper {
@ -1458,7 +1457,7 @@ table {
footer { footer {
padding-left: 0; padding-left: 0;
padding-right: calc(100% - 350px - 1180px); padding-right: calc(100% - #{$sidebar-width-large} - 1180px);
} }
#back-to-top { #back-to-top {
@ -1473,7 +1472,7 @@ table {
} }
#search-result-wrapper { #search-result-wrapper {
padding-right: calc(100% - 350px - 1530px); padding-right: calc(100% - #{$sidebar-width-large} - 1530px);
} }
#panel-wrapper { #panel-wrapper {