-
Notifications
You must be signed in to change notification settings - Fork 842
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
[CSS-in-JS] Sizes with units #4578
[CSS-in-JS] Sizes with units #4578
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_4578/ |
This looks good to me in the theme, but when I look out the output, this nesty
|
We could roll our own calculation function to use instead. That way the output is always a px string. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4578/ |
Exploring options for a custom math function and found https://polished.js.org/docs/#math
Math on mixed units and user provided values is either risky or not possible. CSS |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4578/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4578/ |
Latest commit results in output like: "base": 16,
"sizes": {
"euiSize": "16px",
"euiSizeXS": "4px",
"euiSizeS": "8px",
"euiSizeM": "12px",
"euiSizeL": "24px",
"euiSizeXL": "32px",
"euiSizeXXL": "40px",
"euiButtonMinWidth": "112px",
"euiScrollBar": "16px",
"euiScrollBarCorner": "calc(8px * 0.75)"
}, Note that |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4578/ |
euiSizeXXL: computed(['sizes.euiSize'], ([euiSize]) => euiSize * 2.5), | ||
euiSize: computed(['base'], ([base]) => `${base}px`), | ||
euiSizeXS: computed(['base'], ([base]) => `${base * 0.25}px`), | ||
euiSizeS: computed(['base'], ([base]) => `${base * 0.5}px`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has there been more thought on how we might be able to simplify this without needing to write base
3 times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't put any thought to it until just now. I think at best you're looking at writing base
twice, and I'm not sure it scales well beyond top-level keys like base
. I can think about it a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview documentation changes for this PR: https://eui.elastic.co/pr_4578/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4578/ |
Will merge this soon so that work based on this branch can move forward |
Summary
Converts unitless number values to strings with units. Allows for use in string- and object-based Emotion styling.
Thinking that we can use the
calc
approach for now and determine if we want to move to a custom math function as we build more of the theme.### Checklist