mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 03:53:30 +08:00
refactor(WIP): add new SCSS mixin respond
Theme's stylesheet mixes the use of max-width and min-width for responsive design, and it's horrible.
This commit is contained in:
parent
028ae12ea5
commit
7693cbe731
@ -1,4 +1,32 @@
|
|||||||
$on-phone: 812px;
|
$on-phone: 640px;
|
||||||
$on-tablet: 1024px;
|
$on-tablet: 768px;
|
||||||
$on-desktop: 1519px;
|
$on-desktop: 1024px;
|
||||||
$on-desktop-large: 1920px;
|
$on-desktop-large: 1280px;
|
||||||
|
|
||||||
|
@mixin respond($breakpoint) {
|
||||||
|
@if ($breakpoint == sm) {
|
||||||
|
@media (min-width: 640px) {
|
||||||
|
@content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@if ($breakpoint == md) {
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
@content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@if ($breakpoint == lg) {
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
@content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@if ($breakpoint == xl) {
|
||||||
|
@media (min-width: 1280px) {
|
||||||
|
@content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@if ($breakpoint == 2xl) {
|
||||||
|
@media (min-width: 1536px) {
|
||||||
|
@content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,67 +2,50 @@
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
||||||
|
.left-sidebar {
|
||||||
|
max-width: var(--left-sidebar-max-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-sidebar {
|
||||||
|
max-width: var(--right-sidebar-max-width);
|
||||||
|
|
||||||
|
/// Display right sidebar when min-width: lg
|
||||||
|
@include respond(lg) {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.extended {
|
&.extended {
|
||||||
@media (min-width: $on-phone) {
|
@include respond(md) {
|
||||||
max-width: 800px;
|
--left-sidebar-max-width: 25%;
|
||||||
|
--right-sidebar-max-width: 25%;
|
||||||
.left-sidebar {
|
max-width: 1024px;
|
||||||
width: 25%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: $on-tablet) {
|
@include respond(lg) {
|
||||||
max-width: 972px;
|
max-width: 1280px;
|
||||||
|
|
||||||
.right-sidebar {
|
|
||||||
width: 25%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: $on-desktop) {
|
@include respond(xl) {
|
||||||
max-width: 1200px;
|
|
||||||
|
|
||||||
.left-sidebar {
|
|
||||||
width: 20%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-sidebar {
|
|
||||||
width: 25%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: $on-desktop-large) {
|
|
||||||
max-width: 1536px;
|
max-width: 1536px;
|
||||||
|
--left-sidebar-max-width: 20%;
|
||||||
.left-sidebar {
|
--right-sidebar-max-width: 25%;
|
||||||
width: 15%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.compact {
|
&.compact {
|
||||||
@media (min-width: $on-phone) {
|
@include respond(md) {
|
||||||
max-width: 800px;
|
--left-sidebar-max-width: 25%;
|
||||||
|
max-width: 768px;
|
||||||
.left-sidebar {
|
|
||||||
width: 25%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: $on-tablet) {
|
@include respond(lg) {
|
||||||
max-width: 972px;
|
max-width: 1024px;
|
||||||
|
--left-sidebar-max-width: 20%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: $on-desktop) {
|
@include respond(xl) {
|
||||||
max-width: 1050px;
|
max-width: 1280px;
|
||||||
|
|
||||||
.left-sidebar {
|
|
||||||
width: 20%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: $on-desktop-large) {
|
|
||||||
max-width: 1300px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,8 +59,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.on-phone--column {
|
&.on-phone--column {
|
||||||
@media (max-width: $on-phone) {
|
flex-direction: column;
|
||||||
flex-direction: column;
|
@include respond(md) {
|
||||||
|
flex-direction: unset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,4 +98,12 @@ main.main {
|
|||||||
|
|
||||||
.main-container {
|
.main-container {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
|
||||||
|
@include respond(md) {
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@include respond(lg) {
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -106,9 +106,10 @@
|
|||||||
z-index: 2;
|
z-index: 2;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
@media (min-width: $on-phone + 1) {
|
@include respond(md) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
outline: none;
|
outline: none;
|
||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
@ -126,67 +127,58 @@
|
|||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin-top: var(--sidebar-element-separation);
|
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
font-size: 1.5rem;
|
font-size: 1.4rem;
|
||||||
|
|
||||||
@media (min-width: $on-desktop-large) {
|
background-color: var(--card-background);
|
||||||
margin-top: 30px;
|
margin-top: 0;
|
||||||
|
padding: 15px 0;
|
||||||
|
box-shadow: var(--shadow-l1);
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
&.show {
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $on-phone) {
|
@include respond(md) {
|
||||||
background-color: var(--card-background);
|
|
||||||
margin-top: 0;
|
|
||||||
padding: 15px 0;
|
|
||||||
box-shadow: var(--shadow-l1);
|
|
||||||
display: none;
|
|
||||||
|
|
||||||
&.show {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: $on-phone + 1) {
|
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
|
display: flex;
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
margin-top: var(--sidebar-element-separation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@include respond(xl) {
|
||||||
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
position: relative;
|
position: relative;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: 10px 0;
|
padding: 10px 30px;
|
||||||
|
|
||||||
&:not(:last-of-type) {
|
&:not(:last-of-type) {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
|
|
||||||
@media (min-width: $on-desktop-large) {
|
@include respond(xl) {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $on-phone) {
|
@include respond(md) {
|
||||||
padding: 10px 30px;
|
width: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: $on-phone + 1) and (max-width: ($on-desktop - 1)) {
|
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: $on-phone + 1) {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 25px;
|
|
||||||
height: 25px;
|
|
||||||
stroke-width: 1.33;
|
stroke-width: 1.33;
|
||||||
margin-right: 40px;
|
margin-right: 40px;
|
||||||
|
|
||||||
@media (max-width: $on-desktop-large) {
|
width: 20px;
|
||||||
width: 20px;
|
height: 20px;
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
@ -194,10 +186,6 @@
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: var(--body-text-color);
|
color: var(--body-text-color);
|
||||||
|
|
||||||
@media (max-width: $on-desktop-large) {
|
|
||||||
font-size: 1.4rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
.sidebar {
|
.sidebar {
|
||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
&.sticky {
|
&.sticky {
|
||||||
@media (min-width: ($on-phone + 1)) {
|
@include respond(md) {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,43 +12,39 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
||||||
--sidebar-avatar-size: 150px;
|
width: 100%;
|
||||||
--sidebar-element-separation: 25px;
|
padding: 30px 0 15px 0;
|
||||||
|
max-width: none;
|
||||||
|
|
||||||
@media (max-width: $on-desktop-large) {
|
--sidebar-avatar-size: 120px;
|
||||||
--sidebar-avatar-size: 120px;
|
--sidebar-element-separation: 20px;
|
||||||
--sidebar-element-separation: 20px;
|
|
||||||
|
@include respond(md) {
|
||||||
|
width: auto;
|
||||||
|
margin-right: 1%;
|
||||||
|
padding: var(--main-top-padding) 15px;
|
||||||
|
max-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $on-phone) {
|
@include respond(2xl) {
|
||||||
width: 100%;
|
--sidebar-avatar-size: 140px;
|
||||||
padding: 30px 0;
|
--sidebar-element-separation: 25px;
|
||||||
max-width: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.sticky {
|
&.sticky {
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: $on-phone + 1) {
|
|
||||||
margin-right: 1%;
|
|
||||||
padding: var(--main-top-padding) 15px;
|
|
||||||
max-height: 100vh;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-sidebar {
|
.right-sidebar {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
display: none;
|
||||||
|
|
||||||
&.sticky {
|
&.sticky {
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $on-desktop - 1) {
|
@include respond(lg) {
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: $on-tablet) {
|
|
||||||
margin-left: 1%;
|
margin-left: 1%;
|
||||||
padding-top: var(--main-top-padding);
|
padding-top: var(--main-top-padding);
|
||||||
}
|
}
|
||||||
@ -58,8 +54,10 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
transition: box-shadow 0.5s ease;
|
transition: box-shadow 0.5s ease;
|
||||||
|
|
||||||
@media (max-width: $on-phone) {
|
padding: 15px 30px;
|
||||||
padding: 15px 30px;
|
|
||||||
|
@include respond(md) {
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site-avatar {
|
.site-avatar {
|
||||||
@ -79,9 +77,9 @@
|
|||||||
|
|
||||||
.emoji {
|
.emoji {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 50px;
|
width: 40px;
|
||||||
height: 50px;
|
height: 40px;
|
||||||
line-height: 50px;
|
line-height: 40px;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
@ -90,20 +88,20 @@
|
|||||||
background-color: var(--card-background);
|
background-color: var(--card-background);
|
||||||
box-shadow: var(--shadow-l2);
|
box-shadow: var(--shadow-l2);
|
||||||
|
|
||||||
@media (max-width: $on-desktop-large) {
|
@include respond(2xl) {
|
||||||
width: 40px;
|
width: 50px;
|
||||||
height: 40px;
|
height: 50px;
|
||||||
line-height: 40px;
|
line-height: 50px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.site-name {
|
.site-name {
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
font-size: 2.4rem;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
font-size: 1.8rem;
|
||||||
|
|
||||||
@media (max-width: $on-desktop-large) {
|
@include respond(2xl) {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,10 +110,10 @@
|
|||||||
color: var(--body-text-color);
|
color: var(--body-text-color);
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
font-size: 1.8rem;
|
font-size: 1.6rem;
|
||||||
|
|
||||||
@media (max-width: $on-desktop-large) {
|
@include respond(2xl) {
|
||||||
font-size: 1.6rem;
|
font-size: 1.8rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user