Skip to content
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

Mobile redesign for professor-specific pages and overall app components #816

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/app/components/Nav/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ const RightMenu = styled.div`
`;

const BarsMenu = styled(Button)`
height: 32px;
height: 30px;
padding: 6px;
margin-top: 8px;
display: none;
background: none;

Expand All @@ -80,9 +79,10 @@ const BarsMenu = styled(Button)`
`;

const BarsButton = styled.span`
display: block;
vertical-align: middle;
width: 20px;
height: 2px;
margin-bottom: 5px;
background: #1890ff;
position: relative;

Expand Down
131 changes: 76 additions & 55 deletions packages/app/components/Nav/ProfileDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,32 @@ import {
import { Menu, Popover } from "antd";
import Link from "next/link";
import React, { ReactElement, useState } from "react";
import { useIsMobile } from "../../hooks/useIsMobile";
import styled from "styled-components";
import SelfAvatar from "../common/SelfAvatar";

const { SubMenu } = Menu;

const StyleablePopover = ({ className, ...props }: { className: string }) => (
<Popover {...props} overlayClassName={className} />
);

const StyleableSubMenu = ({ className, ...props }: { className: string }) => (
<SubMenu {...props} popupClassName={className} />
);

const NoPaddingPopover: typeof Popover = styled(StyleablePopover)`
& .ant-popover-inner-content {
padding: 0px;
}
`;

const NoPaddingSubMenu: typeof SubMenu = styled(StyleableSubMenu)`
& .ant-menu-submenu-title {
padding: 0px;
}
`;

const AvatarButton = styled.div`
cursor: pointer;
`;
Expand All @@ -32,64 +46,71 @@ export default function ProfileDrawer({
courseId,
}: ProfileDrawerProps): ReactElement {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const isMobile = useIsMobile();

return (
const renderMenuItems = () => (
<>
<NoPaddingPopover
content={
isPopoverOpen && (
<Menu mode="inline">
<Menu.Item icon={<SettingOutlined />}>
<Link
href={{ pathname: "/settings", query: { cid: courseId } }}
>
<a>Settings</a>
</Link>
</Menu.Item>
<Menu.Item
key="1"
icon={<QuestionCircleOutlined />}
onClick={() => {
window.open("https://info.khouryofficehours.com/help");
setIsPopoverOpen(false);
}}
>
Help Guide
</Menu.Item>
<Menu.Item
key="2"
icon={<FileTextOutlined />}
onClick={() => {
window.open(
"https://info.khouryofficehours.com/release-notes-archive"
);
setIsPopoverOpen(false);
}}
>
Release Notes
</Menu.Item>
<Menu.Item key="3" icon={<ReadOutlined />}>
<Link href={"/about"}>
<a>About Us</a>
</Link>
</Menu.Item>
<Menu.Item key="4" icon={<LogoutOutlined />}>
<Link href={"/api/v1/logout"}>
<a data-cy="logout-button">Logout</a>
</Link>
</Menu.Item>
</Menu>
)
}
placement="bottomRight"
trigger="click"
visible={isPopoverOpen}
onVisibleChange={setIsPopoverOpen}
<Menu.Item icon={<SettingOutlined />}>
<Link href={{ pathname: "/settings", query: { cid: courseId } }}>
<a>Settings</a>
</Link>
</Menu.Item>
<Menu.Item
key="1"
icon={<QuestionCircleOutlined />}
onClick={() => {
window.open("https://info.khouryofficehours.com/help");
}}
>
Help Guide
</Menu.Item>
<Menu.Item
key="2"
icon={<FileTextOutlined />}
onClick={() => {
window.open(
"https://info.khouryofficehours.com/release-notes-archive"
);
}}
>
<AvatarButton>
<SelfAvatar size={40} />
</AvatarButton>
</NoPaddingPopover>
Release Notes
</Menu.Item>
<Menu.Item key="3" icon={<ReadOutlined />}>
<Link href={"/about"}>
<a>About Us</a>
</Link>
</Menu.Item>
<Menu.Item key="4" icon={<LogoutOutlined />}>
<Link href={"/api/v1/logout"}>
<a data-cy="logout-button">Logout</a>
</Link>
</Menu.Item>
</>
);

return (
<>
{isMobile ? (
<Menu mode="inline">
<NoPaddingSubMenu title="Profile">
{renderMenuItems()}
</NoPaddingSubMenu>
</Menu>
) : (
<NoPaddingPopover
content={
isPopoverOpen && <Menu mode="inline">{renderMenuItems()}</Menu>
}
placement="bottomRight"
trigger="click"
visible={isPopoverOpen}
onVisibleChange={setIsPopoverOpen}
>
<AvatarButton>
<SelfAvatar size={40} />
</AvatarButton>
</NoPaddingPopover>
)}
</>
);
}
40 changes: 22 additions & 18 deletions packages/app/components/Settings/CourseAdminPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useRouter } from "next/router";
import React, { ReactElement, useState } from "react";
import styled from "styled-components";
import { useProfile } from "../../hooks/useProfile";
import ResponsiveRowCol from "../common/ResponsiveRowCol";
import CourseOverrideSettings from "./CourseOverrideSettings";
import { SettingsPanelAvatar } from "./SettingsSharedComponents";
import TACheckInCheckOutTimes from "./TACheckInCheckOutTimes";
Expand All @@ -29,7 +30,7 @@ const VerticalDivider = styled.div`
}
`;

const CenteredText = styled.p`
const CenteredText = styled.h2`
text-align: center;
`;

Expand All @@ -38,16 +39,19 @@ export default function CourseAdminPanel({
courseId,
}: CourseAdminPageProps): ReactElement {
const profile = useProfile();
const router = useRouter();

const [currentSettings, setCurrentSettings] = useState(
defaultPage || CourseAdminOptions.CHECK_IN
);

const router = useRouter();

return (
<Row>
<Col span={4} style={{ textAlign: "center" }}>
<SettingsPanelAvatar avatarSize={20} />
{/* { isMobile ?

: */}
<ResponsiveRowCol style={{ textAlign: "center" }}>
<SettingsPanelAvatar avatarSize={50} />
<CenteredText>
Welcome back
<br />
Expand All @@ -69,19 +73,19 @@ export default function CourseAdminPanel({
</Tooltip>
)}
</CenteredText>
<Menu
defaultSelectedKeys={[currentSettings]}
onClick={(e) => setCurrentSettings(e.key as CourseAdminOptions)}
style={{ background: "#f8f9fb", paddingTop: "20px" }}
>
<Menu.Item key={CourseAdminOptions.CHECK_IN} icon={<EditOutlined />}>
TA Check In/Out Times
</Menu.Item>
<Menu.Item key={CourseAdminOptions.OVERRIDES} icon={<BellOutlined />}>
Course Overrides
</Menu.Item>
</Menu>
</Col>
</ResponsiveRowCol>
<Menu
defaultSelectedKeys={[currentSettings]}
onClick={(e) => setCurrentSettings(e.key as CourseAdminOptions)}
style={{ background: "#f8f9fb", paddingTop: "20px" }}
>
<Menu.Item key={CourseAdminOptions.CHECK_IN} icon={<EditOutlined />}>
TA Check In/Out Times
</Menu.Item>
<Menu.Item key={CourseAdminOptions.OVERRIDES} icon={<BellOutlined />}>
Course Overrides
</Menu.Item>
</Menu>
<VerticalDivider />
<Space direction="vertical" size={40} style={{ flexGrow: 1 }}>
<Col span={20}>
Expand Down
12 changes: 4 additions & 8 deletions packages/app/components/Settings/ProfileSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { API } from "@koh/api-client";
import { UpdateProfileParams } from "@koh/common";
import { Button, Form, Input, message, Row } from "antd";
import { Button, Form, Input, message } from "antd";
import { pick } from "lodash";
import { useIsMobile } from "../../hooks/useIsMobile";
import { HeaderTitle } from "./Styled";
import styled from "styled-components";
import React, { ReactElement } from "react";
import useSWR from "swr";
import ResponsiveRowCol from "../common/ResponsiveRowCol";

export default function ProfileSettings(): ReactElement {
const { data: profile, mutate } = useSWR(`api/v1/profile`, async () =>
Expand All @@ -30,17 +30,13 @@ export default function ProfileSettings(): ReactElement {
message.success("Your profile settings have been successfully updated");
};

const ResponsiveFormRow = styled(Row)`
flexdirection: ${isMobile ? "column" : "row"};
`;

return profile ? (
<div>
<HeaderTitle>
<h1>Personal Information</h1>
</HeaderTitle>
<Form wrapperCol={{ span: 18 }} form={form} initialValues={profile}>
<ResponsiveFormRow>
<ResponsiveRowCol>
<Form.Item
label="First Name"
name="firstName"
Expand Down Expand Up @@ -68,7 +64,7 @@ export default function ProfileSettings(): ReactElement {
>
<Input />
</Form.Item>
</ResponsiveFormRow>
</ResponsiveRowCol>
</Form>
<Button
key="submit"
Expand Down
2 changes: 1 addition & 1 deletion packages/app/components/Settings/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function SettingsPage({
}
}}
>
Delete my Profile Picture
Remove photo
</ProfilePicButton>
)}
</Col>
Expand Down
8 changes: 7 additions & 1 deletion packages/app/components/common/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const FullWidth = styled.footer`

display: flex;
justify-content: space-between;

@media (max-width: 650px) {
flex-direction: column;
text-align: center;
align-items: center;
}
`;

export function Footer(): ReactElement {
Expand Down Expand Up @@ -59,7 +65,7 @@ export function Footer(): ReactElement {
);
}}
>
File a bug report
file a bug report
</a>
</div>
</FullWidth>
Expand Down
13 changes: 13 additions & 0 deletions packages/app/components/common/ResponsiveRowCol.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { ReactElement } from "react";
import { Row } from "antd";
import styled from "styled-components";
import { useIsMobile } from "../../hooks/useIsMobile";

export default function ResponsiveRowCol(): ReactElement {
const isMobile = useIsMobile();
const ResponsiveRowCol = styled(Row)`
flex-direction: ${isMobile ? "column" : "row"};
`;

return <ResponsiveRowCol />;
}
Loading