2024-04-28 22:21:18 -04:00
|
|
|
|
|
|
|
const typeface = {
|
|
|
|
sans: "sans serif",
|
|
|
|
serif: "Times New Roman"
|
|
|
|
};
|
|
|
|
const sizes = {
|
|
|
|
small: "1rem",
|
|
|
|
large: "3rem"
|
|
|
|
};
|
|
|
|
const colors = {
|
|
|
|
red: "#ff2200",
|
|
|
|
blue: "#0022ff"
|
|
|
|
};
|
|
|
|
|
2024-05-11 23:33:50 -04:00
|
|
|
const styles = new Map<string, string>()
|
|
|
|
function Mapper<T extends Record<string, string>>(className:string, property:string, lut:T)
|
2024-04-28 22:21:18 -04:00
|
|
|
{
|
|
|
|
return new Proxy(lut, {get(target, prop){
|
2024-05-11 23:33:50 -04:00
|
|
|
const selector = `${className}-${prop as string}${activeQuery?"_"+activeQuery:""}`;
|
|
|
|
const check = styles.get(selector);
|
|
|
|
if(!check)
|
|
|
|
{
|
|
|
|
const body = `{ ${property}:${lut[prop as string]}; }`;
|
|
|
|
styles.set(selector, activeQuery ? `{ @media(${activeQuery})${body}}` : body);
|
|
|
|
}
|
|
|
|
return selector;
|
2024-04-28 22:21:18 -04:00
|
|
|
}});
|
|
|
|
}
|
2024-05-11 23:33:50 -04:00
|
|
|
|
|
|
|
let activeQuery:false|string = false
|
|
|
|
function Query(amount:string)
|
2024-04-28 22:21:18 -04:00
|
|
|
{
|
2024-05-11 23:33:50 -04:00
|
|
|
activeQuery = amount;
|
|
|
|
return (...args:string[])=> {
|
|
|
|
activeQuery = false;
|
|
|
|
return args.join(" ");
|
2024-04-28 22:21:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function config<T>(obj:T)
|
|
|
|
{
|
|
|
|
const CSS = {
|
2024-05-11 23:33:50 -04:00
|
|
|
Sheet()
|
|
|
|
{
|
|
|
|
const rules = []
|
|
|
|
for(const [key, value] of styles.entries())
|
|
|
|
{
|
|
|
|
rules.push(key+value);
|
|
|
|
}
|
|
|
|
return rules.join("\n");
|
|
|
|
},
|
2024-04-28 22:21:18 -04:00
|
|
|
get MD()
|
|
|
|
{
|
2024-05-11 23:33:50 -04:00
|
|
|
return Query("768px");
|
2024-04-28 22:21:18 -04:00
|
|
|
},
|
2024-05-11 23:33:50 -04:00
|
|
|
Face: Mapper("Face", "font-family", {...typeface, ...obj}),
|
|
|
|
Pad: Mapper("P", "padding", sizes)
|
2024-04-28 22:21:18 -04:00
|
|
|
};
|
|
|
|
return CSS;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default config({});
|