Refactor layout (#31)

This commit is contained in:
Mimi 2020-06-18 23:30:20 +08:00 committed by GitHub
parent 4bcccea378
commit a1ee9a7e37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 82 additions and 126 deletions

View File

@ -13,25 +13,23 @@
<div class="container{%- if theme.motion.enable %} use-motion{%- endif %}"> <div class="container{%- if theme.motion.enable %} use-motion{%- endif %}">
<div class="headband"></div> <div class="headband"></div>
<main class="main">
<header class="header" itemscope itemtype="http://schema.org/WPHeader"> <header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner">{% include '_partials/header/index.njk' %}</div> <div class="header-inner">{% include '_partials/header/index.njk' %}</div>
{%- if theme.sidebar.display !== 'remove' %}
{% block sidebar %}{% endblock %}
{%- endif %}
</header> </header>
{{ partial('_partials/widgets.njk', {}, {cache: theme.cache.enable}) }} {{ partial('_partials/widgets.njk', {}, {cache: theme.cache.enable}) }}
<main class="main">
<div class="main-inner"> <div class="main-inner">
<div class="content-wrap">
{% include '_partials/header/sub-menu.njk' %} {% include '_partials/header/sub-menu.njk' %}
<div class="content {% block class %}{% endblock %}"> <div class="content {% block class %}{% endblock %}">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
{% include '_partials/comments.njk' %} {% include '_partials/comments.njk' %}
</div> </div>
{%- if theme.sidebar.display !== 'remove' %}
{% block sidebar %}{% endblock %}
{%- endif %}
</div>
</main> </main>
<footer class="footer"> <footer class="footer">

View File

@ -3,7 +3,7 @@ var pjax = new Pjax({
selectors: [ selectors: [
'head title', 'head title',
'#page-configurations', '#page-configurations',
'.content-wrap', '.main-inner',
'.post-toc-wrap', '.post-toc-wrap',
'.languages', '.languages',
'#pjax' '#pjax'

View File

@ -1,7 +1,3 @@
.content {
padding-top: 40px;
}
.post-body { .post-body {
+desktop() { +desktop() {
text-align: unquote(hexo-config('text_align.desktop')); text-align: unquote(hexo-config('text_align.desktop'));
@ -39,7 +35,7 @@
} }
} }
iframe, img, video { iframe, img, video, embed {
margin-bottom: 20px; margin-bottom: 20px;
} }

View File

@ -5,16 +5,7 @@
} }
.header-inner { .header-inner {
margin: 0 auto; main-container();
width: $content-desktop;
+desktop-large() {
width: $content-desktop-large;
}
+desktop-largest() {
width: $content-desktop-largest;
}
} }
.site-brand-container { .site-brand-container {

View File

@ -7,7 +7,7 @@
+mobile-small() { +mobile-small() {
// For Pisces & Gemini schemes only wider width (remove main blocks in Gemini). // For Pisces & Gemini schemes only wider width (remove main blocks in Gemini).
.content-wrap { .main-inner {
padding: initial !important; padding: initial !important;
} }

View File

@ -3,25 +3,6 @@
position: relative; position: relative;
} }
.main-inner {
margin: 0 auto;
width: $content-desktop;
+desktop-large() {
width: $content-desktop-large;
}
+desktop-largest() {
width: $content-desktop-largest;
}
}
.content-wrap {
+mobile() {
padding: 0 20px;
}
}
@import 'header'; @import 'header';
@import 'sidebar'; @import 'sidebar';
@import 'footer'; @import 'footer';

View File

@ -49,7 +49,7 @@ a, span.exturl {
cursor: pointer; cursor: pointer;
} }
iframe, img, video { iframe, img, video, embed {
display: block; display: block;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;

View File

@ -96,3 +96,16 @@ font-family-icons($icon = '') {
font-family: 'Font Awesome 5 Free'; font-family: 'Font Awesome 5 Free';
font-weight: 900; font-weight: 900;
} }
main-container() {
margin: 0 auto;
width: $content-desktop;
+desktop-large() {
width: $content-desktop-large;
}
+desktop-largest() {
width: $content-desktop-largest;
}
}

View File

@ -27,7 +27,7 @@ $use-seo = hexo-config('seo');
// Desktop layout styles. // Desktop layout styles.
// ================================================== // ==================================================
// Post blocks. // Post blocks.
.content-wrap { .main-inner {
background: initial; background: initial;
box-shadow: initial; box-shadow: initial;
padding: initial; padding: initial;
@ -139,7 +139,7 @@ $use-seo = hexo-config('seo');
// ================================================== // ==================================================
+tablet() { +tablet() {
// Posts in blocks. // Posts in blocks.
.content-wrap { .main-inner {
padding: $content-tablet-padding; padding: $content-tablet-padding;
} }
@ -180,7 +180,7 @@ $use-seo = hexo-config('seo');
// ================================================== // ==================================================
+mobile() { +mobile() {
// Posts in blocks. // Posts in blocks.
.content-wrap { .main-inner {
padding: $content-mobile-padding; padding: $content-mobile-padding;
} }

View File

@ -12,7 +12,6 @@
+mobile() { +mobile() {
display: block; display: block;
padding: 10px 0; padding: 10px 0;
width: auto;
} }
} }

View File

@ -19,10 +19,6 @@ hr {
// -------------------------------------------------- // --------------------------------------------------
.main-inner { .main-inner {
padding-bottom: 80px; padding-bottom: 80px;
+mobile() {
width: auto;
}
} }
.content { .content {
@ -57,6 +53,5 @@ hr {
+mobile() { +mobile() {
text-align: center; text-align: center;
width: auto;
} }
} }

View File

@ -5,5 +5,6 @@
@import '_header'; @import '_header';
@import '_menu'; @import '_menu';
@import '_posts-expand'; @import '_posts-expand';
@import '../Muse/_layout';
@import '../Muse/_sidebar'; @import '../Muse/_sidebar';
@import '../Muse/_sub-menu'; @import '../Muse/_sub-menu';

View File

@ -8,3 +8,23 @@
.brand { .brand {
background: var(--btn-default-bg); background: var(--btn-default-bg);
} }
.header-inner {
padding-top: 100px;
+mobile() {
padding-top: 50px;
}
}
.main-inner {
padding-bottom: 60px;
}
.content {
padding-top: 70px;
+mobile() {
padding-top: 35px;
}
}

View File

@ -1,30 +1,14 @@
.main-inner {
main-container();
+mobile() {
padding-left: 20px;
padding-right: 20px;
}
}
.header-inner, .main-inner, .footer-inner { .header-inner, .main-inner, .footer-inner {
+mobile() { +mobile() {
width: auto; width: auto;
} }
} }
.header-inner {
padding-top: 100px;
+mobile() {
padding-top: 50px;
}
}
.main-inner {
padding-bottom: 60px;
}
.content {
padding-top: 70px;
+mobile() {
padding-top: 35px;
}
}
embed {
display: block;
margin: 0 auto 25px auto;
}

View File

@ -1,14 +1,11 @@
.header { .header {
margin: 0 auto; // Make sure that .header and .main-inner are the same height
position: relative; // Required for .sidebar `position: sticky;`
width: $content-desktop; align-self: stretch;
width: $sidebar-desktop;
+desktop-large() { +desktop-large() {
width: $content-desktop-large; width: $sidebar-desktop;
}
+desktop-largest() {
width: $content-desktop-largest;
} }
+tablet-mobile() { +tablet-mobile() {
@ -22,7 +19,6 @@
box-shadow: $box-shadow-inner; box-shadow: $box-shadow-inner;
overflow: hidden; overflow: hidden;
padding: 0; padding: 0;
position: absolute;
top: 0; top: 0;
width: $sidebar-desktop; width: $sidebar-desktop;
@ -37,20 +33,23 @@
} }
} }
.main-inner { .main {
align-items: flex-start; align-items: flex-start;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
main-container();
if (hexo-config('sidebar.position') != 'right') { if (hexo-config('sidebar.position') == 'right') {
flex-direction: row-reverse; flex-direction: row-reverse;
} }
+tablet-mobile() { +tablet-mobile() {
display: block;
width: auto; width: auto;
} }
} }
.content-wrap { .main-inner {
align-self: stretch; align-self: stretch;
background: var(--content-bg-color); background: var(--content-bg-color);
border-radius: $border-radius-inner; border-radius: $border-radius-inner;
@ -66,6 +65,10 @@
} }
} }
.content {
padding-top: 40px;
}
if (hexo-config('sidebar.position') == 'right') { if (hexo-config('sidebar.position') == 'right') {
.header-inner { .header-inner {
right: 0; right: 0;

View File

@ -1,11 +1,9 @@
.sidebar { .sidebar {
// Make sure that .content-wrap and .sidebar are the same height bottom: initial;
// Required for .sidebar-inner `position: sticky;`
align-self: stretch;
background: initial;
box-shadow: none; box-shadow: none;
position: static; margin-top: $sidebar-offset;
width: $sidebar-desktop; position: sticky;
top: $sidebar-offset;
+tablet-mobile() { +tablet-mobile() {
display: none; display: none;
@ -22,9 +20,6 @@
box-shadow: $box-shadow; box-shadow: $box-shadow;
box-sizing: border-box; box-sizing: border-box;
color: var(--text-color); color: var(--text-color);
position: sticky;
top: $sidebar-offset;
width: $sidebar-desktop;
if (hexo-config('motion.enable') && hexo-config('motion.transition.sidebar')) { if (hexo-config('motion.enable') && hexo-config('motion.transition.sidebar')) {
opacity: 0; opacity: 0;
@ -97,10 +92,6 @@
if (hexo-config('links_settings.layout') == 'inline') { if (hexo-config('links_settings.layout') == 'inline') {
display: inline-block; display: inline-block;
sidebar-inline-links-item(); sidebar-inline-links-item();
if (!hexo-config('social_icons.icons_only')) {
width: unset;
}
} }
} }

View File

@ -71,15 +71,6 @@ NexT.boot.registerEvents = function() {
target && target.click(); target && target.click();
} }
}); });
if (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') {
NexT.utils.setAffixParam();
window.matchMedia('(min-width: 992px)').addListener(event => {
if (event.matches) {
NexT.utils.setAffixParam();
}
});
}
}; };
NexT.boot.refresh = function() { NexT.boot.refresh = function() {

View File

@ -354,13 +354,6 @@ NexT.utils = {
} }
}, },
setAffixParam: function() {
const sidebarOffset = CONFIG.sidebar.offset || 12;
const headerOffset = document.querySelector('.header-inner').offsetHeight;
document.querySelector('.sidebar-inner').style.marginTop = headerOffset + sidebarOffset + 'px';
},
getScript: function(url, callback, condition) { getScript: function(url, callback, condition) {
if (condition) { if (condition) {
callback(); callback();