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

Add many math functions #218

Merged

Conversation

vrugtehagel
Copy link
Contributor

@vrugtehagel vrugtehagel commented Jun 10, 2024

This PR adds all functions from #205 except round(), since that one specifically accepts a keyword for its first argument. Probably I'll handle that one at some point in the future.

I've opted to restructure min, max and clamp slightly here to reduce on repetition. These CSS functions differ only really in their return value; the system already didn't check for the units inside calculations, e.g. you'd never have an angle in a width: calculation, but width: calc(10deg) highlights just fine.

However caring about the return value means that e.g. width: sin(10deg) is not highlighted (since sin() returns a number, not a length) but line-height: sin(10deg) does highlight. min(), max() and clamp() fall in the bucket of functions that can return anything, and their return value depends on their arguments.

Copy link
Collaborator

@argyleink argyleink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rad! these functions are so great, thanks for submitting highlighting enhancements for them and studying their types/syntax

@argyleink argyleink merged commit 9c69945 into ryboe:master Jun 11, 2024
1 check passed
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