Skip to content

Display module title in timetable cell #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 14, 2018

Conversation

shanwpf
Copy link
Contributor

@shanwpf shanwpf commented Jan 12, 2018

Solves issue #677

Added a module title button beside the orientation button.
Had to make changes to the timetable actions button layout to accommodate the new button.
In vertical mode, module titles are not displayed and the button is disabled.

Screenshots

Horizontal mode single row

image

Horizontal mode 2 rows

image

Vertical mode

image

@mods-bot
Copy link

mods-bot commented Jan 12, 2018

Deploy preview for nusmods ready!

Built with commit bda98cc

https://deploy-preview-709--nusmods.netlify.com

Copy link
Member

@taneliang taneliang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! We have been getting many requests for this.

One small UI bug: the button texts overflow in vertical mode on portrait iPad.

@@ -125,10 +127,11 @@ export const defaultTimetableState: TimetablesState = {
colors: {},
hidden: {},
academicYear: config.academicYear,
titleDisplay: HIDE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this isn't a boolean? It seems like in the end it's assigned to a boolean prop in Timetable, and the toggling and checking code will be simpler.

Copy link
Member

@ZhangYiJiang ZhangYiJiang Jan 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is the wrong place for this data. Try putting it in theme or settings state instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taneliang I was referring to the orientation toggling code when I wrote this, so I thought it had to have it's own type. I've simplified it to a boolean.

@ZhangYiJiang Moved the data from timetables to theme

Copy link
Member

@ZhangYiJiang ZhangYiJiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Please update the test snapshots the export reducer (move the data to under settings or theme reducer first)

@@ -125,10 +127,11 @@ export const defaultTimetableState: TimetablesState = {
colors: {},
hidden: {},
academicYear: config.academicYear,
titleDisplay: HIDE,
Copy link
Member

@ZhangYiJiang ZhangYiJiang Jan 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is the wrong place for this data. Try putting it in theme or settings state instead

type="button"
className="btn btn-outline-primary btn-svg"
onClick={props.toggleTitleDisplay}
disabled={isVerticalOrientation}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to switch to outline-secondary or hide the button entirely when its disabled. Bootstrap's disabled style for outline buttons is not very noticeable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

onModifyCell?: Function,
};

function TimetableCell(props: Props) {
const lesson = props.lesson;
const moduleCodeWithTitle = `${lesson.ModuleCode} ${lesson.ModuleTitle}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just inline this - no need for another variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I wrote this because the linter was going crazy, and I didn't know how to format the ternary operator properly to avoid one long line. Anyway, I figured it out and fixed it.

@@ -39,7 +43,7 @@ function TimetableCell(props: Props) {
style={props.style}
>
<div className={styles.cellContainer}>
<div className={styles.moduleCode}>{lesson.ModuleCode}</div>
<div className={styles.moduleCode}>{moduleName}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also update this class name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

onClick={props.toggleTitleDisplay}
disabled={isVerticalOrientation}
>
<Sidebar className={styles.sidebarIcon} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This icon isn't appropriate. We may be able to get away with abusing the icon for credit cards, or find another one in Font Awesome or Icons8

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the type icon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the eye icon would fit in well. I've changed it to show the eye icon when titles are hidden, and the eye-off icon when titles are shown.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're already using the eye icon to hide modules though, and our horizontal/vertical mode icon is too similar to the credit card icon IMO. I think the type icon is probably the best choice here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've changed it to be the type icon.

@@ -9,11 +9,11 @@
$index: 0;

@each $color in $colors {

$index: $index + 1; /* stylelint-disable-line order/order */
Copy link
Member

@taneliang taneliang Jan 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the theme colours have been shifted by one and are therefore missing their first color. I may be wrong but I think it's because this line was moved

c75cc818-0c87-4638-9cd1-1078388c89c8

Copy link
Contributor Author

@shanwpf shanwpf Jan 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember changing that file, but it seems to be caused by incrementing $index before applying the colour at index 0. Fixed it.

@ZhangYiJiang
Copy link
Member

It's a StyleLint bug. Lines that are marked as ignore are only ignored for linting, not autofix.

@taneliang
Copy link
Member

taneliang commented Jan 13, 2018

2 UI issues:

  1. On portrait iPad, the first row buttons get squashed. The new button should probably have its own row, but I'm not sure if we should allocate that much space for a disabled button. effc5af6-55bf-4888-ad69-654646f1d92f
  2. Looks like the Type icon needs to be shrunk a little as it's making the buttons a bit taller.
    781b0d02-1e49-4635-8fcf-a456eb59bce6

Copy link
Member

@taneliang taneliang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Can also confirm that export works.
my timetable

- Update test (switch to non-default state for showTitle)
- Fix showTitle button styles and classnames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants