Skip to content

Commit

Permalink
feat(whiskers): support emoji and order properties (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter authored May 24, 2024
1 parent 37217cc commit 365b2f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions whiskers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ These types are designed to closely match the [palette.json](https://github.com/
| - | - | - | - |
| `name` | `String` | The name of the flavor. | `"Latte"`, `"Frappé"`, `"Macchiato"`, `"Mocha"` |
| `identifier` | `String` | The identifier of the flavor. | `"latte"`, `"frappe"`, `"macchiato"`, `"mocha"` |
| `emoji` | `char` | Emoji associated with the flavor. | `'🌻'`, `'🪴'`, `'🌺'`, `'🌿'` |
| `order` | `u32` | Order of the flavor in the palette spec. | `0` to `3` |
| `dark` | `bool` | Whether the flavor is dark. | `false` for Latte, `true` for others |
| `light` | `bool` | Whether the flavor is light. | `true` for Latte, `false` for others |
| `colors` | `Map<String, Color>` | A map of color identifiers to their respective values. | |
Expand All @@ -134,6 +136,7 @@ These types are designed to closely match the [palette.json](https://github.com/
| - | - | - | - |
| `name` | `String` | The name of the color. | `"Rosewater"`, `"Surface 0"`, `"Base"` |
| `identifier` | `String` | The identifier of the color. | `"rosewater"`, `"surface0"`, `"base"` |
| `order` | `u32` | Order of the color in the palette spec. | `0` to `25` |
| `accent` | `bool` | Whether the color is an accent color. | |
| `hex` | `String` | The color in hexadecimal format. | `"1e1e2e"` |
| `rgb` | `RGB` | The color in RGB format. | |
Expand Down
9 changes: 9 additions & 0 deletions whiskers/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub struct Palette {
pub struct Flavor {
pub name: String,
pub identifier: String,
pub emoji: char,
pub order: u32,
pub dark: bool,
pub light: bool,
pub colors: IndexMap<String, Color>,
Expand All @@ -23,6 +25,7 @@ pub struct Flavor {
pub struct Color {
pub name: String,
pub identifier: String,
pub order: u32,
pub accent: bool,
pub hex: String,
pub rgb: RGB,
Expand Down Expand Up @@ -82,6 +85,7 @@ fn color_from_hex(
Ok(Color {
name: blueprint.name.to_string(),
identifier: blueprint.name.identifier().to_string(),
order: blueprint.order,
accent: blueprint.accent,
hex,
rgb,
Expand All @@ -103,6 +107,7 @@ fn color_from_catppuccin(
Color {
name: color.name.to_string(),
identifier: color.name.identifier().to_string(),
order: color.order,
accent: color.accent,
hex,
rgb: RGB {
Expand Down Expand Up @@ -167,6 +172,8 @@ pub fn build_palette(
Flavor {
name: flavor.name.to_string(),
identifier: flavor.name.identifier().to_string(),
emoji: flavor.emoji,
order: flavor.order,
dark: flavor.dark,
light: !flavor.dark,
colors,
Expand Down Expand Up @@ -233,6 +240,7 @@ impl Color {
Self {
name: blueprint.name.clone(),
identifier: blueprint.identifier.clone(),
order: blueprint.order,
accent: blueprint.accent,
hex: rgb_to_hex(&rgb, opacity),
rgb,
Expand All @@ -257,6 +265,7 @@ impl Color {
Self {
name: blueprint.name.clone(),
identifier: blueprint.identifier.clone(),
order: blueprint.order,
accent: blueprint.accent,
hex: rgb_to_hex(&rgb, opacity),
rgb,
Expand Down

0 comments on commit 365b2f6

Please sign in to comment.