Skip to content

Commit

Permalink
refactor(meta-css): update spec format (key & variations)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 29, 2023
1 parent cc97b95 commit f7f2d09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions packages/meta-css/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ export interface SpecInfo {

export interface Spec {
name: string;
key?: "v" | "i" | "i1";
key?: "v" | "i" | "i+1";
props: string | IObjectOf<NumOrString>;
values: IObjectOf<NumOrString> | string[] | number[] | string;
unit?: string;
var?: string[];
vars?: string[];
user?: any;
}

export type Index = "i" | "i1" | "v";

export const ARG_SPECS = {
specs: string({
alias: "s",
Expand Down
4 changes: 2 additions & 2 deletions packages/meta-css/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const expandSpec = (
defs: IObjectOf<any>,
logger: ILogger
) => {
const variationIDs = isArray(spec.var) ? spec.var : [""];
const variationIDs = isArray(spec.vars) ? spec.vars : [""];
const props = isString(spec.props) ? { [spec.props]: "<v>" } : spec.props!;
const values = __items(spec, config);
const ownNames = new Set<string>();
Expand Down Expand Up @@ -198,7 +198,7 @@ const __items = (spec: Spec, config: Pick<GeneratorConfig, "tables">) => {
const keyFn: Fn2<any, number, string> =
spec.key === "v"
? (v) => String(v)
: spec.key === "i1"
: spec.key === "i+1"
? (_, i) => String(i + 1)
: spec.key === undefined
? (_, i) => String(i)
Expand Down

0 comments on commit f7f2d09

Please sign in to comment.