-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 73b5990
Showing
41 changed files
with
3,304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
.npm-debug.log | ||
logs | ||
*.log* | ||
tmp | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Dimitri Nicolas | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const defaultCLIConfig = { | ||
watch: true, | ||
input: null | ||
}; | ||
|
||
module.exports = defaultCLIConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env node | ||
|
||
const lepto = require('../'); | ||
|
||
const path = require('path'); | ||
const cosmiconfig = require('cosmiconfig'); | ||
const chalk = require('chalk'); | ||
|
||
const argv = require('minimist')(process.argv.slice(2), { | ||
alias: { | ||
w: 'watch', | ||
c: 'config' | ||
} | ||
}); | ||
|
||
const defaultConfig = require('./default-cli-config.js'); | ||
|
||
|
||
const configExplorer = cosmiconfig('lepto'); | ||
|
||
let loadedConfig = null; | ||
|
||
const searchedFor = configExplorer.searchSync(); | ||
if (searchedFor && !searchedFor.isEmpty) { | ||
loadedConfig = searchedFor.config; | ||
} | ||
|
||
if (argv.config) { | ||
const configPath = path.resolve(argv.config); | ||
const loaded = configExplorer.loadSync(configPath); | ||
if (!loaded.isEmpty) { | ||
loadedConfig = loaded.config; | ||
} | ||
else { | ||
console.log(chalk.red.bold('Lepto - Empty config file: ', configPath)); | ||
} | ||
} | ||
|
||
if (!loadedConfig) { | ||
console.log(chalk.red.bold('Lepto - No config file found')); | ||
return; | ||
} | ||
|
||
const config = Object.assign(defaultConfig, loadedConfig || {}); | ||
|
||
lepto(config); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const plugin = (options) => { | ||
return function(input, fulfill) { | ||
let res = Object.assign({}, input, { | ||
data: { | ||
incr: input.data.incr ? input.data.incr + 1 : 1 | ||
} | ||
}) | ||
setTimeout(fulfill.bind(null, res), 100); | ||
}; | ||
}; | ||
|
||
module.exports = plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const plugin2 = (options) => { | ||
return function(input, fulfill) { | ||
let res = Object.assign({}, input, { | ||
data: { | ||
incr: input.data.incr ? input.data.incr + 1 : 1 | ||
} | ||
}) | ||
setTimeout(fulfill.bind(null, res), 100); | ||
}; | ||
}; | ||
|
||
module.exports = plugin2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
'use strict'; | ||
|
||
var topColor = void 0; | ||
var bottomColor = void 0; | ||
var currentColor = void 0; | ||
|
||
var styleTag = void 0; | ||
|
||
var setBgColor = function setBgColor(color) { | ||
|
||
if (currentColor !== color) { | ||
currentColor = color; | ||
|
||
var css = 'html{background:' + color + ';}'; | ||
|
||
if (!styleTag) { | ||
styleTag = document.createElement('style'); | ||
var head = document.head || document.getElementsByTagName('head')[0]; | ||
head.appendChild(styleTag); | ||
} | ||
|
||
if (styleTag.styleSheet) { | ||
styleTag.styleSheet.cssText = css; | ||
} else { | ||
styleTag.innerHTML = css; | ||
} | ||
} | ||
}; | ||
|
||
var checkScroll = function checkScroll() { | ||
|
||
if (document.body.scrollHeight === window.innerHeight) { | ||
setBgColor(bottomColor); | ||
} else { | ||
var scrollFromMiddle = window.innerHeight - document.body.scrollHeight + 2 * Math.max(document.body.scrollTop, document.documentElement.scrollTop); | ||
setBgColor(scrollFromMiddle < 0 ? topColor : bottomColor); | ||
} | ||
}; | ||
|
||
var initOverflowColor = function initOverflowColor() { | ||
|
||
var shortcutEl = document.querySelector('[data-oc]'); | ||
if (shortcutEl) { | ||
var split = shortcutEl.getAttribute('data-oc').split(','); | ||
if (split.length > 1) { | ||
topColor = split[0]; | ||
bottomColor = split[1]; | ||
} else if (split.length === 1) { | ||
topColor = bottomColor = split[0]; | ||
} | ||
} else { | ||
var topEl = document.querySelector('[data-oc-top]'); | ||
var bottomEl = document.querySelector('[data-oc-bottom]'); | ||
if (topEl) { | ||
topColor = topEl.getAttribute('data-oc-top'); | ||
} | ||
if (bottomEl) { | ||
bottomColor = bottomEl.getAttribute('data-oc-bottom'); | ||
} | ||
} | ||
|
||
if (topColor || bottomColor) { | ||
|
||
if (!topColor && bottomColor) { | ||
topColor = bottomColor; | ||
} else if (topColor && !bottomColor) { | ||
bottomColor = topColor; | ||
} | ||
|
||
var bodyComputedStyle = window.getComputedStyle(document.body, null); | ||
var bodyBackground = bodyComputedStyle.getPropertyValue('background'); | ||
if (bodyBackground === '' || bodyComputedStyle.getPropertyValue('background-color') === 'rgba(0, 0, 0, 0)' && bodyBackground.substring(21, 17) === 'none') { | ||
bodyBackground = 'white'; | ||
} | ||
document.body.style.background = 'transparent'; | ||
var bodyWrap = document.createElement('div'); | ||
bodyWrap.setAttribute('data-oc-wrap', ''); | ||
bodyWrap.style.background = bodyBackground; | ||
for (var i = 0, l = document.body.childNodes.length; i < l; i++) { | ||
bodyWrap.appendChild(document.body.childNodes[0]); | ||
} | ||
document.body.appendChild(bodyWrap); | ||
|
||
checkScroll(); | ||
if (typeof window.addEventListener !== 'undefined') { | ||
window.addEventListener('scroll', checkScroll, false); | ||
window.addEventListener('resize', checkScroll, false); | ||
} else { | ||
window.attachEvent('scroll', checkScroll); | ||
window.attachEvent('resize', checkScroll); | ||
} | ||
} | ||
}; | ||
|
||
if (['interactive', 'complete', 'loaded'].indexOf(document.readyState) >= 0) { | ||
initOverflowColor(); | ||
} else if (typeof document.addEventListener !== 'undefined') { | ||
document.addEventListener('DOMContentLoaded', initOverflowColor, false); | ||
} else { | ||
document.attachEvent('onreadystatechange', initOverflowColor); | ||
} | ||
|
||
module.exports = initOverflowColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
var topColor = void 0; | ||
var bottomColor = void 0; | ||
var currentColor = void 0; | ||
|
||
var styleTag = void 0; | ||
|
||
var setBgColor = function setBgColor(color) { | ||
|
||
if (currentColor !== color) { | ||
currentColor = color; | ||
|
||
var css = 'html{background:' + color + ';}'; | ||
|
||
if (!styleTag) { | ||
styleTag = document.createElement('style'); | ||
var head = document.head || document.getElementsByTagName('head')[0]; | ||
head.appendChild(styleTag); | ||
} | ||
|
||
if (styleTag.styleSheet) { | ||
styleTag.styleSheet.cssText = css; | ||
} else { | ||
styleTag.innerHTML = css; | ||
} | ||
} | ||
}; | ||
|
||
var checkScroll = function checkScroll() { | ||
|
||
if (document.body.scrollHeight === window.innerHeight) { | ||
setBgColor(bottomColor); | ||
} else { | ||
var scrollFromMiddle = window.innerHeight - document.body.scrollHeight + 2 * Math.max(document.body.scrollTop, document.documentElement.scrollTop); | ||
setBgColor(scrollFromMiddle < 0 ? topColor : bottomColor); | ||
} | ||
}; | ||
|
||
var initOverflowColor = function initOverflowColor() { | ||
|
||
var shortcutEl = document.querySelector('[data-oc]'); | ||
if (shortcutEl) { | ||
var split = shortcutEl.getAttribute('data-oc').split(','); | ||
if (split.length > 1) { | ||
topColor = split[0]; | ||
bottomColor = split[1]; | ||
} else if (split.length === 1) { | ||
topColor = bottomColor = split[0]; | ||
} | ||
} else { | ||
var topEl = document.querySelector('[data-oc-top]'); | ||
var bottomEl = document.querySelector('[data-oc-bottom]'); | ||
if (topEl) { | ||
topColor = topEl.getAttribute('data-oc-top'); | ||
} | ||
if (bottomEl) { | ||
bottomColor = bottomEl.getAttribute('data-oc-bottom'); | ||
} | ||
} | ||
|
||
if (topColor || bottomColor) { | ||
|
||
if (!topColor && bottomColor) { | ||
topColor = bottomColor; | ||
} else if (topColor && !bottomColor) { | ||
bottomColor = topColor; | ||
} | ||
|
||
var bodyComputedStyle = window.getComputedStyle(document.body, null); | ||
var bodyBackground = bodyComputedStyle.getPropertyValue('background'); | ||
if (bodyBackground === '' || bodyComputedStyle.getPropertyValue('background-color') === 'rgba(0, 0, 0, 0)' && bodyBackground.substring(21, 17) === 'none') { | ||
bodyBackground = 'white'; | ||
} | ||
document.body.style.background = 'transparent'; | ||
var bodyWrap = document.createElement('div'); | ||
bodyWrap.setAttribute('data-oc-wrap', ''); | ||
bodyWrap.style.background = bodyBackground; | ||
for (var i = 0, l = document.body.childNodes.length; i < l; i++) { | ||
bodyWrap.appendChild(document.body.childNodes[0]); | ||
} | ||
document.body.appendChild(bodyWrap); | ||
|
||
checkScroll(); | ||
if (typeof window.addEventListener !== 'undefined') { | ||
window.addEventListener('scroll', checkScroll, false); | ||
window.addEventListener('resize', checkScroll, false); | ||
} else { | ||
window.attachEvent('scroll', checkScroll); | ||
window.attachEvent('resize', checkScroll); | ||
} | ||
} | ||
}; | ||
|
||
if (['interactive', 'complete', 'loaded'].indexOf(document.readyState) >= 0) { | ||
initOverflowColor(); | ||
} else if (typeof document.addEventListener !== 'undefined') { | ||
document.addEventListener('DOMContentLoaded', initOverflowColor, false); | ||
} else { | ||
document.attachEvent('onreadystatechange', initOverflowColor); | ||
} | ||
|
||
export default initOverflowColor; |
Oops, something went wrong.