-
Notifications
You must be signed in to change notification settings - Fork 1
Choose any color as primary #1
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
base: main
Are you sure you want to change the base?
Conversation
Hi @idling-mind This is cool! Thanks! Can you tell me more about how you generated the 10 colors? It can be tricky to generate a high quality sequence that has even steps between the colors and accounts for things like tone and saturation. It would be ideal if we could generate the same color sequence as the Mantine Color generator: https://mantine.dev/colors-generator/ Why choose 4 for the primary shade? The Mantine default is |
hi @AnnMarieW , right now, i'm interpolating using the hsl colors. I'm creating 4 new colors to the left and 5 colors to the right of the chosen color's luminosity. That's why I had to keep the primaryShade to 4. |
Yeah, I'm concerned about generating colors this way -- whether it will work correctly with the Mantine theme. Mantine uses colors throughout the spectrum for things like active, hover, text colors, background colors etc in both light and dark mode. I think it would be better for people to use the Mantine Colors generator if they want to add custom colors. https://mantine.dev/styles/css-variables-list/ This is really cool though. I wonder if there is a way to integrate the Mantine color generator... |
ok, I understand. I found the code here. I'll try to port it to python. |
Interesting... it uses chroma.js I wonder if there is a Python equivalent library. |
I couldn't find any. I tried something anyway. But it's not giving the same colors as mantine's version. But the behavior seems similar. |
This looks pretty good! I tried a few things like entering a very light color, and it correctly placed it low in the series and made a nice 10 color sequence. The app shows good contrast for buttons etc. in light and dark mode using the default primary shades. For another test, I took the custom color from the colorpicker text field and used it in the Mantine color generator. Then asked ChatGPT Code Copilot to analyze the two color series. The results are below. Even if this color generator isn't quite as perfect as the Mantine version, I think including this feature adds a lot of value because it demonstrates how to add custom colors to the theme object. We could update the README to recommend using the Mantine color generator for production apps. To evaluate these two color sequences for use in a Mantine app, I'll analyze their suitability based on key design criteria: smoothness, contrast, cohesion, readability, and accessibility. Sequence 1 Analysis[
"#faebfd", "#f1d5f8", "#e0aced", "#ce82e1", "#bd60d4",
"#b349cd", "#b138cf", "#9e27bb", "#911aae", "#8509a4"
]
Sequence 2 Analysis[
"#feecff", "#f2d8f9", "#e0b0ec", "#cd85df", "#bd60d4",
"#b449ce", "#af3dcc", "#9a2eb4", "#8927a2", "#781e8e"
]
RecommendationSequence 2 is better suited for a Mantine app because:
Suggestions:
|
That's a clever way to analyze the colors! I'll see if I can refine the implementation a bit more. In any case, I'll just update the readme as you suggested. |
I added a color shades swatch now. Just to give us a better idea about which shades are being created when we select a custom color. During this, I realized that for the default colors, (especially yellow and orange), the shades are probably hand crafted. They are much more saturated towards darker tones. I think I'll stop going down the rabbit hole of colors now :). Please do feel free to make any changes to this pull request. It was just something I felt missing, but realized that it was much more complicated than I imagined. Thanks for creating this tool. I hope I can contribute more in the future! |
It looks like the mantine colors generator is available as a seperate package. I might be able to add that function to dash-mantine-components library 🤔 |
That would be quite nice to have in dmc! |
I'm a little backed up on dmc project, but I'll open an issue and see if someone can help with a PR. Might be fairly straight forward. In the meantime, what do you think about having a link to the Mantine colors generator, then have people copy the result and paste it into the customize theme panel? Could use a |
I think that would be nice... So do you mean a JsonInput for only the generated colours or JsonInput for the whole theme? It would also be cool if we could play with the entire theme using a JsonInput field. Then we could try other customisations that the theme object allows.
I can also give a try. Haven't looked into the dmc codebase yet. |
^^ That's a really good idea! Thanks for considering doing a dmc PR 🙂 |
I tried a bit to do a two way bind of jsoninput and the theme controls. I felt it became much more complicated than your current clean implementation. Do you have some proposal on how to do this? As of now, I also would like to bring the theme controls outside of a modal so that I can see the changes in the theme without closing the modal. |
What do you think about another version of the app where it starts with the default theme in the JsonInput that you could edit and see the changes live. Then there would be no need to do a two way sync of the menu driven options? I agree that it would be better to have the theme controls in something other than a modal. Maybe a |
Updated color picker to let user choose any color as primary.
Variations of selected color is automatically calculated and added as new color "myColor" to the theme.
Selected color is created such that it's number 5 in the list so that primaryShade can be set to 4.