Skip to content

Commit

Permalink
feat(meta-css): switch generated framework output to JSON, simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 15, 2023
1 parent f126005 commit 8850cae
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 265 deletions.
79 changes: 27 additions & 52 deletions packages/meta-css/specs/base-specs.json
@@ -1,4 +1,8 @@
{
"info": {
"name": "MetaCSS base specs",
"version": "0.0.1"
},
"media": {
"ns": { "min-width": "30rem" },
"m": { "min-width": "30rem", "max-width": "60rem" },
Expand Down Expand Up @@ -148,53 +152,44 @@
"index": "v",
"prop": "display",
"items": "display",
"unit": "display",
"file": "display.ts",
"responsive": true
"unit": "display"
},
{
"comment": "abs widths",
"prefix": "w",
"index": "i1",
"prop": "width",
"items": "sizes-abs",
"file": "size.ts",
"responsive": true
"items": "sizes-abs"
},
{
"comment": "relative widths",
"prefix": "w",
"index": "v",
"prop": "width",
"items": "sizes-rel",
"unit": "%",
"file": "size.ts",
"responsive": true
"unit": "%"
},
{
"comment": "abs heights",
"prefix": "h",
"index": "i1",
"prop": "height",
"items": "sizes-abs",
"file": "size.ts"
"items": "sizes-abs"
},
{
"comment": "relative heights",
"prefix": "h",
"index": "v",
"prop": "height",
"items": "sizes-rel",
"unit": "%",
"file": "size.ts"
"unit": "%"
},
{
"comment": "paddings",
"prefix": "p",
"index": "i",
"prop": "padding",
"items": "margins",
"file": "margin.ts",
"var": "all"
},
{
Expand All @@ -203,16 +198,14 @@
"index": "i",
"prop": "margin",
"items": "margins",
"file": "margin.ts",
"var": "all"
},
{
"comment": "border radius",
"prefix": "br",
"index": "i",
"prop": "border-radius",
"items": "borders-r",
"file": "border.ts"
"items": "borders-r"
},
{
"prefix": "br*",
Expand All @@ -222,7 +215,6 @@
"border-bottom*-radius": "*"
},
"items": "borders-r",
"file": "border.ts",
"var": "h"
},
{
Expand All @@ -233,7 +225,6 @@
"border*-right-radius": "*"
},
"items": "borders-r",
"file": "border.ts",
"var": "v"
},
{
Expand All @@ -245,90 +236,79 @@
"border*-width": "*"
},
"items": "borders-w",
"file": "border.ts",
"var": "atrbl"
},
{
"comment": "border colors",
"prefix": "border-",
"prefix": "b--",
"index": "v",
"prop": "border-color",
"items": "var-palette",
"unit": "var-palette",
"file": "border.ts"
"unit": "var-palette"
},
{
"prefix": "border-",
"prefix": "b--",
"index": "v",
"prop": "border-color",
"items": "palette",
"unit": "palette",
"file": "border.ts"
"unit": "palette"
},
{
"prefix": "border-",
"prefix": "b--",
"index": "v",
"prop": "border-color",
"items": "grays",
"unit": "grays",
"file": "border.ts"
"unit": "grays"
},
{
"comment": "text colors",
"prefix": "",
"index": "v",
"prop": "color",
"items": "var-palette",
"unit": "var-palette",
"file": "palette.ts"
"unit": "var-palette"
},
{
"prefix": "",
"index": "v",
"prop": "color",
"items": "palette",
"unit": "palette",
"file": "palette.ts"
"unit": "palette"
},
{
"prefix": "",
"index": "v",
"prop": "color",
"items": "grays",
"unit": "grays",
"file": "palette.ts"
"unit": "grays"
},
{
"comment": "background colors",
"prefix": "bg-",
"index": "v",
"prop": "background-color",
"items": "var-palette",
"unit": "var-palette",
"file": "palette.ts"
"unit": "var-palette"
},
{
"prefix": "bg-",
"index": "v",
"prop": "background-color",
"items": "palette",
"unit": "palette",
"file": "palette.ts"
"unit": "palette"
},
{
"prefix": "bg-",
"index": "v",
"prop": "background-color",
"items": "grays",
"unit": "grays",
"file": "palette.ts"
"unit": "grays"
},
{
"prefix": "o",
"index": "v",
"prop": "opacity",
"items": "tens",
"file": "palette.ts",
"unit": "norm",
"comment": "opacities"
},
Expand All @@ -338,42 +318,37 @@
"index": "i1",
"def": { "transition": "*s background-color ease-in-out" },
"items": [0.1, 0.2, 0.5],
"unit": null,
"file": "background.ts"
"unit": null
},
{
"prefix": "cursor-",
"index": "v",
"prop": "cursor",
"items": "cursors",
"unit": "cursors",
"file": "cursor.ts"
"unit": "cursors"
},
{
"comment": "grid column layout",
"prefix": "gc",
"index": "v",
"prop": "grid-template-columns",
"items": "cols-rows",
"unit": "cols-rows",
"file": "grid.ts"
"unit": "cols-rows"
},
{
"comment": "grid row layout",
"prefix": "gr",
"index": "v",
"prop": "grid-template-rows",
"items": "cols-rows",
"unit": "cols-rows",
"file": "grid.ts"
"unit": "cols-rows"
},
{
"comment": "grid gaps",
"prefix": "gap",
"index": "i",
"prop": "gap",
"items": "borders-w",
"file": "grid.ts"
"items": "borders-w"
}
]
}
34 changes: 33 additions & 1 deletion packages/meta-css/src/api.ts
@@ -1,12 +1,44 @@
import type { IObjectOf } from "@thi.ng/api";
import type { CommandCtx } from "@thi.ng/args";
import type { FormatPresets } from "@thi.ng/text-format";

export interface CommonOpts {
out: string;
out?: string;
verbose: boolean;
}

export interface AppCtx<T extends CommonOpts>
extends CommandCtx<T, CommonOpts> {
format: FormatPresets;
}

export interface CompiledSpecs {
defs: IObjectOf<any>;
media: IObjectOf<any>;
info: SpecInfo;
}

export interface GeneratorConfig {
info: SpecInfo;
media: IObjectOf<string>;
indexed: IObjectOf<any>;
specs: Spec[];
}

export interface SpecInfo {
name: string;
version: string;
}

export interface Spec {
prefix: string;
prop: string | string[];
def?: Record<string, string>;
items: string | any[];
index?: Index;
unit?: string | null;
comment?: string;
var?: string | string[];
}

export type Index = "i" | "i1" | "v";
3 changes: 1 addition & 2 deletions packages/meta-css/src/cli.ts
Expand Up @@ -16,8 +16,7 @@ cliApp<CommonOpts, AppCtx<any>>({
opts: {
out: string({
alias: "o",
default: "",
desc: "Output dir (or stdout)",
desc: "Output file (or stdout)",
}),
verbose: flag({
alias: "v",
Expand Down

0 comments on commit 8850cae

Please sign in to comment.