diff --git a/layout/404.pug b/layout/404.pug index aaaa169..364b7cf 100644 --- a/layout/404.pug +++ b/layout/404.pug @@ -25,5 +25,4 @@ html(lang=config.language data-theme=theme.display_mode) i.fas.fa-rocket = _p('error404.back_button') - !=partial('includes/third-party/search/index', {}, {cache:theme.fragment_cache}) include includes/additional-js.pug diff --git a/layout/includes/footer.pug b/layout/includes/footer.pug index 5467bb3..fc612f9 100644 --- a/layout/includes/footer.pug +++ b/layout/includes/footer.pug @@ -14,10 +14,10 @@ span= _p('footer.theme') + ' ' a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly' if theme.footer.custom_text - .footer_custom_text!=`${theme.footer.custom_text}` + .footer_custom_text!=`${theme.footer.custom_text}` if theme.footer.ICP.enable .icp a(href=theme.footer.ICP.url) if theme.footer.ICP.icon - img.icp-icon(src=url_for(theme.footer.ICP.icon) alt='icp') + img.icp-icon(src=url_for(theme.footer.ICP.icon) alt='ICP') span=theme.footer.ICP.text diff --git a/layout/includes/layout.pug b/layout/includes/layout.pug index e40fa05..38c9bbf 100644 --- a/layout/includes/layout.pug +++ b/layout/includes/layout.pug @@ -11,7 +11,7 @@ html(lang=config.language data-theme=theme.display_mode) if theme.background #web_bg - !=partial('includes/mobile-sidebar/index', {}, {cache:theme.fragment_cache}) + !=partial('includes/sidebar', {}, {cache:theme.fragment_cache}) #body-wrap include ./header/index.pug diff --git a/layout/includes/mobile-sidebar/index.pug b/layout/includes/mobile-sidebar/index.pug deleted file mode 100644 index 511a77c..0000000 --- a/layout/includes/mobile-sidebar/index.pug +++ /dev/null @@ -1,3 +0,0 @@ -#mobile-sidebar - #menu_mask - include ../mobile-sidebar/mobile-menus.pug \ No newline at end of file diff --git a/layout/includes/mobile-sidebar/mobile-menus.pug b/layout/includes/mobile-sidebar/mobile-menus.pug deleted file mode 100644 index 42a0bed..0000000 --- a/layout/includes/mobile-sidebar/mobile-menus.pug +++ /dev/null @@ -1,29 +0,0 @@ -#mobile-sidebar-menus - .mobile_author_icon - if theme.lazyload.enable - img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") - else - img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") - .mobile_post_data - if site.posts.length - .mobile_data_item.is-center - .mobile_data_link - a(href=url_for(config.archive_dir) + '/') - .headline= _p('aside.articles') - .length_num= site.posts.length - - if site.tags.length - .mobile_data_item.is-center - .mobile_data_link - a(href=url_for(config.tag_dir) + '/' ) - .headline= _p('aside.tags') - .length_num= site.tags.length - - if site.categories.length - .mobile_data_item.is-center - .mobile_data_link - a(href=url_for(config.category_dir) + '/') - .headline= _p('aside.categories') - .length_num= site.categories.length - hr - !=fragment_cache('menus', function(){return partial('includes/header/menu_item')}) diff --git a/layout/includes/rightside.pug b/layout/includes/rightside.pug index 323a22a..627bca6 100644 --- a/layout/includes/rightside.pug +++ b/layout/includes/rightside.pug @@ -1,4 +1,4 @@ -section#rightside +#rightside #rightside-config-hide if is_post() && theme.readmode button#readmode(type="button" title=_p('rightside.readmode_title')) diff --git a/layout/includes/sidebar.pug b/layout/includes/sidebar.pug new file mode 100644 index 0000000..43c0b2c --- /dev/null +++ b/layout/includes/sidebar.pug @@ -0,0 +1,31 @@ +#sidebar + #menu-mask + #sidebar-menus + .author-avatar + if theme.lazyload.enable + img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") + else + img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") + .site-data + if site.posts.length + .data-item.is-center + .data-item-link + a(href=url_for(config.archive_dir) + '/') + .headline= _p('aside.articles') + .length-num= site.posts.length + + if site.tags.length + .data-item.is-center + .data-item-link + a(href=url_for(config.tag_dir) + '/' ) + .headline= _p('aside.tags') + .length-num= site.tags.length + + if site.categories.length + .data-item.is-center + .data-item-link + a(href=url_for(config.category_dir) + '/') + .headline= _p('aside.categories') + .length-num= site.categories.length + hr + !=fragment_cache('menus', function(){return partial('includes/header/menu_item')}) diff --git a/layout/includes/third-party/search/algolia.pug b/layout/includes/third-party/search/algolia.pug index 15cbb9d..6d22886 100644 --- a/layout/includes/third-party/search/algolia.pug +++ b/layout/includes/third-party/search/algolia.pug @@ -1,12 +1,13 @@ -#algolia-search.search-dialog - #algolia-search-title.search-dialog__title Algolia - #algolia-input-panel - #algolia-search-input - hr - #algolia-search-results - #algolia-hits - #algolia-pagination - #algolia-stats - span.search-close-button - i.fas.fa-times -#search-mask +#algolia-search + .search-dialog + #algolia-search-title.search-dialog__title Algolia + #algolia-input-panel + #algolia-search-input + hr + #algolia-search-results + #algolia-hits + #algolia-pagination + #algolia-stats + span.search-close-button + i.fas.fa-times + #search-mask diff --git a/layout/includes/third-party/search/local-search.pug b/layout/includes/third-party/search/local-search.pug index 545d775..69570a2 100644 --- a/layout/includes/third-party/search/local-search.pug +++ b/layout/includes/third-party/search/local-search.pug @@ -1,23 +1,24 @@ -#local-search.search-dialog - #local-search-title.search-dialog__title=_p("local_search.label") - #local-input-panel - #local-search-input - .local-search-box - input(placeholder=_p("local_search.input_placeholder") type="text").local-search-box--input - hr - #local-search-results - #local-hits - #local-stats - #hr.local-search-stats__hr - case config.language - when "zh-CN" - span=_p("local_search.by") - | #[a(href="https://github.com/wzpan/hexo-generator-search" style={'color': '#49B1F5'}) hexo-generator-search] - | #[span=_p("local_search.powered")] - when "en" - default - span=_p("local_search.powered_by") - | #[a(href="https://github.com/wzpan/hexo-generator-search" style={'color': '#49B1F5'}) hexo-generator-search] - span.search-close-button - i.fas.fa-times -#search-mask \ No newline at end of file +#local-search + .search-dialog + #local-search-title.search-dialog__title=_p("local_search.label") + #local-input-panel + #local-search-input + .local-search-box + input(placeholder=_p("local_search.input_placeholder") type="text").local-search-box--input + hr + #local-search-results + #local-hits + #local-stats + #hr.local-search-stats__hr + case config.language + when "zh-CN" + span=_p("local_search.by") + | #[a(href="https://github.com/wzpan/hexo-generator-search" style={'color': '#49B1F5'}) hexo-generator-search] + | #[span=_p("local_search.powered")] + when "en" + default + span=_p("local_search.powered_by") + | #[a(href="https://github.com/wzpan/hexo-generator-search" style={'color': '#49B1F5'}) hexo-generator-search] + span.search-close-button + i.fas.fa-times + #search-mask \ No newline at end of file diff --git a/layout/includes/third-party/subtitle.pug b/layout/includes/third-party/subtitle.pug index 05b95fc..ad995cc 100644 --- a/layout/includes/third-party/subtitle.pug +++ b/layout/includes/third-party/subtitle.pug @@ -1,97 +1,40 @@ - var source = theme.subtitle.source -if source == '1' - script. - function subtitleType () { - $.getJSON('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json',function (data) { - if (!{theme.subtitle.effect}) { - var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var both = sub.unshift(data.text) - typed = new Typed('#subtitle', { - strings: sub, - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50, - }) - } else { - document.getElementById('subtitle').innerHTML = data.text - } - }) - } - - if (!{theme.subtitle.effect}) { - if (typeof Typed === 'function') subtitleType() - else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) - } else { - subtitleType() - } - -else if source == '2' - script. - function subtitleType () { - $.getJSON('https://v1.hitokoto.cn', function (data) { - if (!{theme.subtitle.effect}) { - var from = '出自 ' + data.from - var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var both = sub.unshift(data.hitokoto, from) - var typed = new Typed('#subtitle', { - strings: sub, - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50, - }) - } else { - document.getElementById('subtitle').innerHTML = data.hitokoto - } - }) - } - - if (!{theme.subtitle.effect}) { - if (typeof Typed === 'function') subtitleType() - else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) - } else { - subtitleType() - } - -else if source == '3' - script. - function subtitleType () { - $.getScript('http://yijuzhan.com/api/word.php?m=js', function () { - var con = str[0] - if (!{theme.subtitle.effect}) { - var from = '出自 ' + str[1] - var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var both = sub.unshift(con, from) - var typed = new Typed('#subtitle', { - strings: sub, - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50, - }) - } else { - document.getElementById('subtitle').innerHTML = con - } - }) - } - - if (!{theme.subtitle.effect}) { - if (typeof Typed === 'function') subtitleType() - else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) - } else { - subtitleType() - } - -else if source == '4' - script. - function subtitleType () { - $.getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js',function () { - jinrishici.load(function (result) { +case source + when 1 + script. + function subtitleType () { + $.getJSON('https://api.btstu.cn/yan/api.php?charset=utf-8&encode=json',function (data) { if (!{theme.subtitle.effect}) { var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') - var content = result.data.content - var both = sub.unshift(content) + var both = sub.unshift(data.text) + typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = data.text + } + }) + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + + when 2 + script. + function subtitleType () { + $.getJSON('https://v1.hitokoto.cn', function (data) { + if (!{theme.subtitle.effect}) { + var from = '出自 ' + data.from + var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') + var both = sub.unshift(data.hitokoto, from) var typed = new Typed('#subtitle', { strings: sub, startDelay: 300, @@ -100,38 +43,96 @@ else if source == '4' backSpeed: 50, }) } else { - document.getElementById('subtitle').innerHTML = result.data.content + document.getElementById('subtitle').innerHTML = data.hitokoto } }) - }) - } - - if (!{theme.subtitle.effect}) { - if (typeof Typed === 'function') subtitleType() - else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) - } else { - subtitleType() - } - -else - script. - function subtitleType () { - if (!{theme.subtitle.effect}) { - var typed = new Typed("#subtitle", { - strings: "!{theme.subtitle.sub}".split(","), - startDelay: 300, - typeSpeed: 150, - loop: !{theme.subtitle.loop}, - backSpeed: 50 - }) - } else { - document.getElementById("subtitle").innerHTML = '!{theme.subtitle.sub[0]}' } - } - if (!{theme.subtitle.effect}) { - if (typeof Typed === 'function') subtitleType() - else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) - } else { - subtitleType() - } \ No newline at end of file + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + + when 3 + script. + function subtitleType () { + $.getScript('http://yijuzhan.com/api/word.php?m=js', function () { + var con = str[0] + if (!{theme.subtitle.effect}) { + var from = '出自 ' + str[1] + var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') + var both = sub.unshift(con, from) + var typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = con + } + }) + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + + when 4 + script. + function subtitleType () { + $.getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js',function () { + jinrishici.load(function (result) { + if (!{theme.subtitle.effect}) { + var sub = "!{theme.subtitle.sub}".length == 0 ? new Array() : "!{theme.subtitle.sub}".split(',') + var content = result.data.content + var both = sub.unshift(content) + var typed = new Typed('#subtitle', { + strings: sub, + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50, + }) + } else { + document.getElementById('subtitle').innerHTML = result.data.content + } + }) + }) + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } + + default + script. + function subtitleType () { + if (!{theme.subtitle.effect}) { + var typed = new Typed("#subtitle", { + strings: "!{theme.subtitle.sub}".split(","), + startDelay: 300, + typeSpeed: 150, + loop: !{theme.subtitle.loop}, + backSpeed: 50 + }) + } else { + document.getElementById("subtitle").innerHTML = '!{theme.subtitle.sub[0]}' + } + } + + if (!{theme.subtitle.effect}) { + if (typeof Typed === 'function') subtitleType() + else $.getScript('!{url_for(theme.CDN.typed)}', subtitleType) + } else { + subtitleType() + } \ No newline at end of file diff --git a/layout/includes/widget/card_author.pug b/layout/includes/widget/card_author.pug index 5b1c8e4..b1faefb 100644 --- a/layout/includes/widget/card_author.pug +++ b/layout/includes/widget/card_author.pug @@ -13,19 +13,19 @@ .card-info-data-item.is-center a(href=url_for(config.archive_dir) + '/') .headline= _p('aside.articles') - .length_num= site.posts.length + .length-num= site.posts.length if site.tags.length .card-info-data-item.is-center a(href=url_for(config.tag_dir) + '/') .headline= _p('aside.tags') - .length_num= site.tags.length + .length-num= site.tags.length if site.categories.length .card-info-data-item.is-center a(href=url_for(config.category_dir) + '/') .headline= _p('aside.categories') - .length_num= site.categories.length + .length-num= site.categories.length a#card-info-btn.button--animated(href=theme.aside.card_author.button.link) i(class=theme.aside.card_author.button.icon) diff --git a/package.json b/package.json index ec6fef4..63109cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.3.0-b4", + "version": "3.3.0-b5", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/events/check.js b/scripts/events/init.js similarity index 75% rename from scripts/events/check.js rename to scripts/events/init.js index 33cfae8..c198e9e 100644 --- a/scripts/events/check.js +++ b/scripts/events/init.js @@ -18,4 +18,10 @@ hexo.extend.filter.register('before_generate', () => { process.exit(-1) } } + + // let stylus to get the hexo highlight config + const themeConfig = hexo.theme.config + const hexoConfig = hexo.config + themeConfig.highlight_settings = hexoConfig.highlight + themeConfig.prismjs_settings = hexoConfig.prismjs }) diff --git a/source/css/_global/function.styl b/source/css/_global/function.styl index 5c9bdde..1ba495d 100644 --- a/source/css/_global/function.styl +++ b/source/css/_global/function.styl @@ -68,7 +68,7 @@ if hexo-config('enter_transitions') #ribbon-canvas animation: ribbon_to_show 4s - #mobile-sidebar-menus + #sidebar-menus &.open for i in 1 2 3 4 > :nth-child({i}) diff --git a/source/css/_global/index.styl b/source/css/_global/index.styl index c2b1db0..fcecdb8 100644 --- a/source/css/_global/index.styl +++ b/source/css/_global/index.styl @@ -25,7 +25,6 @@ --blockquote-color: $blockquote-color --blockquote-bg: $blockquote-background-color --reward-pop: $reward-pop-up-bg - --sidebar-icon-color: $sidebar-icon-color --toc-link-color: $toc-link-color html diff --git a/source/css/_highlight/highlight.styl b/source/css/_highlight/highlight.styl index 4f0390f..fccfaca 100644 --- a/source/css/_highlight/highlight.styl +++ b/source/css/_highlight/highlight.styl @@ -1,8 +1,8 @@ // https://github.com/equinusocio/vsc-material-theme $highlight_theme = hexo-config('highlight_theme') -$highlighEnable = hexo-config('rootConfig.highlight') && hexo-config('rootConfig.highlight.enable') -$prismjsEnable = hexo-config('rootConfig.prismjs') && hexo-config('rootConfig.prismjs.enable') -wordWrap = !hexo-config('rootConfig.highlight.line_number') && hexo-config('code_word_wrap') +$highlighEnable = hexo-config('highlight_settings') && hexo-config('highlight_settings.enable') +$prismjsEnable = hexo-config('prismjs_settings') && hexo-config('prismjs_settings.enable') +wordWrap = !hexo-config('highlight_settings.line_number') && hexo-config('code_word_wrap') @require 'theme' diff --git a/source/css/_highlight/highlight/index.styl b/source/css/_highlight/highlight/index.styl index 4239174..9c3d4f9 100644 --- a/source/css/_highlight/highlight/index.styl +++ b/source/css/_highlight/highlight/index.styl @@ -22,9 +22,9 @@ if $highlight_theme != false overflow: auto border: none - td - padding: 0 - border: none + td + padding: 0 + border: none .gutter pre padding-right: .5rem diff --git a/source/css/_highlight/prismjs/index.styl b/source/css/_highlight/prismjs/index.styl index 17e52df..5ac7f4f 100644 --- a/source/css/_highlight/prismjs/index.styl +++ b/source/css/_highlight/prismjs/index.styl @@ -1,4 +1,4 @@ -if hexo-fonfig('rootConfig.prismjs.line_number') +if hexo-fonfig('prismjs_settings.line_number') @require 'line-number' if $highlight_theme != false diff --git a/source/css/_layout/aside.styl b/source/css/_layout/aside.styl index 862a8b8..4144b37 100644 --- a/source/css/_layout/aside.styl +++ b/source/css/_layout/aside.styl @@ -65,7 +65,7 @@ color: var(--font-color) font-size: 1em - .length_num + .length-num margin-top: -.3rem color: var(--text-highlight-color) font-size: 1.4em @@ -271,7 +271,7 @@ bottom: 30px z-index: 100 display: none - width: 300px + width: $toc-mobile-width transform-origin: right bottom animation: toc-open .3s @@ -303,7 +303,7 @@ &.active border-left-color: darken($theme-toc-color, 20%) background: $theme-toc-color - color: $sidebar-active-color + color: $toc-active-color &:before position: absolute diff --git a/source/css/_layout/mobile-sidebar.styl b/source/css/_layout/sidebar.styl similarity index 86% rename from source/css/_layout/mobile-sidebar.styl rename to source/css/_layout/sidebar.styl index 57a40eb..fa9c68e 100644 --- a/source/css/_layout/mobile-sidebar.styl +++ b/source/css/_layout/sidebar.styl @@ -1,5 +1,5 @@ -#mobile-sidebar - #menu_mask +#sidebar + #menu-mask position: fixed z-index: 102 display: none @@ -7,14 +7,14 @@ height: 100% background: alpha($dark-black, .8) - #mobile-sidebar-menus + #sidebar-menus position: fixed top: 0 - right: -250px + right: -($sidebar-width) z-index: 103 overflow-x: hidden overflow-y: auto - width: 250px + width: $sidebar-width height: 100% background: var(--sidebar-bg) transition: all .5s @@ -22,7 +22,7 @@ &.open transform: translate3d(-100%, 0, 0) - & > .mobile_author_icon + & > .author-avatar padding: 1.3rem 1.5rem 0 text-align: center @@ -35,20 +35,20 @@ &:hover transform: rotate(360deg) - .mobile_post_data + .site-data display: table padding: .6rem .5rem 0 width: 100% table-layout: fixed - .mobile_data_item + .data-item display: table-cell - .mobile_data_link + .data-item-link & > a > div @extend .limit-one-line - .length_num + .length-num color: var(--text-highlight-color) font-size: 1.28em @@ -71,11 +71,11 @@ cursor: pointer i:first-child - width: 30% + width: 25% text-align: left span - width: 70% + width: 75% &:hover color: $light-blue diff --git a/source/css/_layout/third-party.styl b/source/css/_layout/third-party.styl index 7d39528..3ffd4aa 100644 --- a/source/css/_layout/third-party.styl +++ b/source/css/_layout/third-party.styl @@ -14,7 +14,7 @@ background: url(hexo-config('valine.bg')) 100% 100% no-repeat &:focus - background: none + background-image: none .vimg transition: all .3s diff --git a/source/css/_mode/darkmode.styl b/source/css/_mode/darkmode.styl index 14df968..4cd72a5 100644 --- a/source/css/_mode/darkmode.styl +++ b/source/css/_mode/darkmode.styl @@ -26,7 +26,6 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' --blockquote-color: alpha(#FFFFFF, .7) --blockquote-bg: lighten(#121212, 10) --reward-pop: lighten(#121212, 10) - --sidebar-icon-color: alpha(#FFFFFF, .7) --toc-link-color: alpha(#FFFFFF, .6) #web_bg:before, @@ -69,7 +68,7 @@ if hexo-config('darkmode.enable') || hexo-config('display_mode') == 'dark' figure.highlight box-shadow: none - if hexo-config('rootConfig.highlight') && hexo-config('rootConfig.highlight.enable') + if hexo-config('highlight_settings') && hexo-config('highlight_settings.enable') table::-webkit-scrollbar-thumb background: lighten(#121212, 5) diff --git a/source/css/_search/algolia.styl b/source/css/_search/algolia.styl index 0f9c287..55ac8c4 100644 --- a/source/css/_search/algolia.styl +++ b/source/css/_search/algolia.styl @@ -1,76 +1,77 @@ #algolia-search - animation: titlescale .5s + .search-dialog + animation: titlescale .5s - .ais-search-box - margin: 0 auto - max-width: 100% - width: 100% + .ais-search-box + margin: 0 auto + max-width: 100% + width: 100% - input - padding: .25rem .7rem - outline: none - border: 2px solid $search-color - border-radius: 2rem - background: var(--search-bg) - color: var(--search-input-color) + input + padding: .25rem .7rem + outline: none + border: 2px solid $search-color + border-radius: 2rem + background: var(--search-bg) + color: var(--search-input-color) - .ais-hits--item.algolia-hit-item - position: relative - padding-left: 1.2rem - - &:hover - &:before - border-color: $pseudo-hover - - &:before - $w = .5em - position: absolute - top: .53em - left: 0 - width: w = $w - height: h = w - border: .15rem solid $search-color - border-radius: w - background: transparent - content: '' - line-height: h - transition: all .2s ease-in-out - - a - display: block - color: var(--search-result-title) - cursor: pointer + .ais-hits--item.algolia-hit-item + position: relative + padding-left: 1.2rem &:hover - color: $search-color + &:before + border-color: $pseudo-hover - em - color: $search-keyword-highlight - font-weight: bold + &:before + $w = .5em + position: absolute + top: .53em + left: 0 + width: w = $w + height: h = w + border: .15rem solid $search-color + border-radius: w + background: transparent + content: '' + line-height: h + transition: all .2s ease-in-out - .ais-pagination.pagination - margin: .8rem 0 0 - padding: 0 - text-align: center + a + display: block + color: var(--search-result-title) + cursor: pointer - .ais-pagination--item - margin: 0 .2rem + &:hover + color: $search-color + + em + color: $search-keyword-highlight + font-weight: bold + + .ais-pagination.pagination + margin: .8rem 0 0 padding: 0 + text-align: center - a - display: inline-block - min-width: 1.2rem - height: 1.2rem - text-align: center - line-height: 1.2rem + .ais-pagination--item + margin: 0 .2rem + padding: 0 - .ais-pagination--item.current - a - background: $theme-paginator-color - color: #eee - cursor: default + a + display: inline-block + min-width: 1.2rem + height: 1.2rem + text-align: center + line-height: 1.2rem - .algolia-logo - padding-top: 2px - width: 4rem - height: 1.5rem \ No newline at end of file + .ais-pagination--item.current + a + background: $theme-paginator-color + color: #eee + cursor: default + + .algolia-logo + padding-top: 2px + width: 4rem + height: 1.5rem \ No newline at end of file diff --git a/source/css/_search/local-search.styl b/source/css/_search/local-search.styl index 85462a5..8f9fe95 100644 --- a/source/css/_search/local-search.styl +++ b/source/css/_search/local-search.styl @@ -1,68 +1,69 @@ #local-search - animation: titlescale .5s + .search-dialog + animation: titlescale .5s - .local-search-box - margin: 0 auto - max-width: 100% - width: 100% - - input - padding: .25rem .7rem + .local-search-box + margin: 0 auto + max-width: 100% width: 100% - outline: none - border: 2px solid $search-color - border-radius: 2rem - background: var(--search-bg) - color: var(--search-input-color) - -webkit-appearance: none - .local-search__hit-item - position: relative - padding-left: 1.2rem - line-height: 1.7 + input + padding: .25rem .7rem + width: 100% + outline: none + border: 2px solid $search-color + border-radius: 2rem + background: var(--search-bg) + color: var(--search-input-color) + -webkit-appearance: none - &:hover - &:before - border-color: $pseudo-hover - - &:before - $w = .5em - position: absolute - top: .45em - left: 0 - width: w = $w - height: h = w - border: .15rem solid $search-color - border-radius: w - background: transparent - content: '' - line-height: h - transition: all .2s ease-in-out - - a - display: block - color: var(--search-result-title) - font-weight: 600 - cursor: pointer + .local-search__hit-item + position: relative + padding-left: 1.2rem + line-height: 1.7 &:hover - color: $search-color + &:before + border-color: $pseudo-hover - .search-result - margin: 0 0 .4rem - word-break: break-all + &:before + $w = .5em + position: absolute + top: .45em + left: 0 + width: w = $w + height: h = w + border: .15rem solid $search-color + border-radius: w + background: transparent + content: '' + line-height: h + transition: all .2s ease-in-out - .search-keyword - color: $search-keyword-highlight - font-weight: bold + a + display: block + color: var(--search-result-title) + font-weight: 600 + cursor: pointer - .local-search-stats__hr - display: none !important + &:hover + color: $search-color - .search-result-list - overflow-y: auto - max-height: 10.5rem + .search-result + margin: 0 0 .4rem + word-break: break-all - +maxWidth768() - padding-bottom: 2rem - max-height: 75vh !important + .search-keyword + color: $search-keyword-highlight + font-weight: bold + + .local-search-stats__hr + display: none !important + + .search-result-list + overflow-y: auto + max-height: 10.5rem + + +maxWidth768() + padding-bottom: 2rem + max-height: 75vh !important diff --git a/source/css/var.styl b/source/css/var.styl index 70328ef..f3f0267 100644 --- a/source/css/var.styl +++ b/source/css/var.styl @@ -58,16 +58,12 @@ $a-link-color = #99a9bf $sticky-color = $light-orange $theme-meta-color = $themeColorEnable && hexo-config('theme_color.meta_color') ? convert(hexo-config('theme_color.meta_color')) : #858585 // sidebar -$sidebar-icon-top = 20px -$sidebar-icon-left = $sidebar-icon-top - 4px -$sidebar-icon-size = 16px -$sidebar-icon-color = #1F2D3D -$sidebar-width = 300px $sidebar-background = #f6f8fa -$sidebar-active-color = #fff -$mobile-sidebar-width = 250px +$sidebar-width = 300px // aside $toc-link-color = #666261 +$toc-mobile-width = 300px +$toc-active-color = #fff // Button $button-color = #fff $button-hover-color = $themeColorEnable && hexo-config('theme_color.button_hover') ? convert(hexo-config('theme_color.button_hover')) : $light-orange diff --git a/source/js/main.js b/source/js/main.js index 8a5e1e7..c8c4e4b 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -24,8 +24,8 @@ $(function () { // sidebar menus const sidebarFn = () => { const $toggleMenu = $('#toggle-menu') - const $mobileSidebarMenus = $('#mobile-sidebar-menus') - const $menuMask = $('#menu_mask') + const $mobileSidebarMenus = $('#sidebar-menus') + const $menuMask = $('#menu-mask') const $body = $('body') function openMobileSidebar () { @@ -489,7 +489,7 @@ $(function () { * 解決menus在觸摸屏下,滑動屏幕menus_item_child不消失的問題(手機hover的bug) */ const clickFnOfSubMenu = function () { - $('#mobile-sidebar-menus .expand').on('click', function () { + $('#sidebar-menus .expand').on('click', function () { $(this).parents('.menus_item').find('> .menus_item_child').slideToggle() $(this).toggleClass('hide') }) diff --git a/source/js/search/algolia.js b/source/js/search/algolia.js index 822607c..00fe0a0 100644 --- a/source/js/search/algolia.js +++ b/source/js/search/algolia.js @@ -1,7 +1,7 @@ $(function () { const openSearch = () => { $('body').css({ width: '100%', overflow: 'hidden' }) - $('#algolia-search').css('display', 'block') + $('#algolia-search .search-dialog').css('display', 'block') $('.ais-search-box--input').focus() $('#search-mask').fadeIn() // shortcut: ESC @@ -15,12 +15,12 @@ $(function () { const closeSearch = () => { $('body').css({ width: '', overflow: '' }) - $('#algolia-search').css({ + $('#algolia-search .search-dialog').css({ animation: 'search_close .5s' }) setTimeout(function () { - $('#algolia-search').css({ + $('#algolia-search .search-dialog').css({ animation: '', display: 'none' }) diff --git a/source/js/search/local-search.js b/source/js/search/local-search.js index 088d54c..721ddc3 100644 --- a/source/js/search/local-search.js +++ b/source/js/search/local-search.js @@ -5,7 +5,7 @@ $(function () { width: '100%', overflow: 'hidden' }) - $('#local-search').css('display', 'block') + $('#local-search .search-dialog').css('display', 'block') $('#local-search-input input').focus() $('#search-mask').fadeIn() if (!loadFlag) { @@ -27,12 +27,12 @@ $(function () { width: '', overflow: '' }) - $('#local-search').css({ + $('#local-search .search-dialog').css({ animation: 'search_close .5s' }) setTimeout(function () { - $('#local-search').css({ + $('#local-search .search-dialog').css({ animation: '', display: 'none' }) @@ -49,7 +49,7 @@ $(function () { searchClickFn() window.addEventListener('pjax:complete', function () { - $('#local-search').is(':visible') && closeSearch() + $('#local-search .search-dialog').is(':visible') && closeSearch() searchClickFn() })