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

Set CSS variables with the css setter #1230

Closed
Glandos opened this issue Nov 4, 2021 · 3 comments
Closed

Set CSS variables with the css setter #1230

Glandos opened this issue Nov 4, 2021 · 3 comments

Comments

@Glandos
Copy link
Contributor

Glandos commented Nov 4, 2021

Feature request

Currently the following code doesn't work as expected:

const draw = SVG()

draw.rect(10, 10).css({ '--myVar': 'black' })

There are 2 issues:

  1. The setter will call camelCase and remove the first dash, leading to an invalid CSS value declaration.
  2. The Typescript definition doesn't allow this because (obviously) --myVar is not a part of CSSStyleDeclaration.

I don't think that 2. is concerning this project, but 1. is :)

I don't see this as a bug report, because in the meantime, we can use attr({ 'style': '--myVar: black'}).

@Fuzzyma Fuzzyma closed this as completed in 70125d5 Sep 3, 2023
@Fuzzyma
Copy link
Member

Fuzzyma commented Sep 3, 2023

This ended up being a bit more tricky. However, after 2 years its fair that I finally do it :D

@Glandos
Copy link
Contributor Author

Glandos commented Sep 4, 2023

I think some Typescript part were not possible 2 years ago. I'm not 100% sure…
Anyway, thanks a lot!

@Fuzzyma
Copy link
Member

Fuzzyma commented Jun 18, 2024

I am sorry, I somehow forgot to publish all the fixes I made. I just released it:
https://github.com/svgdotjs/svg.js/releases/tag/3.2.1

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