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 size_as_rem() to BaseTypographyOptionsSize #41

Open
gadenbuie opened this issue Oct 24, 2024 · 1 comment
Open

Add size_as_rem() to BaseTypographyOptionsSize #41

gadenbuie opened this issue Oct 24, 2024 · 1 comment

Comments

@gadenbuie
Copy link
Collaborator

Often useful in particular for typography.base.size.

@gadenbuie
Copy link
Collaborator Author

In Python, I implemented this in e59ea9d. I was able to use pydantic's serialization context feature, which is where users can provide serialization options to the context argument of .model_dump().

from brand_yml import Brand

brand = Brand.from_yaml_str(
    f"""
    typography:
      base:
        size: 18px
    """
)

brand.typography.model_dump(
  exclude_none = True,
  context={"typography_base_size_unit": "rem"}
)
#> {'fonts': [], 'base': {'size': '1.125rem'}}

(From the example in the docs.)

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

1 participant