-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(ui): Tweak form field layout #6879
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
7 changes: 4 additions & 3 deletions
7
...try/static/sentry/app/views/settings/components/forms/formField/formFieldControlState.jsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| import styled from 'react-emotion'; | ||
| import {Box} from 'grid-emotion'; | ||
| import {Flex} from 'grid-emotion'; | ||
|
|
||
| const FormFieldControlState = styled(Box)` | ||
| const FormFieldControlState = styled(Flex)` | ||
| position: relative; | ||
| width: 36px; | ||
| text-align: right; | ||
| flex-shrink: 0; | ||
| `; | ||
|
|
||
| export default FormFieldControlState; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import SettingsInputField from '../styled/input'; | |
| import SettingsTextAreaField from '../styled/textarea'; | ||
|
|
||
| const FormFieldWrapper = styled(({highlighted, ...props}) => <Flex {...props} />)` | ||
| padding: 15px 20px; | ||
| padding: 15px 0 15px 20px; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed right padding because of whitespace from control state icons |
||
| border-bottom: 1px solid ${p => p.theme.borderLight}; | ||
| align-items: center; | ||
| transition: background 0.15s; | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,39 @@ | ||
| import {Box, Flex} from 'grid-emotion'; | ||
| import {Observer} from 'mobx-react'; | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import styled from 'react-emotion'; | ||
|
|
||
| import {defined} from '../../../../../utils'; | ||
| import FormState from '../../../../../components/forms/state'; | ||
| import FormFieldWrapper from './formFieldWrapper'; | ||
| import FormFieldDescription from './formFieldDescription'; | ||
| import {pulse, fadeOut} from '../styled/animations'; | ||
| import FormFieldControl from './formFieldControl'; | ||
| import FormFieldControlState from './formFieldControlState'; | ||
| import FormFieldDescription from './formFieldDescription'; | ||
| import FormFieldHelp from './formFieldHelp'; | ||
| import FormFieldLabel from './formFieldLabel'; | ||
| import FormFieldRequiredBadge from './formFieldRequiredBadge'; | ||
|
|
||
| import FormFieldWrapper from './formFieldWrapper'; | ||
| import FormState from '../../../../../components/forms/state'; | ||
| import InlineSvg from '../../../../../components/inlineSvg'; | ||
| import Spinner from '../styled/spinner'; | ||
| import {pulse, fadeOut} from '../styled/animations'; | ||
|
|
||
| // This wraps Control + ControlError message | ||
| // * can NOT be a flex box have because of position: absolute on "control error message" | ||
| // * can NOT have overflow hidden because "control error message" overflows | ||
| const FormFieldControlErrorWrapper = styled(Box)` | ||
| width: 50%; | ||
| padding-left: 10px; | ||
| `; | ||
|
|
||
| const FormFieldControlWrapper = styled(Flex)` | ||
| overflow: hidden; | ||
| `; | ||
|
|
||
| const FormFieldErrorReason = styled.div` | ||
| color: ${p => p.theme.redDark}; | ||
| position: absolute; | ||
| background: #fff; | ||
| left: 10px; | ||
| padding: 6px 8px; | ||
| font-weight: 600; | ||
| font-size: 12px; | ||
|
|
@@ -34,13 +45,23 @@ const FormFieldErrorReason = styled.div` | |
| const FormFieldError = styled.div` | ||
| color: ${p => p.theme.redDark}; | ||
| animation: ${pulse} 1s ease infinite; | ||
| width: 16px; | ||
| margin-left: auto; | ||
| `; | ||
|
|
||
| const FormFieldIsSaved = styled.div` | ||
| color: ${p => p.theme.green}; | ||
| animation: ${fadeOut} 0.3s ease 2s 1 forwards; | ||
| position: absolute; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| top: 0; | ||
| bottom: 0; | ||
| left: 0; | ||
| right: 0; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| `; | ||
|
|
||
| const FormSpinner = styled(Spinner)` | ||
| margin-left: 0; | ||
| `; | ||
|
|
||
| /** | ||
|
|
@@ -211,37 +232,77 @@ class FormField extends React.Component { | |
| )} | ||
| {help && <FormFieldHelp>{help}</FormFieldHelp>} | ||
| </FormFieldDescription> | ||
| <FormFieldControl> | ||
| <Observer> | ||
| {() => { | ||
| let error = this.getError(); | ||
| let value = model.getValue(this.props.name); | ||
|
|
||
| return ( | ||
| <this.props.children | ||
| innerRef={this.handleInputMount} | ||
| {...{ | ||
| ...this.props, | ||
| id, | ||
| onKeyDown: this.handleKeyDown, | ||
| onChange: this.handleChange, | ||
| onBlur: this.handleBlur, | ||
| value, | ||
| error, | ||
| disabled: isDisabled, | ||
| }} | ||
| initialData={model.initialData} | ||
| /> | ||
| ); | ||
| }} | ||
| </Observer> | ||
|
|
||
| {isDisabled && | ||
| disabledReason && ( | ||
| <span className="disabled-indicator tip" title={disabledReason}> | ||
| <span className="icon-question" /> | ||
| </span> | ||
| )} | ||
| <FormFieldControlErrorWrapper> | ||
| <FormFieldControlWrapper shrink="0"> | ||
| <FormFieldControl flex="1"> | ||
| <Observer> | ||
| {() => { | ||
| let error = this.getError(); | ||
| let value = model.getValue(this.props.name); | ||
|
|
||
| return ( | ||
| <this.props.children | ||
| innerRef={this.handleInputMount} | ||
| {...{ | ||
| ...this.props, | ||
| id, | ||
| onKeyDown: this.handleKeyDown, | ||
| onChange: this.handleChange, | ||
| onBlur: this.handleBlur, | ||
| value, | ||
| error, | ||
| disabled: isDisabled, | ||
| }} | ||
| initialData={model.initialData} | ||
| /> | ||
| ); | ||
| }} | ||
| </Observer> | ||
|
|
||
| {isDisabled && | ||
| disabledReason && ( | ||
| <span className="disabled-indicator tip" title={disabledReason}> | ||
| <span className="icon-question" /> | ||
| </span> | ||
| )} | ||
| </FormFieldControl> | ||
|
|
||
| <FormFieldControlState justify="center" align="center"> | ||
| <Observer> | ||
| {() => { | ||
| let isSaving = model.getFieldState(this.props.name, FormState.SAVING); | ||
| let isSaved = model.getFieldState(this.props.name, FormState.READY); | ||
|
|
||
| if (isSaving) { | ||
| return <FormSpinner />; | ||
| } else if (isSaved) { | ||
| return ( | ||
| <FormFieldIsSaved> | ||
| <InlineSvg src="icon-checkmark-sm" size="18px" /> | ||
| </FormFieldIsSaved> | ||
| ); | ||
| } | ||
|
|
||
| return null; | ||
| }} | ||
| </Observer> | ||
|
|
||
| <Observer> | ||
| {() => { | ||
| let error = this.getError(); | ||
|
|
||
| if (!error) return null; | ||
|
|
||
| return ( | ||
| <FormFieldError> | ||
| <InlineSvg src="icon-warning-sm" size="18px" /> | ||
| </FormFieldError> | ||
| ); | ||
| }} | ||
| </Observer> | ||
| </FormFieldControlState> | ||
| </FormFieldControlWrapper> | ||
|
|
||
| <Observer> | ||
| {() => { | ||
|
|
@@ -251,41 +312,7 @@ class FormField extends React.Component { | |
| return <FormFieldErrorReason>{error}</FormFieldErrorReason>; | ||
| }} | ||
| </Observer> | ||
| </FormFieldControl> | ||
| <FormFieldControlState> | ||
| <Observer> | ||
| {() => { | ||
| let isSaving = model.getFieldState(this.props.name, FormState.SAVING); | ||
| let isSaved = model.getFieldState(this.props.name, FormState.READY); | ||
|
|
||
| if (isSaving) { | ||
| return <Spinner />; | ||
| } else if (isSaved) { | ||
| return ( | ||
| <FormFieldIsSaved> | ||
| <InlineSvg src="icon-checkmark-sm" size="18px" /> | ||
| </FormFieldIsSaved> | ||
| ); | ||
| } | ||
|
|
||
| return null; | ||
| }} | ||
| </Observer> | ||
|
|
||
| <Observer> | ||
| {() => { | ||
| let error = this.getError(); | ||
|
|
||
| if (!error) return null; | ||
|
|
||
| return ( | ||
| <FormFieldError> | ||
| <InlineSvg src="icon-warning-sm" size="18px" /> | ||
| </FormFieldError> | ||
| ); | ||
| }} | ||
| </Observer> | ||
| </FormFieldControlState> | ||
| </FormFieldControlErrorWrapper> | ||
| </FormFieldWrapper> | ||
| ); | ||
| } | ||
|
|
||
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.
Prevent controls with a long string from overflowing