Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to generate font/space values via function #6

Open
Zuzuesque opened this issue Jun 1, 2024 · 0 comments
Open

Possibility to generate font/space values via function #6

Zuzuesque opened this issue Jun 1, 2024 · 0 comments

Comments

@Zuzuesque
Copy link

I wondered if there are plans to include font/space variants of the utopia.clamp() function?

Unless you are familiar with the system (or consult the website), there is no easy way to tell whether a space scale with 4 positive steps will generate a --space-3xl property or not. It's not terrible, but it's a mental overhead over copying the values from the website and seeing what tokens are available at one glance.

What I would hope to do is declare variables on the plugin level (similar to min/max width) and then tell the function which step in the scale I want to output. E.g.

// postcss.config.js
module.exports = {
  plugins: {
    'postcss-utopia': {
      minWidth: 320,
      maxWidth: 1080,
      minFontSize: 16,
      maxFontSize: 18,
      minTypeScale: 1.2,
      maxTypeScale: 1.25,
    },
  },
}
// token.css
:root {
  --typography-sm: utopia.typography(-1);
  --typography-md: utopia.typography(0);
  --typography-lg: utopia.typography(1);
  --typography-xl: utopia.typography(2);
  ...
}

It may be a bit repetitive over having the plugin generate all the tokens, but it is also more declarative/less magic-y and makes it easier to reason about the tokens you have available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant