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

Full css support for colours #3328

Open
4 tasks
EliotRagueneau opened this issue Jan 31, 2025 · 1 comment
Open
4 tasks

Full css support for colours #3328

EliotRagueneau opened this issue Jan 31, 2025 · 1 comment

Comments

@EliotRagueneau
Copy link
Contributor

Description of new feature

It would be awesome to be able to support css color-mix() and light-dark() function for colours.

e.g. being able to use those css variables within the style definition:

--primary: light-dark(#006782, #5CD4FF);
--on-surface: light-dark(#001F24, #FFFFFF);

--primary-contrast-1: color-mix(in lch, var(--primary) 10%, var(--on-surface) 90%);
--primary-contrast-2: color-mix(in lch, var(--primary) 20%, var(--on-surface) 80%);

Motivation for new feature

This would allow Cytoscape users to use modern theme definitions within their cytoscape environment. I'm not sure how complicated that might be, and maybe it's just not possible, but if it is, I think it would help to modernise Cytoscape.js usage

For reviewers

Reviewers should ensure that the following tasks are carried out for incorporated issues:

  • Ensure that the reporter has adequately described their idea. If not, elicit more information about the use case. You should iteratively build a spec together.
  • Ensure that the issue is a good fit for the core library. Some things are best done in extensions (e.g. UI-related features that aren't style-related). Some things are best done by app authors themselves -- instead of in Cytoscape libraries.
  • The issue has been associated with a corresponding milestone.
  • The commits have been incorporated into the unstable branch via pull request. The corresponding pull request is cross-referenced.
@maxkfranz
Copy link
Member

Since everything in Cytoscape.js has access to JS, you can use functions. It isn't advisable to use function mappers for everything, especially for performance. However, you could use a top-level function that returns a stylesheet conditionally based on the dark mode.

Again, because you have access to JS, variables can just be variables, e.g. 'background-color': myRedColour

A dark mode function would make a great extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants