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

feat: brand_yaml Python package #12

Merged
merged 119 commits into from
Oct 4, 2024
Merged

feat: brand_yaml Python package #12

merged 119 commits into from
Oct 4, 2024

Conversation

gadenbuie
Copy link
Collaborator

@gadenbuie gadenbuie commented Aug 30, 2024

Demo

from brand_yaml import read_brand_yaml

posit = read_brand_yaml("examples/brand-posit.yml")
posit_json = posit.model_dump_json(exclude_none=True, indent=2)
print(posit_json)
{
  "meta": {
    "name": {
      "full": "Posit Software, PBC",
      "short": "Posit"
    },
    "link": {
      "home": "https://posit.co/",
      "mastodon": "https://fosstodon.org/@Posit",
      "linkedin": "https://www.linkedin.com/company/posit-software/",
      "twitter": "https://twitter.com/posit_pbc",
      "guide": "https://positpbc.atlassian.net/wiki/x/AQAgBQ"
    }
  },
  "logo": {
    "small": "posit-icon.png",
    "medium": "posit.png",
    "large": "posit.svg"
  },
  "color": {
    "with_": {
      "blue": "#447099",
      "orange": "#EE6331",
      "gray": "#404041",
      "white": "#FFFFFF",
      "teal": "#419599",
      "green": "#72994E",
      "burgundy": "#9A4665"
    },
    "foreground": "#151515",
    "background": "#FFFFFF",
    "primary": "#447099",
    "secondary": "#707073",
    "tertiary": "#C2C2C4",
    "success": "#72994E",
    "info": "#419599",
    "warning": "#EE6331",
    "danger": "#9A4665",
    "light": "#FFFFFF",
    "dark": "#404041"
  },
  "typography": {
    "fonts": [
      {
        "source": "google",
        "family": "Open Sans",
        "weight": [
          400.0,
          700.0
        ],
        "style": [
          "normal",
          "italic"
        ],
        "display": "auto"
      },
      {
        "source": "google",
        "family": "Fira Code",
        "weight": [
          400.0,
          700.0
        ],
        "style": [
          "normal",
          "italic"
        ],
        "display": "auto"
      },
      {
        "source": "google",
        "family": "Roboto Slab",
        "weight": 600.0,
        "style": "normal",
        "display": "block"
      }
    ],
    "base": {
      "family": "Open Sans",
      "line_height": 1.25,
      "size": "1rem"
    },
    "headings": {
      "family": "Roboto Slab",
      "weight": 600.0,
      "color": "primary"
    },
    "monospace": {
      "family": "Fira Code",
      "size": "0.9em"
    }
  }
}

The result is that you can post-hoc re-use `with` values.
This will make it possible to blend color.{named} and color.with,
plus other more complicated scenarios, without having to rewrite
the recursive definition resolution for those scenarios individually.
pyproject.toml Outdated Show resolved Hide resolved
* Fixes import and validation of font-weight ranges, e.g. "400..800"
* Fixes writing of font-family CSS
* Adds tests to assert expected behavior
@gadenbuie
Copy link
Collaborator Author

Thanks for the reviews @cpsievert! I'm going to merge this but feel free to ping me here or offline if you have any more comments.

@gadenbuie gadenbuie merged commit 1b1a7fb into main Oct 4, 2024
5 checks passed
@gadenbuie gadenbuie deleted the feat/python branch October 4, 2024 20:39
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

Successfully merging this pull request may close these issues.

2 participants