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

Add documentation for the type prop in token files #176

Open
JasonNutmeg opened this issue Feb 18, 2019 · 4 comments
Open

Add documentation for the type prop in token files #176

JasonNutmeg opened this issue Feb 18, 2019 · 4 comments

Comments

@JasonNutmeg
Copy link

The readme shows the usage of the type prop in the token files but doesn't describe what the prop is used for or what values are available for it.

It would be great to add that to the readme.

@NoWorries
Copy link

I believe that the basic values are below, these are then used with value transforms:

  • Size
  • Number
  • Color
  • String

You can extend it with custom types/transforms, example of size transform below:

module.exports = theo => {
  theo.registerValueTransform(
    'addpx',
    prop => prop.get('type') === 'size',
    prop => prop.get('value') + 'px'
  );
  theo.registerTransform("web", ['addpx']);
}

@JasonNutmeg
Copy link
Author

Thanks @NoWorries !
Would be useful to have that information in the official documentation as well 🙂

@CH-RhyMoore
Copy link
Contributor

CH-RhyMoore commented Jul 9, 2019

The mental list I've been keeping is size, number, color, string, and property.

There's a big difference between string and property in some output formats--presence or absence of outer quotes.

I don't think this covers all of the formats that support them, but the ones I remember off the top of my head that were important were in CSS Modules.

I can have a token that's usable in composes like below if it's a property, while a string won't work:

@values * as componentTokens from 'component-tokens.cssmodules.css';

.my-selector {
  composes: componentTokens.typography-style;
}

Similarly, for breakpoints, string results in a malformed media query, while property doesn't...

@values phone, tablet, desktop from 'breakpoint-tokens.cssmodules.css';

@media phone, tablet {
  /* styles */
}

@frebro
Copy link

frebro commented Jan 15, 2020

Stumbling on this a year later. Are there any docs on what values are available for the type prop? Unsure where to look.

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

4 participants