forked from ONEARMY/community-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): searchfield component with icons and center eye icon…
… in passwordfield
- Loading branch information
Lahuen Garcia
committed
Sep 24, 2024
1 parent
055430a
commit ab5f426
Showing
12 changed files
with
236 additions
and
96 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { Box, Input } from 'theme-ui' | ||
|
||
import { Icon } from '../Icon/Icon' | ||
|
||
import type { ThemeUIStyleObject } from 'theme-ui' | ||
|
||
export type Props = { | ||
autoComplete?: string | ||
name?: string | ||
id?: string | ||
dataCy: string | ||
placeHolder: string | ||
value: string | ||
onChange: (value: string) => void | ||
onClickDelete: () => void | ||
onClickSearch: () => void | ||
additionalStyle?: ThemeUIStyleObject | ||
} | ||
|
||
export const SearchField = ({ | ||
autoComplete = 'on', | ||
name = 'rand-name', | ||
id = 'rand-id', | ||
dataCy, | ||
placeHolder, | ||
value, | ||
onChange, | ||
onClickDelete, | ||
onClickSearch, | ||
additionalStyle = {}, | ||
}: Props) => { | ||
return ( | ||
<Box | ||
sx={{ | ||
position: 'relative', | ||
width: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Input | ||
autoComplete={autoComplete} | ||
name={name} | ||
id={id} | ||
variant="inputOutline" | ||
type="search" | ||
data-cy={dataCy} | ||
placeholder={placeHolder} | ||
value={value} | ||
onChange={(e) => onChange(e.target.value)} | ||
sx={{ | ||
...additionalStyle, | ||
paddingRight: 11, | ||
'::-webkit-search-cancel-button': { | ||
display: 'none', | ||
}, | ||
'::-ms-clear': { | ||
display: 'none', | ||
}, | ||
}} | ||
/> | ||
<Box | ||
sx={{ | ||
right: 2, | ||
position: 'absolute', | ||
display: 'flex', | ||
alignItems: 'center', | ||
}} | ||
> | ||
{value && ( | ||
<Icon | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
marginRight: 1, | ||
}} | ||
glyph="close" | ||
onClick={onClickDelete} | ||
size="17" | ||
/> | ||
)} | ||
<Icon | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
}} | ||
glyph="search" | ||
onClick={onClickSearch} | ||
size="19" | ||
/> | ||
</Box> | ||
</Box> | ||
) | ||
} |
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
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
Oops, something went wrong.