Skip to content

Commit

Permalink
feat(scheme): add android_scheme keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
InioX committed Aug 15, 2023
1 parent d41bb3f commit 510b44b
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 264 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,33 @@ You can also get the image (if it was provided) by using:
@define-color inverseSurface @{inverse_surface.strip};
@define-color inverseOnSurface @{inverse_on_surface};
@define-color inversePrimary @{inverse_primary.strip};

@define-color source_color @{source_color};
@define-color color_accent_primary @{color_accent_primary};
@define-color color_accent_primary_variant @{color_accent_primary_variant};
@define-color color_accent_secondary @{color_accent_secondary};
@define-color color_accent_secondary_variant @{color_accent_secondary_variant};
@define-color color_accent_tertiary @{color_accent_tertiary};
@define-color color_accent_tertiary_variant @{color_accent_tertiary_variant};
@define-color text_color_primary @{text_color_primary};
@define-color text_color_secondary @{text_color_secondary};
@define-color text_color_tertiary @{text_color_tertiary};
@define-color text_color_primary_inverse @{text_color_primary_inverse};
@define-color text_color_secondary_inverse @{text_color_secondary_inverse};
@define-color text_color_tertiary_inverse @{text_color_tertiary_inverse};
@define-color color_background @{color_background};
@define-color color_background_floating @{color_background_floating};
@define-color color_surface @{color_surface};
@define-color color_surface_variant @{color_surface_variant};
@define-color color_surface_highlight @{color_surface_highlight};
@define-color surface_header @{surface_header};
@define-color under_surface @{under_surface};
@define-color off_state @{off_state};
@define-color accent_surface @{accent_surface};
@define-color text_primary_on_accent @{text_primary_on_accent};
@define-color text_secondary_on_accent @{text_secondary_on_accent};
@define-color volume_background @{volume_background};
@define-color scrim_android @{scrim_android};
```

## Configuration
Expand Down
193 changes: 0 additions & 193 deletions material-color-utilities-rs/src/scheme.rs

This file was deleted.

72 changes: 8 additions & 64 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::process::Command;
use color_eyre::{eyre::Result, eyre::WrapErr, Report};
use material_color_utilities_rs::{
palettes::core::{ColorPalette, CorePalette},
scheme::Scheme,
scheme::{scheme::Scheme, scheme_android::SchemeAndroid},
};

use clap::{Parser, ValueEnum};
Expand All @@ -27,6 +27,9 @@ pub struct Schemes {
pub light: Scheme,
pub dark: Scheme,
pub amoled: Scheme,
pub light_android: SchemeAndroid,
pub dark_android: SchemeAndroid,
pub amoled_android: SchemeAndroid,
}

#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
Expand All @@ -36,67 +39,6 @@ pub enum SchemesEnum {
Amoled,
}

const COLORS: [&str; 30] = [
"source_color",
"primary",
"on_primary",
"primary_container",
"on_primary_container",
"secondary",
"on_secondary",
"secondary_container",
"on_secondary_container",
"tertiary",
"on_tertiary",
"tertiary_container",
"on_tertiary_container",
"error",
"on_error",
"error_container",
"on_error_container",
"background",
"on_background",
"surface",
"on_surface",
"surface_variant",
"on_surface_variant",
"outline",
"outline_variant",
"shadow",
"scrim",
"inverse_surface",
"inverse_on_surface",
"inverse_primary",
];

const COLORS_ANDROID: [&str; 25] = [
"color_accent_primary",
"color_accent_primary_variant",
"color_accent_secondary",
"color_accent_secondary_variant",
"color_accent_tertiary",
"color_accent_tertiary_variant",
"text_color_primary",
"text_color_secondary",
"text_color_tertiary",
"text_color_primary_inverse",
"text_color_secondary_inverse",
"text_color_tertiary_inverse",
"color_background",
"color_background_floating",
"color_surface",
"color_surface_variant",
"color_surface_highlight",
"surface_header",
"under_surface",
"off_state",
"accent_surface",
"text_primary_on_accent",
"text_secondary_on_accent",
"volume_background",
"scrim",
];

fn main() -> Result<(), Report> {
color_eyre::install()?;
let args = Cli::parse();
Expand All @@ -115,12 +57,14 @@ fn main() -> Result<(), Report> {
light: Scheme::light_from_core_palette(&mut palette),
dark: Scheme::dark_from_core_palette(&mut palette),
amoled: Scheme::pure_dark_from_core_palette(&mut palette),
light_android: SchemeAndroid::light_from_core_palette(&mut palette),
dark_android: SchemeAndroid::dark_from_core_palette(&mut palette),
amoled_android: SchemeAndroid::pure_dark_from_core_palette(&mut palette),
};


if args.dry_run == Some(false) {
Template::generate(
&COLORS,
&schemes,
&config,
&args,
Expand All @@ -140,7 +84,7 @@ fn main() -> Result<(), Report> {
}

if args.show_colors == Some(true) {
show_color(&schemes, &COLORS, &source_color);
show_color(&schemes, &source_color);
}

Ok(())
Expand Down
Loading

0 comments on commit 510b44b

Please sign in to comment.