提交 f674618d 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

refactor: Introduced css style on demand

上级 454bb9a6
...@@ -17,10 +17,15 @@ hexo.extend.filter.register('after_post_render', function(data) { ...@@ -17,10 +17,15 @@ hexo.extend.filter.register('after_post_render', function(data) {
$('a').each(function() { $('a').each(function() {
var href = $(this).attr('href'); var href = $(this).attr('href');
var className = $(this).attr('class');
if (!href) return; if (!href) return;
if (className && className.indexOf('friends-item') !== -1) return;
var className = $(this).attr('class');
var classNameWhitelist = [
'friends-plugin__item',
];
if (className && classNameWhitelist.includes(className)) return;
var data = url.parse(href); var data = url.parse(href);
......
...@@ -25,11 +25,11 @@ function friends(args) { ...@@ -25,11 +25,11 @@ function friends(args) {
var result = '<div class="friends-plugin">'; var result = '<div class="friends-plugin">';
datas.forEach(data => { datas.forEach(data => {
result += `<a class="friends-item" href="${data.url}">`; result += `<a class="friends-plugin__item" href="${data.url}">`;
result += `<img class="avatar" src="${data.avatar}">`; result += `<img class="friends-plugin__item-avatar" src="${data.avatar}">`;
result += '<div class="info">'; result += '<div class="friends-plugin__item-info">';
result += `<p class="name">${data.name}</p>`; result += `<p class="friends-plugin__item-info__name">${data.name}</p>`;
result += `<p class="intro">${data.introduction}</p>`; result += `<p class="friends-plugin__item-info__intro">${data.introduction}</p>`;
result += '</div>'; result += '</div>';
result += '</a>'; result += '</a>';
}); });
......
.friends-plugin { .friends-plugin {
overflow: hidden; overflow: hidden;
max-width: 100%; max-width: 100%;
}
.friends-item { &__item {
display: block; display: block;
float: left; float: left;
padding: .5rem; padding: .5rem;
width: calc(50% - 10px); width: 50%;
height: 100px; height: 100px;
transition: background-color .3s; transition: background-color .3s;
&:hover { &:hover {
background-color: alpha($blue-light, .1); background-color: alpha($blue-light, .1);
} }
p { p {
margin: 0; margin: 0;
} }
.avatar { avatar-width = 60px;
display: inline-block;
border-radius: 50%;
width: 60px;
height: 60px;
vertical-align: middle;
}
.info { &-avatar {
display: inline-block; display: inline-block;
margin-left: 1rem; border-radius: 50% !important;
padding-top: .6rem; width: avatar-width;
width: calc(100% - 60px - 1rem); height: avatar-width;
height: 100%; vertical-align: middle;
vertical-align: middle; }
color: $font-color;
}
.name, info-margin = 20px;
.intro {
overflow: hidden; &-info {
white-space: nowrap; display: inline-block;
text-overflow: ellipsis; margin-left: info-margin;
} padding-top: .6rem;
width: 'calc(100% - %s)' % (avatar-width + info-margin);
height: 100%;
vertical-align: middle;
color: $font-color;
&__name,
&__intro {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.intro { &__intro {
font-size: .9em; font-size: .9em;
color: #999; color: #999;
}
}
} }
} }
...@@ -49,10 +49,13 @@ ...@@ -49,10 +49,13 @@
font-weight: 700; font-weight: 700;
} }
time-width = 3em;
time-margin = 1em;
&__time { &__time {
display: inline-block; display: inline-block;
margin-right: 1em; /* Affect the width of title */ margin-right: time-margin;
width: 3em; /* Affect the width of title */ width: time-width;
vertical-align: middle; vertical-align: middle;
color: #99a9bf; color: #99a9bf;
transform: translateY(3%); transform: translateY(3%);
...@@ -61,7 +64,7 @@ ...@@ -61,7 +64,7 @@
&-title { &-title {
display: inline-block; display: inline-block;
margin: 0; margin: 0;
width: calc(100% - 4em); width: 'calc(100% - %s)' % (time-width + time-margin);
font-size: 1em; font-size: 1em;
font-weight: normal; font-weight: normal;
vertical-align: middle; vertical-align: middle;
......
.comments { if (hexo-config('gitalk.enable') || hexo-config('valine.enable') || hexo-config('livere.enable') || hexo-config('disqus.enable')) {
margin: 1.5rem 0 0; .comments {
width: $content-width; margin: 1.5rem 0 0;
layout-card(); width: $content-width;
layout-card();
if (hexo-config('sidebar.position') == 'left') { if (hexo-config('sidebar.position') == 'left') {
float: right; float: right;
} else if (hexo-config('sidebar.position') == 'right') { } else if (hexo-config('sidebar.position') == 'right') {
float: left; float: left;
}
} }
} }
// Disqus if (hexo-config('gitalk.enable')) {
#disqus_thread { // Gitalk
width: 100%; #gitalk-container {
} width: 100%;
// Gitalk .gt-meta {
#gitalk-container { margin-top: 0;
width: 100%; padding-top: 0;
}
}
}
.gt-meta { if (hexo-config('livere.enable')) {
margin-top: 0; // Livere
padding-top: 0; #lv-container {
width: 100%;
} }
} }
// Livere if (hexo-config('disqus.enable')) {
#lv-container { // Disqus
width: 100%; #disqus_thread {
width: 100%;
}
} }
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@import './zoom-image.styl' if (hexo-config('zoom_image.enable')); @import './zoom-image.styl' if (hexo-config('zoom_image.enable'));
@import './gallery-image.styl' if (hexo-config('gallery_waterfall.enable')); @import './gallery-image.styl' if (hexo-config('gallery_waterfall.enable'));
@import './lazyload.styl' if (hexo-config('lazyload.enable')); @import './lazyload.styl' if (hexo-config('lazyload.enable'));
@import './loading-bar.styl' if (hexo-config('pjax.enable'));
@import './comments.styl'; @import './comments.styl';
@import './copy-button.styl' @import './copy-button.styl'
@import './loading-bar.styl';
@import './sticky-top.styl'; @import './sticky-top.styl';
@import './pagination.styl'; @import './pagination.styl';
...@@ -26,14 +26,16 @@ ...@@ -26,14 +26,16 @@
font-size: $font-size-main; font-size: $font-size-main;
} }
.sidebar { if (hexo-config('sidebar.enable')) {
float: convert(hexo-config('sidebar.position')); .sidebar {
float: convert(hexo-config('sidebar.position'));
&.sticky {
position: fixed; &.sticky {
top: convert(hexo-config('sidebar.offsetTop') || '30px'); position: fixed;
z-index: $z-index0; top: convert(hexo-config('sidebar.offsetTop') || '30px');
transform: translateZ(0); z-index: $z-index0;
transform: translateZ(0);
}
} }
} }
......
...@@ -32,8 +32,10 @@ ...@@ -32,8 +32,10 @@
width: 100%; width: 100%;
} }
.sidebar { if (hexo-config('sidebar.enable')) {
display: none; .sidebar {
display: none;
}
} }
.post-list .post { .post-list .post {
...@@ -91,18 +93,20 @@ ...@@ -91,18 +93,20 @@
font-size: .9rem; font-size: .9rem;
} }
.search-popup { if (hexo-config('algolia_search.enable') || hexo-config('local_search.enable')) {
top: 0; .search-popup {
left: 0; top: 0;
margin: 0; left: 0;
border-radius: 0; margin: 0;
width: 100%; border-radius: 0;
height: 100vh; width: 100%;
max-height: 100vh; height: 100vh;
} max-height: 100vh;
}
.search-results { .search-results {
max-height: 'calc(100vh - %s)' % search-results-height; max-height: 'calc(100vh - %s)' % search-results-height;
}
} }
} }
...@@ -145,8 +149,10 @@ ...@@ -145,8 +149,10 @@
padding: .8rem; padding: .8rem;
} }
.algolia-hit-item { if (hexo-config('algolia_search.enable')) {
margin: 0; .algolia-hit-item {
margin: 0;
}
} }
.gallery__img { .gallery__img {
......
// avatar animation // avatar animation
// ---------------------------------------- // ----------------------------------------
if (hexo-config('author.enable')) { if (hexo-config('author.enable')) {
// shake if (hexo-config('author.animation') == 'shake') {
@keyframes avatar-shake { @keyframes avatar-shake {
0% { 0% {
transform: scale(1); transform: scale(1);
} }
10%, 10%,
20% { 20% {
transform: scale(.9) rotate(3deg); transform: scale(.9) rotate(3deg);
} }
30%, 30%,
50%, 50%,
70%, 70%,
90% { 90% {
transform: scale(1.1) rotate(-3deg); transform: scale(1.1) rotate(-3deg);
} }
40%, 40%,
60%, 60%,
80% { 80% {
transform: scale(1.1) rotate(3deg); transform: scale(1.1) rotate(3deg);
} }
100% { 100% {
transform: scale(1); transform: scale(1);
} }
} }
} else if (hexo-config('author.animation') == 'turn') {
// trun @keyframes avatar-turn {
@keyframes avatar-turn { 100% {
100% { transform: rotate(1turn);
transform: rotate(1turn); }
} }
} }
} }
// footer heart beat animation // footer heart beat animation
// ---------------------------------------- // ----------------------------------------
if (hexo-config('footer.icon.enable')) { if (hexo-config('footer.icon.enable') && hexo-config('footer.icon.animation')) {
@keyframes footer-heart-beat { @keyframes footer-heart-beat {
0% { 0% {
transform: scale(1); transform: scale(1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册