-
Notifications
You must be signed in to change notification settings - Fork 165
[terra-search-field] Removed the terra-form-input and replaced it with a native input #3078
Changes from all commits
3990a42
fca32de
978b077
e87bc5c
7c7364d
468041b
2ee19f2
820d750
d4564e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ThemeContext from 'terra-theme-context'; | |
import Button from 'terra-button'; | ||
import * as KeyCode from 'keycode-js'; | ||
import IconSearch from 'terra-icon/lib/icon/IconSearch'; | ||
import Input from 'terra-form-input'; | ||
import { injectIntl, intlShape } from 'react-intl'; | ||
import styles from './SearchField.module.scss'; | ||
|
||
|
@@ -273,17 +272,17 @@ class SearchField extends React.Component { | |
return ( | ||
<div {...customProps} className={searchFieldClassNames}> | ||
<div className={cx('input-group')}> | ||
<Input | ||
<input | ||
className={cx('input')} | ||
type="search" | ||
placeholder={placeholder} | ||
onChange={this.handleTextChange} | ||
disabled={isDisabled} | ||
ariaLabel={inputText} | ||
aria-label={inputText} | ||
aria-disabled={isDisabled} | ||
onKeyDown={this.handleKeyDown} | ||
onInput={this.handleInput} | ||
refCallback={this.setInputRef} | ||
ref={this.setInputRef} | ||
{...additionalInputAttributes} | ||
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. It maybe not be part of this scope, but in general we spread pass-through attributes before our implementation specific ones so the behaviors cannot be overridden. So I'd like to see this moved. 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. Thanks @dkasper-was-taken - logged this new issue here to move the spread to first in the list: #3086 |
||
/> | ||
{clearButton} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,22 +18,6 @@ | |
position: relative; | ||
} | ||
|
||
.input { | ||
appearance: none; | ||
border-bottom-left-radius: var(--terra-search-field-input-border-bottom-left-radius, 3px); | ||
border-bottom-right-radius: 0; | ||
border-top-left-radius: var(--terra-search-field-input-border-top-left-radius, 3px); | ||
border-top-right-radius: 0; | ||
flex: 1 1 auto; | ||
margin-bottom: var(--terra-search-field-input-margin-bottom, 0); | ||
margin-left: var(--terra-search-field-input-margin-left, 0); | ||
margin-right: var(--terra-search-field-input-margin-right, 0); | ||
margin-top: var(--terra-search-field-input-margin-top, 0); | ||
min-width: 0; | ||
outline-offset: -0.143em; // Adjust the outline offset for search input in Safari. | ||
padding-right: var(--terra-search-field-input-padding-right, 2.28571rem); // Match the padding to width of the clear button | ||
} | ||
|
||
.input::-ms-clear, | ||
.input::-ms-reveal { | ||
display: none; | ||
|
@@ -103,6 +87,83 @@ | |
display: flex; | ||
width: 100%; | ||
} | ||
} | ||
|
||
.input { | ||
appearance: none; | ||
background-color: var(--terra-search-field-input-background-color, #fff); | ||
background-image: none; | ||
background-position: 0 100%; | ||
background-repeat: no-repeat; | ||
background-size: auto; | ||
border: var(--terra-search-field-input-border, 1px solid #dedfe0); | ||
border-bottom-left-radius: var(--terra-search-field-input-border-bottom-left-radius, 3px); | ||
border-bottom-right-radius: 0; | ||
border-top-left-radius: var(--terra-search-field-input-border-top-left-radius, 3px); | ||
border-top-right-radius: 0; | ||
box-shadow: none; | ||
color: var(--terra-search-field-input-color, #1c1f21); | ||
flex: 1 1 auto; | ||
font-family: inherit; | ||
font-size: var(--terra-search-field-input-font-size, 1.142857rem); | ||
height: var(--terra-search-field-input-height, 2.142857rem); | ||
line-height: 1.25; | ||
margin-bottom: var(--terra-search-field-input-margin-bottom, 0); | ||
margin-left: var(--terra-search-field-input-margin-left, 0); | ||
margin-right: var(--terra-search-field-input-margin-right, 0); | ||
margin-top: var(--terra-search-field-input-margin-top, 0); | ||
min-width: 0; | ||
outline-offset: -0.143em; // Adjust the outline offset for search input in Safari. | ||
padding-bottom: var(--terra-search-field-input-padding-bottom, 0.28571rem); | ||
padding-left: var(--terra-search-field-input-padding-left, 0.28571rem); | ||
padding-right: var(--terra-search-field-input-padding-right, 2.28571rem); // Match the padding to width of the clear button | ||
padding-top: var(--terra-search-field-input-padding-top, 0.28571rem); | ||
transition-duration: 0s; | ||
transition-property: background-size; | ||
transition-timing-function: ease; | ||
width: 100%; | ||
|
||
&::placeholder { | ||
color: var(--terra-search-field-input-placeholder-color, rgba(21, 33, 41, 0.62)); | ||
font-style: var(--terra-search-field-input-placeholder-font-style, italic); | ||
opacity: 1; | ||
} | ||
|
||
&:hover { | ||
background-color: var(--terra-search-field-input-hover-background-color, #fff); | ||
border: var(--terra-search-field-input-hover-border, 1px solid #dedfe0); | ||
color: var(--terra-search-field-input-hover-color); | ||
} | ||
|
||
&[disabled] { | ||
background-color: var(--terra-search-field-input-disabled-background-color, rgba(111, 116, 119, 0.2)); | ||
border: var(--terra-search-field-input-disabled-border, 1px solid #868a8c); | ||
color: var(--terra-search-field-input-disabled-color, #1c1f21); | ||
cursor: default; | ||
opacity: var(--terra-search-field-input-disabled-opacity, 0.25); | ||
pointer-events: none; | ||
} | ||
|
||
&[disabled]::placeholder { | ||
color: var(--terra-search-field-input-placeholder-disabled-color, rgba(21, 33, 41, 0.62)); | ||
font-style: var(--terra-search-field-input-placeholder-disabled-font-style, italic); | ||
} | ||
|
||
&:focus { | ||
background-color: var(--terra-search-field-input-focus-background-color, #fff); | ||
background-size: auto; | ||
border: var(--terra-search-field-input-focus-border, 1px solid #4cb2e9); | ||
box-shadow: var(--terra-search-field-input-focus-box-shadow); | ||
color: var(--terra-search-field-input-focus-color); | ||
outline: none; | ||
|
||
[dir=ltr] & { | ||
box-shadow: var(--terra-search-field-input-focus-ltr-box-shadow); | ||
} | ||
|
||
[dir=rtl] & { | ||
box-shadow: var(--terra-search-field-input-focus-rtl-box-shadow); | ||
} | ||
} | ||
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. We should reduce these styles/variables as much as possible and apply only the ones necessary for theming the search field appropriately. Are all terra-form-input variables required to theme the search field? 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.
I had imported only the ones that were used by search-field when it imported form-input. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React from 'react'; | ||
import SearchField from '../../../SearchField'; | ||
|
||
export default () => <SearchField id="searchfield" placeholder="Search Text" />; | ||
export default () => <SearchField id="searchfield" placeholder="- Search Text -" />; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React from 'react'; | ||
import SearchField from '../../../SearchField'; | ||
|
||
export default () => <SearchField id="searchfield" placeholder="Search Text" />; | ||
export default () => <SearchField id="searchfield" placeholder="- Search Text -" />; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React from 'react'; | ||
import SearchField from '../../../SearchField'; | ||
|
||
export default () => <SearchField id="searchfield" placeholder="- Search Text -" isDisabled />; |
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.
Previously, form-input will automatically add
aria-required
ifrequired
was passed toinputAttributes
. Since this is no longer leveraging form-input, it would lose this logic. Should this be added here?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 and @neilpfeiffer discussed this and decided that it is unneeded to make
search-field
a required field.