oncss 1.2.10 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.cjs +11 -4
- package/core.cjs.map +1 -1
- package/core.js +11 -4
- package/core.js.map +1 -1
- package/index.cjs.map +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +397 -397
package/core.cjs
CHANGED
|
@@ -107,6 +107,12 @@ const cssPrefix = (prop, value) => {
|
|
|
107
107
|
return { prop: _prop, value: _value };
|
|
108
108
|
};
|
|
109
109
|
const resolveStyleContainer = (input) => {
|
|
110
|
+
if (typeof window === 'undefined') {
|
|
111
|
+
return {
|
|
112
|
+
document: undefined,
|
|
113
|
+
container: undefined
|
|
114
|
+
};
|
|
115
|
+
}
|
|
110
116
|
// Default → current document
|
|
111
117
|
if (!input) {
|
|
112
118
|
return {
|
|
@@ -278,11 +284,12 @@ const style = (_css, cls, opt, dept = 1) => {
|
|
|
278
284
|
tag && tag.remove();
|
|
279
285
|
},
|
|
280
286
|
inject: () => {
|
|
281
|
-
|
|
282
|
-
|
|
287
|
+
var _a, _b;
|
|
288
|
+
const tag = r.getStyleTag() || ((_a = d.document) === null || _a === void 0 ? void 0 : _a.createElement("style"));
|
|
289
|
+
if (tag && !(tag === null || tag === void 0 ? void 0 : tag.innerHTML)) {
|
|
283
290
|
tag.innerHTML = r.css;
|
|
284
291
|
tag.setAttribute(`data-href`, classname);
|
|
285
|
-
d.container.appendChild(tag);
|
|
292
|
+
(_b = d.container) === null || _b === void 0 ? void 0 : _b.appendChild(tag);
|
|
286
293
|
}
|
|
287
294
|
return tag;
|
|
288
295
|
},
|
|
@@ -293,7 +300,7 @@ const style = (_css, cls, opt, dept = 1) => {
|
|
|
293
300
|
};
|
|
294
301
|
ONCSS_CACHE.set(cacheId, cachekey, r);
|
|
295
302
|
let inject = (_b = opt === null || opt === void 0 ? void 0 : opt.injectStyle) !== null && _b !== void 0 ? _b : true;
|
|
296
|
-
if (inject &&
|
|
303
|
+
if (inject && d.document) {
|
|
297
304
|
r.inject();
|
|
298
305
|
}
|
|
299
306
|
return r;
|
package/core.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.cjs","sources":["../src/core.ts"],"sourcesContent":["import { CSSOptionProps, CSSFactoryType, CSSProps } from './types';\r\nimport youid from 'youid';\r\n// const _global: any = typeof window !== 'undefined' ? window : global;\r\n// _global.Factory = _global.Factory || new Map<string, CSSFactoryType>();\r\n// export const CSSFactory = _global.Factory as Map<string, CSSFactoryType>\r\n\r\nconst caches = new Map<string, Map<string, CSSFactoryType>>()\r\n\r\nexport const ONCSS_CACHE = {\r\n set(cacheId: string, cachekey: string, value: CSSFactoryType) {\r\n let cache = caches.get(cacheId)\r\n if (!cache) {\r\n cache = new Map()\r\n caches.set(cacheId, cache)\r\n }\r\n cache.set(cachekey, value)\r\n },\r\n get(cacheId: string, cachekey: string) {\r\n let cache = caches.get(cacheId)\r\n if (cache) {\r\n return cache.get(cachekey)\r\n }\r\n },\r\n has(cacheId: string, cachekey: string) {\r\n let cache = caches.get(cacheId)\r\n if (cache) {\r\n return cache.has(cachekey)\r\n }\r\n return false\r\n },\r\n delete(cacheId: string, cachekey: string,) {\r\n let cache = caches.get(cacheId)\r\n if (cache) {\r\n cache.delete(cachekey)\r\n }\r\n },\r\n caches() {\r\n return caches\r\n }\r\n}\r\n\r\n\r\n\r\nconst number_val_props = [\r\n \"fontWeight\",\r\n \"font-weight\",\r\n \"lineHeight\",\r\n \"line-height\",\r\n \"opacity\",\r\n \"zIndex\",\r\n \"z-index\",\r\n \"flex\",\r\n \"order\",\r\n \"flexGrow\",\r\n \"flex-grow\",\r\n \"flexShrink\",\r\n \"flex-shrink\",\r\n \"flexBasis\",\r\n \"flex-basis\",\r\n \"columns\",\r\n \"perspective\",\r\n \"stroke-dashoffset\"\r\n]\r\n\r\nexport const formatCSSProp = (prop: string) => prop.split(/(?=[A-Z])/).join(\"-\").toLowerCase();\r\nexport const formatCSSValue = (prop: string, val: any) => typeof val === 'number' && !number_val_props.includes(prop) ? `${val}px` : val\r\n\r\nconst PREFIXES = ['webkit', 'moz', 'ms', 'o'];\r\nlet _declaration: CSSStyleDeclaration;\r\nconst PREFIXCACHE = new Map();\r\n\r\nexport const cssPrefix = (prop: string, value: string): { prop: string, value: string } => {\r\n value = formatCSSValue(prop, value);\r\n prop = formatCSSProp(prop);\r\n\r\n if (typeof window === 'undefined') {\r\n return { prop, value };\r\n }\r\n\r\n const declaration = _declaration || (_declaration = document.createElement(\"div\").style);\r\n value = value?.toString();\r\n\r\n // Check if the property and value work as is\r\n if (declaration.setProperty(prop, value), declaration.getPropertyValue(prop) === value) {\r\n return { prop, value };\r\n }\r\n\r\n // Check cached property and value prefix\r\n const cached = PREFIXCACHE.get(prop);\r\n if (cached) {\r\n return { prop: cached._prop, value: `${cached._vprefix}${value}` };\r\n }\r\n\r\n let _prop = prop;\r\n let _value = value;\r\n let _vprefix = '';\r\n\r\n // Try property prefixes\r\n const camelCaseProp = prop.includes('-') ? prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase()) : prop;\r\n for (const prefix of PREFIXES) {\r\n if (declaration[`${prefix}${camelCaseProp}` as any] !== undefined) {\r\n _prop = `-${prefix}-${prop}`;\r\n break;\r\n }\r\n }\r\n\r\n // Check if prefixed property works with the value\r\n declaration.setProperty(_prop, value);\r\n if (!declaration.getPropertyValue(_prop)) {\r\n for (const prefix of PREFIXES) {\r\n const prefixedValue = `-${prefix}-${value}`;\r\n if (declaration.setProperty(_prop, prefixedValue), declaration.getPropertyValue(_prop) === prefixedValue) {\r\n _value = prefixedValue;\r\n _vprefix = `-${prefix}-`;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n PREFIXCACHE.set(prop, { _prop, _vprefix });\r\n return { prop: _prop, value: _value };\r\n};\r\n\r\n\r\nconst resolveStyleContainer = (input?: Document | HTMLElement): { document: Document; container: HTMLElement } => {\r\n // Default → current document\r\n if (!input) {\r\n return {\r\n document,\r\n container: document.head,\r\n };\r\n }\r\n\r\n // If input is a Document (works across iframes)\r\n if (\"nodeType\" in input && input.nodeType === 9) {\r\n return {\r\n document: input as Document,\r\n container: (input as Document).head || input.getElementsByTagName(\"head\")[0],\r\n };\r\n }\r\n\r\n // If input is an HTMLElement → use its owner document\r\n if (\"ownerDocument\" in input && input instanceof HTMLElement) {\r\n return {\r\n document: input.ownerDocument,\r\n container: input,\r\n };\r\n }\r\n\r\n throw new Error(\"Invalid input: must be Document or HTMLElement\");\r\n}\r\n\r\nexport const style = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, cls?: string, opt?: CSSOptionProps<Aliases, BreakpointKeys>, dept = 1) => {\r\n let cachekey\r\n let classname = cls\r\n const cacheId = opt?.cacheId || \"global\"\r\n\r\n if (!cls) {\r\n cachekey = JSON.stringify(_css, (_key, value) => typeof value === \"function\" ? value.toString() : value);\r\n const has = ONCSS_CACHE.get(cacheId, cachekey)\r\n if (has) {\r\n has.cache = true\r\n return has\r\n }\r\n classname = `${opt?.classPrefix || \"\"}x${youid(cachekey)}`\r\n } else if (typeof cls !== 'string') {\r\n throw new Error(`Invalid class name: ${cls}`)\r\n }\r\n\r\n let stack: any = [`${classname}{`]\r\n let medias: any = {}\r\n let skiped: any = {}\r\n for (let prop in _css) {\r\n let val = (_css as any)[prop]\r\n let firstChar = prop.charAt(0)\r\n if (firstChar === '&') {\r\n let ncls = prop.replace(/&/g, classname as string)\r\n const r: any = style(val, ncls, opt, dept + 1)\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n stack.push(r.stack)\r\n } else if (firstChar === '@') {\r\n if (prop.startsWith(\"@global\") || prop.startsWith(\"@keyframes\")) {\r\n let _css = ''\r\n for (let selector in val) {\r\n let r: any = style(val[selector], selector, opt, dept + 1)\r\n _css += r.stack\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n }\r\n if (prop.startsWith(\"@keyframes\")) {\r\n stack.push(`${prop}{${_css}}`)\r\n } else {\r\n stack.push(_css)\r\n }\r\n } else {\r\n let r: any = style(val, classname, opt, dept + 1)\r\n const atcss = prop + \"{\" + r.stack + \"}\"\r\n stack.push(atcss)\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n }\r\n } else {\r\n if (opt?.skipProps && opt.skipProps(prop, val, dept)) {\r\n if (!((classname as any) in skiped)) skiped[classname as string] = []\r\n skiped[classname as string].push(prop)\r\n continue\r\n }\r\n if (typeof val === 'function' || Array.isArray(val)) {\r\n continue\r\n }\r\n if (typeof val === 'object') {\r\n for (let media in val) {\r\n if (typeof val[media] === 'object' || typeof val[media] === 'function' || Array.isArray(val[media])) {\r\n throw new Error(`Invalid css value: ${val[media]}`);\r\n }\r\n let breakpoint = media\r\n let isNumber = !isNaN(parseInt(breakpoint))\r\n if (!isNumber) {\r\n if (opt?.breakpoints && !isNaN(parseInt((opt.breakpoints as any)[media]))) {\r\n breakpoint = opt.breakpoints[media as BreakpointKeys].toString()\r\n } else {\r\n throw new Error(`Invalid breakpoint prop: ${media}`);\r\n }\r\n }\r\n let _css = { [prop]: val[media] }\r\n let r: any = style(_css, classname, opt, dept)\r\n let _style = r.stack\r\n let mediakey = `@media (min-width: ${breakpoint}px)`\r\n medias[mediakey] = medias[mediakey] ? medias[mediakey] + _style : _style\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n }\r\n } else {\r\n if (opt?.getProps) {\r\n let _props: any = opt.getProps(prop, val, _css, dept)\r\n if (_props) {\r\n let r: any = style(_props, classname, {\r\n ...opt,\r\n getProps: undefined\r\n })\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n stack.push(r.stack)\r\n continue;\r\n }\r\n }\r\n if (opt?.aliases && (opt.aliases as any)[prop]) {\r\n let _props = (opt.aliases as any)[prop](val)\r\n if (_props) {\r\n let r: any = style(_props, classname, {\r\n ...opt,\r\n aliases: undefined\r\n }, dept)\r\n r.stack = r.stack.replace(`${classname}{`, '').replace(`}`, '')\r\n stack[0] += r.stack\r\n continue;\r\n }\r\n }\r\n if (opt?.getValue) {\r\n val = opt.getValue(prop, val, _css, dept)\r\n }\r\n let p = cssPrefix(prop, val)\r\n stack[0] += `${p.prop}:${p.value};`\r\n }\r\n }\r\n }\r\n stack[0] += \"}\"\r\n if (stack[0] === `${classname}{}`) {\r\n stack[0] = \"\"\r\n }\r\n stack = stack.join('')\r\n for (let media in medias) {\r\n stack += `${media}{${medias[media].replace(new RegExp(`}\\\\${classname}\\\\{`, 'g'), '')}}`\r\n }\r\n\r\n if (cachekey) {\r\n const d = resolveStyleContainer(opt?.container);\r\n\r\n const selector = opt?.selector ?? \".\"\r\n stack = stack.replace(new RegExp(classname as string, 'g'), `${selector}${classname}`)\r\n const r = {\r\n cache: false,\r\n cachekey,\r\n selector,\r\n classname: classname as string,\r\n css: stack,\r\n cssraw: _css,\r\n skiped,\r\n cacheId,\r\n getStyleTag: () => d.container?.querySelector(`style[data-href=\"${classname}\"]`) as HTMLStyleElement | null,\r\n deleteStyle: () => {\r\n const tag = r.getStyleTag()\r\n tag && tag.remove()\r\n },\r\n inject: () => {\r\n const tag = r.getStyleTag() || d.document.createElement(\"style\");\r\n if (!tag.innerHTML) {\r\n tag.innerHTML = r.css\r\n tag.setAttribute(`data-href`, classname as string)\r\n d.container.appendChild(tag);\r\n }\r\n return tag\r\n },\r\n refresh: () => {\r\n r.deleteStyle()\r\n return r.inject()\r\n }\r\n }\r\n\r\n ONCSS_CACHE.set(cacheId, cachekey, r)\r\n\r\n let inject = opt?.injectStyle ?? true\r\n if (inject && typeof d.document !== 'undefined') {\r\n r.inject()\r\n }\r\n return r\r\n }\r\n return { stack, skiped }\r\n}"],"names":[],"mappings":";;;;AAEA;AACA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A,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE;AAC3B,gBAAA,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE;YACvB,CAAC;YACD,MAAM,EAAE,MAAK;AACT,gBAAA,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAChE,gBAAA,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;AAChB,oBAAA,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG;AACrB,oBAAA,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,SAAmB,CAAC;AAClD,oBAAA,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC;gBAChC;AACA,gBAAA,OAAO,GAAG;YACd,CAAC;YACD,OAAO,EAAE,MAAK;gBACV,CAAC,CAAC,WAAW,EAAE;AACf,gBAAA,OAAO,CAAC,CAAC,MAAM,EAAE;YACrB;SACH;QAED,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAErC,QAAA,IAAI,MAAM,GAAG,CAAA,EAAA,GAAA,GAAG,KAAA,IAAA,IAAH,GAAG,KAAA,MAAA,GAAA,MAAA,GAAH,GAAG,CAAE,WAAW,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;QACrC,IAAI,MAAM,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,WAAW,EAAE;YAC7C,CAAC,CAAC,MAAM,EAAE;QACd;AACA,QAAA,OAAO,CAAC;IACZ;AACA,IAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;AAC5B;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"core.cjs","sources":["../src/core.ts"],"sourcesContent":["import { CSSOptionProps, CSSFactoryType, CSSProps } from './types';\nimport youid from 'youid';\n// const _global: any = typeof window !== 'undefined' ? window : global;\n// _global.Factory = _global.Factory || new Map<string, CSSFactoryType>();\n// export const CSSFactory = _global.Factory as Map<string, CSSFactoryType>\n\nconst caches = new Map<string, Map<string, CSSFactoryType>>()\n\nexport const ONCSS_CACHE = {\n set(cacheId: string, cachekey: string, value: CSSFactoryType) {\n let cache = caches.get(cacheId)\n if (!cache) {\n cache = new Map()\n caches.set(cacheId, cache)\n }\n cache.set(cachekey, value)\n },\n get(cacheId: string, cachekey: string) {\n let cache = caches.get(cacheId)\n if (cache) {\n return cache.get(cachekey)\n }\n },\n has(cacheId: string, cachekey: string) {\n let cache = caches.get(cacheId)\n if (cache) {\n return cache.has(cachekey)\n }\n return false\n },\n delete(cacheId: string, cachekey: string,) {\n let cache = caches.get(cacheId)\n if (cache) {\n cache.delete(cachekey)\n }\n },\n caches() {\n return caches\n }\n}\n\n\n\nconst number_val_props = [\n \"fontWeight\",\n \"font-weight\",\n \"lineHeight\",\n \"line-height\",\n \"opacity\",\n \"zIndex\",\n \"z-index\",\n \"flex\",\n \"order\",\n \"flexGrow\",\n \"flex-grow\",\n \"flexShrink\",\n \"flex-shrink\",\n \"flexBasis\",\n \"flex-basis\",\n \"columns\",\n \"perspective\",\n \"stroke-dashoffset\"\n]\n\nexport const formatCSSProp = (prop: string) => prop.split(/(?=[A-Z])/).join(\"-\").toLowerCase();\nexport const formatCSSValue = (prop: string, val: any) => typeof val === 'number' && !number_val_props.includes(prop) ? `${val}px` : val\n\nconst PREFIXES = ['webkit', 'moz', 'ms', 'o'];\nlet _declaration: CSSStyleDeclaration;\nconst PREFIXCACHE = new Map();\n\nexport const cssPrefix = (prop: string, value: string): { prop: string, value: string } => {\n value = formatCSSValue(prop, value);\n prop = formatCSSProp(prop);\n\n if (typeof window === 'undefined') {\n return { prop, value };\n }\n\n const declaration = _declaration || (_declaration = document.createElement(\"div\").style);\n value = value?.toString();\n\n // Check if the property and value work as is\n if (declaration.setProperty(prop, value), declaration.getPropertyValue(prop) === value) {\n return { prop, value };\n }\n\n // Check cached property and value prefix\n const cached = PREFIXCACHE.get(prop);\n if (cached) {\n return { prop: cached._prop, value: `${cached._vprefix}${value}` };\n }\n\n let _prop = prop;\n let _value = value;\n let _vprefix = '';\n\n // Try property prefixes\n const camelCaseProp = prop.includes('-') ? prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase()) : prop;\n for (const prefix of PREFIXES) {\n if (declaration[`${prefix}${camelCaseProp}` as any] !== undefined) {\n _prop = `-${prefix}-${prop}`;\n break;\n }\n }\n\n // Check if prefixed property works with the value\n declaration.setProperty(_prop, value);\n if (!declaration.getPropertyValue(_prop)) {\n for (const prefix of PREFIXES) {\n const prefixedValue = `-${prefix}-${value}`;\n if (declaration.setProperty(_prop, prefixedValue), declaration.getPropertyValue(_prop) === prefixedValue) {\n _value = prefixedValue;\n _vprefix = `-${prefix}-`;\n break;\n }\n }\n }\n\n PREFIXCACHE.set(prop, { _prop, _vprefix });\n return { prop: _prop, value: _value };\n};\n\n\nconst resolveStyleContainer = (input?: Document | HTMLElement): { document?: Document; container?: HTMLElement } => {\n if (typeof window === 'undefined') {\n return {\n document: undefined,\n container: undefined\n }\n }\n // Default → current document\n if (!input) {\n return {\n document,\n container: document.head,\n };\n }\n\n // If input is a Document (works across iframes)\n if (\"nodeType\" in input && input.nodeType === 9) {\n return {\n document: input as Document,\n container: (input as Document).head || input.getElementsByTagName(\"head\")[0],\n };\n }\n\n // If input is an HTMLElement → use its owner document\n if (\"ownerDocument\" in input && input instanceof HTMLElement) {\n return {\n document: input.ownerDocument,\n container: input,\n };\n }\n\n throw new Error(\"Invalid input: must be Document or HTMLElement\");\n}\n\nexport const style = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, cls?: string, opt?: CSSOptionProps<Aliases, BreakpointKeys>, dept = 1) => {\n let cachekey\n let classname = cls\n const cacheId = opt?.cacheId || \"global\"\n\n if (!cls) {\n cachekey = JSON.stringify(_css, (_key, value) => typeof value === \"function\" ? value.toString() : value);\n const has = ONCSS_CACHE.get(cacheId, cachekey)\n if (has) {\n has.cache = true\n return has\n }\n classname = `${opt?.classPrefix || \"\"}x${youid(cachekey)}`\n } else if (typeof cls !== 'string') {\n throw new Error(`Invalid class name: ${cls}`)\n }\n\n let stack: any = [`${classname}{`]\n let medias: any = {}\n let skiped: any = {}\n for (let prop in _css) {\n let val = (_css as any)[prop]\n let firstChar = prop.charAt(0)\n if (firstChar === '&') {\n let ncls = prop.replace(/&/g, classname as string)\n const r: any = style(val, ncls, opt, dept + 1)\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n stack.push(r.stack)\n } else if (firstChar === '@') {\n if (prop.startsWith(\"@global\") || prop.startsWith(\"@keyframes\")) {\n let _css = ''\n for (let selector in val) {\n let r: any = style(val[selector], selector, opt, dept + 1)\n _css += r.stack\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n }\n if (prop.startsWith(\"@keyframes\")) {\n stack.push(`${prop}{${_css}}`)\n } else {\n stack.push(_css)\n }\n } else {\n let r: any = style(val, classname, opt, dept + 1)\n const atcss = prop + \"{\" + r.stack + \"}\"\n stack.push(atcss)\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n }\n } else {\n if (opt?.skipProps && opt.skipProps(prop, val, dept)) {\n if (!((classname as any) in skiped)) skiped[classname as string] = []\n skiped[classname as string].push(prop)\n continue\n }\n if (typeof val === 'function' || Array.isArray(val)) {\n continue\n }\n if (typeof val === 'object') {\n for (let media in val) {\n if (typeof val[media] === 'object' || typeof val[media] === 'function' || Array.isArray(val[media])) {\n throw new Error(`Invalid css value: ${val[media]}`);\n }\n let breakpoint = media\n let isNumber = !isNaN(parseInt(breakpoint))\n if (!isNumber) {\n if (opt?.breakpoints && !isNaN(parseInt((opt.breakpoints as any)[media]))) {\n breakpoint = opt.breakpoints[media as BreakpointKeys].toString()\n } else {\n throw new Error(`Invalid breakpoint prop: ${media}`);\n }\n }\n let _css = { [prop]: val[media] }\n let r: any = style(_css, classname, opt, dept)\n let _style = r.stack\n let mediakey = `@media (min-width: ${breakpoint}px)`\n medias[mediakey] = medias[mediakey] ? medias[mediakey] + _style : _style\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n }\n } else {\n if (opt?.getProps) {\n let _props: any = opt.getProps(prop, val, _css, dept)\n if (_props) {\n let r: any = style(_props, classname, {\n ...opt,\n getProps: undefined\n })\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n stack.push(r.stack)\n continue;\n }\n }\n if (opt?.aliases && (opt.aliases as any)[prop]) {\n let _props = (opt.aliases as any)[prop](val)\n if (_props) {\n let r: any = style(_props, classname, {\n ...opt,\n aliases: undefined\n }, dept)\n r.stack = r.stack.replace(`${classname}{`, '').replace(`}`, '')\n stack[0] += r.stack\n continue;\n }\n }\n if (opt?.getValue) {\n val = opt.getValue(prop, val, _css, dept)\n }\n let p = cssPrefix(prop, val)\n stack[0] += `${p.prop}:${p.value};`\n }\n }\n }\n stack[0] += \"}\"\n if (stack[0] === `${classname}{}`) {\n stack[0] = \"\"\n }\n stack = stack.join('')\n for (let media in medias) {\n stack += `${media}{${medias[media].replace(new RegExp(`}\\\\${classname}\\\\{`, 'g'), '')}}`\n }\n\n if (cachekey) {\n const d = resolveStyleContainer(opt?.container);\n\n const selector = opt?.selector ?? \".\"\n stack = stack.replace(new RegExp(classname as string, 'g'), `${selector}${classname}`)\n const r = {\n cache: false,\n cachekey,\n selector,\n classname: classname as string,\n css: stack,\n cssraw: _css,\n skiped,\n cacheId,\n getStyleTag: () => d.container?.querySelector(`style[data-href=\"${classname}\"]`) as HTMLStyleElement | null,\n deleteStyle: () => {\n const tag = r.getStyleTag()\n tag && tag.remove()\n },\n inject: () => {\n const tag = r.getStyleTag() || d.document?.createElement(\"style\");\n if (tag && !tag?.innerHTML) {\n tag.innerHTML = r.css\n tag.setAttribute(`data-href`, classname as string)\n d.container?.appendChild(tag);\n }\n return tag as HTMLStyleElement\n },\n refresh: () => {\n r.deleteStyle()\n return r.inject()\n }\n }\n\n ONCSS_CACHE.set(cacheId, cachekey, r)\n\n let inject = opt?.injectStyle ?? true\n if (inject && d.document) {\n r.inject()\n }\n return r\n }\n return { stack, skiped }\n}"],"names":[],"mappings":";;;;AAEA;AACA;AACA;AAEA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAuC;AAEtD,MAAM,WAAW,GAAG;AACvB,IAAA,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAE,KAAqB,EAAA;QACxD,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,KAAK,EAAE;AACR,YAAA,KAAK,GAAG,IAAI,GAAG,EAAE;AACjB,YAAA,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;QAC9B;AACA,QAAA,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;IAC9B,CAAC;IACD,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAA;QACjC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC9B;IACJ,CAAC;IACD,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAA;QACjC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC9B;AACA,QAAA,OAAO,KAAK;IAChB,CAAC;IACD,MAAM,CAAC,OAAe,EAAE,QAAgB,EAAA;QACpC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC1B;IACJ,CAAC;IACD,MAAM,GAAA;A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ErC,QAAA,IAAI,MAAM,GAAG,CAAA,EAAA,GAAA,GAAG,KAAA,IAAA,IAAH,GAAG,KAAA,MAAA,GAAA,MAAA,GAAH,GAAG,CAAE,WAAW,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AACrC,QAAA,IAAI,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE;YACtB,CAAC,CAAC,MAAM,EAAE;QACd;AACA,QAAA,OAAO,CAAC;IACZ;AACA,IAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;AAC5B;;;;;;;;"}
|
package/core.js
CHANGED
|
@@ -105,6 +105,12 @@ const cssPrefix = (prop, value) => {
|
|
|
105
105
|
return { prop: _prop, value: _value };
|
|
106
106
|
};
|
|
107
107
|
const resolveStyleContainer = (input) => {
|
|
108
|
+
if (typeof window === 'undefined') {
|
|
109
|
+
return {
|
|
110
|
+
document: undefined,
|
|
111
|
+
container: undefined
|
|
112
|
+
};
|
|
113
|
+
}
|
|
108
114
|
// Default → current document
|
|
109
115
|
if (!input) {
|
|
110
116
|
return {
|
|
@@ -276,11 +282,12 @@ const style = (_css, cls, opt, dept = 1) => {
|
|
|
276
282
|
tag && tag.remove();
|
|
277
283
|
},
|
|
278
284
|
inject: () => {
|
|
279
|
-
|
|
280
|
-
|
|
285
|
+
var _a, _b;
|
|
286
|
+
const tag = r.getStyleTag() || ((_a = d.document) === null || _a === void 0 ? void 0 : _a.createElement("style"));
|
|
287
|
+
if (tag && !(tag === null || tag === void 0 ? void 0 : tag.innerHTML)) {
|
|
281
288
|
tag.innerHTML = r.css;
|
|
282
289
|
tag.setAttribute(`data-href`, classname);
|
|
283
|
-
d.container.appendChild(tag);
|
|
290
|
+
(_b = d.container) === null || _b === void 0 ? void 0 : _b.appendChild(tag);
|
|
284
291
|
}
|
|
285
292
|
return tag;
|
|
286
293
|
},
|
|
@@ -291,7 +298,7 @@ const style = (_css, cls, opt, dept = 1) => {
|
|
|
291
298
|
};
|
|
292
299
|
ONCSS_CACHE.set(cacheId, cachekey, r);
|
|
293
300
|
let inject = (_b = opt === null || opt === void 0 ? void 0 : opt.injectStyle) !== null && _b !== void 0 ? _b : true;
|
|
294
|
-
if (inject &&
|
|
301
|
+
if (inject && d.document) {
|
|
295
302
|
r.inject();
|
|
296
303
|
}
|
|
297
304
|
return r;
|
package/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sources":["../src/core.ts"],"sourcesContent":["import { CSSOptionProps, CSSFactoryType, CSSProps } from './types';\r\nimport youid from 'youid';\r\n// const _global: any = typeof window !== 'undefined' ? window : global;\r\n// _global.Factory = _global.Factory || new Map<string, CSSFactoryType>();\r\n// export const CSSFactory = _global.Factory as Map<string, CSSFactoryType>\r\n\r\nconst caches = new Map<string, Map<string, CSSFactoryType>>()\r\n\r\nexport const ONCSS_CACHE = {\r\n set(cacheId: string, cachekey: string, value: CSSFactoryType) {\r\n let cache = caches.get(cacheId)\r\n if (!cache) {\r\n cache = new Map()\r\n caches.set(cacheId, cache)\r\n }\r\n cache.set(cachekey, value)\r\n },\r\n get(cacheId: string, cachekey: string) {\r\n let cache = caches.get(cacheId)\r\n if (cache) {\r\n return cache.get(cachekey)\r\n }\r\n },\r\n has(cacheId: string, cachekey: string) {\r\n let cache = caches.get(cacheId)\r\n if (cache) {\r\n return cache.has(cachekey)\r\n }\r\n return false\r\n },\r\n delete(cacheId: string, cachekey: string,) {\r\n let cache = caches.get(cacheId)\r\n if (cache) {\r\n cache.delete(cachekey)\r\n }\r\n },\r\n caches() {\r\n return caches\r\n }\r\n}\r\n\r\n\r\n\r\nconst number_val_props = [\r\n \"fontWeight\",\r\n \"font-weight\",\r\n \"lineHeight\",\r\n \"line-height\",\r\n \"opacity\",\r\n \"zIndex\",\r\n \"z-index\",\r\n \"flex\",\r\n \"order\",\r\n \"flexGrow\",\r\n \"flex-grow\",\r\n \"flexShrink\",\r\n \"flex-shrink\",\r\n \"flexBasis\",\r\n \"flex-basis\",\r\n \"columns\",\r\n \"perspective\",\r\n \"stroke-dashoffset\"\r\n]\r\n\r\nexport const formatCSSProp = (prop: string) => prop.split(/(?=[A-Z])/).join(\"-\").toLowerCase();\r\nexport const formatCSSValue = (prop: string, val: any) => typeof val === 'number' && !number_val_props.includes(prop) ? `${val}px` : val\r\n\r\nconst PREFIXES = ['webkit', 'moz', 'ms', 'o'];\r\nlet _declaration: CSSStyleDeclaration;\r\nconst PREFIXCACHE = new Map();\r\n\r\nexport const cssPrefix = (prop: string, value: string): { prop: string, value: string } => {\r\n value = formatCSSValue(prop, value);\r\n prop = formatCSSProp(prop);\r\n\r\n if (typeof window === 'undefined') {\r\n return { prop, value };\r\n }\r\n\r\n const declaration = _declaration || (_declaration = document.createElement(\"div\").style);\r\n value = value?.toString();\r\n\r\n // Check if the property and value work as is\r\n if (declaration.setProperty(prop, value), declaration.getPropertyValue(prop) === value) {\r\n return { prop, value };\r\n }\r\n\r\n // Check cached property and value prefix\r\n const cached = PREFIXCACHE.get(prop);\r\n if (cached) {\r\n return { prop: cached._prop, value: `${cached._vprefix}${value}` };\r\n }\r\n\r\n let _prop = prop;\r\n let _value = value;\r\n let _vprefix = '';\r\n\r\n // Try property prefixes\r\n const camelCaseProp = prop.includes('-') ? prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase()) : prop;\r\n for (const prefix of PREFIXES) {\r\n if (declaration[`${prefix}${camelCaseProp}` as any] !== undefined) {\r\n _prop = `-${prefix}-${prop}`;\r\n break;\r\n }\r\n }\r\n\r\n // Check if prefixed property works with the value\r\n declaration.setProperty(_prop, value);\r\n if (!declaration.getPropertyValue(_prop)) {\r\n for (const prefix of PREFIXES) {\r\n const prefixedValue = `-${prefix}-${value}`;\r\n if (declaration.setProperty(_prop, prefixedValue), declaration.getPropertyValue(_prop) === prefixedValue) {\r\n _value = prefixedValue;\r\n _vprefix = `-${prefix}-`;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n PREFIXCACHE.set(prop, { _prop, _vprefix });\r\n return { prop: _prop, value: _value };\r\n};\r\n\r\n\r\nconst resolveStyleContainer = (input?: Document | HTMLElement): { document: Document; container: HTMLElement } => {\r\n // Default → current document\r\n if (!input) {\r\n return {\r\n document,\r\n container: document.head,\r\n };\r\n }\r\n\r\n // If input is a Document (works across iframes)\r\n if (\"nodeType\" in input && input.nodeType === 9) {\r\n return {\r\n document: input as Document,\r\n container: (input as Document).head || input.getElementsByTagName(\"head\")[0],\r\n };\r\n }\r\n\r\n // If input is an HTMLElement → use its owner document\r\n if (\"ownerDocument\" in input && input instanceof HTMLElement) {\r\n return {\r\n document: input.ownerDocument,\r\n container: input,\r\n };\r\n }\r\n\r\n throw new Error(\"Invalid input: must be Document or HTMLElement\");\r\n}\r\n\r\nexport const style = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, cls?: string, opt?: CSSOptionProps<Aliases, BreakpointKeys>, dept = 1) => {\r\n let cachekey\r\n let classname = cls\r\n const cacheId = opt?.cacheId || \"global\"\r\n\r\n if (!cls) {\r\n cachekey = JSON.stringify(_css, (_key, value) => typeof value === \"function\" ? value.toString() : value);\r\n const has = ONCSS_CACHE.get(cacheId, cachekey)\r\n if (has) {\r\n has.cache = true\r\n return has\r\n }\r\n classname = `${opt?.classPrefix || \"\"}x${youid(cachekey)}`\r\n } else if (typeof cls !== 'string') {\r\n throw new Error(`Invalid class name: ${cls}`)\r\n }\r\n\r\n let stack: any = [`${classname}{`]\r\n let medias: any = {}\r\n let skiped: any = {}\r\n for (let prop in _css) {\r\n let val = (_css as any)[prop]\r\n let firstChar = prop.charAt(0)\r\n if (firstChar === '&') {\r\n let ncls = prop.replace(/&/g, classname as string)\r\n const r: any = style(val, ncls, opt, dept + 1)\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n stack.push(r.stack)\r\n } else if (firstChar === '@') {\r\n if (prop.startsWith(\"@global\") || prop.startsWith(\"@keyframes\")) {\r\n let _css = ''\r\n for (let selector in val) {\r\n let r: any = style(val[selector], selector, opt, dept + 1)\r\n _css += r.stack\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n }\r\n if (prop.startsWith(\"@keyframes\")) {\r\n stack.push(`${prop}{${_css}}`)\r\n } else {\r\n stack.push(_css)\r\n }\r\n } else {\r\n let r: any = style(val, classname, opt, dept + 1)\r\n const atcss = prop + \"{\" + r.stack + \"}\"\r\n stack.push(atcss)\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n }\r\n } else {\r\n if (opt?.skipProps && opt.skipProps(prop, val, dept)) {\r\n if (!((classname as any) in skiped)) skiped[classname as string] = []\r\n skiped[classname as string].push(prop)\r\n continue\r\n }\r\n if (typeof val === 'function' || Array.isArray(val)) {\r\n continue\r\n }\r\n if (typeof val === 'object') {\r\n for (let media in val) {\r\n if (typeof val[media] === 'object' || typeof val[media] === 'function' || Array.isArray(val[media])) {\r\n throw new Error(`Invalid css value: ${val[media]}`);\r\n }\r\n let breakpoint = media\r\n let isNumber = !isNaN(parseInt(breakpoint))\r\n if (!isNumber) {\r\n if (opt?.breakpoints && !isNaN(parseInt((opt.breakpoints as any)[media]))) {\r\n breakpoint = opt.breakpoints[media as BreakpointKeys].toString()\r\n } else {\r\n throw new Error(`Invalid breakpoint prop: ${media}`);\r\n }\r\n }\r\n let _css = { [prop]: val[media] }\r\n let r: any = style(_css, classname, opt, dept)\r\n let _style = r.stack\r\n let mediakey = `@media (min-width: ${breakpoint}px)`\r\n medias[mediakey] = medias[mediakey] ? medias[mediakey] + _style : _style\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n }\r\n } else {\r\n if (opt?.getProps) {\r\n let _props: any = opt.getProps(prop, val, _css, dept)\r\n if (_props) {\r\n let r: any = style(_props, classname, {\r\n ...opt,\r\n getProps: undefined\r\n })\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n stack.push(r.stack)\r\n continue;\r\n }\r\n }\r\n if (opt?.aliases && (opt.aliases as any)[prop]) {\r\n let _props = (opt.aliases as any)[prop](val)\r\n if (_props) {\r\n let r: any = style(_props, classname, {\r\n ...opt,\r\n aliases: undefined\r\n }, dept)\r\n r.stack = r.stack.replace(`${classname}{`, '').replace(`}`, '')\r\n stack[0] += r.stack\r\n continue;\r\n }\r\n }\r\n if (opt?.getValue) {\r\n val = opt.getValue(prop, val, _css, dept)\r\n }\r\n let p = cssPrefix(prop, val)\r\n stack[0] += `${p.prop}:${p.value};`\r\n }\r\n }\r\n }\r\n stack[0] += \"}\"\r\n if (stack[0] === `${classname}{}`) {\r\n stack[0] = \"\"\r\n }\r\n stack = stack.join('')\r\n for (let media in medias) {\r\n stack += `${media}{${medias[media].replace(new RegExp(`}\\\\${classname}\\\\{`, 'g'), '')}}`\r\n }\r\n\r\n if (cachekey) {\r\n const d = resolveStyleContainer(opt?.container);\r\n\r\n const selector = opt?.selector ?? \".\"\r\n stack = stack.replace(new RegExp(classname as string, 'g'), `${selector}${classname}`)\r\n const r = {\r\n cache: false,\r\n cachekey,\r\n selector,\r\n classname: classname as string,\r\n css: stack,\r\n cssraw: _css,\r\n skiped,\r\n cacheId,\r\n getStyleTag: () => d.container?.querySelector(`style[data-href=\"${classname}\"]`) as HTMLStyleElement | null,\r\n deleteStyle: () => {\r\n const tag = r.getStyleTag()\r\n tag && tag.remove()\r\n },\r\n inject: () => {\r\n const tag = r.getStyleTag() || d.document.createElement(\"style\");\r\n if (!tag.innerHTML) {\r\n tag.innerHTML = r.css\r\n tag.setAttribute(`data-href`, classname as string)\r\n d.container.appendChild(tag);\r\n }\r\n return tag\r\n },\r\n refresh: () => {\r\n r.deleteStyle()\r\n return r.inject()\r\n }\r\n }\r\n\r\n ONCSS_CACHE.set(cacheId, cachekey, r)\r\n\r\n let inject = opt?.injectStyle ?? true\r\n if (inject && typeof d.document !== 'undefined') {\r\n r.inject()\r\n }\r\n return r\r\n }\r\n return { stack, skiped }\r\n}"],"names":[],"mappings":";;AAEA;AACA;AACA;AAEA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAuC;AAEtD,MAAM,WAAW,GAAG;AACvB,IAAA,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAE,KAAqB,EAAA;QACxD,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,KAAK,EAAE;AACR,YAAA,KAAK,GAAG,IAAI,GAAG,EAAE;AACjB,YAAA,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;QAC9B;AACA,QAAA,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;IAC9B,CAAC;IACD,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAA;QACjC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC9B;IACJ,CAAC;IACD,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAA;QACjC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC9B;AACA,QAAA,OAAO,KAAK;IAChB,CAAC;IACD,MAAM,CAAC,OAAe,EAAE,QAAgB,EAAA;QACpC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC1B;IACJ,CAAC;IACD,MAAM,GAAA;AACF,QAAA,OAAO,MAAM;IACjB;;AAKJ,MAAM,gBAAgB,GAAG;IACr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sourcesContent":["import { CSSOptionProps, CSSFactoryType, CSSProps } from './types';\nimport youid from 'youid';\n// const _global: any = typeof window !== 'undefined' ? window : global;\n// _global.Factory = _global.Factory || new Map<string, CSSFactoryType>();\n// export const CSSFactory = _global.Factory as Map<string, CSSFactoryType>\n\nconst caches = new Map<string, Map<string, CSSFactoryType>>()\n\nexport const ONCSS_CACHE = {\n set(cacheId: string, cachekey: string, value: CSSFactoryType) {\n let cache = caches.get(cacheId)\n if (!cache) {\n cache = new Map()\n caches.set(cacheId, cache)\n }\n cache.set(cachekey, value)\n },\n get(cacheId: string, cachekey: string) {\n let cache = caches.get(cacheId)\n if (cache) {\n return cache.get(cachekey)\n }\n },\n has(cacheId: string, cachekey: string) {\n let cache = caches.get(cacheId)\n if (cache) {\n return cache.has(cachekey)\n }\n return false\n },\n delete(cacheId: string, cachekey: string,) {\n let cache = caches.get(cacheId)\n if (cache) {\n cache.delete(cachekey)\n }\n },\n caches() {\n return caches\n }\n}\n\n\n\nconst number_val_props = [\n \"fontWeight\",\n \"font-weight\",\n \"lineHeight\",\n \"line-height\",\n \"opacity\",\n \"zIndex\",\n \"z-index\",\n \"flex\",\n \"order\",\n \"flexGrow\",\n \"flex-grow\",\n \"flexShrink\",\n \"flex-shrink\",\n \"flexBasis\",\n \"flex-basis\",\n \"columns\",\n \"perspective\",\n \"stroke-dashoffset\"\n]\n\nexport const formatCSSProp = (prop: string) => prop.split(/(?=[A-Z])/).join(\"-\").toLowerCase();\nexport const formatCSSValue = (prop: string, val: any) => typeof val === 'number' && !number_val_props.includes(prop) ? `${val}px` : val\n\nconst PREFIXES = ['webkit', 'moz', 'ms', 'o'];\nlet _declaration: CSSStyleDeclaration;\nconst PREFIXCACHE = new Map();\n\nexport const cssPrefix = (prop: string, value: string): { prop: string, value: string } => {\n value = formatCSSValue(prop, value);\n prop = formatCSSProp(prop);\n\n if (typeof window === 'undefined') {\n return { prop, value };\n }\n\n const declaration = _declaration || (_declaration = document.createElement(\"div\").style);\n value = value?.toString();\n\n // Check if the property and value work as is\n if (declaration.setProperty(prop, value), declaration.getPropertyValue(prop) === value) {\n return { prop, value };\n }\n\n // Check cached property and value prefix\n const cached = PREFIXCACHE.get(prop);\n if (cached) {\n return { prop: cached._prop, value: `${cached._vprefix}${value}` };\n }\n\n let _prop = prop;\n let _value = value;\n let _vprefix = '';\n\n // Try property prefixes\n const camelCaseProp = prop.includes('-') ? prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase()) : prop;\n for (const prefix of PREFIXES) {\n if (declaration[`${prefix}${camelCaseProp}` as any] !== undefined) {\n _prop = `-${prefix}-${prop}`;\n break;\n }\n }\n\n // Check if prefixed property works with the value\n declaration.setProperty(_prop, value);\n if (!declaration.getPropertyValue(_prop)) {\n for (const prefix of PREFIXES) {\n const prefixedValue = `-${prefix}-${value}`;\n if (declaration.setProperty(_prop, prefixedValue), declaration.getPropertyValue(_prop) === prefixedValue) {\n _value = prefixedValue;\n _vprefix = `-${prefix}-`;\n break;\n }\n }\n }\n\n PREFIXCACHE.set(prop, { _prop, _vprefix });\n return { prop: _prop, value: _value };\n};\n\n\nconst resolveStyleContainer = (input?: Document | HTMLElement): { document?: Document; container?: HTMLElement } => {\n if (typeof window === 'undefined') {\n return {\n document: undefined,\n container: undefined\n }\n }\n // Default → current document\n if (!input) {\n return {\n document,\n container: document.head,\n };\n }\n\n // If input is a Document (works across iframes)\n if (\"nodeType\" in input && input.nodeType === 9) {\n return {\n document: input as Document,\n container: (input as Document).head || input.getElementsByTagName(\"head\")[0],\n };\n }\n\n // If input is an HTMLElement → use its owner document\n if (\"ownerDocument\" in input && input instanceof HTMLElement) {\n return {\n document: input.ownerDocument,\n container: input,\n };\n }\n\n throw new Error(\"Invalid input: must be Document or HTMLElement\");\n}\n\nexport const style = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, cls?: string, opt?: CSSOptionProps<Aliases, BreakpointKeys>, dept = 1) => {\n let cachekey\n let classname = cls\n const cacheId = opt?.cacheId || \"global\"\n\n if (!cls) {\n cachekey = JSON.stringify(_css, (_key, value) => typeof value === \"function\" ? value.toString() : value);\n const has = ONCSS_CACHE.get(cacheId, cachekey)\n if (has) {\n has.cache = true\n return has\n }\n classname = `${opt?.classPrefix || \"\"}x${youid(cachekey)}`\n } else if (typeof cls !== 'string') {\n throw new Error(`Invalid class name: ${cls}`)\n }\n\n let stack: any = [`${classname}{`]\n let medias: any = {}\n let skiped: any = {}\n for (let prop in _css) {\n let val = (_css as any)[prop]\n let firstChar = prop.charAt(0)\n if (firstChar === '&') {\n let ncls = prop.replace(/&/g, classname as string)\n const r: any = style(val, ncls, opt, dept + 1)\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n stack.push(r.stack)\n } else if (firstChar === '@') {\n if (prop.startsWith(\"@global\") || prop.startsWith(\"@keyframes\")) {\n let _css = ''\n for (let selector in val) {\n let r: any = style(val[selector], selector, opt, dept + 1)\n _css += r.stack\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n }\n if (prop.startsWith(\"@keyframes\")) {\n stack.push(`${prop}{${_css}}`)\n } else {\n stack.push(_css)\n }\n } else {\n let r: any = style(val, classname, opt, dept + 1)\n const atcss = prop + \"{\" + r.stack + \"}\"\n stack.push(atcss)\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n }\n } else {\n if (opt?.skipProps && opt.skipProps(prop, val, dept)) {\n if (!((classname as any) in skiped)) skiped[classname as string] = []\n skiped[classname as string].push(prop)\n continue\n }\n if (typeof val === 'function' || Array.isArray(val)) {\n continue\n }\n if (typeof val === 'object') {\n for (let media in val) {\n if (typeof val[media] === 'object' || typeof val[media] === 'function' || Array.isArray(val[media])) {\n throw new Error(`Invalid css value: ${val[media]}`);\n }\n let breakpoint = media\n let isNumber = !isNaN(parseInt(breakpoint))\n if (!isNumber) {\n if (opt?.breakpoints && !isNaN(parseInt((opt.breakpoints as any)[media]))) {\n breakpoint = opt.breakpoints[media as BreakpointKeys].toString()\n } else {\n throw new Error(`Invalid breakpoint prop: ${media}`);\n }\n }\n let _css = { [prop]: val[media] }\n let r: any = style(_css, classname, opt, dept)\n let _style = r.stack\n let mediakey = `@media (min-width: ${breakpoint}px)`\n medias[mediakey] = medias[mediakey] ? medias[mediakey] + _style : _style\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n }\n } else {\n if (opt?.getProps) {\n let _props: any = opt.getProps(prop, val, _css, dept)\n if (_props) {\n let r: any = style(_props, classname, {\n ...opt,\n getProps: undefined\n })\n if (opt?.skipProps) {\n skiped = {\n ...skiped,\n ...r.skiped\n }\n }\n stack.push(r.stack)\n continue;\n }\n }\n if (opt?.aliases && (opt.aliases as any)[prop]) {\n let _props = (opt.aliases as any)[prop](val)\n if (_props) {\n let r: any = style(_props, classname, {\n ...opt,\n aliases: undefined\n }, dept)\n r.stack = r.stack.replace(`${classname}{`, '').replace(`}`, '')\n stack[0] += r.stack\n continue;\n }\n }\n if (opt?.getValue) {\n val = opt.getValue(prop, val, _css, dept)\n }\n let p = cssPrefix(prop, val)\n stack[0] += `${p.prop}:${p.value};`\n }\n }\n }\n stack[0] += \"}\"\n if (stack[0] === `${classname}{}`) {\n stack[0] = \"\"\n }\n stack = stack.join('')\n for (let media in medias) {\n stack += `${media}{${medias[media].replace(new RegExp(`}\\\\${classname}\\\\{`, 'g'), '')}}`\n }\n\n if (cachekey) {\n const d = resolveStyleContainer(opt?.container);\n\n const selector = opt?.selector ?? \".\"\n stack = stack.replace(new RegExp(classname as string, 'g'), `${selector}${classname}`)\n const r = {\n cache: false,\n cachekey,\n selector,\n classname: classname as string,\n css: stack,\n cssraw: _css,\n skiped,\n cacheId,\n getStyleTag: () => d.container?.querySelector(`style[data-href=\"${classname}\"]`) as HTMLStyleElement | null,\n deleteStyle: () => {\n const tag = r.getStyleTag()\n tag && tag.remove()\n },\n inject: () => {\n const tag = r.getStyleTag() || d.document?.createElement(\"style\");\n if (tag && !tag?.innerHTML) {\n tag.innerHTML = r.css\n tag.setAttribute(`data-href`, classname as string)\n d.container?.appendChild(tag);\n }\n return tag as HTMLStyleElement\n },\n refresh: () => {\n r.deleteStyle()\n return r.inject()\n }\n }\n\n ONCSS_CACHE.set(cacheId, cachekey, r)\n\n let inject = opt?.injectStyle ?? true\n if (inject && d.document) {\n r.inject()\n }\n return r\n }\n return { stack, skiped }\n}"],"names":[],"mappings":";;AAEA;AACA;AACA;AAEA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAuC;AAEtD,MAAM,WAAW,GAAG;AACvB,IAAA,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAE,KAAqB,EAAA;QACxD,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,KAAK,EAAE;AACR,YAAA,KAAK,GAAG,IAAI,GAAG,EAAE;AACjB,YAAA,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;QAC9B;AACA,QAAA,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;IAC9B,CAAC;IACD,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAA;QACjC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC9B;IACJ,CAAC;IACD,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAA;QACjC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,KAAK,EAAE;AACP,YAAA,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC9B;AACA,QAAA,OAAO,KAAK;IAChB,CAAC;IACD,MAAM,CAAC,OAAe,EAAE,QAAgB,EAAA;QACpC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CA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AAA,OAAO,CAAC,CAAC,MAAM,EAAE;YACrB;SACH;QAED,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAErC,QAAA,IAAI,MAAM,GAAG,CAAA,EAAA,GAAA,GAAG,KAAA,IAAA,IAAH,GAAG,KAAA,MAAA,GAAA,MAAA,GAAH,GAAG,CAAE,WAAW,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AACrC,QAAA,IAAI,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE;YACtB,CAAC,CAAC,MAAM,EAAE;QACd;AACA,QAAA,OAAO,CAAC;IACZ;AACA,IAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;AAC5B;;;;"}
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { style } from \"./core\";\
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { style } from \"./core\";\nimport { CSSProps, CSSOptionProps, CSSFactoryType } from \"./types\";\nexport { ONCSS_CACHE, formatCSSProp, formatCSSValue } from './core'\nexport * from './types'\n\nexport const css = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, options?: CSSOptionProps<Aliases, BreakpointKeys>): CSSFactoryType => style<Aliases, BreakpointKeys>(_css, undefined, options) as any"],"names":["style"],"mappings":";;;;AAKO,MAAM,GAAG,GAAG,CAAyC,IAAuC,EAAE,OAAiD,KAAqBA,UAAK,CAA0B,IAAI,EAAE,SAAS,EAAE,OAAO;;;;;;;"}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { style } from \"./core\";\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { style } from \"./core\";\nimport { CSSProps, CSSOptionProps, CSSFactoryType } from \"./types\";\nexport { ONCSS_CACHE, formatCSSProp, formatCSSValue } from './core'\nexport * from './types'\n\nexport const css = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, options?: CSSOptionProps<Aliases, BreakpointKeys>): CSSFactoryType => style<Aliases, BreakpointKeys>(_css, undefined, options) as any"],"names":[],"mappings":";;;AAKO,MAAM,GAAG,GAAG,CAAyC,IAAuC,EAAE,OAAiD,KAAqB,KAAK,CAA0B,IAAI,EAAE,SAAS,EAAE,OAAO;;;;"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,397 +1,397 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img width="120" src="https://raw.githubusercontent.com/devnax/oncss/main/logo.png" alt="ONCSS Logo">
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">ONCSS</h1>
|
|
6
|
-
|
|
7
|
-
`oncss` is a CSS-in-JS library that provides developers with a powerful `css` function to style their web applications. It enables modern styling techniques, including nested selectors, responsive design, and dynamic keyframes, all while offering seamless integration with JavaScript frameworks like React.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
Install the `oncss` package via npm:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install oncss
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Import the `css` function in your project:
|
|
20
|
-
|
|
21
|
-
```javascript
|
|
22
|
-
import css from 'oncss';
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Core Concept: The `css` Function
|
|
28
|
-
|
|
29
|
-
The `css` function is the heart of `oncss`, designed to dynamically generate and inject CSS into your application. It supports:
|
|
30
|
-
|
|
31
|
-
- **CSS Properties**: Use standard CSS properties and values.
|
|
32
|
-
- **Nested Selectors**: Apply styles to child elements or states using `&`.
|
|
33
|
-
- **Media Queries**: Implement responsive designs with `@media` rules.
|
|
34
|
-
- **Keyframes**: Create animations with `@keyframes`.
|
|
35
|
-
- **Global Styles**: Apply styles globally with `@global`.
|
|
36
|
-
- **Custom Breakpoints**: Define reusable breakpoints for responsiveness.
|
|
37
|
-
- **Other At-Rules**: Utilize additional at-rules like `@container`, `@layer`, and `@supports`.
|
|
38
|
-
|
|
39
|
-
### Basic Example
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
const buttonStyles = css({
|
|
43
|
-
backgroundColor: 'blue',
|
|
44
|
-
color: 'white',
|
|
45
|
-
padding: '10px 20px',
|
|
46
|
-
borderRadius: '5px',
|
|
47
|
-
'&:hover': {
|
|
48
|
-
backgroundColor: 'darkblue',
|
|
49
|
-
},
|
|
50
|
-
'@media (min-width: 768px)': {
|
|
51
|
-
padding: '15px 30px',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
console.log(buttonStyles);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Configuration Options
|
|
61
|
-
|
|
62
|
-
The `css` function can be customized through an options object:
|
|
63
|
-
|
|
64
|
-
### Available Properties
|
|
65
|
-
|
|
66
|
-
| Property | Type | Description |
|
|
67
|
-
| ------------- | ---------- | ------------------------------------------------------------------------------------------------- |
|
|
68
|
-
| `classPrefix` | `string` | Adds a prefix to generated class names. |
|
|
69
|
-
| `breakpoints` | `object` | Custom breakpoints for responsive designs. |
|
|
70
|
-
| `aliases` | `object` | Custom shorthand properties for CSS rules. |
|
|
71
|
-
| `injectStyle` | `boolean` | Controls whether styles are auto-injected. |
|
|
72
|
-
| `skipProps` | `function` | Filters out unwanted properties. Receives `prop`, `value`, and `dept` as arguments. |
|
|
73
|
-
| `getValue` | `function` | Transforms property values dynamically. Receives `value`, `prop`, `css`, and `dept` as arguments. |
|
|
74
|
-
| `getProps` | `function` | Customizes specific property handling. Receives `prop`, `value`, `css`, and `dept` as arguments. |
|
|
75
|
-
|
|
76
|
-
### Example with Options
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
const styles = css({
|
|
80
|
-
fontSize: 16,
|
|
81
|
-
padding: 10,
|
|
82
|
-
}, {
|
|
83
|
-
classPrefix: 'myprefix',
|
|
84
|
-
breakpoints: {
|
|
85
|
-
sm: 480,
|
|
86
|
-
md: 768,
|
|
87
|
-
lg: 1024,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Using Breakpoints
|
|
93
|
-
|
|
94
|
-
You can use the defined breakpoints in your styles to create responsive designs:
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
const responsiveStyles = css({
|
|
98
|
-
fontSize: 14,
|
|
99
|
-
padding: {
|
|
100
|
-
sm: 12,
|
|
101
|
-
lg: 24
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
}, {
|
|
105
|
-
breakpoints: {
|
|
106
|
-
sm: 480,
|
|
107
|
-
md: 768,
|
|
108
|
-
lg: 1024,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## React Integration
|
|
116
|
-
|
|
117
|
-
oncss integrates seamlessly with React. Simply pass the generated class name to your component.
|
|
118
|
-
|
|
119
|
-
### React Example
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
import React from 'react';
|
|
123
|
-
import css from 'oncss';
|
|
124
|
-
|
|
125
|
-
const buttonStyle = css({
|
|
126
|
-
backgroundColor: 'green',
|
|
127
|
-
color: 'white',
|
|
128
|
-
padding: '10px 20px',
|
|
129
|
-
borderRadius: '8px',
|
|
130
|
-
'&:hover': {
|
|
131
|
-
backgroundColor: 'darkgreen',
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
function Button() {
|
|
136
|
-
return <button className={buttonStyle.toString()}>Click Me</button>;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export default Button;
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Advanced Features
|
|
145
|
-
|
|
146
|
-
### Nested Selectors
|
|
147
|
-
|
|
148
|
-
Apply styles to child elements or pseudo-classes:
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
const cardStyles = css({
|
|
152
|
-
padding: '20px',
|
|
153
|
-
border: '1px solid #ccc',
|
|
154
|
-
'& h1': {
|
|
155
|
-
fontSize: '24px',
|
|
156
|
-
margin: 0,
|
|
157
|
-
},
|
|
158
|
-
'&:hover': {
|
|
159
|
-
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)',
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Media Queries
|
|
165
|
-
|
|
166
|
-
Easily add responsive styles:
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
const responsiveStyles = css({
|
|
170
|
-
fontSize: '14px',
|
|
171
|
-
'@media (min-width: 768px)': {
|
|
172
|
-
fontSize: '18px',
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Keyframes
|
|
178
|
-
|
|
179
|
-
Define and use animations:
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
const animationStyles = css({
|
|
183
|
-
'@keyframes fadeIn': {
|
|
184
|
-
from: { opacity: 0 },
|
|
185
|
-
to: { opacity: 1 },
|
|
186
|
-
},
|
|
187
|
-
animation: 'fadeIn 2s ease-in-out',
|
|
188
|
-
});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Global Styles
|
|
192
|
-
|
|
193
|
-
Apply global styles effortlessly:
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
const globalStyles = css({
|
|
197
|
-
'@global': {
|
|
198
|
-
body: {
|
|
199
|
-
margin: 0,
|
|
200
|
-
fontFamily: 'Arial, sans-serif',
|
|
201
|
-
},
|
|
202
|
-
a: {
|
|
203
|
-
color: 'blue',
|
|
204
|
-
textDecoration: 'none',
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
});
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## Supported At-Rules
|
|
213
|
-
|
|
214
|
-
`oncss` supports various CSS at-rules to enhance your styling capabilities. Here is a list of supported at-rules with descriptions:
|
|
215
|
-
|
|
216
|
-
| At-Rule | Description |
|
|
217
|
-
| ------------ | ---------------------------------------------------------------------------- |
|
|
218
|
-
| `@media` | Used for applying styles based on media queries for responsive design. |
|
|
219
|
-
| `@keyframes` | Defines animations that can be applied to elements. |
|
|
220
|
-
| `@global` | Applies styles globally across the entire application. |
|
|
221
|
-
| `@container` | Used for container queries to apply styles based on container size. |
|
|
222
|
-
| `@layer` | Defines style layers to control the order of style application. |
|
|
223
|
-
| `@supports` | Applies styles based on the support of specific CSS features in the browser. |
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## Server-Side Styling
|
|
228
|
-
|
|
229
|
-
`oncss` supports server-side rendering (SSR) by utilizing the `CSSFactory` to store and manage generated CSS styles. This allows you to extract and inject styles into your server-rendered HTML.
|
|
230
|
-
|
|
231
|
-
### Example with React
|
|
232
|
-
|
|
233
|
-
Here's an example of how to use `oncss` for server-side rendering with React:
|
|
234
|
-
|
|
235
|
-
```tsx
|
|
236
|
-
import React from 'react';
|
|
237
|
-
import ReactDOMServer from 'react-dom/server';
|
|
238
|
-
import css, { CSSFactory } from 'oncss';
|
|
239
|
-
|
|
240
|
-
const buttonStyle = css({
|
|
241
|
-
backgroundColor: 'blue',
|
|
242
|
-
color: 'white',
|
|
243
|
-
padding: '10px 20px',
|
|
244
|
-
borderRadius: '5px',
|
|
245
|
-
'&:hover': {
|
|
246
|
-
backgroundColor: 'darkblue',
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
function Button() {
|
|
251
|
-
return <button className={buttonStyle}>Click Me</button>;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const App = () => (
|
|
255
|
-
<div>
|
|
256
|
-
<Button />
|
|
257
|
-
</div>
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
// Render the component to a string
|
|
261
|
-
const html = ReactDOMServer.renderToString(<App />);
|
|
262
|
-
|
|
263
|
-
let styles: any = Array.from(CSSFactory.values()).map((style) => {
|
|
264
|
-
return `<style data-href="${style.classname}">${style.css}</style>`
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
// Inject the styles into the HTML
|
|
268
|
-
const fullHtml = `
|
|
269
|
-
<!DOCTYPE html>
|
|
270
|
-
<html lang="en">
|
|
271
|
-
<head>
|
|
272
|
-
<meta charset="UTF-8">
|
|
273
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
274
|
-
<title>SSR with oncss</title>
|
|
275
|
-
${styles}
|
|
276
|
-
</head>
|
|
277
|
-
<body>
|
|
278
|
-
<div id="root">${html}</div>
|
|
279
|
-
</body>
|
|
280
|
-
</html>
|
|
281
|
-
`;
|
|
282
|
-
|
|
283
|
-
console.log(fullHtml);
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
In this example, the `CSSFactory` is used to collect all generated CSS styles during the server-side rendering process. These styles are then injected into the HTML document, ensuring that the styles are applied correctly when the page is loaded in the browser.
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## Utility Functions
|
|
291
|
-
|
|
292
|
-
### CSSFactory
|
|
293
|
-
|
|
294
|
-
`CSSFactory` is a global cache for storing generated CSS styles. It helps in reusing styles and avoiding redundant style generation.
|
|
295
|
-
|
|
296
|
-
### formatCSSProp
|
|
297
|
-
|
|
298
|
-
`formatCSSProp` is a utility function that converts camelCase CSS property names to kebab-case.
|
|
299
|
-
|
|
300
|
-
```typescript
|
|
301
|
-
import { formatCSSProp } from 'oncss';
|
|
302
|
-
|
|
303
|
-
const formattedProp = formatCSSProp('backgroundColor');
|
|
304
|
-
console.log(formattedProp); // 'background-color'
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### formatCSSValue
|
|
308
|
-
|
|
309
|
-
`formatCSSValue` is a utility function that formats CSS values, adding units like `px` where necessary.
|
|
310
|
-
|
|
311
|
-
```typescript
|
|
312
|
-
import { formatCSSValue } from 'oncss';
|
|
313
|
-
|
|
314
|
-
const formattedValue = formatCSSValue('width', 100);
|
|
315
|
-
console.log(formattedValue); // '100px'
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
---
|
|
319
|
-
|
|
320
|
-
## TypeScript Integration
|
|
321
|
-
|
|
322
|
-
`oncss` provides full TypeScript support, allowing you to define types for your CSS properties and options.
|
|
323
|
-
|
|
324
|
-
### Defining CSS Properties
|
|
325
|
-
|
|
326
|
-
You can define the types for your CSS properties using the `CSSProps` type:
|
|
327
|
-
|
|
328
|
-
```typescript
|
|
329
|
-
import { CSSProps } from 'oncss';
|
|
330
|
-
|
|
331
|
-
interface MyAliases {
|
|
332
|
-
customColor?: string;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
const styles: CSSProps<MyAliases, 'sm' | 'md' | 'lg'> = {
|
|
336
|
-
backgroundColor: 'blue',
|
|
337
|
-
customColor: 'red',
|
|
338
|
-
'@media (min-width: 768px)': {
|
|
339
|
-
backgroundColor: 'green',
|
|
340
|
-
},
|
|
341
|
-
};
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### Using Options with Types
|
|
345
|
-
|
|
346
|
-
You can also define types for the options object:
|
|
347
|
-
|
|
348
|
-
```typescript
|
|
349
|
-
import { CSSOptionProps } from 'oncss';
|
|
350
|
-
|
|
351
|
-
const options: CSSOptionProps<MyAliases, 'sm' | 'md' | 'lg'> = {
|
|
352
|
-
classPrefix: 'myprefix',
|
|
353
|
-
breakpoints: {
|
|
354
|
-
sm: 480,
|
|
355
|
-
md: 768,
|
|
356
|
-
lg: 1024,
|
|
357
|
-
},
|
|
358
|
-
aliases: {
|
|
359
|
-
customColor: (value) => ({ color: value }),
|
|
360
|
-
},
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const styles = css({
|
|
364
|
-
fontSize: 16,
|
|
365
|
-
padding: 10,
|
|
366
|
-
}, options);
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
## Conclusion
|
|
372
|
-
|
|
373
|
-
`oncss` simplifies styling for modern web applications. Its robust feature set, from responsive design to keyframe animations, makes it an invaluable tool for developers.
|
|
374
|
-
|
|
375
|
-
## Author
|
|
376
|
-
|
|
377
|
-
<table>
|
|
378
|
-
<tr>
|
|
379
|
-
<td>
|
|
380
|
-
<img src="https://raw.githubusercontent.com/devnax/devnax/main/me-circle-200.png" alt="devnax" width="100" height="100">
|
|
381
|
-
</td>
|
|
382
|
-
<td>
|
|
383
|
-
<strong>Naxrul Ahmed</strong><br>
|
|
384
|
-
<a href="https://github.com/devnax">GitHub Profile</a><br>
|
|
385
|
-
<a href="https://www.npmjs.com/~devnax">npm Profile</a><br>
|
|
386
|
-
<a href="https://github.com/devnax/open-source">Open Source Projects</a>
|
|
387
|
-
</td>
|
|
388
|
-
</tr>
|
|
389
|
-
</table>
|
|
390
|
-
|
|
391
|
-
<h2>⚡️ Where to find me</h2>
|
|
392
|
-
|
|
393
|
-
<p><a target="_blank" href="mailto:devnaxrul@gmail.com" style="display: inline-block;"><img src="https://img.shields.io/badge/-Email-05122A?style=for-the-badge&logo=gmail&logoColor=white&color=orange" alt="gmail" /></a>
|
|
394
|
-
<a target="_blank" href="https://twitter.com/devnaxx" style="display: inline-block;"><img src="https://img.shields.io/badge/twitter-x?style=for-the-badge&logo=x&logoColor=white&color=%230f1419" alt="twitter" /></a>
|
|
395
|
-
<a target="_blank" href="https://www.linkedin.com/in/devnax" style="display: inline-block;"><img src="https://img.shields.io/badge/linkedin-logo?style=for-the-badge&logo=linkedin&logoColor=white&color=%230a77b6" alt="linkedin" /></a>
|
|
396
|
-
<a target="_blank" href="https://www.facebook.com/devnax" style="display: inline-block;"><img src="https://img.shields.io/badge/facebook-logo?style=for-the-badge&logo=facebook&logoColor=white&color=%230866ff" alt="facebook" /></a>
|
|
397
|
-
<a target="_blank" href="https://www.instagram.com/devnaxx" style="display: inline-block;"><img src="https://img.shields.io/badge/instagram-logo?style=for-the-badge&logo=instagram&logoColor=white&color=%23F35369" alt="instagram" /></a></p>
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="120" src="https://raw.githubusercontent.com/devnax/oncss/main/logo.png" alt="ONCSS Logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">ONCSS</h1>
|
|
6
|
+
|
|
7
|
+
`oncss` is a CSS-in-JS library that provides developers with a powerful `css` function to style their web applications. It enables modern styling techniques, including nested selectors, responsive design, and dynamic keyframes, all while offering seamless integration with JavaScript frameworks like React.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the `oncss` package via npm:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install oncss
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Import the `css` function in your project:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import css from 'oncss';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Core Concept: The `css` Function
|
|
28
|
+
|
|
29
|
+
The `css` function is the heart of `oncss`, designed to dynamically generate and inject CSS into your application. It supports:
|
|
30
|
+
|
|
31
|
+
- **CSS Properties**: Use standard CSS properties and values.
|
|
32
|
+
- **Nested Selectors**: Apply styles to child elements or states using `&`.
|
|
33
|
+
- **Media Queries**: Implement responsive designs with `@media` rules.
|
|
34
|
+
- **Keyframes**: Create animations with `@keyframes`.
|
|
35
|
+
- **Global Styles**: Apply styles globally with `@global`.
|
|
36
|
+
- **Custom Breakpoints**: Define reusable breakpoints for responsiveness.
|
|
37
|
+
- **Other At-Rules**: Utilize additional at-rules like `@container`, `@layer`, and `@supports`.
|
|
38
|
+
|
|
39
|
+
### Basic Example
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const buttonStyles = css({
|
|
43
|
+
backgroundColor: 'blue',
|
|
44
|
+
color: 'white',
|
|
45
|
+
padding: '10px 20px',
|
|
46
|
+
borderRadius: '5px',
|
|
47
|
+
'&:hover': {
|
|
48
|
+
backgroundColor: 'darkblue',
|
|
49
|
+
},
|
|
50
|
+
'@media (min-width: 768px)': {
|
|
51
|
+
padding: '15px 30px',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log(buttonStyles);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Configuration Options
|
|
61
|
+
|
|
62
|
+
The `css` function can be customized through an options object:
|
|
63
|
+
|
|
64
|
+
### Available Properties
|
|
65
|
+
|
|
66
|
+
| Property | Type | Description |
|
|
67
|
+
| ------------- | ---------- | ------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `classPrefix` | `string` | Adds a prefix to generated class names. |
|
|
69
|
+
| `breakpoints` | `object` | Custom breakpoints for responsive designs. |
|
|
70
|
+
| `aliases` | `object` | Custom shorthand properties for CSS rules. |
|
|
71
|
+
| `injectStyle` | `boolean` | Controls whether styles are auto-injected. |
|
|
72
|
+
| `skipProps` | `function` | Filters out unwanted properties. Receives `prop`, `value`, and `dept` as arguments. |
|
|
73
|
+
| `getValue` | `function` | Transforms property values dynamically. Receives `value`, `prop`, `css`, and `dept` as arguments. |
|
|
74
|
+
| `getProps` | `function` | Customizes specific property handling. Receives `prop`, `value`, `css`, and `dept` as arguments. |
|
|
75
|
+
|
|
76
|
+
### Example with Options
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const styles = css({
|
|
80
|
+
fontSize: 16,
|
|
81
|
+
padding: 10,
|
|
82
|
+
}, {
|
|
83
|
+
classPrefix: 'myprefix',
|
|
84
|
+
breakpoints: {
|
|
85
|
+
sm: 480,
|
|
86
|
+
md: 768,
|
|
87
|
+
lg: 1024,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Using Breakpoints
|
|
93
|
+
|
|
94
|
+
You can use the defined breakpoints in your styles to create responsive designs:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const responsiveStyles = css({
|
|
98
|
+
fontSize: 14,
|
|
99
|
+
padding: {
|
|
100
|
+
sm: 12,
|
|
101
|
+
lg: 24
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
}, {
|
|
105
|
+
breakpoints: {
|
|
106
|
+
sm: 480,
|
|
107
|
+
md: 768,
|
|
108
|
+
lg: 1024,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## React Integration
|
|
116
|
+
|
|
117
|
+
oncss integrates seamlessly with React. Simply pass the generated class name to your component.
|
|
118
|
+
|
|
119
|
+
### React Example
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import React from 'react';
|
|
123
|
+
import css from 'oncss';
|
|
124
|
+
|
|
125
|
+
const buttonStyle = css({
|
|
126
|
+
backgroundColor: 'green',
|
|
127
|
+
color: 'white',
|
|
128
|
+
padding: '10px 20px',
|
|
129
|
+
borderRadius: '8px',
|
|
130
|
+
'&:hover': {
|
|
131
|
+
backgroundColor: 'darkgreen',
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
function Button() {
|
|
136
|
+
return <button className={buttonStyle.toString()}>Click Me</button>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export default Button;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Advanced Features
|
|
145
|
+
|
|
146
|
+
### Nested Selectors
|
|
147
|
+
|
|
148
|
+
Apply styles to child elements or pseudo-classes:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const cardStyles = css({
|
|
152
|
+
padding: '20px',
|
|
153
|
+
border: '1px solid #ccc',
|
|
154
|
+
'& h1': {
|
|
155
|
+
fontSize: '24px',
|
|
156
|
+
margin: 0,
|
|
157
|
+
},
|
|
158
|
+
'&:hover': {
|
|
159
|
+
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)',
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Media Queries
|
|
165
|
+
|
|
166
|
+
Easily add responsive styles:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
const responsiveStyles = css({
|
|
170
|
+
fontSize: '14px',
|
|
171
|
+
'@media (min-width: 768px)': {
|
|
172
|
+
fontSize: '18px',
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Keyframes
|
|
178
|
+
|
|
179
|
+
Define and use animations:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
const animationStyles = css({
|
|
183
|
+
'@keyframes fadeIn': {
|
|
184
|
+
from: { opacity: 0 },
|
|
185
|
+
to: { opacity: 1 },
|
|
186
|
+
},
|
|
187
|
+
animation: 'fadeIn 2s ease-in-out',
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Global Styles
|
|
192
|
+
|
|
193
|
+
Apply global styles effortlessly:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const globalStyles = css({
|
|
197
|
+
'@global': {
|
|
198
|
+
body: {
|
|
199
|
+
margin: 0,
|
|
200
|
+
fontFamily: 'Arial, sans-serif',
|
|
201
|
+
},
|
|
202
|
+
a: {
|
|
203
|
+
color: 'blue',
|
|
204
|
+
textDecoration: 'none',
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Supported At-Rules
|
|
213
|
+
|
|
214
|
+
`oncss` supports various CSS at-rules to enhance your styling capabilities. Here is a list of supported at-rules with descriptions:
|
|
215
|
+
|
|
216
|
+
| At-Rule | Description |
|
|
217
|
+
| ------------ | ---------------------------------------------------------------------------- |
|
|
218
|
+
| `@media` | Used for applying styles based on media queries for responsive design. |
|
|
219
|
+
| `@keyframes` | Defines animations that can be applied to elements. |
|
|
220
|
+
| `@global` | Applies styles globally across the entire application. |
|
|
221
|
+
| `@container` | Used for container queries to apply styles based on container size. |
|
|
222
|
+
| `@layer` | Defines style layers to control the order of style application. |
|
|
223
|
+
| `@supports` | Applies styles based on the support of specific CSS features in the browser. |
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Server-Side Styling
|
|
228
|
+
|
|
229
|
+
`oncss` supports server-side rendering (SSR) by utilizing the `CSSFactory` to store and manage generated CSS styles. This allows you to extract and inject styles into your server-rendered HTML.
|
|
230
|
+
|
|
231
|
+
### Example with React
|
|
232
|
+
|
|
233
|
+
Here's an example of how to use `oncss` for server-side rendering with React:
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
import React from 'react';
|
|
237
|
+
import ReactDOMServer from 'react-dom/server';
|
|
238
|
+
import css, { CSSFactory } from 'oncss';
|
|
239
|
+
|
|
240
|
+
const buttonStyle = css({
|
|
241
|
+
backgroundColor: 'blue',
|
|
242
|
+
color: 'white',
|
|
243
|
+
padding: '10px 20px',
|
|
244
|
+
borderRadius: '5px',
|
|
245
|
+
'&:hover': {
|
|
246
|
+
backgroundColor: 'darkblue',
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
function Button() {
|
|
251
|
+
return <button className={buttonStyle}>Click Me</button>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const App = () => (
|
|
255
|
+
<div>
|
|
256
|
+
<Button />
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// Render the component to a string
|
|
261
|
+
const html = ReactDOMServer.renderToString(<App />);
|
|
262
|
+
|
|
263
|
+
let styles: any = Array.from(CSSFactory.values()).map((style) => {
|
|
264
|
+
return `<style data-href="${style.classname}">${style.css}</style>`
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Inject the styles into the HTML
|
|
268
|
+
const fullHtml = `
|
|
269
|
+
<!DOCTYPE html>
|
|
270
|
+
<html lang="en">
|
|
271
|
+
<head>
|
|
272
|
+
<meta charset="UTF-8">
|
|
273
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
274
|
+
<title>SSR with oncss</title>
|
|
275
|
+
${styles}
|
|
276
|
+
</head>
|
|
277
|
+
<body>
|
|
278
|
+
<div id="root">${html}</div>
|
|
279
|
+
</body>
|
|
280
|
+
</html>
|
|
281
|
+
`;
|
|
282
|
+
|
|
283
|
+
console.log(fullHtml);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
In this example, the `CSSFactory` is used to collect all generated CSS styles during the server-side rendering process. These styles are then injected into the HTML document, ensuring that the styles are applied correctly when the page is loaded in the browser.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Utility Functions
|
|
291
|
+
|
|
292
|
+
### CSSFactory
|
|
293
|
+
|
|
294
|
+
`CSSFactory` is a global cache for storing generated CSS styles. It helps in reusing styles and avoiding redundant style generation.
|
|
295
|
+
|
|
296
|
+
### formatCSSProp
|
|
297
|
+
|
|
298
|
+
`formatCSSProp` is a utility function that converts camelCase CSS property names to kebab-case.
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
import { formatCSSProp } from 'oncss';
|
|
302
|
+
|
|
303
|
+
const formattedProp = formatCSSProp('backgroundColor');
|
|
304
|
+
console.log(formattedProp); // 'background-color'
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### formatCSSValue
|
|
308
|
+
|
|
309
|
+
`formatCSSValue` is a utility function that formats CSS values, adding units like `px` where necessary.
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
import { formatCSSValue } from 'oncss';
|
|
313
|
+
|
|
314
|
+
const formattedValue = formatCSSValue('width', 100);
|
|
315
|
+
console.log(formattedValue); // '100px'
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## TypeScript Integration
|
|
321
|
+
|
|
322
|
+
`oncss` provides full TypeScript support, allowing you to define types for your CSS properties and options.
|
|
323
|
+
|
|
324
|
+
### Defining CSS Properties
|
|
325
|
+
|
|
326
|
+
You can define the types for your CSS properties using the `CSSProps` type:
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
import { CSSProps } from 'oncss';
|
|
330
|
+
|
|
331
|
+
interface MyAliases {
|
|
332
|
+
customColor?: string;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const styles: CSSProps<MyAliases, 'sm' | 'md' | 'lg'> = {
|
|
336
|
+
backgroundColor: 'blue',
|
|
337
|
+
customColor: 'red',
|
|
338
|
+
'@media (min-width: 768px)': {
|
|
339
|
+
backgroundColor: 'green',
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Using Options with Types
|
|
345
|
+
|
|
346
|
+
You can also define types for the options object:
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import { CSSOptionProps } from 'oncss';
|
|
350
|
+
|
|
351
|
+
const options: CSSOptionProps<MyAliases, 'sm' | 'md' | 'lg'> = {
|
|
352
|
+
classPrefix: 'myprefix',
|
|
353
|
+
breakpoints: {
|
|
354
|
+
sm: 480,
|
|
355
|
+
md: 768,
|
|
356
|
+
lg: 1024,
|
|
357
|
+
},
|
|
358
|
+
aliases: {
|
|
359
|
+
customColor: (value) => ({ color: value }),
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const styles = css({
|
|
364
|
+
fontSize: 16,
|
|
365
|
+
padding: 10,
|
|
366
|
+
}, options);
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Conclusion
|
|
372
|
+
|
|
373
|
+
`oncss` simplifies styling for modern web applications. Its robust feature set, from responsive design to keyframe animations, makes it an invaluable tool for developers.
|
|
374
|
+
|
|
375
|
+
## Author
|
|
376
|
+
|
|
377
|
+
<table>
|
|
378
|
+
<tr>
|
|
379
|
+
<td>
|
|
380
|
+
<img src="https://raw.githubusercontent.com/devnax/devnax/main/me-circle-200.png" alt="devnax" width="100" height="100">
|
|
381
|
+
</td>
|
|
382
|
+
<td>
|
|
383
|
+
<strong>Naxrul Ahmed</strong><br>
|
|
384
|
+
<a href="https://github.com/devnax">GitHub Profile</a><br>
|
|
385
|
+
<a href="https://www.npmjs.com/~devnax">npm Profile</a><br>
|
|
386
|
+
<a href="https://github.com/devnax/open-source">Open Source Projects</a>
|
|
387
|
+
</td>
|
|
388
|
+
</tr>
|
|
389
|
+
</table>
|
|
390
|
+
|
|
391
|
+
<h2>⚡️ Where to find me</h2>
|
|
392
|
+
|
|
393
|
+
<p><a target="_blank" href="mailto:devnaxrul@gmail.com" style="display: inline-block;"><img src="https://img.shields.io/badge/-Email-05122A?style=for-the-badge&logo=gmail&logoColor=white&color=orange" alt="gmail" /></a>
|
|
394
|
+
<a target="_blank" href="https://twitter.com/devnaxx" style="display: inline-block;"><img src="https://img.shields.io/badge/twitter-x?style=for-the-badge&logo=x&logoColor=white&color=%230f1419" alt="twitter" /></a>
|
|
395
|
+
<a target="_blank" href="https://www.linkedin.com/in/devnax" style="display: inline-block;"><img src="https://img.shields.io/badge/linkedin-logo?style=for-the-badge&logo=linkedin&logoColor=white&color=%230a77b6" alt="linkedin" /></a>
|
|
396
|
+
<a target="_blank" href="https://www.facebook.com/devnax" style="display: inline-block;"><img src="https://img.shields.io/badge/facebook-logo?style=for-the-badge&logo=facebook&logoColor=white&color=%230866ff" alt="facebook" /></a>
|
|
397
|
+
<a target="_blank" href="https://www.instagram.com/devnaxx" style="display: inline-block;"><img src="https://img.shields.io/badge/instagram-logo?style=for-the-badge&logo=instagram&logoColor=white&color=%23F35369" alt="instagram" /></a></p>
|