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

Storybook / Demo page SD example for documenting tokens #477

Open
kellettemma opened this issue Oct 16, 2020 · 10 comments
Open

Storybook / Demo page SD example for documenting tokens #477

kellettemma opened this issue Oct 16, 2020 · 10 comments

Comments

@kellettemma
Copy link

Hi,

Is there a way to generate a style guide listing all the tokens and how they look? e.g.

https://raw.githubusercontent.com/salesforce-ux/theo/master/assets/doc_example.png

Thanks,
Emma

@dbanksdesign
Copy link
Member

Looks like we used to have one a while ago, but when we transitioned from 'templates' to 'formats' we didn't include it. You can take a look at the template here: https://github.com/amzn/style-dictionary/blob/main/lib/common/templates/static-style-guide/index.html.template

You can use that template in a custom format like this:

const fs = require('fs');
const styleDictionary = require('style-dictionary').extend('config.json');
const _ = require('lodash');

const template = _.template( fs.readFileSync('templates/myFormat.template') );

styleDictionary.registerFormat({
  name: 'my/format',
  formatter: template
});

where templates/myFormat.template is the path to that template. I haven't tested this so I'm not sure of exactly what it would look like, but hopefully it is a start.

@chazzmoney
Copy link
Collaborator

Also, if anyone wants to provide/update a generic style guide generator, we would be love to merge that in to the codebase

@chazzmoney
Copy link
Collaborator

@didoo @elliotdickison @davixyz @tonyjwalt @7studio @jreichenberg

Quick question for some of our biggest contributors:

Do you have a favorite example style guide that you would love to see included in SD as a template?

Bonus points for any of the following:

  1. Beautiful
  2. Open source
  3. Includes tools for navigating the guide
  4. Easily templatable
  5. Any other "value add" for a style guide

Thanks so much for your thoughts...

@nhoizey
Copy link
Contributor

nhoizey commented Jan 26, 2021

Hi, I'm not (yet?) one of your biggest contributors, but I was planning to work this week on a template to generate Storybook stories for my tokens.

I'm currently using storybook-design-token to show Design Tokens based on the Sass files generated with Style Dictionary, but it currently shows tokens in a panel in each component, not in their own space.

I plan to generate MDX stories with code like that:

<ColorPalette>
  <ColorItem
    title="theme.color.greyscale"
    subtitle="Some of the greys"
    colors={['#FFFFFF', '#F8F8F8', '#F3F3F3']}
  />
</ColorPalette>

ColorPalette comes from https://github.com/storybookjs/storybook/blob/6.0-docs/lib/components/src/blocks/ColorPalette.stories.tsx

@nhoizey
Copy link
Contributor

nhoizey commented Jan 26, 2021

Here's how this simple example look like:

image

@elliotdickison
Copy link

+1 to something like a storybook plugin. Maybe not the most beautiful thing ever but capitalizing on a really popular tool like that would be a great start.

@chazzmoney
Copy link
Collaborator

@nhoizey how is your template going? I would love to see what you've built!

@nhoizey
Copy link
Contributor

nhoizey commented Mar 11, 2021

@chazzmoney I just shared something in a related Storybook issue:
storybookjs/storybook#7671 (comment)

@cssinate
Copy link
Contributor

Something I would want/need to see here is somehow including some metadata... Using CTI, I often have color-background-inverse (like a dark background on a light theme) and then color-foreground-inverse (the foreground color for the inverse background). The tool would need to know that I want this foreground color to have that background color when it's displayed.

@jorenbroekema jorenbroekema changed the title Style guide? Storybook / Demo page SD example for documenting tokens Dec 10, 2024
@jorenbroekema
Copy link
Collaborator

#1353 is related but does not cover this issue entirely, changing this issue to "enhancement", I definitely think a storybook example would be great. Style Dictionary definitely could output tokens to CSF stories files to get an overview of the tokens.

PRs welcome for adding it, see #1344 as a good example

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

No branches or pull requests

7 participants