fixed image height & js formatting

This commit is contained in:
cupcakearmy 2020-09-07 17:06:01 +02:00
parent 331d47c9e9
commit 6ff2e56501
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9
7 changed files with 94 additions and 96 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ node_modules/
# Generated
.cache/
liquet/dist/
liquet.zip

View File

@ -2,7 +2,7 @@
Theme Name: Liquet
Author: Niccolo Borgioli
Description: Minimalistic clean theme
Version: 0.16
Version: 0.17
License: MIT
Tags: minimal, simple, typography, clean
Author URI: https://nicco.io

View File

@ -3,9 +3,9 @@ import lazy from './lazy'
import swup from './swup'
document.addEventListener('DOMContentLoaded', () => {
lights()
lights()
lazy()
swup(() => {
lazy()
swup(() => {
lazy()
})
})
})

View File

@ -1,42 +1,39 @@
import $ from 'jquery'
export default () => {
const bottomOffset = 300
const app = document.getElementById('app')
let loading = false
let page = WPParams.lazy.current_page
const bottomOffset = 300
const app = document.getElementById('app')
let loading = false
let page = WPParams.lazy.current_page
function load() {
function load() {
const pixelToBottom = this.scrollHeight - (this.scrollTop + this.clientHeight)
const pixelToBottom = this.scrollHeight - (this.scrollTop + this.clientHeight)
if (!loading && pixelToBottom < bottomOffset) {
loading = true
if (!loading && pixelToBottom < bottomOffset) {
loading = true
$.ajax({
url: WPParams.lazy.ajaxurl,
data: {
name: window.location.pathname
.replace(/(\/\d+){3}\//, '')
.replace(/\/$/, ''),
action: 'lazy_load',
page,
},
type: 'POST',
success: (data) => {
if (data) {
$('#list').find('hr:last-of-type').after(data) // where to insert posts
page++
loading = false
}
}
})
}
$.ajax({
url: WPParams.lazy.ajaxurl,
data: {
name: window.location.pathname.replace(/(\/\d+){3}\//, '').replace(/\/$/, ''),
action: 'lazy_load',
page,
},
type: 'POST',
success: (data) => {
if (data) {
$('#list').find('hr:last-of-type').after(data) // where to insert posts
page++
loading = false
}
},
})
}
}
// Bind to the scroll event
$('#app').scroll(load)
// Bind to the scroll event
$('#app').scroll(load)
// Check initial page if they need loading
load.bind(app)()
// Check initial page if they need loading
load.bind(app)()
}

View File

@ -1,30 +1,30 @@
export default () => {
// Lights
const key = 'nicco.io:blog:lights'
const CSS = 'body, .wp-block-image img, .thumbnail img {filter: invert(1);} '
const style = window.document.createElement('style')
document.head.appendChild(style)
// Lights
const key = 'nicco.io:blog:lights'
const CSS = 'body, .wp-block-image img, .thumbnail img {filter: invert(1);} '
const style = window.document.createElement('style')
document.head.appendChild(style)
const on = () => {
style.sheet.deleteRule(parseInt(window.localStorage.getItem(key)))
window.localStorage.removeItem(key)
}
const on = () => {
style.sheet.deleteRule(parseInt(window.localStorage.getItem(key)))
window.localStorage.removeItem(key)
}
const off = () => {
const i = style.sheet.insertRule(CSS)
window.localStorage.setItem(key, i)
}
const off = () => {
const i = style.sheet.insertRule(CSS)
window.localStorage.setItem(key, i)
}
const isDark = () => window.localStorage.getItem(key) !== null
const isDark = () => window.localStorage.getItem(key) !== null
if (isDark()) off()
if (isDark()) off()
window.toggleLights = () => isDark() ? on() : off()
window.toggleLights = () => (isDark() ? on() : off())
// Focus scrolling
document.addEventListener('DOMContentLoaded', () => {
const toFocus = document.querySelector('[data-focusme]')
toFocus.tabIndex = '1'
toFocus.focus({preventScroll: true})
})
// Focus scrolling
document.addEventListener('DOMContentLoaded', () => {
const toFocus = document.querySelector('[data-focusme]')
toFocus.tabIndex = '1'
toFocus.focus({ preventScroll: true })
})
}

View File

@ -2,11 +2,11 @@ import Swup from 'swup'
import SwupPreloadPlugin from '@swup/preload-plugin'
export default (fn) => {
const swup = new Swup({
linkSelector: `a[href^="${window.location.origin}"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup])`,
plugins: [new SwupPreloadPlugin()],
containers: ['#app']
})
const swup = new Swup({
linkSelector: `a[href^="${window.location.origin}"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup])`,
plugins: [new SwupPreloadPlugin()],
containers: ['#app'],
})
swup.on('contentReplaced', fn)
swup.on('contentReplaced', fn)
}

View File

@ -19,12 +19,12 @@
semver "^5.5.0"
"@babel/core@^7.4.4":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.11.5.tgz#6ad96e2f71899ea3f9b651f0a911e85205d1ff6d"
integrity sha512-fsEANVOcZHzrsV6dMVWqpSeXClq3lNbYrfFGme6DE25FQWe7pyeYpXyx9guqUnpy466JLzZ8z4uwSr2iv60V5Q==
version "7.11.6"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.11.6.tgz#3a9455dc7387ff1bac45770650bc13ba04a15651"
integrity sha512-Wpcv03AGnmkgm6uS6k8iwhIwTrcP0m17TL1n1sy7qD0qelDu4XNeW0dN0mHfa+Gei211yDaLoEe/VlbXQzM4Bg==
dependencies:
"@babel/code-frame" "^7.10.4"
"@babel/generator" "^7.11.5"
"@babel/generator" "^7.11.6"
"@babel/helper-module-transforms" "^7.11.0"
"@babel/helpers" "^7.10.4"
"@babel/parser" "^7.11.5"
@ -38,16 +38,16 @@
lodash "^4.17.19"
resolve "^1.3.2"
semver "^5.4.1"
source-map "^0.6.1"
source-map "^0.5.0"
"@babel/generator@^7.11.5", "@babel/generator@^7.4.4":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.11.5.tgz#a5582773425a468e4ba269d9a1f701fbca6a7a82"
integrity sha512-9UqHWJ4IwRTy4l0o8gq2ef8ws8UPzvtMkVKjTLAiRmza9p9V6Z+OfuNd9fB1j5Q67F+dVJtPC2sZXI8NM9br4g==
"@babel/generator@^7.11.5", "@babel/generator@^7.11.6", "@babel/generator@^7.4.4":
version "7.11.6"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.11.6.tgz#b868900f81b163b4d464ea24545c61cbac4dc620"
integrity sha512-DWtQ1PV3r+cLbySoHrwn9RWEgKMBLLma4OBQloPRyDYvc5msJM9kvTLo1YnlJd1P/ZuKbdli3ijr5q3FvAF3uA==
dependencies:
"@babel/types" "^7.11.5"
jsesc "^2.5.1"
source-map "^0.6.1"
source-map "^0.5.0"
"@babel/helper-annotate-as-pure@^7.10.4":
version "7.10.4"
@ -1329,12 +1329,12 @@ browserify-zlib@^0.2.0:
pako "~1.0.5"
browserslist@^4.0.0, browserslist@^4.1.0, browserslist@^4.12.0, browserslist@^4.8.5:
version "4.14.0"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.0.tgz#2908951abfe4ec98737b72f34c3bcedc8d43b000"
integrity sha512-pUsXKAF2lVwhmtpeA3LJrZ76jXuusrNyhduuQs7CDFf9foT4Y38aQOserd2lMe5DSSrjf3fx34oHwryuvxAUgQ==
version "4.14.1"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.1.tgz#cb2b490ba881d45dc3039078c7ed04411eaf3fa3"
integrity sha512-zyBTIHydW37pnb63c7fHFXUG6EcqWOqoMdDx6cdyaDFriZ20EoVxcE95S54N+heRqY8m8IUgB5zYta/gCwSaaA==
dependencies:
caniuse-lite "^1.0.30001111"
electron-to-chromium "^1.3.523"
caniuse-lite "^1.0.30001124"
electron-to-chromium "^1.3.562"
escalade "^3.0.2"
node-releases "^1.1.60"
@ -1416,10 +1416,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001111:
version "1.0.30001123"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001123.tgz#7b981d81382ab2c8fd062f3e6439215e8c503c22"
integrity sha512-03dJDoa4YC4332jq0rqwiM+Hw6tA5RJtrnZKvOQy7ASoIUv8CinkcmGhYpCvCjedvkBQrrKnkcELxrUSW/XwNQ==
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001124:
version "1.0.30001124"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001124.tgz#5d9998190258e11630d674fc50ea8e579ae0ced2"
integrity sha512-zQW8V3CdND7GHRH6rxm6s59Ww4g/qGWTheoboW9nfeMg7sUoopIfKCcNZUjwYRCOrvereh3kwDpZj4VLQ7zGtA==
caseless@~0.12.0:
version "0.12.0"
@ -2063,9 +2063,9 @@ domutils@^1.5.1, domutils@^1.7.0:
domelementtype "1"
dot-prop@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.2.0.tgz#c34ecc29556dc45f1f4c22697b6f4904e0cc4fcb"
integrity sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==
version "5.3.0"
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.3.0.tgz#90ccce708cd9cd82cc4dc8c3ddd9abdd55b20e88"
integrity sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==
dependencies:
is-obj "^2.0.0"
@ -2099,10 +2099,10 @@ ee-first@1.1.1:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
electron-to-chromium@^1.3.523:
version "1.3.560"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.560.tgz#6c3f61fe50324770b75705300e9f98f29312ea8d"
integrity sha512-0cEFfOA3sNXfSxo0FIClBhrLVSe/QO9LBiqmmYPm3N/IYyt41NRTa2EhvOMWAOKpjd91t/rq062yhnJzfVMKkQ==
electron-to-chromium@^1.3.562:
version "1.3.562"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.562.tgz#79c20277ee1c8d0173a22af00e38433b752bc70f"
integrity sha512-WhRe6liQ2q/w1MZc8mD8INkenHivuHdrr4r5EQHNomy3NJux+incP6M6lDMd0paShP3MD0WGe5R1TWmEClf+Bg==
elliptic@^6.5.3:
version "6.5.3"
@ -4600,7 +4600,7 @@ source-map@0.6.1, source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
source-map@^0.5.6:
source-map@^0.5.0, source-map@^0.5.6:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=