-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Wave8] Search Input component #32439
Merged
hayata-suenaga
merged 17 commits into
Expensify:main
from
software-mansion-labs:wave8/top-bar-search-no-usage
Dec 15, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3e6b99a
Translations for Search Input
MaciejSWM ddd3152
Create Search component
MaciejSWM f569b7b
Storybook for Search component
MaciejSWM 4d23fbc
Merge branch 'main' into wave8/top-bar-search-no-usage
MaciejSWM 4608493
Drop spaces around brackets
MaciejSWM 0521050
Rename prompt to placeholder
MaciejSWM 68aeaf2
Default placeholder and tooltip texts
MaciejSWM 145f1b4
Use predefined value for borderRadius
MaciejSWM aad68bc
Fix height of search bar
MaciejSWM cdea74e
Create style for search input instead of reusing existing styles
MaciejSWM 371ce8f
Migrate Search.stories to TypeScript
MaciejSWM 0e88819
Merge branch 'main' into wave8/top-bar-search-no-usage
MaciejSWM 9a8b385
Adjust color after merge
MaciejSWM 0f0d235
Merge branch 'main' into wave8/top-bar-search-no-usage
MaciejSWM a620689
Change import path
MaciejSWM 83094a8
Merge branch 'main' into wave8/top-bar-search-no-usage
MaciejSWM d1dac19
Adjust NAB
MaciejSWM 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 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,62 @@ | ||
import React from 'react'; | ||
import {GestureResponderEvent, StyleProp, View, ViewStyle} from 'react-native'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import variables from '@styles/variables'; | ||
import CONST from '@src/CONST'; | ||
import Icon from './Icon'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import {PressableWithFeedback} from './Pressable'; | ||
import Text from './Text'; | ||
import Tooltip from './Tooltip'; | ||
|
||
type SearchProps = { | ||
// Callback fired when component is pressed | ||
onPress: (event?: GestureResponderEvent | KeyboardEvent) => void; | ||
|
||
// Text explaining what the user can search for | ||
placeholder?: string; | ||
|
||
// Text showing up in a tooltip when component is hovered | ||
tooltip?: string; | ||
|
||
// Styles to apply on the outer element | ||
style?: StyleProp<ViewStyle>; | ||
}; | ||
|
||
function Search({onPress, placeholder, tooltip, style}: SearchProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<Tooltip text={tooltip ?? translate('common.search')}> | ||
<PressableWithFeedback | ||
accessibilityLabel={tooltip ?? translate('common.search')} | ||
role={CONST.ROLE.BUTTON} | ||
onPress={onPress} | ||
style={styles.searchPressable} | ||
> | ||
{({hovered}) => ( | ||
<View style={[styles.searchContainer, hovered && styles.searchContainerHovered, style]}> | ||
<Icon | ||
src={Expensicons.MagnifyingGlass} | ||
width={variables.iconSizeSmall} | ||
height={variables.iconSizeSmall} | ||
/> | ||
<Text | ||
style={styles.searchInputStyle} | ||
numberOfLines={1} | ||
> | ||
{placeholder ?? translate('common.searchWithThreeDots')} | ||
</Text> | ||
</View> | ||
)} | ||
</PressableWithFeedback> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
Search.displayName = 'Search'; | ||
|
||
export type {SearchProps}; | ||
export default Search; |
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,42 @@ | ||
import React from 'react'; | ||
import Search, {SearchProps} from '@components/Search'; | ||
|
||
/** | ||
* We use the Component Story Format for writing stories. Follow the docs here: | ||
* | ||
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format | ||
*/ | ||
const story = { | ||
title: 'Components/Search', | ||
component: Search, | ||
}; | ||
|
||
type StoryType = typeof Template & {args?: Partial<SearchProps>}; | ||
|
||
function Template(args: SearchProps) { | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return <Search {...args} />; | ||
} | ||
|
||
// Arguments can be passed to the component by binding | ||
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args | ||
const Default: StoryType = Template.bind({}); | ||
Default.args = { | ||
onPress: () => alert('Pressed'), | ||
}; | ||
|
||
const CustomPlaceholderAndTooltip: StoryType = Template.bind({}); | ||
CustomPlaceholderAndTooltip.args = { | ||
placeholder: 'Search for a specific thing...', | ||
tooltip: 'Custom tooltip text', | ||
onPress: () => alert('This component has custom placeholder text. Also custom tooltip text when hovered.'), | ||
}; | ||
|
||
const CustomBackground: StoryType = Template.bind({}); | ||
CustomBackground.args = { | ||
onPress: () => alert('This component has custom styles applied'), | ||
style: {backgroundColor: 'darkgreen'}, | ||
}; | ||
|
||
export default story; | ||
export {Default, CustomPlaceholderAndTooltip, CustomBackground}; |
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.
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.
no background color when press/long press on mobile. Is it expected?
ios.hover.mov
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.
Hey @aimane-chnaif . If you change the sidebar background color from
sidebar: colors.productDark200,
tosidebar: colors.productDark100,
you will see the touchable feedback in action. It's visible ononPress
. There's no style change whenonPress
becomesonLongPress
.@dannymcclain @shawnborton LMK if this looks good.
Screen.Recording.2023-12-13.at.16.07.48.mov
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.
Ah yeah a couple of things 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.
Same concern on light theme. There's no visual feedback on background color on press/long press. (not blocker)
light.mov
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.
Asked Maciej to address this in the follow up PRs
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.
Oh, the color of the search input from figma (#07271F) seems to be gone from the repo after recent changes in the theme. So I'll do 300/400/500 @shawnborton. Although our app now suggests something like that:
But I know it can change as currently we have the wrong background color in the sidebar, while ideal-nav will have bg200 if I remember correctly
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.
While on the buttons currently we have:
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.
@shawnborton
300/400/500:
Screen.Recording.2023-12-15.at.17.20.54.mov
Screen.Recording.2023-12-15.at.17.24.20.mov