Skip to content

Commit 5774b51

Browse files
authored
fix(planner): prevent overflow in planner module list (#3701)
* Make planner module lists scrollable * Allow horizontal scrolling on all elements with element shrinking * Fix capitalisation on courses * Fix lint issues * Capitalize "course" for planner year * Fix scss styles to use prettier * Ensure consistency in component naming and props
1 parent 7334b07 commit 5774b51

File tree

5 files changed

+56
-18
lines changed

5 files changed

+56
-18
lines changed

website/src/views/planner/PlannerContainer/PlannerContainer.scss

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@
1414
display: flex;
1515
justify-content: space-between;
1616
align-items: center;
17+
width: 100%;
18+
gap: 1rem;
1719

18-
h1 {
20+
.headerLeft {
1921
display: flex;
2022
align-items: center;
2123
margin: 0;
22-
font-size: $font-size-xlg;
24+
25+
h1 {
26+
font-size: $font-size-xlg;
27+
}
2328

2429
button {
2530
margin-left: 1rem;
@@ -33,11 +38,21 @@
3338
.headerRight {
3439
display: flex;
3540
align-items: center;
41+
width: 100%;
3642
}
3743

3844
.moduleStats {
45+
display: flex;
46+
flex-direction: row;
47+
flex-wrap: wrap;
3948
margin-right: 1rem;
49+
50+
p {
51+
white-space: nowrap;
52+
}
4053
}
54+
55+
@include scrollable;
4156
}
4257

4358
.addYearButton {
@@ -60,6 +75,9 @@
6075

6176
.moduleLists {
6277
display: flex;
78+
width: 100%;
79+
80+
@include scrollable;
6381
}
6482

6583
.modListHeaders {
@@ -71,6 +89,7 @@
7189
.trash {
7290
opacity: 0.6;
7391
width: $semester-width;
92+
min-width: $semester-width;
7493
border: 1px dashed;
7594
border-radius: 0.4rem;
7695
text-align: center;

website/src/views/planner/PlannerContainer/PlannerContainer.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { flatMap, flatten, sortBy, toPairs, values } from 'lodash';
44
import { DragDropContext, Droppable, OnDragEndResponder } from 'react-beautiful-dnd';
55
import classnames from 'classnames';
66

7-
import { Settings, Trash } from 'react-feather';
7+
import { Trash } from 'react-feather';
88
import { Module, ModuleCode, Semester } from 'types/modules';
99
import { PlannerModulesWithInfo, PlannerModuleInfo, AddModuleData } from 'types/planner';
1010
import { MODULE_CODE_REGEX, renderMCs, subtractAcadYear } from 'utils/modules';
@@ -30,6 +30,7 @@ import Title from 'views/components/Title';
3030
import LoadingSpinner from 'views/components/LoadingSpinner';
3131
import Modal from 'views/components/Modal';
3232
import { State as StoreState } from 'types/state';
33+
import PlannerSettingsButton from '../PlannerSettingsButton';
3334
import PlannerSemester from '../PlannerSemester';
3435
import PlannerYear from '../PlannerYear';
3536
import PlannerSettings from '../PlannerSettings';
@@ -140,29 +141,26 @@ export class PlannerContainerComponent extends PureComponent<Props, State> {
140141

141142
return (
142143
<header className={styles.header}>
143-
<h1>
144-
Course Planner{' '}
144+
<div className={styles.headerLeft}>
145+
<h1>Course Planner </h1>
145146
<button
146147
className="btn btn-sm btn-outline-success"
147148
type="button"
148149
onClick={this.props.toggleFeedback}
149150
>
150151
Beta - Send Feedback
151152
</button>
152-
</h1>
153+
</div>
153154

154155
<div className={styles.headerRight}>
155-
<p className={styles.moduleStats}>
156-
{count} {count === 1 ? 'course' : 'courses'} / {renderMCs(credits)}
157-
</p>
156+
<div className={styles.moduleStats}>
157+
<p>
158+
{count} {count === 1 ? 'Course' : 'Courses'}&nbsp;/&nbsp;
159+
</p>
160+
<p>{renderMCs(credits)}</p>
161+
</div>
158162

159-
<button
160-
className="btn btn-svg btn-outline-primary"
161-
type="button"
162-
onClick={() => this.setState({ showSettings: true })}
163-
>
164-
<Settings className="svg" /> Settings
165-
</button>
163+
<PlannerSettingsButton onClick={() => this.setState({ showSettings: true })} />
166164
</div>
167165
</header>
168166
);

website/src/views/planner/PlannerSemester.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function renderSemesterMeta(plannerModules: PlannerModuleInfo[]) {
3737
return (
3838
<div className={styles.semesterMeta}>
3939
<p>
40-
{plannerModules.length} {plannerModules.length === 1 ? 'course' : 'courses'}
40+
{plannerModules.length} {plannerModules.length === 1 ? 'Course' : 'Courses'}
4141
</p>
4242
<p>{renderMCs(moduleCredits)}</p>
4343
</div>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { Settings } from 'react-feather';
3+
import { breakpointDown } from 'utils/css';
4+
import useMediaQuery from 'views/hooks/useMediaQuery';
5+
6+
type Props = Readonly<{
7+
onClick: () => void;
8+
}>;
9+
10+
const PlannerSettingsButton: React.FC<Props> = ({ onClick }) => {
11+
const narrowViewport = useMediaQuery(breakpointDown('sm'));
12+
13+
return (
14+
<button className="btn btn-svg btn-outline-primary" type="button" onClick={onClick}>
15+
<Settings className="svg" />
16+
{narrowViewport ? '' : 'Settings'}
17+
</button>
18+
);
19+
};
20+
21+
export default PlannerSettingsButton;

website/src/views/planner/PlannerYear.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default class PlannerYear extends PureComponent<Props, State> {
5050
</h2>
5151
<div className={styles.yearMeta}>
5252
<p>
53-
{count} {count === 1 ? 'course' : 'courses'}
53+
{count} {count === 1 ? 'Course' : 'Courses'}
5454
</p>
5555
<p>{renderMCs(credits)}</p>
5656
</div>

0 commit comments

Comments
 (0)