Skip to content

Commit 8ee4df2

Browse files
committed
TableSearchBar: add support for specifying width
1 parent b8b0bb2 commit 8ee4df2

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/app/components/Search/TableSearchBar.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,29 @@ export interface TableSearchBarProps {
1818
placeholder: string
1919
warning?: string
2020
value: string
21+
/**
22+
* Should we go 100% width?
23+
*/
24+
fullWidth?: boolean
25+
26+
/**
27+
* Width of the whole component
28+
*
29+
* Note: fullWidth overrides this.
30+
*/
31+
width?: string | number
32+
2133
onChange: (value: string) => void
2234
}
2335

24-
export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, placeholder, warning }) => {
36+
export const TableSearchBar: FC<TableSearchBarProps> = ({
37+
value,
38+
onChange,
39+
placeholder,
40+
warning,
41+
fullWidth,
42+
width = 250,
43+
}) => {
2544
const { isTablet } = useScreenSize()
2645

2746
const [isWarningFresh, setIsWarningFresh] = useState(false)
@@ -72,7 +91,7 @@ export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, place
7291
verticalAlign: 'middle',
7392
mt: 3,
7493
mb: 4,
75-
width: isTablet ? '160px' : undefined,
94+
width: fullWidth ? '100%' : isTablet ? '160px' : undefined,
7695
}}
7796
>
7897
<WarningIcon sx={{ mr: 3 }} />
@@ -99,6 +118,7 @@ export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, place
99118
}
100119
: {}),
101120
zIndex: 10,
121+
...(fullWidth ? { width: '100%' } : {}),
102122
}}
103123
variant={'outlined'}
104124
value={value}
@@ -107,7 +127,7 @@ export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, place
107127
inputProps: {
108128
sx: {
109129
p: 0,
110-
width: isTablet ? 110 : 300,
130+
width: fullWidth ? '100%' : width,
111131
margin: 2,
112132
},
113133
},

0 commit comments

Comments
 (0)