@symbo.ls/init
Advanced tools
Comparing version 2.10.31 to 2.10.41
31
index.js
@@ -6,3 +6,5 @@ 'use strict' | ||
getActiveConfig, | ||
getFontFaceString | ||
getFontFaceString, | ||
appendSVGSprite, | ||
appendIconsSprite | ||
} from '@symbo.ls/scratch' | ||
@@ -19,3 +21,3 @@ | ||
const prepareInit = (config = CONFIG, RC_FILE) => { | ||
const mergeWithLocalFile = (config = CONFIG, RC_FILE) => { | ||
const rcfile = isObject(RC_FILE) ? RC_FILE : DYNAMIC_JSON || {} | ||
@@ -28,7 +30,10 @@ return deepMerge(config, rcfile) | ||
useVariable: true, | ||
useReset: true | ||
useReset: true, | ||
useFontImport: true, | ||
useIconSprite: true, | ||
useSvgSprite: true | ||
} | ||
export const init = (config, RC_FILE, options = SET_OPTIONS) => { | ||
const resultConfig = prepareInit(config, RC_FILE) | ||
const resultConfig = mergeWithLocalFile(config, RC_FILE) | ||
const emotion = options.emotion || defaultEmotion | ||
@@ -39,3 +44,6 @@ | ||
useReset: options.useReset, | ||
useFontImport: options.useFontImport, | ||
useVariable: options.useVariable, | ||
useSvgSprite: options.useSvgSprite, | ||
useIconSprite: options.useIconSprite, | ||
...resultConfig | ||
@@ -48,7 +56,18 @@ }, { newConfig: options.newConfig }) | ||
const useVariable = conf.useVariable | ||
const useFontImport = conf.useFontImport | ||
const useSvgSprite = conf.useSvgSprite | ||
const hasSvgs = config.svg || config.SVG | ||
const useIconSprite = conf.useIconSprite | ||
const hasIcons = config.icons || config.ICONS | ||
emotion.injectGlobal(FontFace) | ||
if (useFontImport) emotion.injectGlobal(FontFace) | ||
if (useVariable) emotion.injectGlobal({ ':root': conf.CSS_VARS }) | ||
if (useReset) emotion.injectGlobal(conf.RESET) | ||
if (hasSvgs) appendSVGSprite(hasSvgs, { document: options.document }) | ||
else if (useSvgSprite) appendSVGSprite(conf.SVG, { document: options.document }) | ||
if (hasIcons) appendIconsSprite(hasIcons, { document: options.document }) | ||
else if (useIconSprite) appendIconsSprite(conf.ICONS, { document: options.document }) | ||
return conf | ||
@@ -58,3 +77,3 @@ } | ||
export const updateReset = (config, RC_FILE, options = { emotion: defaultEmotion }) => { | ||
const resultConfig = prepareInit(config, RC_FILE) | ||
const resultConfig = mergeWithLocalFile(config, RC_FILE) | ||
const conf = set({ | ||
@@ -61,0 +80,0 @@ verbose: false, |
{ | ||
"name": "@symbo.ls/init", | ||
"version": "2.10.31", | ||
"version": "2.10.41", | ||
"license": "MIT", | ||
"gitHead": "828e14653b4f33040eaf9f42ba4adcc5111feb91", | ||
"gitHead": "fe191d138564726ccb26fb5a6643c4d78709f0d3", | ||
"source": "index.js", | ||
@@ -7,0 +7,0 @@ "main": "index.js", |
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
3802
65