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 CSS custom properties in createCursor #95

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

bornajazvo
Copy link
Contributor

Currently there is an issue when passing a CSS custom property to the createCursor method:

image

While the flag and the caret colour are set correctly, modifying the alpha value for the selection block fails. This results in rgb(0, 0, 0) as a CSS variable is not a valid input for tinycolor.

element.style.backgroundColor = tinycolor(this.color).setAlpha(0.3).toString();

This change addresses the issue by applying the fade effect via the opacity property instead of manipulating the alpha channel.

Note

This will slightly change functionality, as before the existing opacity would be overwritten (for example, passing rgba(0, 0, 0, 0.5) would result in the selection block being rgba(0, 0, 0, 0.3)). Now the fade will apply to the existing colour (so the previous example will result in rgba(0, 0, 0, 0.15) instead).

This behaviour is more intuitive, especially when working with colours that have alpha values less than 0.3. Previously, these would result in the fade making the colour stronger instead of lighter.

@bornajazvo bornajazvo force-pushed the css-custom-properties-support branch from 2adf07b to 7be000f Compare January 7, 2025 13:08
@bornajazvo bornajazvo requested a review from a team January 7, 2025 13:14
@bornajazvo bornajazvo merged commit 6b840d6 into main Jan 7, 2025
1 check passed
@bornajazvo bornajazvo deleted the css-custom-properties-support branch January 7, 2025 15:14
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

Successfully merging this pull request may close these issues.

2 participants