-
Notifications
You must be signed in to change notification settings - Fork 862
[Emotion] Logical property, padding, and background color utilities #5850
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
Conversation
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
| quarter: css` | ||
| width: 25%; | ||
| margin-inline: auto; | ||
| ${logicalCSS('width', '25%')} | ||
| ${logicalCSS('margin-horizontal', 'auto')} | ||
| `, |
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.
I've started updating some properties, but at the end of the day, if we know/remember the logical property as we see below with margin-block it's somewhat easier to read. So I 🤷♀️ about whether we need to use these helpers everywhere or not. The two arguments I see for using the util are:
- Future proof readability for folks not fully knowledgable of the new properties
- If the CSS spec ever changes, we have one place we need to update (least likely scenario at this point)
src/global_styling/mixins/_color.ts
Outdated
|
|
||
| export type EuiBackgroundColor = typeof BACKGROUND_COLORS[number]; | ||
|
|
||
| export const euiBackgroundColorStyles = ({ |
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.
This is basically the generic equivalent/conversion of $euiPanelBackgroundColorModifiers
| export const PADDING_SIZES = ['none', 'xs', 's', 'm', 'l', 'xl'] as const; | ||
| export type EuiPaddingSize = typeof PADDING_SIZES[number]; | ||
|
|
||
| export const euiPaddingStyles = ( |
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.
This is basically the generic equivalent/conversion of $euiPanelPaddingModifiers
|
Ready for review 😄 |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
|
I took another page out of @constancecchen's book (i.e. copied her work) and created tests for these utils. This is a great method also to quickly compare the values of every acceptable parameter (and makes it easy for me to update Figma 😉 ) |
_might as well :)_
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
This reverts commit 972d57e.
- `euiBackgroundColorStyles` is now a hook version: `useEuiBackgroundColorStyles` - Added table of values in docs section - Added specific contrast section
- `euiPaddingSize` just passes back the value - `useEuiPadding` is the hook version - `useEuiPaddingStyles` is the hook that passes back the entire object - Fixed the value for size `m` to be `base` not `m` - Fixed up tests and docs
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
|
I think I've addressed all concerns. Thank you both! 💟 P.S. I'll update the docs' sections with parameter types when #5855 merges to utilize the new ThemeValue prop added there. |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
|
Oh no! I'm not sure what's going wrong, but it looks like Emotion isn't rendering the expected output on https://eui.elastic.co/pr_5850/#/display/avatar 😬 Maybe it's the semi-colons following the mixin usage? I'm not actually sure they should be included when returning an object EDIT: Yeah I think it's the semi-colons. https://eui.elastic.co/pr_5850/#/layout/horizontal-rule works and it has no trailing semi-colons. |
|
Womp womp. It's not just the semicolons. It seems passing back an object expects it to be very precisely applied. After removing them, I still got the following css output: overflow-block: hidden;
font-weight: 500;
[object Object] [object Object] line-height: calc(16px * 4);It's because of the extra wrapping function that was supposed to just return a string: eui/src/components/avatar/avatar.styles.ts Lines 20 to 22 in ded07ab
I can change this particular instance to return a serialized string, but I think we may run into this more often than not since we're trying to always return strings. That's why I think optimizing for the string value is better than optimizing for the object. Still begs the question though of whether we need to have two mixins per. |
|
D'oh. Totally makes sense. I'd be good with consistently returning strings personally. I do think we should prefer to pick 1 or the other for developer experience. @thompsongl any thoughts here? |
|
Per our sync today, I'd be good with reverting ded07ab and shipping this PR with both string and object utils! |
This reverts commit 29c6642.
This reverts commit ded07ab.
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much. - Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) Signed-off-by: naveen <[email protected]>
* Commented out some unused (yet) properties and updated the Focus docs section * Make `focus` global token required * Updated ThemeExamples code snippets to scroll horizontally * [EuiSplitPanel] Fix border-radius of nested split panels # Conflicts: # src/global_styling/mixins/index.ts
# Conflicts: # src/global_styling/mixins/index.ts
|
Sorry about the commit history, but this PR should be up to date now based on the discussion. 😅 |
cee-chen
left a comment
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_5850/ |
1 similar comment
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5850/ |
elizabetdev
left a comment
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.
LGTM! 🎉
These added utilities are some of the most commonly used/re-used properties among EUI and consumer styles.
Logical properties
These help convert standard direction properties like
left,height, andmargin-bottominto logical properties likeinline-start,inset-block, andmargin-block-end.Docs lives under Theming/SIze: https://eui.elastic.co/pr_5850/#/theming/sizing#utilities
**NOTE: ** I did not prefix these helpers with
euibecause they're generic and not specific to EUI in any way.logicals{}: Map of all the directional properties to the logical counterpartlogicalCSS(): Function to return the string version of theproperty: valuepairlogicalStyle(): Function to return the object version of theproperty: valuepairlogicalTextAlign(): Text-specific function because it's the value that needs to change not the propertyPadding
These helpers either create the full map of common padding sizes (styles function) including logical side or quickly grab one of the pre-defined padding attributes based on side and size (hook).
Docs lives under Theming/Size: https://eui.elastic.co/pr_5850/#/theming/sizing#utilities
euiPaddingSize(): Returns the calculated padding size value onlyuseEuiPaddingSize(): Hook version of ^^useEuiPaddingStyles(): Returns the full map of size to padding value for quick styling of components that can have their padding size changed via a prop. It also accepts asidethat will update the property based on the logical property equivelant.Background color
Similar to the padding functions, these create maps specifically around colorizing background colors based off the brand colors (lightly shaded versions). It's similar to how EuiPanel colors it's background but now in a re-usable style fashion.
Docs lives under Theming/Color: https://eui.elastic.co/pr_5850/#/theming/colors#utilities
euiBackgroundColor(): just calculates and returns the coloruseEuiBackgroundColor(): Hook that returns the string version calculated coloruseEuiBackgroundColorStyles(): Returns the full map of token tobackground-color: valuepair for quick styling of components that can have their background color changed via a propContrast specific docs added to the bottom of the contrast tab.
Checklist
[ ] Checked in mobile[ ] Props have proper autodocs and playground toggles[ ] Checked Code Sandbox works for any docs examples[ ] Added or updated jest and cypress tests[ ] Checked for breaking changes and labeled appropriately[ ] Checked for accessibility including keyboard-only and screenreader modes