Skip to content

Use string literals for alignX/alignY instead of magic numbers #3

Description

@cowboyd

Currently alignX and alignY take raw numbers that map to Clay's internal enum:

// alignX: LEFT=0, RIGHT=1, CENTER=2
// alignY: TOP=0, BOTTOM=1, CENTER=2
alignX: 2, alignY: 1  // what does this mean?

Change the type from number to string literal unions:

alignX?: "left" | "center" | "right";
alignY?: "top" | "center" | "bottom";

The conversion to 0/1/2 happens in pack(). Callers get readable code with zero helpers:

alignX: "center", alignY: "bottom"

V8 interns these short strings so there's no performance cost vs integers.

Files to change

  • ops.ts — update OpenElement interface and pack() function
  • validate.ts — update schema from u8 to string enum

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions