Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@ def load_palette_json() -> dict[str, Any]:
return cast(dict[str, Any], json.load(f))


def make_color(fields: dict[str, Any]) -> Color:
def make_color(identifier: str, fields: dict[str, Any]) -> Color:
"""Create a Color instance from a set of fields."""
return Color(
name=fields["name"],
identifier=identifier,
accent=fields["accent"],
order=fields["order"],
hex=fields["hex"],
rgb=RGB(**fields["rgb"]),
hsl=HSL(**fields["hsl"]),
accent=fields["accent"],
)


def make_flavor(fields: dict[str, Any]) -> Flavor:
def make_flavor(identifier: str, fields: dict[str, Any]) -> Flavor:
"""Create a Flavor instance from a set of fields."""
return Flavor(
name=fields["name"],
identifier=identifier,
order=fields["order"],
dark=fields["dark"],
colors=FlavorColors(
**{
color_name: make_color(color_data)
for color_name, color_data in fields["colors"].items()
identifier: make_color(identifier, fields)
for identifier, fields in fields["colors"].items()
}
),
)
Expand All @@ -48,7 +50,10 @@ def codegen() -> str:
"""Generate contents of `catppuccin/palette.py`."""
palette_json = load_palette_json()
palette = Palette(
*[make_flavor(flavor_data) for flavor_data in palette_json.values()]
*[
make_flavor(identifier, fields)
for identifier, fields in palette_json.items()
]
)

lines = [
Expand Down
2 changes: 0 additions & 2 deletions catppuccin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""🐍 Soothing pastel theme for Python."""


from catppuccin.palette import PALETTE

__all__ = ["PALETTE"]
4 changes: 3 additions & 1 deletion catppuccin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class Color:
"""A single color in the Catppuccin palette."""

name: str
identifier: str
accent: bool
order: int
hex: str
rgb: RGB
hsl: HSL
accent: bool


@dataclass(frozen=True)
Expand Down Expand Up @@ -105,6 +106,7 @@ class Flavor:
"""

name: str
identifier: str
order: int
dark: bool
colors: FlavorColors
Expand Down
Loading