solid-theme-provider icon indicating copy to clipboard operation
solid-theme-provider copied to clipboard

Algorithmic Themes

Open gnomical opened this issue 1 year ago • 1 comments

Description

To enhance the theming capabilities of the solid-theme-provider, it's proposed to introduce a sophisticated algorithmic theme generation feature, drawing inspiration from Material Design 3's color system. This new feature aims to elevate the current simplistic and naive approach to a more robust and dynamic system that can generate comprehensive themes based on one or more source colors.

The current implementation, as outlined in special considerations for color and the calculate variants prop, provides a foundational layer. However, to achieve more adaptive, aesthetically pleasing, and efficient color schemes, a more advanced algorithm is required.

Design Considerations

The primary goal is to ensure that any theme generated by this feature is not only aesthetically pleasing but also maintains backward compatibility. As such, the system should:

  • Generate themes dynamically based on input colors, adjusting hues, saturation, and lightness to create a balanced and harmonious palette.
  • Include a set of predefined color roles for UI elements (e.g., background, foreground, container, button, error states) ensuring sufficient contrast and readability according to WCAG guidelines.
  • Allow for the future introduction of additional color roles or adjustments without breaking existing themes.

Implementation Steps

  1. Algorithm Development: Develop a JavaScript algorithm to include dynamic generation of complementary and contrasting colors, ensuring accessibility standards are met for text and background contrast ratios.
  2. Integration: Embed the algorithm within the solid-theme-provider, allowing users to input one or more seed colors to generate a theme dynamically.
  3. Demo Site Creation: Develop a demo site that visually represents the generated theme based on user-input seed colors. This site should allow users to tweak colors and see the effects in real-time, providing an intuitive interface for theme customization.
  4. Export Functionality: Implement a feature to export the generated theme as a themes.json file, serving both as a reference for available CSS variables and as a tool for preserving theme versions.

Future Enhancements

  • Theme Customization: Introduce advanced options for users to fine-tune generated themes, including adjusting color contrasts, adding custom color roles, and modifying saturation or lightness for specific UI elements.
  • Documentation and Tutorials: Provide comprehensive documentation and tutorials on using the theme generation feature, including best practices for selecting seed colors and integrating the generated themes into projects.

Conclusion

This feature represents a significant enhancement to the solid-theme-provider, promising to deliver a dynamic and user-friendly approach to theme generation that is both aesthetically pleasing and accessible. By drawing inspiration from established design systems and focusing on adaptability and backward compatibility, we can ensure that this feature remains valuable for a wide range of applications and user needs.

gnomical avatar Feb 19 '24 03:02 gnomical

possible color manipulation libraries

  • Tiny Color lighten is broken into increments of 1 percent, however this is relative to the entire spectrum, not just the colors difference from white.
  • Chroma.js lighten is divided into 1/18th of the whole spectrum but allows passing in floats for partial increments.
  • Color lighten is a percent of the color's current luminance. E.g. 50% luminance with a lighten(0.5) results in 75% luminance - a 50% increase of its initial value.

additional libraries

  • Color Thief allow pulling a palette from an image
  • Please.js generates random color schemes or a scheme based on a seed color

gnomical avatar Feb 20 '24 04:02 gnomical