oncss 1.0.0
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.d.ts +23 -0
- package/core.js +2 -0
- package/core.js.map +7 -0
- package/index.d.ts +5 -0
- package/index.js +2 -0
- package/index.js.map +7 -0
- package/package.json +35 -0
- package/readme.md +284 -0
- package/types.d.ts +57 -0
- package/types.js +1 -0
- package/types.js.map +7 -0
package/core.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSSOptionProps, CSSFactoryType, CSSProps } from './types';
|
|
2
|
+
export declare const CSSFactory: Map<string, CSSFactoryType>;
|
|
3
|
+
export declare const uid: (str: string) => any;
|
|
4
|
+
export declare const formatCSSProp: (prop: string) => string;
|
|
5
|
+
export declare const formatCSSValue: (prop: string, val: any) => any;
|
|
6
|
+
export declare const cssPrefix: (prop: string, value: string) => {
|
|
7
|
+
prop: string;
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const style: <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, cls?: string, opt?: CSSOptionProps<Aliases, BreakpointKeys>) => CSSFactoryType | {
|
|
11
|
+
cache: boolean;
|
|
12
|
+
cachekey: string;
|
|
13
|
+
classname: string;
|
|
14
|
+
css: any;
|
|
15
|
+
cssraw: CSSProps<Aliases, BreakpointKeys>;
|
|
16
|
+
skiped: any;
|
|
17
|
+
toString: () => string;
|
|
18
|
+
getStyleTag: () => HTMLStyleElement | null;
|
|
19
|
+
deleteStyle: () => void;
|
|
20
|
+
} | {
|
|
21
|
+
stack: any;
|
|
22
|
+
skiped: any;
|
|
23
|
+
} | undefined;
|
package/core.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const k=typeof window<"u"?window:global;k.Factory=k.Factory||new Map;const h=k.Factory,w=n=>{for(var i=0,e=n.length,f=0;f<e;f++)i=(i<<5)-i+n.charCodeAt(f),i|=0;let t=i.toString(32).slice(-10).replaceAll("-","");return/^\d/.test(t.charAt(0))&&(t="c"+t),t},b=["fontWeight","font-weight","lineHeight","line-height","opacity","zIndex","z-index","flex","order","flexGrow","flex-grow","flexShrink","flex-shrink","flexBasis","flex-basis","columns","perspective","stroke-dashoffset"],C=n=>n.split(/(?=[A-Z])/).join("-").toLowerCase(),A=(n,i)=>typeof i=="number"&&!b.includes(n)?`${i}px`:i,$=["webkit","moz","ms","o"];let P;const x=new Map,E=(n,i)=>{if(i=A(n,i),n=C(n),typeof window>"u")return{prop:n,value:i};const e=P||(P=document.createElement("div").style);if(i=i?.toString(),e.setProperty(n,i),e.getPropertyValue(n)===i)return{prop:n,value:i};const f=x.get(n);if(f)return{prop:f._prop,value:`${f._vprefix}${i}`};let t=n,o=i,y="";const c=n.includes("-")?n.replace(/-([a-z])/g,(s,a)=>a.toUpperCase()):n;for(const s of $)if(e[`${s}${c}`]!==void 0){t=`-${s}-${n}`;break}if(e.setProperty(t,i),!e.getPropertyValue(t))for(const s of $){const a=`-${s}-${i}`;if(e.setProperty(t,a),e.getPropertyValue(t)===a){o=a,y=`-${s}-`;break}}return x.set(n,{_prop:t,_vprefix:y}),{prop:t,value:o}},g=(n,i,e)=>{let f,t=i;if(i){if(typeof i!="string")throw new Error(`Invalid class name: ${i}`)}else{f=JSON.stringify(n);const s=h.get(f);if(s)return s.cache=!0,s;t=w(f)}let o=[`${t}{`],y={},c={};for(let s in n){let a=n[s];if(s.startsWith("&")){let r=s.replaceAll("&",t);const l=g(a,r,e);e?.skipProps&&(c={...c,...l.skiped}),o.push(l.stack)}else if(s.startsWith("@media")){let r=g(a,t,e);const l=s+"{"+r.stack+"}";o.push(l),e?.skipProps&&(c={...c,...r.skiped})}else if(s.startsWith("@keyframes")){let r="";for(let l in a){const p=g(a[l],l,e);r+=p.stack,e?.skipProps&&(c={...c,...p.skiped})}o.push(`${s}{${r}}`)}else if(s.startsWith("@global")){let r="";for(let l in a){let p=g(a[l],l,e);r+=p.stack,e?.skipProps&&(c={...c,...p.skiped})}o.push(r)}else if(typeof a=="object")for(let r in a){if(typeof a[r]=="object"||typeof a[r]=="function"||Array.isArray(a[r]))throw new Error(`Invalid css value: ${a[r]}`);let l=r;if(!!isNaN(parseInt(l)))if(e?.breakpoints&&!isNaN(parseInt(e.breakpoints[r])))l=e.breakpoints[r].toString();else throw new Error(`Invalid breakpoint prop: ${r}`);let d={[s]:a[r]},m=g(d,t,e),S=m.stack,u=`@media (min-width: ${l}px)`;y[u]=y[u]?y[u]+S:S,e?.skipProps&&(c={...c,...m.skiped})}else{if(e?.skipProps&&e.skipProps(s,a)){c[t]||(c[t]=[]),c[t].push(s);continue}if(e?.getProps){let l=e.getProps(s,a,n);if(l){let p=g(l,t,{...e,getProps:void 0});o.push(p);continue}}if(e?.getValue)a=e.getValue(s,a,n);else if(e?.aliases&&e.aliases[s]){let l=e.aliases[s](s,a);if(l){let p=g(l,t,{...e,getProps:void 0}),d=p.stack;d=d.replace(`${t}{`,"").replace("}",""),d=d.replace("}",""),o[0]+=d,c[t]=p.skiped;continue}}const r=E(s,a);o[0]+=`${r.prop}:${r.value};`}}o[0]+="}",o[0]===`${t}{}`&&(o[0]=""),o=o.join("");for(let s in y)o+=`${s}{${y[s].replaceAll(`}${t}{`,"")}}`;if(f){o=o.replaceAll(t,"."+t);const s={cache:!1,cachekey:f,classname:t,css:o,cssraw:n,skiped:c,toString:()=>t,getStyleTag:()=>document?.querySelector(`[data-oncss="${t}"]`),deleteStyle:()=>{const r=document?.querySelector(`[data-oncss="${t}"]`);r&&r.remove()}};if(h.set(f,s),(e?.injectStyle||!0)&&typeof window<"u"){if(document.querySelector(`[data-oncss="${t}"]`))return;const r=document.createElement("style");r.innerHTML=s.css,r.setAttribute("data-oncss",t),document.head.append(r)}return s}return{stack:o,skiped:c}};export{h as CSSFactory,E as cssPrefix,C as formatCSSProp,A as formatCSSValue,g as style,w as uid};
|
|
2
|
+
//# sourceMappingURL=core.js.map
|
package/core.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core.ts"],
|
|
4
|
+
"sourcesContent": ["import { CSSOptionProps, CSSFactoryType, CSSProps } from './types';\r\n\r\nconst _global: any = typeof window !== 'undefined' ? window : global;\r\n_global.Factory = _global.Factory || new Map<string, CSSFactoryType>();\r\nexport const CSSFactory = _global.Factory as Map<string, CSSFactoryType>\r\n\r\nexport const uid = (str: string) => {\r\n var hash = 0, len = str.length;\r\n for (var i = 0; i < len; i++) {\r\n hash = ((hash << 5) - hash) + str.charCodeAt(i);\r\n hash |= 0;\r\n }\r\n let id = hash.toString(32).slice(-10).replaceAll(\"-\", \"\");\r\n if (/^\\d/.test(id.charAt(0))) id = 'c' + id;\r\n return id;\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\nexport const style = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, cls?: string, opt?: CSSOptionProps<Aliases, BreakpointKeys>) => {\r\n let cachekey\r\n let classname = cls\r\n if (!cls) {\r\n cachekey = JSON.stringify(_css)\r\n const has = CSSFactory.get(cachekey)\r\n if (has) {\r\n has.cache = true\r\n return has\r\n }\r\n classname = uid(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\r\n for (let prop in _css) {\r\n let val = (_css as any)[prop]\r\n\r\n if (prop.startsWith(\"&\")) {\r\n let ncls = prop.replaceAll(\"&\", classname as string)\r\n const r: any = style(val, ncls, opt)\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 (prop.startsWith(\"@media\")) {\r\n let r: any = style(val, classname, opt)\r\n const mediacss = prop + \"{\" + r.stack + \"}\"\r\n stack.push(mediacss)\r\n if (opt?.skipProps) {\r\n skiped = {\r\n ...skiped,\r\n ...r.skiped\r\n }\r\n }\r\n } else if (prop.startsWith(\"@keyframes\")) {\r\n let frams = ''\r\n for (let frame in val) {\r\n const r: any = style(val[frame], frame, opt)\r\n frams += 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 stack.push(`${prop}{${frams}}`)\r\n } else if (prop.startsWith(\"@global\")) {\r\n let _css = ''\r\n for (let selector in val) {\r\n let r: any = style(val[selector], selector, opt)\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 stack.push(_css)\r\n } else 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)\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?.skipProps && opt.skipProps(prop, val)) {\r\n if (!skiped[classname as string]) skiped[classname as string] = []\r\n skiped[classname as string].push(prop)\r\n continue\r\n }\r\n if (opt?.getProps) {\r\n let _props: any = opt.getProps(prop, val, _css)\r\n if (_props) {\r\n let s = style(_props, classname, {\r\n ...opt,\r\n getProps: undefined\r\n })\r\n stack.push(s)\r\n continue;\r\n }\r\n }\r\n if (opt?.getValue) {\r\n val = opt.getValue(prop, val, _css)\r\n } else if (opt?.aliases && (opt.aliases as any)[prop]) {\r\n let _props = (opt.aliases as any)[prop](prop, val)\r\n if (_props) {\r\n let r: any = style(_props, classname, {\r\n ...opt,\r\n getProps: undefined\r\n })\r\n let s = r.stack\r\n s = s.replace(`${classname}{`, '').replace(`}`, '')\r\n s = s.replace(`}`, '')\r\n stack[0] += s\r\n skiped[classname as string] = r.skiped\r\n continue;\r\n }\r\n }\r\n const format = cssPrefix(prop, val)\r\n stack[0] += `${format.prop}:${format.value};`\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].replaceAll(`}${classname}{`, '')}}`\r\n }\r\n\r\n if (cachekey) {\r\n stack = stack.replaceAll(classname, \".\" + classname)\r\n const r = {\r\n cache: false,\r\n cachekey,\r\n classname: classname as string,\r\n css: stack,\r\n cssraw: _css,\r\n skiped,\r\n toString: () => classname as string,\r\n getStyleTag: () => document?.querySelector(`[data-oncss=\"${classname}\"]`) as HTMLStyleElement | null,\r\n deleteStyle: () => {\r\n const tag = document?.querySelector(`[data-oncss=\"${classname}\"]`)\r\n tag && tag.remove()\r\n },\r\n }\r\n CSSFactory.set(cachekey, r)\r\n let inject = opt?.injectStyle || true\r\n if (inject && typeof window !== 'undefined') {\r\n if (document.querySelector(`[data-oncss=\"${classname}\"]`)) return;\r\n const tag = document.createElement(\"style\");\r\n tag.innerHTML = r.css\r\n tag.setAttribute(`data-onc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Y,EAAI,aAAa,aAAclB,CAAmB,EAClD,SAAS,KAAK,OAAOkB,CAAG,CAC5B,CACA,OAAOZ,CACX,CACA,MAAO,CAAE,MAAAJ,EAAO,OAAAE,CAAO,CAC3B",
|
|
6
|
+
"names": ["_global", "CSSFactory", "uid", "str", "hash", "len", "i", "id", "number_val_props", "formatCSSProp", "prop", "formatCSSValue", "val", "PREFIXES", "_declaration", "PREFIXCACHE", "cssPrefix", "value", "declaration", "cached", "_prop", "_value", "_vprefix", "camelCaseProp", "_", "c", "prefix", "prefixedValue", "style", "_css", "cls", "opt", "cachekey", "classname", "has", "stack", "medias", "skiped", "ncls", "r", "mediacss", "frams", "frame", "selector", "media", "breakpoint", "_style", "mediakey", "_props", "s", "format", "tag"]
|
|
7
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CSSProps, CSSOptionProps } from "./types";
|
|
2
|
+
export { CSSFactory, formatCSSProp, formatCSSValue } from './core';
|
|
3
|
+
export * from './types';
|
|
4
|
+
declare const css: <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, options?: CSSOptionProps<Aliases, BreakpointKeys>) => any;
|
|
5
|
+
export default css;
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { style } from \"./core\";\r\nimport { CSSProps, CSSOptionProps } from \"./types\";\r\nexport { CSSFactory, formatCSSProp, formatCSSValue } from './core'\r\nexport * from './types'\r\n\r\nconst css = <Aliases, BreakpointKeys extends string>(_css: CSSProps<Aliases, BreakpointKeys>, options?: CSSOptionProps<Aliases, BreakpointKeys>): any => style<Aliases, BreakpointKeys>(_css, undefined, options)\r\nexport default css"],
|
|
5
|
+
"mappings": "AAAA,OAAS,SAAAA,MAAa,SAEtB,OAAS,cAAAC,EAAY,iBAAAC,EAAe,kBAAAC,MAAsB,SAC1D,WAAc,UAEd,MAAMC,EAAM,CAAyCC,EAAyCC,IAA2DN,EAA+BK,EAAM,OAAWC,CAAO,EAChN,IAAOC,EAAQH",
|
|
6
|
+
"names": ["style", "CSSFactory", "formatCSSProp", "formatCSSValue", "css", "_css", "options", "index_default"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "oncss",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "makepack serve",
|
|
8
|
+
"pack": "makepack pack",
|
|
9
|
+
"publish:pack": "makepack pack -p"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/react": "^19.0.2",
|
|
13
|
+
"@types/react-dom": "^19.0.2",
|
|
14
|
+
"makepack": "latest",
|
|
15
|
+
"react": "^19.0.0",
|
|
16
|
+
"react-dom": "^19.0.0",
|
|
17
|
+
"typescript": "^4.4.2"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"css",
|
|
21
|
+
"oncss",
|
|
22
|
+
"styles",
|
|
23
|
+
"web development",
|
|
24
|
+
"frontend"
|
|
25
|
+
],
|
|
26
|
+
"author": "Your Name",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/yourusername/oncss.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/yourusername/oncss/issues"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# oncss Documentation
|
|
2
|
+
|
|
3
|
+
`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.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the `oncss` package via npm:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install oncss
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Import the `css` function in your project:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import css from 'oncss';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Core Concept: The `css` Function
|
|
24
|
+
|
|
25
|
+
The `css` function is the heart of `oncss`, designed to dynamically generate and inject CSS into your application. It supports:
|
|
26
|
+
|
|
27
|
+
- **CSS Properties**: Use standard CSS properties and values.
|
|
28
|
+
- **Nested Selectors**: Apply styles to child elements or states using `&`.
|
|
29
|
+
- **Media Queries**: Implement responsive designs with `@media` rules.
|
|
30
|
+
- **Keyframes**: Create animations with `@keyframes`.
|
|
31
|
+
- **Global Styles**: Apply styles globally with `@global`.
|
|
32
|
+
- **Custom Breakpoints**: Define reusable breakpoints for responsiveness.
|
|
33
|
+
|
|
34
|
+
### Basic Example
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const buttonStyles = css({
|
|
38
|
+
backgroundColor: 'blue',
|
|
39
|
+
color: 'white',
|
|
40
|
+
padding: '10px 20px',
|
|
41
|
+
borderRadius: '5px',
|
|
42
|
+
'&:hover': {
|
|
43
|
+
backgroundColor: 'darkblue',
|
|
44
|
+
},
|
|
45
|
+
'@media (min-width: 768px)': {
|
|
46
|
+
padding: '15px 30px',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
console.log(buttonStyles.toString());
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Configuration Options
|
|
56
|
+
|
|
57
|
+
The `css` function can be customized through an options object:
|
|
58
|
+
|
|
59
|
+
### Available Properties
|
|
60
|
+
|
|
61
|
+
| Property | Type | Description |
|
|
62
|
+
| ------------- | ---------- | ------------------------------------------ |
|
|
63
|
+
| `classPrefix` | `string` | Adds a prefix to generated class names. |
|
|
64
|
+
| `breakpoints` | `object` | Custom breakpoints for responsive designs. |
|
|
65
|
+
| `aliases` | `object` | Custom shorthand properties for CSS rules. |
|
|
66
|
+
| `injectStyle` | `boolean` | Controls whether styles are auto-injected. |
|
|
67
|
+
| `skipProps` | `function` | Filters out unwanted properties. |
|
|
68
|
+
| `getValue` | `function` | Transforms property values dynamically. |
|
|
69
|
+
| `getProps` | `function` | Customizes specific property handling. |
|
|
70
|
+
|
|
71
|
+
### Example with Options
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const styles = css({
|
|
75
|
+
fontSize: 16,
|
|
76
|
+
padding: 10,
|
|
77
|
+
}, {
|
|
78
|
+
classPrefix: 'myprefix',
|
|
79
|
+
breakpoints: {
|
|
80
|
+
sm: 480,
|
|
81
|
+
md: 768,
|
|
82
|
+
lg: 1024,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Using Breakpoints
|
|
88
|
+
|
|
89
|
+
You can use the defined breakpoints in your styles to create responsive designs:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const responsiveStyles = css({
|
|
93
|
+
fontSize: 14,
|
|
94
|
+
padding: {
|
|
95
|
+
sm: 12,
|
|
96
|
+
lg: 24
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
}, {
|
|
100
|
+
breakpoints: {
|
|
101
|
+
sm: 480,
|
|
102
|
+
md: 768,
|
|
103
|
+
lg: 1024,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## React Integration
|
|
111
|
+
|
|
112
|
+
oncss integrates seamlessly with React. Simply pass the generated class name to your component.
|
|
113
|
+
|
|
114
|
+
### React Example
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import React from 'react';
|
|
118
|
+
import css from 'oncss';
|
|
119
|
+
|
|
120
|
+
const buttonStyle = css({
|
|
121
|
+
backgroundColor: 'green',
|
|
122
|
+
color: 'white',
|
|
123
|
+
padding: '10px 20px',
|
|
124
|
+
borderRadius: '8px',
|
|
125
|
+
'&:hover': {
|
|
126
|
+
backgroundColor: 'darkgreen',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
function Button() {
|
|
131
|
+
return <button className={buttonStyle.toString()}>Click Me</button>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default Button;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Advanced Features
|
|
140
|
+
|
|
141
|
+
### Nested Selectors
|
|
142
|
+
|
|
143
|
+
Apply styles to child elements or pseudo-classes:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const cardStyles = css({
|
|
147
|
+
padding: '20px',
|
|
148
|
+
border: '1px solid #ccc',
|
|
149
|
+
'& h1': {
|
|
150
|
+
fontSize: '24px',
|
|
151
|
+
margin: 0,
|
|
152
|
+
},
|
|
153
|
+
'&:hover': {
|
|
154
|
+
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.1)',
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Media Queries
|
|
160
|
+
|
|
161
|
+
Easily add responsive styles:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const responsiveStyles = css({
|
|
165
|
+
fontSize: '14px',
|
|
166
|
+
'@media (min-width: 768px)': {
|
|
167
|
+
fontSize: '18px',
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Keyframes
|
|
173
|
+
|
|
174
|
+
Define and use animations:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
const animationStyles = css({
|
|
178
|
+
'@keyframes fadeIn': {
|
|
179
|
+
from: { opacity: 0 },
|
|
180
|
+
to: { opacity: 1 },
|
|
181
|
+
},
|
|
182
|
+
animation: 'fadeIn 2s ease-in-out',
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Global Styles
|
|
187
|
+
|
|
188
|
+
Apply global styles effortlessly:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
const globalStyles = css({
|
|
192
|
+
'@global': {
|
|
193
|
+
body: {
|
|
194
|
+
margin: 0,
|
|
195
|
+
fontFamily: 'Arial, sans-serif',
|
|
196
|
+
},
|
|
197
|
+
a: {
|
|
198
|
+
color: 'blue',
|
|
199
|
+
textDecoration: 'none',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## TypeScript Integration
|
|
208
|
+
|
|
209
|
+
`oncss` provides full TypeScript support, allowing you to define types for your CSS properties and options.
|
|
210
|
+
|
|
211
|
+
### Defining CSS Properties
|
|
212
|
+
|
|
213
|
+
You can define the types for your CSS properties using the `CSSProps` type:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { CSSProps } from 'oncss';
|
|
217
|
+
|
|
218
|
+
interface MyAliases {
|
|
219
|
+
customColor?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const styles: CSSProps<MyAliases, 'sm' | 'md' | 'lg'> = {
|
|
223
|
+
backgroundColor: 'blue',
|
|
224
|
+
customColor: 'red',
|
|
225
|
+
'@media (min-width: 768px)': {
|
|
226
|
+
backgroundColor: 'green',
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Using Options with Types
|
|
232
|
+
|
|
233
|
+
You can also define types for the options object:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { CSSOptionProps } from 'oncss';
|
|
237
|
+
|
|
238
|
+
const options: CSSOptionProps<MyAliases, 'sm' | 'md' | 'lg'> = {
|
|
239
|
+
classPrefix: 'myprefix',
|
|
240
|
+
breakpoints: {
|
|
241
|
+
sm: 480,
|
|
242
|
+
md: 768,
|
|
243
|
+
lg: 1024,
|
|
244
|
+
},
|
|
245
|
+
aliases: {
|
|
246
|
+
customColor: (prop, value) => ({ color: value }),
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const styles = css({
|
|
251
|
+
fontSize: 16,
|
|
252
|
+
padding: 10,
|
|
253
|
+
}, options);
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Conclusion
|
|
259
|
+
|
|
260
|
+
`oncss` simplifies styling for modern web applications. Its robust feature set, from responsive design to keyframe animations, makes it an invaluable tool for developers.
|
|
261
|
+
|
|
262
|
+
## Author
|
|
263
|
+
|
|
264
|
+
<table>
|
|
265
|
+
<tr>
|
|
266
|
+
<td>
|
|
267
|
+
<img src="https://raw.githubusercontent.com/devnax/devnax/main/me-circle-200.png" alt="devnax" width="100" height="100">
|
|
268
|
+
</td>
|
|
269
|
+
<td>
|
|
270
|
+
<strong>Naxrul Ahmed</strong><br>
|
|
271
|
+
<a href="https://github.com/devnax">GitHub Profile</a><br>
|
|
272
|
+
<a href="https://www.npmjs.com/~devnax">npm Profile</a><br>
|
|
273
|
+
<a href="https://github.com/devnax/open-source">Open Source Projects</a>
|
|
274
|
+
</td>
|
|
275
|
+
</tr>
|
|
276
|
+
</table>
|
|
277
|
+
|
|
278
|
+
<h2>⚡️ Where to find me</h2>
|
|
279
|
+
|
|
280
|
+
<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>
|
|
281
|
+
<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>
|
|
282
|
+
<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>
|
|
283
|
+
<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>
|
|
284
|
+
<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>
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as CSS from 'csstype';
|
|
2
|
+
type CSSProperties = CSS.Properties<number | string>;
|
|
3
|
+
type CSSNestedSelectors<Aliases, BreakpointKeys extends string> = {
|
|
4
|
+
[key: `& ${string}`]: CSSPropsWithoutGlobal<Aliases, BreakpointKeys>;
|
|
5
|
+
};
|
|
6
|
+
type MediaCSS<Aliases, BreakpointKeys extends string> = {
|
|
7
|
+
[key: `@media ${string}`]: CSSProps<Aliases, BreakpointKeys>;
|
|
8
|
+
};
|
|
9
|
+
type KeyframesCSS<Aliases> = {
|
|
10
|
+
[key: `@keyframes ${string}`]: {
|
|
11
|
+
from?: CSSValueWithoutBreakpoint<Aliases>;
|
|
12
|
+
to?: CSSValueWithoutBreakpoint<Aliases>;
|
|
13
|
+
[key: `${string}%`]: CSSValueWithoutBreakpoint<Aliases>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
type GlobalCSS<Aliases, BreakpointKeys extends string> = {
|
|
17
|
+
'@global'?: {
|
|
18
|
+
[key: string]: CSSPropsWithoutGlobal<Aliases, BreakpointKeys>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type BreakpointTypes<BreakpointKeys extends string, ValueTypes> = {
|
|
22
|
+
[key in number | BreakpointKeys]?: ValueTypes;
|
|
23
|
+
};
|
|
24
|
+
export type CSSValueWithoutBreakpoint<Aliases> = {
|
|
25
|
+
[Property in keyof (CSSProperties & Aliases)]?: (CSSProperties & Aliases)[Property];
|
|
26
|
+
};
|
|
27
|
+
type CSSValue<Aliases, BreakpointKeys extends string> = {
|
|
28
|
+
[Property in keyof (CSSProperties & Aliases)]?: (CSSProperties & Aliases)[Property] | BreakpointTypes<BreakpointKeys, (CSSProperties & Aliases)[Property]>;
|
|
29
|
+
};
|
|
30
|
+
export type CSSPropsWithoutGlobal<Aliases, BreakpointKeys extends string> = CSSValue<Aliases, BreakpointKeys> | KeyframesCSS<Aliases> | MediaCSS<Aliases, BreakpointKeys> | CSSNestedSelectors<Aliases, BreakpointKeys>;
|
|
31
|
+
export type CSSProps<Aliases, BreakpointKeys extends string> = GlobalCSS<Aliases, BreakpointKeys> | CSSPropsWithoutGlobal<Aliases, BreakpointKeys>;
|
|
32
|
+
export type AliasFn<Aliases> = (prop: string, value: string | number) => CSSValueWithoutBreakpoint<Aliases>;
|
|
33
|
+
export interface CSSOptionProps<Aliases, BreakpointKeys extends string> {
|
|
34
|
+
classPrefix?: string;
|
|
35
|
+
breakpoints?: {
|
|
36
|
+
[key in BreakpointKeys]: number;
|
|
37
|
+
};
|
|
38
|
+
aliases?: {
|
|
39
|
+
[key in keyof Aliases]: AliasFn<Aliases>;
|
|
40
|
+
};
|
|
41
|
+
injectStyle?: boolean;
|
|
42
|
+
skipProps?: (prop: string, value: string | number) => boolean;
|
|
43
|
+
getValue?: (value: string | number, prop: string, css: CSSProps<Aliases, BreakpointKeys>) => (string | number);
|
|
44
|
+
getProps?: (prop: string, value: string | number, css: CSSProps<Aliases, BreakpointKeys>) => CSSProps<Aliases, BreakpointKeys> | void;
|
|
45
|
+
}
|
|
46
|
+
export type CSSFactoryType = {
|
|
47
|
+
css: string;
|
|
48
|
+
cachekey: string;
|
|
49
|
+
classname: string;
|
|
50
|
+
cssraw: CSSProps<any, any>;
|
|
51
|
+
cache: boolean;
|
|
52
|
+
skiped: string[];
|
|
53
|
+
getStyleTag: () => HTMLStyleElement | null;
|
|
54
|
+
deleteStyle: () => void;
|
|
55
|
+
toString: () => string;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
package/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|