Comparing version 0.0.10 to 0.1.0
45
index.js
@@ -13,3 +13,5 @@ import getConfig from "./lib/config.js"; | ||
.flat() | ||
.filter(filterClasses) | ||
.filter(a => { | ||
return filterClasses(a) | ||
}) | ||
)] | ||
@@ -19,9 +21,24 @@ .map(process) | ||
styles = [...styles, [...new Set( | ||
styles = [...styles, ...[...new Set( | ||
mutations | ||
.filter(f => f.type === 'childList' && f.addedNodes.length && f.addedNodes[0].classList) // only works on a single node | ||
.map(i => (i.addedNodes[0].classList.value || "").split(' ')).flat().filter(filterClasses)) | ||
.filter(f => { | ||
return f.type === 'childList' && f.addedNodes.length && f.addedNodes[0].classList | ||
}) | ||
.map(i => { | ||
let classes = []; | ||
const node = i.addedNodes[0] | ||
const all = node.getElementsByTagName('*'); | ||
for (var i = -1, l = all.length; ++i < l;) { | ||
classes.push((all[i].classList.value ||'').split(' ')); | ||
} | ||
return [...classes.flat(), ...(node.classList.value || '').split(' ')]; | ||
}) | ||
.flat() | ||
) | ||
] | ||
.filter(filterClasses) | ||
.map(process) | ||
.filter(Boolean)]; | ||
.filter(Boolean) | ||
]; | ||
@@ -32,3 +49,3 @@ appendStyle(styles.filter(s => !s.includes('@media')).join('\n')); | ||
const getInitialClasses = (process, filterClasses) => [...new Set( | ||
const getInitialClasses = (process) => [...new Set( | ||
[...document.querySelectorAll("*")] | ||
@@ -38,3 +55,2 @@ .map(i => i.classList.value.split(' ')) | ||
)] | ||
.filter(filterClasses) | ||
.map(process) | ||
@@ -80,2 +96,4 @@ .filter(Boolean); | ||
function appendCssToEl(css, el) { | ||
if (!css) return; | ||
if (el.styleSheet) { | ||
@@ -105,3 +123,3 @@ el.styleSheet.cssText = css; | ||
const classes = new Set(); | ||
const filterClasses = i => Boolean(i) && !i.startsWith('svelte-') && !classes.has(i); | ||
const filterClasses = i => Boolean(i) && typeof i === "string" && !i.startsWith('svelte-'); | ||
@@ -113,14 +131,15 @@ const configMerged = mergeUserConfig(getConfig(), userConfig); | ||
const css = parse(c); | ||
if (css) classes.add(c); | ||
if (css) { | ||
classes.add(c); | ||
} | ||
return css; | ||
} | ||
const classObserver = new MutationObserver(onObserve(process, filterClasses, appendStyle, appendStyleMedia)); | ||
observeClasses(classObserver, container); | ||
const initialStyles = getInitialClasses(process, filterClasses); | ||
appendStyle(preflight + variables(configMerged) + initialStyles.filter(s => !s.includes('@media')).join('\n') + keyframes); | ||
appendStyleMedia(initialStyles.filter(s => s.includes('@media')).join('\n')); | ||
const classObserver = new MutationObserver(onObserve(process, filterClasses, appendStyle, appendStyleMedia)); | ||
observeClasses(classObserver, container); | ||
return { | ||
@@ -127,0 +146,0 @@ unsubscribe: () => classObserver.disconnect(), |
@@ -18,3 +18,2 @@ import colors from "./colors.js"; | ||
white: colors.white, | ||
gray: colors.coolGray, | ||
red: colors.red, | ||
@@ -21,0 +20,0 @@ yellow: colors.amber, |
@@ -37,8 +37,8 @@ // TODO: respect config values (how to calculate missing bits | ||
transform: translateY(-25%); | ||
animationTimingFunction: cubic-bezier(0.8, 0, 1, 1); | ||
animation-timing-function: cubic-bezier(0.8, 0, 1, 1); | ||
} | ||
50% { | ||
transform: translateY(0); | ||
animationTimingFunction: cubic-bezier(0, 0, 0.2, 1); | ||
animation-timing-function: cubic-bezier(0, 0, 0.2, 1); | ||
} | ||
}`; |
{ | ||
"name": "headlong", | ||
"version": "0.0.10", | ||
"version": "0.1.0", | ||
"description": "Tailwind CSS on the fly", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238608
2863