Giter VIP home page Giter VIP logo

Comments (5)

Sqrrl avatar Sqrrl commented on May 27, 2024 1

The Design Tokens tab in the addon panel isn't aware of which tokens the currently open component uses. It will always show all tokens. Currently there is no way to filter tokens by component usage.

from storybook-design-token.

Sqrrl avatar Sqrrl commented on May 27, 2024

Yes. You should be able to specify the parsed files via https://github.com/UX-and-I/storybook-design-token/tree/v3?tab=readme-ov-file#specify-a-custom-glob-for-your-token-files.

from storybook-design-token.

fglendrange avatar fglendrange commented on May 27, 2024

Thank you, @Sqrrl - That sounds promising! I am a bit uncertain as to how I am supposed to do this? Should I mark my component-based CSS classes in a distinct way and have the parser only look for those files? And it would thus exclude any design-tokens in the global files in each story. Or am I misunderstanding something here?

from storybook-design-token.

Sqrrl avatar Sqrrl commented on May 27, 2024

Assuming you have separate files containing your tokens (colors.css, spacings.css, …), I would define a blob pattern that only matches these token files. You could name all your token files *.tokens.css for example, and use a glob pattern like **/*.tokens.{css,scss,less,svg}. Or you could use the glob pattern to "whitelist" only specific file names (e.g. **/{colors,spacings}.css).

from storybook-design-token.

fglendrange avatar fglendrange commented on May 27, 2024

I apologize for my slow-ness here - I still am not sure I have understood this correctly.

Given this "global" Colors.tokens.css file:

:root {
    /**
    * @tokens Colors
    * @presenter Color
    */
    --color-button-primary: #1ea7fd;
    --color-button-primary-hover: #1b7ec2;
    --color-button-primary-active: #116699;
    --color-button-primary-disabled: #a0dfff;
    --color-button-secondary: #e9ecef;
    --color-button-secondary-hover: #e2e6ea;
    --color-button-secondary-active: #d4d8db;
    --color-button-secondary-disabled: #f1f3f5;
}

And a Button.css file like this:

.storybook-button--primary {
  background-color: var(--color-button-primary);
}
.storybook-button--primary:hover {
  background-color: var(--color-button-primary-hover);
}
.storybook-button--primary:active {
  background-color: var(--color-button-primary-active);
}
.storybook-button--primary:disabled {
  background-color: var(--color-button-primary-disabled);
}

I would assume that the color tokens for --color-button-secondary* to not be shown in the tab in the button story as it is not utilized in this component? Am I mistaken?

Skjermbilde 2023-12-20 kl  14 12 19

from storybook-design-token.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.