Skip to content

Commit

Permalink
Improve styling of SearchRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kicu committed Sep 11, 2024
1 parent 4b45263 commit 2a2796b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type HeaderWithBackButtonProps from '@components/HeaderWithBackButton/typ
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
import SearchButton from '@components/Search/SearchRouter/SearchButton';
import type {ReportActionListItemType, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
import Text from '@components/Text';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
Expand All @@ -32,6 +31,7 @@ import type {SearchDataTypes, SearchReport} from '@src/types/onyx/SearchResults'
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type IconAsset from '@src/types/utils/IconAsset';
import {useSearchContext} from './SearchContext';
import SearchButton from './SearchRouter/SearchButton';
import type {SearchQueryJSON} from './types';

type HeaderWrapperProps = Pick<HeaderWithBackButtonProps, 'title' | 'subtitle' | 'icon' | 'children'> & {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function SearchRouter({type}: SearchRouterProps) {
toggleSearchRouter();
}}
>
<View style={[styles.flex1, styles.p5]}>
<View style={[styles.flex1, styles.p3]}>
<SearchRouterInput onSearch={onSearch} />
</View>
</Modal>
Expand Down
14 changes: 9 additions & 5 deletions src/components/Search/SearchRouter/SearchRouterContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useContext, useState} from 'react';
import React, {useCallback, useContext, useMemo, useState} from 'react';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

const defaultSearchContext = {
Expand All @@ -17,10 +17,14 @@ function SearchRouterContextProvider({children}: ChildrenProps) {
setIsSearchRouterDisplayed(!isSearchRouterDisplayed);
}, [isSearchRouterDisplayed]);

const routerContext = {
isSearchRouterDisplayed,
toggleSearchRouter,
};
const routerContext = useMemo(
() => ({
isSearchRouterDisplayed,
toggleSearchRouter,
}),
[isSearchRouterDisplayed, toggleSearchRouter],
);

return <Context.Provider value={routerContext}>{children}</Context.Provider>;
}

Expand Down
22 changes: 5 additions & 17 deletions src/components/Search/SearchRouter/SearchRouterInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useState} from 'react';
import {View} from 'react-native';
import TextInput from '@components/TextInput';
import useTheme from '@hooks/useTheme';
import BaseTextInput from '@components/TextInput/BaseTextInput';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import CONST from '@src/CONST';

type SearchRouterInputProps = {
Expand All @@ -11,7 +11,6 @@ type SearchRouterInputProps = {

function SearchRouterInput({onSearch}: SearchRouterInputProps) {
const styles = useThemeStyles();
const theme = useTheme();

const [value, setValue] = useState('');

Expand All @@ -22,23 +21,12 @@ function SearchRouterInput({onSearch}: SearchRouterInputProps) {

return (
<View style={[]}>
<TextInput
<BaseTextInput
value={value}
onChangeText={onChangeText}
textInputContainerStyles={[{borderWidth: 0}]}
containerStyles={[]}
hideFocusedState
inputStyle={[
styles.w80,
styles.h13,
styles.ph4,
{
width: 400,
borderRadius: 8,
borderWidth: 4,
borderColor: theme.borderFocus,
},
]}
textInputContainerStyles={[{borderBottomWidth: 0, width: variables.popoverWidth}]}
inputStyle={[styles.searchInputStyle, styles.searchRouterInputStyle, styles.ph2]}
role={CONST.ROLE.PRESENTATION}
/>
</View>
Expand Down
26 changes: 7 additions & 19 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3593,31 +3593,19 @@ const styles = (theme: ThemeColors) =>
flex: 1,
},

searchPressable: {
height: variables.componentSizeNormal,
},

searchContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
gap: 8,
paddingHorizontal: 24,
backgroundColor: theme.hoverComponentBG,
borderRadius: variables.componentBorderRadiusRounded,
justifyContent: 'center',
},

searchContainerHovered: {
backgroundColor: theme.border,
},

searchInputStyle: {
color: theme.textSupporting,
fontSize: 13,
lineHeight: 16,
},

searchRouterInputStyle: {
borderRadius: variables.componentBorderRadiusSmall,
borderWidth: 2,
borderColor: theme.borderFocus,
paddingHorizontal: 8,
},

searchTableHeaderActive: {
fontWeight: FontUtils.fontWeight.bold,
},
Expand Down

0 comments on commit 2a2796b

Please sign in to comment.