Skip to content

Commit ae14c3b

Browse files
authored
Merge pull request #113 from kube-js/develop
fix: changed course view
2 parents 81a0d57 + d30c172 commit ae14c3b

File tree

31 files changed

+293
-313
lines changed

31 files changed

+293
-313
lines changed

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.6.0
5+
appVersion: 1.6.1
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.6.0
9+
tag: 1.6.1
1010
pullPolicy: Always
1111
containerPort: 80
1212

src/atoms/Autocomplete/index.tsx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Paper from '@material-ui/core/Paper';
44
import Popper from '@material-ui/core/Popper';
55
import TextField from '@material-ui/core/TextField';
66
import CloseIcon from '@material-ui/icons/Close';
7+
import OndemandVideoOutlinedIcon from '@material-ui/icons/OndemandVideoOutlined';
8+
import PersonOutlineOutlinedIcon from '@material-ui/icons/PersonOutlineOutlined';
79
import SearchIcon from '@material-ui/icons/Search';
810
import Downshift from 'downshift';
911
import _isNil from 'ramda/src/isNil';
@@ -22,6 +24,9 @@ export interface GetFormattedResultsOptions {
2224
readonly users: User[];
2325
}
2426

27+
const USERS_RESULT_COUNT = 2;
28+
const COURSES_RESULT_COUNT = 4;
29+
2530
const getFormattedResults = ({
2631
courses,
2732
users,
@@ -32,7 +37,7 @@ const getFormattedResults = ({
3237
label: course.title,
3338
type: 'course',
3439
}))
35-
.slice(0, 4);
40+
.slice(0, COURSES_RESULT_COUNT);
3641
const updatedUsers = users
3742
.map((user: User) => ({
3843
...user,
@@ -41,7 +46,7 @@ const getFormattedResults = ({
4146
: user.email,
4247
type: 'user',
4348
}))
44-
.slice(0, 2);
49+
.slice(0, USERS_RESULT_COUNT);
4550

4651
return [...updatedCourses, ...updatedUsers];
4752
};
@@ -65,7 +70,7 @@ function renderInput(inputProps: any) {
6570
);
6671
}
6772

68-
function renderSuggestion(suggestionProps: any) {
73+
const renderSuggestion = (suggestionProps: any) => {
6974
const {
7075
suggestion,
7176
index,
@@ -75,21 +80,27 @@ function renderSuggestion(suggestionProps: any) {
7580
} = suggestionProps;
7681
const isHighlighted = highlightedIndex === index;
7782
const isSelected = (selectedItem || '').indexOf(suggestion.label) > -1;
83+
const otherProps = isSelected
84+
? {
85+
style: {
86+
fontWeight: isSelected ? 600 : 400,
87+
},
88+
}
89+
: {};
90+
const icon = suggestion.type === 'course' ? <OndemandVideoOutlinedIcon /> : <PersonOutlineOutlinedIcon />;
7891

7992
return (
8093
<MenuItem
8194
{...itemProps}
8295
key={suggestion.label}
8396
selected={isHighlighted}
8497
component="div"
85-
style={{
86-
fontWeight: isSelected ? 500 : 400,
87-
}}
98+
{...otherProps}
8899
>
89-
{suggestion.label}
100+
<>{icon} <span style={{marginLeft: '5px'}}>{suggestion.label}</span></>
90101
</MenuItem>
91102
);
92-
}
103+
};
93104

94105
type AutocompleteType = 'navbar' | 'heroContent';
95106

@@ -144,8 +155,10 @@ const Autocomplete = ({ id, type }: Options) => {
144155
const link =
145156
item.type === 'course'
146157
? `/courses/${item.slug}`
147-
// TODO: create username property as uniq db field
148-
: `/instructors/${String(item.firstName + item.lastName).toLowerCase()}`;
158+
: // TODO: create username property as uniq db field
159+
`/instructors/${String(
160+
item.firstName + item.lastName
161+
).toLowerCase()}`;
149162
setValue('');
150163
history.push(link);
151164
} else if (changes.hasOwnProperty('inputValue')) {
@@ -183,7 +196,7 @@ const Autocomplete = ({ id, type }: Options) => {
183196
classes,
184197
fullWidth: true,
185198
inputProps,
186-
ref: popperNode
199+
ref: popperNode,
187200
})}
188201
{String(inputProps.value).length > 0 && (
189202
<div className={[classes.icon, classes.closeIcon].join(' ')}>
@@ -200,7 +213,10 @@ const Autocomplete = ({ id, type }: Options) => {
200213
square
201214
style={{
202215
marginTop: '4px',
203-
width: popperNode.current && popperNode.current.clientWidth ? popperNode.current.clientWidth - POPPER_OFFSET : undefined,
216+
width:
217+
popperNode.current && popperNode.current.clientWidth
218+
? popperNode.current.clientWidth - POPPER_OFFSET
219+
: undefined,
204220
}}
205221
>
206222
{results.map((suggestion: any, index: number) =>
@@ -221,7 +237,6 @@ const Autocomplete = ({ id, type }: Options) => {
221237
</Downshift>
222238
</div>
223239
);
224-
// tslint:disable-next-line:max-file-line-count
225240
};
226241

227242
// tslint:disable-next-line:max-file-line-count

src/atoms/CourseMetaInfo/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Typography } from '@material-ui/core';
22
import React from 'react';
3+
import { useTranslation } from 'react-i18next';
34
import { EnhancedCourse } from '../../redux/discoveryItems/actionCreators';
45
import CourseRating from '../CourseRating';
56
import useStyles from './styles';
@@ -10,6 +11,7 @@ export interface Options {
1011

1112
const CourseMetaInfo = ({ course }: Options) => {
1213
const classes = useStyles();
14+
const { t } = useTranslation();
1315
// TODO: get the real value
1416
const courseRating = 3.5;
1517
const courseLabel = `${courseRating} (1132 ratings)`;
@@ -23,7 +25,7 @@ const CourseMetaInfo = ({ course }: Options) => {
2325
<CourseRating value={courseRating} label={courseLabel} />
2426

2527
<Typography variant="h3" className={classes.autorInfo}>
26-
Instructor: {course.user.firstName} {course.user.lastName}
28+
{t('courseView.instructor')}: {course.user.firstName} {course.user.lastName}
2729
</Typography>
2830

2931
</div>

src/atoms/CourseSection/index.tsx

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import MuiExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
55
import MuiExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
66
import { withStyles } from '@material-ui/core/styles';
77
import Typography from '@material-ui/core/Typography';
8+
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
9+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
810
import PlayCircleOutlineIcon from '@material-ui/icons/PlayCircleOutline';
911
import React from 'react';
1012
import Section from '../../types/items/Section';
@@ -18,7 +20,7 @@ const ExpansionPanel = withStyles({
1820
display: 'none',
1921
},
2022
'&:not(:last-child)': {
21-
borderBottom: 0,
23+
margin: '12px 0',
2224
},
2325
border: '1px solid rgba(0, 0, 0, .125)',
2426
expanded: {},
@@ -27,25 +29,24 @@ const ExpansionPanel = withStyles({
2729

2830
const ExpansionPanelSummary = withStyles({
2931
content: {
30-
'&$expanded': {
31-
margin: '12px 0',
32-
},
32+
margin: '12px 0',
3333
},
3434
expanded: {},
3535
root: {
3636
'&$expanded': {
3737
minHeight: 56,
3838
},
39+
alignItems: 'center',
3940
backgroundColor: 'rgba(0, 0, 0, .03)',
4041
borderBottom: '1px solid rgba(0, 0, 0, .125)',
41-
marginBottom: -1,
42+
display: 'flex',
4243
minHeight: 56,
4344
},
4445
})(MuiExpansionPanelSummary);
4546

4647
const ExpansionPanelDetails = withStyles(theme => ({
4748
root: {
48-
padding: theme.spacing(2),
49+
padding: theme.spacing(1),
4950
},
5051
}))(MuiExpansionPanelDetails);
5152

@@ -62,40 +63,46 @@ interface Options {
6263
) => void;
6364
}
6465

65-
const CourseSection = ({ section, expandedIds, onChange }: Options) => (
66-
<ExpansionPanel
67-
square
68-
expanded={expandedIds.includes(section.id)}
69-
onChange={onChange}
70-
>
71-
<ExpansionPanelSummary
72-
aria-controls={`panel-${section.id}-content`}
73-
id={`panel-header-${section.id}`}
66+
const CourseSection = ({ section, expandedIds, onChange }: Options) => {
67+
const expanded = expandedIds.includes(section.id);
68+
69+
return (
70+
<ExpansionPanel
71+
square
72+
elevation={0}
73+
expanded={expanded}
74+
onChange={onChange}
7475
>
75-
<Typography>{section.title}</Typography>
76-
</ExpansionPanelSummary>
77-
<ExpansionPanelDetails>
78-
<List
79-
component="nav"
80-
/** TODO: move to classes */
81-
style={{
82-
backgroundColor: '#fff',
83-
width: '100%',
84-
}}
85-
aria-label="mailbox folders"
76+
<ExpansionPanelSummary
77+
aria-controls={`panel-${section.id}-content`}
78+
id={`panel-header-${section.id}`}
8679
>
87-
{section.units.map((unit: Unit, index: number) => (
88-
<ListItem key={index} divider={section.units.length - 1 !== index}>
89-
<>
90-
<PlayCircleOutlineIcon style={{marginRight: '1rem'}} />
91-
<ListItemText primary={unit.title}></ListItemText>
92-
</>
93-
</ListItem>
94-
))}
95-
</List>
96-
</ExpansionPanelDetails>
97-
</ExpansionPanel>
98-
);
80+
{expanded ? <ExpandLessIcon /> : <ExpandMoreIcon />}
81+
<Typography style={{marginLeft: '10px'}}>{section.title}</Typography>
82+
</ExpansionPanelSummary>
83+
<ExpansionPanelDetails>
84+
<List
85+
component="nav"
86+
/** TODO: move to classes */
87+
style={{
88+
backgroundColor: '#fff',
89+
width: '100%',
90+
}}
91+
aria-label="course section"
92+
>
93+
{section.units.map((unit: Unit, index: number) => (
94+
<ListItem key={index} divider={section.units.length - 1 !== index}>
95+
<>
96+
<PlayCircleOutlineIcon style={{ marginRight: '1rem' }} />
97+
<ListItemText primary={unit.title}></ListItemText>
98+
</>
99+
</ListItem>
100+
))}
101+
</List>
102+
</ExpansionPanelDetails>
103+
</ExpansionPanel>
104+
);
105+
};
99106

100107
// tslint:disable-next-line:max-file-line-count
101108
export default CourseSection;

src/atoms/CourseSections/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ interface Options {
77
}
88

99
const CourseSections = ({ sections }: Options) => {
10+
const sortedSections = sections.sort((x: Section, y: Section) => x.order - y.order);
11+
1012
const [expandedIds, setExpandedIds] = React.useState<string[]>([
11-
sections[0].id,
13+
sortedSections[0].id,
1214
]);
1315

1416
const handleChange = (panelId: string) => (
@@ -24,8 +26,6 @@ const CourseSections = ({ sections }: Options) => {
2426
}
2527
};
2628

27-
const sortedSections = sections.sort((x: Section, y: Section) => x.order - y.order);
28-
2929
return (
3030
<div>
3131
{sortedSections.map(section => (

src/atoms/LanguageDropdown/index.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ const StyledMenuItem = withStyles(theme => ({
4040
},
4141
}))(MenuItem);
4242

43-
const langLabels: {[keyof: string]: string} = {
43+
const langLabels: { [keyof: string]: string } = {
4444
'en-GB': 'English',
45-
'pl-PL': 'Polski'
46-
}
45+
'pl-PL': 'Polski',
46+
};
4747

48-
export default function LanguageDropdown() {
48+
const LanguageDropdown = () => {
4949
// TODO: refactor component
5050
const [anchorEl, setAnchorEl] = React.useState(null);
5151

@@ -56,26 +56,29 @@ export default function LanguageDropdown() {
5656
const handleClose = () => {
5757
setAnchorEl(null);
5858
};
59-
59+
6060
const { i18n } = useTranslation();
6161

62-
const currentLang = (Array.isArray(i18n.languages)) ? i18n.languages[0] : i18n.languages;
62+
const currentLang = Array.isArray(i18n.languages)
63+
? i18n.languages[0]
64+
: i18n.languages;
6365

6466
const changeLanguage = (lng: string) => {
6567
i18n.changeLanguage(lng);
6668
setAnchorEl(null);
6769
};
6870

6971
return (
70-
<div style={{display: 'flex', alignItems: 'center'}}>
72+
<div style={{ display: 'flex', alignItems: 'center' }}>
7173
<Button
7274
aria-controls="customized-menu"
7375
aria-haspopup="true"
74-
variant="contained"
75-
color="primary"
76+
variant="outlined"
77+
color="inherit"
7678
onClick={handleClick}
7779
>
78-
<LanguageIcon style={{marginRight: '5'}} /> {langLabels[currentLang]} <ExpandMoreIcon style={{marginLeft: '5'}} />
80+
<LanguageIcon style={{ marginRight: '5' }} /> {langLabels[currentLang]}{' '}
81+
<ExpandMoreIcon style={{ marginLeft: '5' }} />
7982
</Button>
8083
<StyledMenu
8184
id="customized-menu"
@@ -93,4 +96,7 @@ export default function LanguageDropdown() {
9396
</StyledMenu>
9497
</div>
9598
);
96-
}
99+
};
100+
101+
// tslint:disable-next-line:max-file-line-count
102+
export default LanguageDropdown;

0 commit comments

Comments
 (0)