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

Color palettes #2035

Closed
uncenter opened this issue Dec 12, 2024 · 8 comments
Closed

Color palettes #2035

uncenter opened this issue Dec 12, 2024 · 8 comments
Labels
feature New feature request

Comments

@uncenter
Copy link
Contributor

uncenter commented Dec 12, 2024

Would like to revisit #200, but I can't comment on it to get it reopened so I'll just copy it here.

The default themes don't use hex codes, but rather colors like "red" and "lightyellow". It would make it a lot easier for people to make their own simple color palette themes, keeping the choice of blue for this component or whatever, but allowing them to use their own shades of that color.

[palette]
red = "#80AEFA"
green = "#CD9EFC"
white = "#FFA577"

https://starship.rs/ has this kind of thing, e.g. https://github.com/catppuccin/starship/blob/e99ba6b210c0739af2a18094024ca0bdf4bb3225/starship.toml#L23-L133. They support arbitrary color names too, which should ideally be the case here as well.

@uncenter uncenter added the feature New feature request label Dec 12, 2024
@sxyazi
Copy link
Owner

sxyazi commented Dec 15, 2024

What is its behavior under light and dark modes respectively? Specifically, can users use different color palettes for light and dark modes? If so, how can this be supported? If not, why?

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Dec 15, 2024
@uncenter
Copy link
Contributor Author

In the theme.toml light/dark could be supported by:

[palette.light]
red = "#80AEFA"
green = "#CD9EFC"
white = "#FFA577"

[palette.dark]
...

Or/in addition to that a palette could be used in flavor.toml (just the palette, nothing else) and then put under flavor.dark or flavor.light in the theme.toml like how flavors are used.

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Dec 15, 2024
@sxyazi
Copy link
Owner

sxyazi commented Feb 5, 2025

I probably won't support it. Recently, I experimented with creating a color scheme-agnostic color palette based on yazi-rs/flavors, aiming to abstract common colors, but the results weren't great.

Specifically, Yazi uses 16 abstract colors to cover the entire theme, but there are issues:

  • For themes with a small number of colors, like Solarized (16 colors) or Dracula (11 colors), they don't map one-to-one with Yazi's 16 colors. To achieve good contrast that fits Yazi's color palette, I'd have to "invent" some transitional colors that don't actually exist (this and this).
  • For themes with a large number of colors, like Tokyonight (33 colors) or Catppuccin (36 colors), it's hard to represent them properly within Yazi's 16-color limit, which prevents them from fully showcasing their unique characteristics, since there's structural differences in Tokyonight and Catppuccin.

Because of this, introducing a color palette may not be truly meaningful compared to the effort and complexity it would add. So unless I see strong, convincing evidence that justifies it 1, this is unlikely to happen.

Footnotes

  1. For example, a simple replacement script based on theme.toml that swaps red, blue, etc., with the hex colors of any given theme to see how well it actually works

@uncenter
Copy link
Contributor Author

uncenter commented Feb 5, 2025

I think you misunderstand. With the proposed color palettes theme feature, an arbitrary number of colors in the palette can be defined. There is no restriction to Yazi's 16 colors. I'd suggest looking again at the Starship palette configuration example I linked originally.

  • Catppuccin (36 colors)

26 for each flavor actually :)

@sxyazi
Copy link
Owner

sxyazi commented Feb 5, 2025

an arbitrary number of colors in the palette can be defined. There is no restriction to Yazi's 16 colors

Yazi's preset theme only uses ANSI colors (blue, red, etc.), if you define a custom color like mycolor, how do you expect Yazi to use it?

26 for each flavor actually :)

Indeed, not sure why I typed 36 :-/

@uncenter
Copy link
Contributor Author

uncenter commented Feb 5, 2025

Yazi's preset theme only uses ANSI colors (blue, red, etc.), if you define a custom color like mycolor, how do you expect Yazi to use it?

Again, read how Starship's palette system works. We would do basically the exact same thing here.

@uncenter
Copy link
Contributor Author

uncenter commented Feb 5, 2025

Specifically https://starship.rs/config/#example gives a good reference. Maybe something like this for Yazi:

palette = "catppuccin_mocha"

[manager]
cwd = { fg = "${mauve}" }

[palettes.catppuccin_mocha]
rosewater = "#f5e0dc"
flamingo = "#f2cdcd"
pink = "#f5c2e7"
mauve = "#cba6f7"
red = "#f38ba8"
maroon = "#eba0ac"
peach = "#fab387"
yellow = "#f9e2af"
green = "#a6e3a1"
teal = "#94e2d5"
sky = "#89dceb"
sapphire = "#74c7ec"
blue = "#89b4fa"
lavender = "#b4befe"
text = "#cdd6f4"
subtext1 = "#bac2de"
subtext0 = "#a6adc8"
overlay2 = "#9399b2"
overlay1 = "#7f849c"
overlay0 = "#6c7086"
surface2 = "#585b70"
surface1 = "#45475a"
surface0 = "#313244"
base = "#1e1e2e"
mantle = "#181825"
crust = "#11111b"

Someone could use this flavor, but then say - hmm, actually I want to use blue for the CWD:

# theme.toml

flavor = "catppuccin_mocha"

[manager]
cwd = { fg = "${blue}" }

Using the catppuccin_mocha flavor would inherit the palettes.catppuccin_mocha that the catppuccin_mocha flavor defines/uses.

Ideally the ${<color>} syntax could be avoided, but since as you mention Yazi already treats strings like "red" as CSS colors that would not work well.

@sxyazi
Copy link
Owner

sxyazi commented Feb 5, 2025

OK, I think I get what you mean now.

You want to introduce a new color system parallel to the existing one, where the colors in the color palette don't directly correspond to the existing ANSI colors (red, blue, etc.), but instead function as an independent system, like ${blue}. To me, this feels like an unnecessary complication, and I'm not interested in it, sorry.

Closing as not planned

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

2 participants