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

calc easier to extend syntax #1007

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

RobertasJ
Copy link
Contributor

@RobertasJ RobertasJ commented Nov 30, 2024

A pr where instead of using symbols for custom values, we have variables instead, list of variables:

  • root
  • root.cross
  • root.width
  • root.height
  • parent
  • parent.cross
  • parent.width
  • parent.height
  • scale
    in addition to that there are now new functions one can use within calc:
  • min(value1, value2, value3, ...)
  • max(value1, value2, value3, ...)
  • clamp(minimum_value, value, maximum_value)

an always square rect element example:

rsx! {
    rect {
        width: "100", // imagine this value changing arbitrarily
        height: "400", // imagine this value changing arbitrarily
        rect {
            width: "calc(min(parent, parent.cross))", 
            height: "calc(min(parent, parent.cross))"
        }
    }
}

i marked it as a draft as im sure this is pretty new. might be interesting to discuss if this syntax would be good or not.

@RobertasJ RobertasJ changed the title functions and other values calc easier to extend syntax Dec 4, 2024
@RobertasJ
Copy link
Contributor Author

@marc2332 wondering on how you would want me to change this in order to limit the possibility of invalid states.

@RobertasJ RobertasJ force-pushed the feat/calc-functions branch from bbed35b to 78b8cd3 Compare January 26, 2025 17:15
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.

1 participant