-
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
[Emotion] Convert EuiFormRow #7968
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
296d1c3
[tech debt] Convert EuiFormRow from a class to a function component
cee-chen 9323d7f
[tests tech debt] Convert Enzyme to RTL + update behavior tests to ac…
cee-chen 6e20d9a
Convert basic styles
cee-chen a91903a
Convert basic differentiated styles between row and column layout
cee-chen d726757
Convert remaining row vs column styles
cee-chen be845c5
Convert `center` display styling
cee-chen 019b3d1
Convert column switch-specific CSS
cee-chen 9f95c6e
Update docs to mark `rowCompressed` and `columCompressedSwitch` displ…
cee-chen 5a7f84a
Convert `hasEmptyLabelSpace` styles
cee-chen f8b64fa
Delete Sass files
cee-chen dfa9f10
[stories] Add VRT/examples for column and inline form row layouts
cee-chen b0cb928
Update downstream snapshots
cee-chen f2bb478
[storybook] Only show `hasEmptyLabelSpace` control if label field is …
cee-chen 58f3255
[PR feedback] Remove centering styling from `hasEmptyLabelSpace`
cee-chen 82c1ca8
[misc] fix prepend/append bug
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**CSS-in-JS conversions** | ||
|
||
- Converted `EuiFormRow` to Emotion |
This file contains 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
This file contains 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
101 changes: 101 additions & 0 deletions
101
packages/eui/src/components/form/form_row/form_row.styles.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { css } from '@emotion/react'; | ||
|
||
import { UseEuiTheme } from '../../../services'; | ||
import { logicalCSS } from '../../../global_styling'; | ||
import { euiFormVariables } from '../form.styles'; | ||
|
||
export const euiFormRowStyles = (euiThemeContext: UseEuiTheme) => { | ||
const { euiTheme } = euiThemeContext; | ||
const { maxWidth, controlHeight, controlCompressedHeight } = | ||
euiFormVariables(euiThemeContext); | ||
|
||
return { | ||
euiFormRow: css` | ||
/* Coerce inline form elements to behave as block-level elements */ | ||
display: flex; | ||
|
||
+ .euiButton { | ||
${logicalCSS('margin-top', euiTheme.size.base)} | ||
} | ||
`, | ||
// Skip css`` to avoid generating an Emotion className | ||
formWidth: ` | ||
${logicalCSS('max-width', maxWidth)} | ||
`, | ||
fullWidth: css` | ||
${logicalCSS('max-width', '100%')} | ||
`, | ||
|
||
// Skip css`` to avoid generating an extra className | ||
row: ` | ||
flex-direction: column; | ||
row-gap: ${euiTheme.size.xs}; | ||
|
||
.euiFormRow__labelWrapper { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
} | ||
|
||
+ .euiFormRow { | ||
${logicalCSS('margin-top', euiTheme.size.base)} | ||
} | ||
`, | ||
|
||
columnCompressed: css` | ||
flex-direction: row; | ||
align-items: stretch; | ||
column-gap: ${euiTheme.size.s}; | ||
|
||
.euiFormRow__label { | ||
hyphens: auto; | ||
} | ||
|
||
.euiFormRow__labelWrapper { | ||
flex-basis: calc(33% - ${euiTheme.size.s}); /* Account for gap */ | ||
${logicalCSS('min-width', 0)} | ||
line-height: ${controlCompressedHeight}; | ||
} | ||
|
||
.euiFormRow__fieldWrapper { | ||
flex-basis: 67%; | ||
${logicalCSS('min-width', 0)} | ||
} | ||
|
||
+ .euiFormRow { | ||
${logicalCSS('margin-top', euiTheme.size.s)} | ||
} | ||
`, | ||
|
||
centerDisplayCss: (compressed: boolean) => ` | ||
.euiFormRow__fieldWrapperDisplayOnly { | ||
display: flex; | ||
align-items: center; | ||
${logicalCSS( | ||
'min-height', | ||
compressed ? controlCompressedHeight : controlHeight | ||
)} | ||
} | ||
`, | ||
get center() { | ||
return css` | ||
${this.row} | ||
${this.centerDisplayCss(false)} | ||
`; | ||
}, | ||
get centerCompressed() { | ||
return css` | ||
${this.row} | ||
${this.centerDisplayCss(true)} | ||
`; | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.
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.
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.
[Not a change request, just trying to understand the exact reason :D] Are these two getters so you can access
this.row
andthis.centerDisplayCss
? I'd normally prefer to movecenterDisplayCss
above this so we could get rid of these getters but sincerow
does the same thing it feels clean to do it like this hereThere 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.
Yes, I use getters are for
this
access/repeating styles: https://github.com/elastic/eui/blob/main/wiki/contributing-to-eui/developing/writing-styles-with-emotion.md#duplicate-stylesAnd yes, it's essentially repeating
row
styles hence me trying to write it a bit more DRYly. It's not perfect but to be honest thecenter
display is a little weird and I'd rather get rid of it entirely if we can in the future 🤷