Skip to content

Add Open Props emitter (<host>-open-props.css) #106

Description

@Manavarya09

Add a new emitter that writes Open Props (https://open-props.style) CSS custom properties from the extracted DTCG tokens. Mirrors the existing emitters in src/formatters/.

Why

Open Props is a popular zero-runtime CSS variables library and a natural fit for designlang's output. Adding it means users can plug an extraction straight into an Open Props project without a manual translation step.

What to build

src/formatters/open-props.js exporting formatOpenProps(design) that returns a string of @layer blocks following the Open Props conventions:

@layer base {
  :root {
    --brand-1: <primary>;
    --brand-2: <secondary>;
    --size-1: <spacing[0]>;
    --size-2: <spacing[1]>;
    --font-sans: <typography.families[0]>;
    --radius-1: <radii[0]>;
    /* ...etc */
  }
}

Wire it up

  1. Add formatOpenProps to the extract command's emit loop in bin/design-extract.js (search for where formatTailwind is written).
  2. Add a corresponding entry to website/lib/build-files.js so the web extractor includes it too.
  3. Add a unit test in tests/formatters.test.js (use the existing mockDesign fixture; assert the output contains --brand-1 and a known value).

Acceptance

  • Running npx designlang stripe.com writes stripe-com-open-props.css alongside the other outputs.
  • Running node --test tests/formatters.test.js passes including the new test.
  • README is unchanged (we add to features list later in batch).

Scope

~60 lines of code plus a test. The closest reference implementation is src/formatters/css-vars.js.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomersjavascriptPull requests that update javascript codetransformExtends the remix/transformation axis

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions