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

Create aliases for colors #207

Open
Noodlez1232 opened this issue Jan 1, 2024 · 3 comments · May be fixed by #270
Open

Create aliases for colors #207

Noodlez1232 opened this issue Jan 1, 2024 · 3 comments · May be fixed by #270
Labels
feature A new feature or a feature request

Comments

@Noodlez1232
Copy link
Contributor

In the style guide there's some guidelines for what colors to use for what. I think it'd be pretty useful to add aliases for these uses under stylix.colors.general.{colorAlias} stylix.colors.notifications.{colorAlias} and so on.

With this, we might be able to have modules that look like this (using the bemenu module because it's nice and simple)

# KEY
with config.lib.stylix.colors.withHashtag;
with config.lib.stylix.colors.withHashtag.general;
  config = lib.mkMerge [
    (lib.mkIf config.stylix.targets.bemenu.enable {
      programs.bemenu.settings = with config.stylix.targets.bemenu; {
        tb = "${defaultBackground}${bemenuOpacity}"; # Title bg
        nb = "${defaultBackground}${bemenuOpacity}"; # Normal bg
        fb = "${defaultBackground}${bemenuOpacity}"; # Filter bg
        hb = "${selectionBackground}${bemenuOpacity}"; # Highlighted bg
        sb = "${selectionBackground}${bemenuOpacity}"; # Selected bg
        scb = "${defaultBackground}"; # Scrollbar bg

        hf = "${warning}"; # Highlighted fg
        sf = "${defaultText}"; # Selected fg
        tf = "${defaultText}"; # Title fg
        ff = "${defaultText}"; # Filter fg
        nf = "${defaultText}"; # Normal fg
        scf = "${selectionBackground}"; # Scrollbar fg

        ab = "${if alternate then alternateBackground else defaultBackground}"; # Alternate bg
        af = "${if alternate then alternateText else defaultText}"; # Alternate fg

        # Font name
        fn = "${sansSerif.name} ${lib.optionalString (fontSize != null) (builtins.toString fontSize)}";
      };
    })
  ];

It's much easier to read what's going on, and could make styling much easier to unify, since you could just use the color names instead of having to go through the documentation.

@danth
Copy link
Owner

danth commented Jan 3, 2024

This looks very nice, and it's something I've been considering for a while.

It might be useful for implementing #205 since that will introduce new named colors which lie outside of the main palette.

It also opens up the possibility of supporting non-base16 color schemes in the future.

Internally, palettes are handled by base16.nix so any modifications would need to go through there, or more likely we would replace it with our own library since this is such a large change.

@Noodlez1232
Copy link
Contributor Author

That's true, which might mean a break from any other base16.nix compatible extensions that stylix uses.
I kinda wonder if we could store these somewhere else, then.
For example store it in lib.stylix.colorAliases for now until we can get some sort of other solution worked out

@danth
Copy link
Owner

danth commented Jan 9, 2024

Note that that would take away the ability to use the colors in mustache templates, which may or may not be something we want to support. Theoretically the template files could just be converted to multiline strings within Nix, using ${...} in place of {{...}}.

@danth danth added the feature A new feature or a feature request label Jan 18, 2024
@RANKSHANK RANKSHANK linked a pull request Mar 2, 2024 that will close this issue
11 tasks
@danth danth linked a pull request Mar 4, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature or a feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants