[CSS-in-JS] Add utility for converting style to logical properties#6426
Merged
cee-chen merged 4 commits intoelastic:mainfrom Dec 2, 2022
Merged
[CSS-in-JS] Add utility for converting style to logical properties#6426cee-chen merged 4 commits intoelastic:mainfrom
style to logical properties#6426cee-chen merged 4 commits intoelastic:mainfrom
Conversation
- they're vanilla JS functions, they aren't hooks
- for converting an entire `style` obj (of unknown properties) to logical properties, rather than manually passing properties
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6426/ |
Contributor
Author
|
@1Copenut, do you mind giving this a review when you have a chance? |
1Copenut
approved these changes
Dec 2, 2022
| }); | ||
| }); | ||
|
|
||
| describe('logicalStyles returns an object property', () => { |
Contributor
There was a problem hiding this comment.
These tests are so helpful in communicating intent. 💯
Contributor
Author
There was a problem hiding this comment.
Test-driven development y'all! 🎉
jbudz
pushed a commit
to elastic/kibana
that referenced
this pull request
Dec 19, 2022
eui@70.4.0 ⏩ eui@71.0.0 --- ## [`71.0.0`](https://github.com/elastic/eui/tree/v71.0.0) - Implemented new `EuiRange` and `EuiDualRange` designs where the `levels` are now on top of the tracks ([#6092](elastic/eui#6092)) - Added `discuss` and `dotInCircle` glyphs to `EuiIcon` ([#6434](elastic/eui#6434)) - Added `article` glyph to `EuiIcon` ([#6437](elastic/eui#6437)) - Changed the `EuiProvider` usage warnings to not rely on development mode. ([#6451](elastic/eui#6451)) **Breaking changes** - `EuiDualRange` now explicitly requires both `min` and `max` via props types, to match `EuiRange` ([#6092](elastic/eui#6092)) - `EuiRange` and `EuiDualRange`'s `compressed` size no longer impacts track or level sizes, but continues to compress tick and input sizes. ([#6092](elastic/eui#6092)) - Removed all variables for the following components from EUI's theme JSON files: ([#6443](elastic/eui#6443)) - `euiCollapsibleNav*` - `euiColorPicker*` - `euiContextMenu*` - `euiControlBar*` - `euiDataGrid* `(except for z-indices and cell padding sizes) - `euiDatePicker*` - `euiSuperDatePicker*` - `euiDragAndDrop*` - `euiEuiEmptyPrompt*` - `euiFilePicker*` - `euiRange*` - `euiHeaderLinks*` - `euiKeyPad*` - `euiMarkdownEditor*` - `euiResizable*` - `euiSelectable*` - `euiSideNav*` - `euiStep*` - `euiSuggest*` - `euiTable*` (except for color variables) - `euiTooltip*` - `euiButtonFontWeight`, `euiButtonDefaultTransparency`, and `euiButtonMinWidth` - If you were importing any of the above removed JSON variables, we strongly recommend using generic color or sizing variables from `useEuiTheme()` instead. ([#6443](elastic/eui#6443)) **CSS-in-JS conversions** - Converted `EuiRange` and `EuiDualRange` to Emotion; Removed `$euiRangeThumbRadius` ([#6092](elastic/eui#6092)) - Added a new `logicalStyles` utility that automatically converts all non-logical properties in a `style` object to their corresponding logical properties ([#6426](elastic/eui#6426)) - Added a new `logicalShorthandCSS` utility that automatically converts `margin`, `padding`, and other 4-sided shorthands to their corresponding logical properties ([#6429](elastic/eui#6429)) - Added a new `logicalBorderRadiusCSS` utility that automatically converts `border-radius` to corresponding logical properties ([#6429](elastic/eui#6429)) Co-authored-by: Constance Chen <constance.chen@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This utility allows us to convert any
styleobject to use corresponding logical properties instead of, e.g.width,height, etc. It checks the entire style obj for keys that have corresponding logical properties and converts them if so. It's particular desired for anywhere we use a virtualization library.The example/snapshot change for
EuiCodeBlockmost clearly illustrates what this utility accomplishes.This is very much a "nice to have" util and doesn't necessarily exactly work 100% as expected in
react-windowin actualdirection: rtlorwriting-mode: vertical-rlprod behavior (although it's hard to tell if this is because EUI as a whole is not fully converted to logical properties yet).It also contains an incidental test cleanup commit.
QA
General checklist