Skip to content

Commit

Permalink
[EuiFilePicker] Use alert icon when isInvalid (#6678)
Browse files Browse the repository at this point in the history
* Change EuiFilePicker's icon to an alert icon if `isInvalid`

* Tweak the border behavior of EuiFilePicker to match other form controls when disabled or focused

* Fix casing of file picker docs section

* changelog
  • Loading branch information
cee-chen committed Apr 5, 2023
1 parent 936b758 commit 34748f9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src-docs/src/views/form_controls/form_controls_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export const FormControlsExample = {
playground: TextAreaConfig,
},
{
title: 'File Picker',
title: 'File picker',
source: [
{
type: GuideSectionTypes.JS,
Expand Down
5 changes: 3 additions & 2 deletions src/components/form/file_picker/_file_picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@
height: $euiFilePickerTallHeight - $euiSizeL; /* 4 */
}

.euiFilePicker-isInvalid & {
border: $euiBorderWidthThick dashed $euiColorDanger;
// To match other EUI form controls, do not color the border red if focused or disabled
.euiFilePicker-isInvalid:not(.euiFilePicker__showDrop) .euiFilePicker__input:not(:disabled):not(:focus) + & {
border-color: $euiColorDanger;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/components/form/file_picker/file_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ export class EuiFilePicker extends Component<EuiFilePickerProps> {
<div className="euiFilePicker__prompt" id={promptId}>
<EuiIcon
className="euiFilePicker__icon"
color={disabled ? 'subdued' : 'primary'}
type="importAction"
color={
isInvalid ? 'danger' : disabled ? 'subdued' : 'primary' // eslint-disable-line no-nested-ternary
}
type={isInvalid ? 'alert' : 'importAction'}
size={normalFormControl ? 'm' : 'l'}
aria-hidden="true"
/>
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/6678.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Updated `EuiFilePicker` to display an alert icon when `isInvalid`

0 comments on commit 34748f9

Please sign in to comment.