-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathindex.js
More file actions
197 lines (188 loc) · 9.33 KB
/
index.js
File metadata and controls
197 lines (188 loc) · 9.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import React, { useState } from 'react';
// material-ui
import { makeStyles } from '@material-ui/styles';
import { Avatar, Box, ButtonBase, Card, CardContent, Grid, InputAdornment, OutlinedInput, Popper } from '@material-ui/core';
// third-party
import PopupState, { bindPopper, bindToggle } from 'material-ui-popup-state';
// project imports
import Transitions from '../../../../ui-component/extended/Transitions';
// assets
import { IconAdjustmentsHorizontal, IconSearch, IconX } from '@tabler/icons';
// style constant
const useStyles = makeStyles((theme) => ({
searchControl: {
width: '434px',
margin: '0 16px',
paddingRight: '16px',
paddingLeft: '16px',
'& input': {
background: 'transparent !important',
paddingLeft: '5px !important'
},
[theme.breakpoints.down('lg')]: {
width: '250px'
},
[theme.breakpoints.down('md')]: {
width: '100%',
marginLeft: '4px',
background: '#fff'
}
},
startAdornment: {
fontSize: '1rem',
color: theme.palette.grey[500]
},
headerAvatar: {
...theme.typography.commonAvatar,
...theme.typography.mediumAvatar,
background: theme.palette.secondary.light,
color: theme.palette.secondary.dark,
'&:hover': {
background: theme.palette.secondary.dark,
color: theme.palette.secondary.light
}
},
closeAvatar: {
...theme.typography.commonAvatar,
...theme.typography.mediumAvatar,
background: theme.palette.orange.light,
color: theme.palette.orange.dark,
'&:hover': {
background: theme.palette.orange.dark,
color: theme.palette.orange.light
}
},
popperContainer: {
zIndex: 1100,
width: '99%',
top: '-55px !important',
padding: '0 12px',
[theme.breakpoints.down('sm')]: {
padding: '0 10px'
}
},
cardContent: {
padding: '12px !important'
},
card: {
background: '#fff',
[theme.breakpoints.down('sm')]: {
border: 0,
boxShadow: 'none'
}
}
}));
//-----------------------|| SEARCH INPUT ||-----------------------//
const SearchSection = () => {
const classes = useStyles();
const [value, setValue] = useState('');
return (
<React.Fragment>
<Box sx={{ display: { xs: 'block', md: 'none' } }}>
<PopupState variant="popper" popupId="demo-popup-popper">
{(popupState) => (
<React.Fragment>
<Box
sx={{
ml: 2
}}
>
<ButtonBase sx={{ borderRadius: '12px' }}>
<Avatar variant="rounded" className={classes.headerAvatar} {...bindToggle(popupState)}>
<IconSearch stroke={1.5} size="1.2rem" />
</Avatar>
</ButtonBase>
</Box>
<Popper {...bindPopper(popupState)} transition className={classes.popperContainer}>
{({ TransitionProps }) => (
<Transitions type="zoom" {...TransitionProps} sx={{ transformOrigin: 'center left' }}>
<Card className={classes.card}>
<CardContent className={classes.cardContent}>
<Grid container alignItems="center" justifyContent="space-between">
<Grid item xs>
<OutlinedInput
className={classes.searchControl}
id="input-search-header"
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Search"
startAdornment={
<InputAdornment position="start">
<IconSearch
stroke={1.5}
size="1rem"
className={classes.startAdornment}
/>
</InputAdornment>
}
endAdornment={
<InputAdornment position="end">
<ButtonBase sx={{ borderRadius: '12px' }}>
<Avatar variant="rounded" className={classes.headerAvatar}>
<IconAdjustmentsHorizontal stroke={1.5} size="1.3rem" />
</Avatar>
</ButtonBase>
<Box
sx={{
ml: 2
}}
>
<ButtonBase sx={{ borderRadius: '12px' }}>
<Avatar
variant="rounded"
className={classes.closeAvatar}
{...bindToggle(popupState)}
>
<IconX stroke={1.5} size="1.3rem" />
</Avatar>
</ButtonBase>
</Box>
</InputAdornment>
}
aria-describedby="search-helper-text"
inputProps={{
'aria-label': 'weight'
}}
/>
</Grid>
</Grid>
</CardContent>
</Card>
</Transitions>
)}
</Popper>
</React.Fragment>
)}
</PopupState>
</Box>
<Box sx={{ display: { xs: 'none', md: 'block' } }}>
<OutlinedInput
className={classes.searchControl}
id="input-search-header"
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Search"
startAdornment={
<InputAdornment position="start">
<IconSearch stroke={1.5} size="1rem" className={classes.startAdornment} />
</InputAdornment>
}
endAdornment={
<InputAdornment position="end">
<ButtonBase sx={{ borderRadius: '12px' }}>
<Avatar variant="rounded" className={classes.headerAvatar}>
<IconAdjustmentsHorizontal stroke={1.5} size="1.3rem" />
</Avatar>
</ButtonBase>
</InputAdornment>
}
aria-describedby="search-helper-text"
inputProps={{
'aria-label': 'weight'
}}
/>
</Box>
</React.Fragment>
);
};
export default SearchSection;