Storybook: Add ability to document typesets in different units

Created on 25 Oct 2019  Â·  6Comments  Â·  Source: storybookjs/storybook

Is your feature request related to a problem? Please describe.
We using rem units in our typography and would like to document it with addon-docs. Right now Typeset component accepts numbers in pixels to show those sizes. If we provide rem units, it works correctly, except for size itself - it shows rempx

Describe the solution you'd like
It would be great to accept not only numbers, but strings with units. Since it already works, it should take single isNaN check to determine if it should append px or leave as is. Also types should be changed.

Describe alternatives you've considered
We can make our own component for Typesets, if you not willing to accept this proposal

Are you able to assist bring the feature to reality?
yes, I can... I just need guidance on codebase and tests.

Additional context

This code:

<Typeset fontSizes={[16, '1rem']} />

Gives us this result:
image

And this is _almost_ desirable result

docs feature request good first issue help wanted

Most helpful comment

Yippee!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.30 containing PR #8574 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

All 6 comments

Why not just make it an array of strings?

Array of strings is good, but it will be breaking change, since there is explicit typings with numbers.

I see. It's an undocumented component anyway, so I think it's fine if we break the API. cc @domyen

Anyway, I'd like to make necessary changes if it's ok.

Absolutely, definitely open to a PR!

On Fri, Oct 25, 2019 at 12:45 PM Kirill Popolov notifications@github.com
wrote:

Anyway, I'd like to make necessary changes if it's ok.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/storybookjs/storybook/issues/8568?email_source=notifications&email_token=AACAJWICMF5SJPQG6W7EYKLQQMPCZA5CNFSM4JFAEPVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECI5CZI#issuecomment-546427237,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AACAJWKAJO3CKQZFYOBOFILQQMPCZANCNFSM4JFAEPVA
.

Yippee!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.30 containing PR #8574 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrOrz picture MrOrz  Â·  3Comments

ZigGreen picture ZigGreen  Â·  3Comments

sakulstra picture sakulstra  Â·  3Comments

dnlsandiego picture dnlsandiego  Â·  3Comments

Jonovono picture Jonovono  Â·  3Comments