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

FontWeightProperty doesn't accept arbitrary strings #2318

Open
hasparus opened this issue Sep 12, 2022 Discussed in #2317 · 1 comment
Open

FontWeightProperty doesn't accept arbitrary strings #2318

hasparus opened this issue Sep 12, 2022 Discussed in #2317 · 1 comment
Labels
bug Something isn't working types

Comments

@hasparus
Copy link
Member

Currently, we're just exposing the types from csstype. We should expose our own layer of types instead and allow string & {} in fontWeights.

Discussed in #2317

Originally posted by joriswitteman September 12, 2022
Hi, we're looking to use CSS variables as values for Theme.fontWeights, but the typings don't allow for this. Could this be changed?

  fontWeights: {
    // See global-styles for font weight variables
    thin: 'var(--font-weight-thin-200)',
    light: 'var(--font-weight-light-300)',
    body: 'var(--font-weight-regular-400)',
    regular: 'var(--font-weight-regular-400)',
    book: 'var(--font-weight-book-450)',
    medium: 'var(--font-weight-medium-500)',
    semiBold: 'var(--font-weight-semiBold-600)',
    bold: 'var(--font-weight-bold-700)',
    extraBold: 'var(--font-weight-extraBold-800)',
    black: 'var(--font-weight-black-900)',
    extraBlack: 'var(--font-weight-extraBlack-950)',
  },

The reason we want to do this is so that both the font weight name, and the numeral weight, can be seen when inspecting elements, for QA purposes. Like so:

image

The type error I get is:

Type '"var(--font-weight-book-450)"' is not assignable to type 'FontWeightProperty'. ts(2322)

I think I should be allowed to set an arbitrary string here, so that I can use CSS variables.

@hasparus hasparus added the bug Something isn't working label Sep 12, 2022
@joriswitteman
Copy link

An issue for exactly this exists at csstype also but is not planned until v3.1.0:
frenic/csstype#126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types
Projects
None yet
Development

No branches or pull requests

3 participants