Skip to content

Commit

Permalink
label 3.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryc127 committed Jul 4, 2021
1 parent 829a3db commit 026a348
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 76 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ fancybox: true
# --------------------------------------

# mermaid
# see https://github.com/knsv/mermaid
# see https://github.com/mermaid-js/mermaid
mermaid:
enable: false
# built-in themes: default/forest/dark/neutral
Expand Down
7 changes: 4 additions & 3 deletions layout/includes/page/flink.pug
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
each item in i.link_list
.flink-list-item
a(href=url_for(item.link) title=item.name target="_blank")
img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name )
span.flink-item-name= item.name
span.flink-item-desc(title=item.descr)= item.descr
.flink-item-icon
img(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name )
.flink-item-name= item.name
.flink-item-desc(title=item.descr)= item.descr
!= page.content

2 changes: 1 addition & 1 deletion layout/includes/third-party/math/katex.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ link(rel="stylesheet" type="text/css" href=theme.CDN.katex_copytex_css)
script.
(() => {
document.querySelectorAll('#article-container span.katex-display').forEach(item => {
btf.wrap(item, 'div', '', 'katex-wrap')
btf.wrap(item, 'div', { class: 'katex-wrap'})
})
})()

3 changes: 2 additions & 1 deletion layout/includes/third-party/pjax.pug
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ script.

document.addEventListener('pjax:send', function () {

// removeEventListener toc scroll
// removeEventListener scroll
window.removeEventListener('scroll', window.tocScrollFn)
window.removeEventListener('scroll', scrollCollect)

typeof preloader === 'object' && preloader.initLoading()

Expand Down
2 changes: 1 addition & 1 deletion layout/includes/widget/card_newest_comment.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if theme.newest_comments.enable
.card-widget#card-newest-comments
.item-headline
i.fas.fa-bolt
i.fas.fa-comment-dots
span= _p('aside.card_newest_comments.headline')
.aside-list
span= _p('aside.card_newest_comments.loading_text')
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-butterfly",
"version": "3.8.0-b3",
"version": "3.8.0",
"description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json",
"scripts": {
Expand All @@ -27,6 +27,6 @@
"hexo-renderer-pug": "^1.0.0"
},
"homepage": "https://butterfly.js.org/",
"author": "Jerry <btf@immyw.com>",
"author": "Jerry <i@immyw.com>",
"license": "Apache-2.0"
}
2 changes: 1 addition & 1 deletion source/css/_global/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
--btn-hover-color: $button-hover-color
--btn-color: $button-color
--btn-bg: $button-bg
--text-bg-hover: $text-bg-hover
--text-bg-hover: rgba($text-bg-hover, .7)
--light-grey: $light-grey
--white: $white
--text-highlight-color: $text-highlight-color
Expand Down
2 changes: 1 addition & 1 deletion source/css/_highlight/highlight.styl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ blockquote
color: var(--hltools-color)
font-size: $code-font-size

&.closed + table
&.closed ~ *
display: none

.expand
Expand Down
2 changes: 1 addition & 1 deletion source/css/_layout/aside.styl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
font-size: 1.2em

span
margin-left: .5rem
margin-left: .3rem

.sticky_layout
+minWidth900()
Expand Down
16 changes: 6 additions & 10 deletions source/css/_layout/sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,21 @@
@extend .limit-one-line
position: relative
display: block
padding: .3rem 1.5rem
padding: .3rem 1.5rem .3rem 1.1rem
color: var(--font-color)
font-size: 1.15em
cursor: pointer

&:hover
background: var(--text-bg-hover)

i:first-child
width: 25%
width: 15%
text-align: left

span
width: 75%

&:hover
color: $light-blue

.expand
position: absolute
top: .78em
right: .4rem
right: .9rem
transition: transform .3s

&.hide
Expand Down
15 changes: 13 additions & 2 deletions source/css/_layout/third-party.styl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#vcomment,
#waline
#vcomment
font-size: 1.1em

.vbtn
Expand All @@ -21,6 +20,18 @@
&:after
z-index: 22

#waline-wrap
--waline-font-size: 1.1em
--waline-theme-color: $button-bg
--waline-active-color: $button-hover-color
--waline-avatar-size: 2.75rem

.vuser
transition: all .5s

&:hover
transform: rotate(360deg)

if hexo-config('valine.bg')
#vcomment
textarea
Expand Down
11 changes: 7 additions & 4 deletions source/css/_page/flink.styl
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,31 @@
color: var(--font-color)
text-decoration: none

img
.flink-item-icon
float: left
overflow: hidden
margin: 15px 10px
width: 60px
height: 60px
border-radius: 35px
transition: all .3s

img
width: 100%
height: 100%
transition: all .3s

.img-alt
display: none

.flink-item-name
@extend .limit-one-line
display: block
padding: 16px 10px 0 0
height: 40px
font-weight: bold
font-size: 1.43em

.flink-item-desc
@extend .limit-one-line
display: block
padding: 16px 10px 16px 0
height: 50px
font-size: .93em
2 changes: 0 additions & 2 deletions source/css/_search/algolia.styl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#algolia-search
.search-dialog
animation: titlescale .5s

.ais-search-box
margin: 0 auto
max-width: 100%
Expand Down
3 changes: 3 additions & 0 deletions source/css/_search/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
margin-left: -15rem
padding: 1rem
width: 30rem
border-radius: 8px
background: var(--search-bg)
animation: titlescale .5s

+maxWidth768()
top: 0
left: 0
margin: 0
width: 100%
height: 100%
border-radius: 0

hr
margin: 1rem auto
Expand Down
2 changes: 0 additions & 2 deletions source/css/_search/local-search.styl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#local-search
.search-dialog
animation: titlescale .5s

.local-search-box
margin: 0 auto
max-width: 100%
Expand Down
75 changes: 40 additions & 35 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ document.addEventListener('DOMContentLoaded', function () {
$figureHighlight.forEach(function (item) {
const langName = item.getAttribute('data-language') ? item.getAttribute('data-language') : 'Code'
const highlightLangEle = `<div class="code-lang">${langName}</div>`
btf.wrap(item, 'figure', '', 'highlight')
btf.wrap(item, 'figure', { class: 'highlight' })
createEle(highlightLangEle, item)
})
} else {
Expand All @@ -208,7 +208,7 @@ document.addEventListener('DOMContentLoaded', function () {
} else {
if (isPrismjs) {
$figureHighlight.forEach(function (item) {
btf.wrap(item, 'figure', '', 'highlight')
btf.wrap(item, 'figure', { class: 'highlight' })
createEle('', item)
})
} else {
Expand Down Expand Up @@ -332,50 +332,55 @@ document.addEventListener('DOMContentLoaded', function () {
return
}

// find the scroll direction
function scrollDirection (currentTop) {
const result = currentTop > initTop // true is down & false is up
initTop = currentTop
return result
}

let initTop = 0
let isChatShow = true
const $header = document.getElementById('page-header')
const isChatBtnHide = typeof chatBtnHide === 'function'
const isChatBtnShow = typeof chatBtnShow === 'function'
window.addEventListener('scroll', btf.throttle(function (e) {
const currentTop = window.scrollY || document.documentElement.scrollTop
const isDown = scrollDirection(currentTop)
if (currentTop > 56) {
if (isDown) {
if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
if (isChatBtnShow && isChatShow === true) {
chatBtnHide()
isChatShow = false

window.scrollCollect = () => {
return btf.throttle(function (e) {
const currentTop = window.scrollY || document.documentElement.scrollTop
const isDown = scrollDirection(currentTop)
if (currentTop > 56) {
if (isDown) {
if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
if (isChatBtnShow && isChatShow === true) {
chatBtnHide()
isChatShow = false
}
} else {
if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
if (isChatBtnHide && isChatShow === false) {
chatBtnShow()
isChatShow = true
}
}
$header.classList.add('nav-fixed')
if (window.getComputedStyle($rightside).getPropertyValue('opacity') === '0') {
$rightside.style.cssText = 'opacity: 1; transform: translateX(-38px)'
}
} else {
if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
if (isChatBtnHide && isChatShow === false) {
chatBtnShow()
isChatShow = true
if (currentTop === 0) {
$header.classList.remove('nav-fixed', 'nav-visible')
}
$rightside.style.cssText = "opacity: ''; transform: ''"
}
$header.classList.add('nav-fixed')
if (window.getComputedStyle($rightside).getPropertyValue('opacity') === '0') {

if (document.body.scrollHeight <= innerHeight) {
$rightside.style.cssText = 'opacity: 1; transform: translateX(-38px)'
}
} else {
if (currentTop === 0) {
$header.classList.remove('nav-fixed', 'nav-visible')
}
$rightside.style.cssText = "opacity: ''; transform: ''"
}

if (document.body.scrollHeight <= innerHeight) {
$rightside.style.cssText = 'opacity: 1; transform: translateX(-38px)'
}
}, 200))

// find the scroll direction
function scrollDirection (currentTop) {
const result = currentTop > initTop // true is down & false is up
initTop = currentTop
return result
}, 200)()
}

window.addEventListener('scroll', scrollCollect)
}

/**
Expand Down Expand Up @@ -687,7 +692,7 @@ document.addEventListener('DOMContentLoaded', function () {
const $table = document.querySelectorAll('#article-container :not(.highlight) > table, #article-container > table')
if ($table.length) {
$table.forEach(item => {
btf.wrap(item, 'div', '', 'table-wrap')
btf.wrap(item, 'div', { class: 'table-wrap' })
})
}
}
Expand Down
18 changes: 9 additions & 9 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,36 +207,36 @@ const btf = {
*
* @param {*} selector
* @param {*} eleType the type of create element
* @param {*} id id
* @param {*} cn class name
* @param {*} options object key: value
*/
wrap: function (selector, eleType, id = '', cn = '') {
wrap: (selector, eleType, options) => {
const creatEle = document.createElement(eleType)
if (id) creatEle.id = id
if (cn) creatEle.className = cn
for (const [key, value] of Object.entries(options)) {
creatEle.setAttribute(key, value)
}
selector.parentNode.insertBefore(creatEle, selector)
creatEle.appendChild(selector)
},

unwrap: function (el) {
unwrap: el => {
const elParentNode = el.parentNode
if (elParentNode !== document.body) {
elParentNode.parentNode.insertBefore(el, elParentNode)
elParentNode.parentNode.removeChild(elParentNode)
}
},

isJqueryLoad: (fn) => {
isJqueryLoad: fn => {
if (typeof jQuery === 'undefined') {
getScript(GLOBAL_CONFIG.source.jQuery).then(fn)
} else {
fn()
}
},

isHidden: (ele) => ele.offsetHeight === 0 && ele.offsetWidth === 0,
isHidden: ele => ele.offsetHeight === 0 && ele.offsetWidth === 0,

getEleTop: (ele) => {
getEleTop: ele => {
let actualTop = ele.offsetTop
let current = ele.offsetParent

Expand Down

0 comments on commit 026a348

Please sign in to comment.