-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟 🎉 Add SearchInput component (#6239)
Co-authored-by: Vladimir <dizel852@gmail.com>
- Loading branch information
Showing
9 changed files
with
75 additions
and
7 deletions.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ export type IconType = | |
| "docs" | ||
| "ga" | ||
| "info" | ||
| "lens" | ||
| "minus" | ||
| "modification" | ||
| "moon" | ||
|
23 changes: 23 additions & 0 deletions
23
airbyte-webapp/src/components/ui/SearchInput/SearchInput.module.scss
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,23 @@ | ||
.searchInput { | ||
display: block; | ||
isolation: isolate; | ||
position: relative; | ||
--padding-left: 36px; | ||
|
||
&__iconWrapper { | ||
z-index: 2; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: var(--padding-left); | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
&__input { | ||
padding-left: var(--padding-left); | ||
z-index: 1; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
airbyte-webapp/src/components/ui/SearchInput/SearchInput.stories.tsx
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,10 @@ | ||
import { StoryObj } from "@storybook/react"; | ||
|
||
import { SearchInput } from "./SearchInput"; | ||
|
||
export default { | ||
title: "Ui/SearchInput", | ||
component: SearchInput, | ||
} as StoryObj<typeof SearchInput>; | ||
|
||
export const Default: StoryObj<typeof SearchInput> = {}; |
34 changes: 34 additions & 0 deletions
34
airbyte-webapp/src/components/ui/SearchInput/SearchInput.tsx
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,34 @@ | ||
import { useIntl } from "react-intl"; | ||
|
||
import { Input } from "components/ui/Input"; | ||
|
||
import styles from "./SearchInput.module.scss"; | ||
import { Icon } from "../Icon"; | ||
|
||
interface SearchInputProps { | ||
placeholder?: string; | ||
value: string; | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
} | ||
|
||
export const SearchInput: React.FC<SearchInputProps> = ({ value, onChange, placeholder }) => { | ||
const { formatMessage } = useIntl(); | ||
|
||
return ( | ||
// Our <Input> component contains an <input>, but eslint is not smart enough to find it | ||
// eslint-disable-next-line jsx-a11y/label-has-associated-control | ||
<label className={styles.searchInput}> | ||
<div className={styles.searchInput__iconWrapper}> | ||
<Icon type="lens" color="action" size="lg" /> | ||
</div> | ||
<Input | ||
type="search" | ||
className={styles.searchInput__input} | ||
placeholder={placeholder ?? formatMessage({ id: "form.search.placeholder" })} | ||
value={value} | ||
onChange={onChange} | ||
light | ||
/> | ||
</label> | ||
); | ||
}; |
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 @@ | ||
export { SearchInput } from "./SearchInput"; |
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