Skip to content

Commit 465e326

Browse files
authored
feat: add identifier field to Color and Flavor (#32)
1 parent 411e2df commit 465e326

File tree

5 files changed

+229
-113
lines changed

5 files changed

+229
-113
lines changed

build.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,30 @@ def load_palette_json() -> dict[str, Any]:
1717
return cast(dict[str, Any], json.load(f))
1818

1919

20-
def make_color(fields: dict[str, Any]) -> Color:
20+
def make_color(identifier: str, fields: dict[str, Any]) -> Color:
2121
"""Create a Color instance from a set of fields."""
2222
return Color(
2323
name=fields["name"],
24+
identifier=identifier,
25+
accent=fields["accent"],
2426
order=fields["order"],
2527
hex=fields["hex"],
2628
rgb=RGB(**fields["rgb"]),
2729
hsl=HSL(**fields["hsl"]),
28-
accent=fields["accent"],
2930
)
3031

3132

32-
def make_flavor(fields: dict[str, Any]) -> Flavor:
33+
def make_flavor(identifier: str, fields: dict[str, Any]) -> Flavor:
3334
"""Create a Flavor instance from a set of fields."""
3435
return Flavor(
3536
name=fields["name"],
37+
identifier=identifier,
3638
order=fields["order"],
3739
dark=fields["dark"],
3840
colors=FlavorColors(
3941
**{
40-
color_name: make_color(color_data)
41-
for color_name, color_data in fields["colors"].items()
42+
identifier: make_color(identifier, fields)
43+
for identifier, fields in fields["colors"].items()
4244
}
4345
),
4446
)
@@ -48,7 +50,10 @@ def codegen() -> str:
4850
"""Generate contents of `catppuccin/palette.py`."""
4951
palette_json = load_palette_json()
5052
palette = Palette(
51-
*[make_flavor(flavor_data) for flavor_data in palette_json.values()]
53+
*[
54+
make_flavor(identifier, fields)
55+
for identifier, fields in palette_json.items()
56+
]
5257
)
5358

5459
lines = [

catppuccin/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""🐍 Soothing pastel theme for Python."""
2-
3-
42
from catppuccin.palette import PALETTE
53

64
__all__ = ["PALETTE"]

catppuccin/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ class Color:
2626
"""A single color in the Catppuccin palette."""
2727

2828
name: str
29+
identifier: str
30+
accent: bool
2931
order: int
3032
hex: str
3133
rgb: RGB
3234
hsl: HSL
33-
accent: bool
3435

3536

3637
@dataclass(frozen=True)
@@ -105,6 +106,7 @@ class Flavor:
105106
"""
106107

107108
name: str
109+
identifier: str
108110
order: int
109111
dark: bool
110112
colors: FlavorColors

0 commit comments

Comments
 (0)