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

Support for creating custom properties as functions #647

Closed
mineclover opened this issue Jul 18, 2024 · 2 comments
Closed

Support for creating custom properties as functions #647

mineclover opened this issue Jul 18, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@mineclover
Copy link

Describe the feature request

Creating a style with a function already creates custom properties
There are two unnecessary actions

It is recommended that you skip these two unnecessary tasks if they are preceded by two dashes

  1. In front of the name -- more
  2. Perform var(--{name}) with name as key

image

example

dynamic: (color: string) => ({
    color: color,
    '--test': color,
  }),

These features make custom properties within more accessible

@mineclover mineclover added the enhancement New feature or request label Jul 18, 2024
@mineclover
Copy link
Author

image
Unnecessary properties occur when an approach to the declared --color-slot-1 inside the svg is assumed

@nmn
Copy link
Contributor

nmn commented Jul 21, 2024

This is an intentional part of the design to ensure consistency and to enable some important features in the future. There's also a potential performance improvement we can make with the current design.

  1. Consistency - It is a very complicated edge-case to explain, and TBH, I've forgotten some of the details, but TLDR; inline styles having the highest specificity can cause some problems.
  2. Future features - We're planning on polyfilling future/experimental CSS features using a CSS post-processor. Some of these features are reliant on knowing all possible values a variable can take. Inline styles are not part of the CSS file and would cause issues. With the current design, the post-processing step can detect when a variable has a dynamic value and handle/error on that as appropriate.
  3. Performance - Variable values are normally inherited, and this increases the performance cost of using variables. With the new @property feature, it possible to mark certain variables as non-inheriting. Using this enables us to speed up the usage of variables that are created for dynamic values.

@nmn nmn closed this as completed Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants