Skip to content

Commit ac605c4

Browse files
committed
fix: added navbar autocomplete
1 parent 3cc6f8f commit ac605c4

File tree

11 files changed

+45
-98
lines changed

11 files changed

+45
-98
lines changed

assets/jscpd-badge.svg

Lines changed: 2 additions & 2 deletions
Loading

k8s/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
description: A Helm chart for kube-ts-react-client
33
name: kube-ts-react-client
44
version: 1.0.0
5-
appVersion: 1.5.21
5+
appVersion: 1.5.23
66
home: https://cloud.docker.com/u/kubejs/repository/docker/kubejs/kube-ts-react-client
77
icon: https://avatars2.githubusercontent.com/u/47761918?s=200&v=4
88
sources:

k8s/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replicaCount: 2
66

77
image:
88
repository: kubejs/kube-ts-react-client
9-
tag: 1.5.21
9+
tag: 1.5.23
1010
pullPolicy: Always
1111
containerPort: 80
1212

src/atoms/Autocomplete/index.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,35 @@ function renderSuggestion(suggestionProps: any) {
9090
);
9191
}
9292

93-
let popperNode: any;
93+
type AutocompleteType = 'navbar' | 'heroContent';
94+
95+
const autocompleteOptions = {
96+
heroContent: {
97+
inputProps: {},
98+
},
99+
navbar: {
100+
inputProps: {
101+
style: {
102+
paddingBottom: '12px',
103+
paddingTop: '12px',
104+
},
105+
},
106+
},
107+
};
108+
109+
interface Options {
110+
readonly id: string;
111+
readonly type: AutocompleteType;
112+
}
94113

95-
const Autocomplete = () => {
114+
const Autocomplete = ({ id, type }: Options) => {
96115
const classes = useStyles();
97116

117+
const additionalOptions = autocompleteOptions[type];
118+
119+
// TODO: explore useRef, fix popper width
120+
let popperNode: any;
121+
98122
const [value, setValue] = useState('');
99123
const history = useHistory();
100124
const { courses, users } = useSelector((state: State) => state.autocomplete);
@@ -118,7 +142,7 @@ const Autocomplete = () => {
118142
item.type === 'course'
119143
? `/courses/${item.slug}`
120144
: `/instructors/${item.email}`;
121-
145+
setValue('');
122146
history.push(link);
123147
} else if (changes.hasOwnProperty('inputValue')) {
124148
setValue(changes.inputValue);
@@ -128,11 +152,7 @@ const Autocomplete = () => {
128152

129153
return (
130154
<div className={classes.root}>
131-
<Downshift
132-
id="downshift-popper"
133-
selectedItem={value}
134-
onStateChange={handleChange}
135-
>
155+
<Downshift id={id} selectedItem={value} onStateChange={handleChange}>
136156
{({
137157
clearSelection,
138158
getInputProps,
@@ -145,6 +165,7 @@ const Autocomplete = () => {
145165
}) => {
146166
const { onBlur, onFocus, ...inputProps } = getInputProps({
147167
placeholder: 'What would you like to learn?',
168+
...additionalOptions.inputProps,
148169
});
149170

150171
return (

src/atoms/Autocomplete/styles.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const useStyles = makeStyles((theme: Theme) => ({
1717
},
1818
icon: {
1919
alignItems: 'center',
20+
color: '#000',
2021
display: 'flex',
2122
height: '100%',
2223
justifyContent: 'center',
@@ -41,11 +42,9 @@ const useStyles = makeStyles((theme: Theme) => ({
4142
marginTop: theme.spacing(1),
4243
position: 'absolute',
4344
right: 0,
44-
zIndex: 1,
4545
},
4646
root: {
4747
flexGrow: 1,
48-
height: 250,
4948
},
5049
}));
5150

src/atoms/SearchBox/index.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/atoms/SearchBox/styles.ts

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/components/HeroContent/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const HeroContent = () => {
3434
Find any course and topic and start learning today.
3535
</Typography>
3636
<div className={classes.searchBox}>
37-
<Autocomplete />
37+
<Autocomplete id="heroContent" type="heroContent" />
3838
</div>
3939
</Grid>
4040
</Container>

src/components/HeroContent/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const useStyles = makeStyles((theme: Theme) => ({
1616
flexGrow: 1,
1717
},
1818
searchBox: {
19-
19+
height: '250px',
2020
}
2121
}));
2222

src/components/NavBar/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import MoreIcon from '@material-ui/icons/MoreVert';
77
import clsx from 'clsx';
88
import React from 'react';
99
import { Link } from 'react-router-dom';
10+
import Autocomplete from '../../atoms/Autocomplete';
1011
import LogoutButton from '../../atoms/LogoutButton';
11-
import SearchBox from '../../atoms/SearchBox';
1212
import { LOGIN, REGISTER } from '../../constants/routes';
1313
// source: https://www.freepik.com
1414
import Logo from '../../images/logo.svg';
@@ -83,7 +83,9 @@ const NavBar = ({ handleSidebarOpen, open }: any) => {
8383
<img className={classes.logo} src={Logo} /> Kudemy
8484
</Button>
8585

86-
<SearchBox />
86+
<div className={classes.searchBox}>
87+
<Autocomplete id="navbar" type="navbar" />
88+
</div>
8789

8890
<div className={classes.grow} />
8991

0 commit comments

Comments
 (0)