Skip to content

Commit

Permalink
teacher tool: initial homescreen (#9863)
Browse files Browse the repository at this point in the history
* initial home screen

* use swiper

* refine swiper

* errant imports

* eslint

* update constants

* strings

* lint!

* unify ticks

* tidy

* cleanup imports

* remove a tick

* tweak opacity

* rename handler

* tidy splitpane

* prettier

* newline removal

* extract strings

* w -> o

* remove debug border

* remove extra div

* simplify toast styling hook

* restore css

* remove `fromUserInteraction`
  • Loading branch information
eanders-ms authored Feb 12, 2024
1 parent 38ed80e commit 12b273d
Show file tree
Hide file tree
Showing 39 changed files with 600 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,7 @@ module.exports = {
"@microsoft/sdl/react-iframe-missing-sandbox": "error",
"@typescript-eslint/no-implied-eval": "error",
"react/no-danger": "error",
"import/no-unassigned-import": "off",
"import/no-internal-modules": "off",
}
};
59 changes: 59 additions & 0 deletions teachertool/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions teachertool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"nanoid": "^4.0.2",
"react-scripts": "5.0.1",
"sass": "^1.70.0",
"swiper": "^8.4.4",
"tslib": "^2.6.2",
"typescript": "^4.6.4"
},
Expand Down
7 changes: 6 additions & 1 deletion teachertool/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export const App = () => {
await tryLoadLastActiveRubricAsync();

// Test notification
showToast(makeToast("success", "🎓", 2000));
showToast({
...makeToast("success", "🎓", 2000),
hideIcon: true,
hideDismissBtn: true,
className: "app-large-toast",
});

setInited(true);
logDebug("App initialized");
Expand Down
39 changes: 33 additions & 6 deletions teachertool/src/components/HeaderBar.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
import * as React from "react";
// eslint-disable-next-line import/no-internal-modules
import { useContext } from "react";
import css from "./styling/HeaderBar.module.scss";
import { Button } from "react-common/components/controls/Button";
import { MenuBar } from "react-common/components/controls/MenuBar";
import { AppStateContext } from "../state/appStateContext";
import { getSafeRubricName } from "../state/helpers";
import { Ticks } from "../constants";

interface HeaderBarProps {}

export const HeaderBar: React.FC<HeaderBarProps> = () => {
const { state: teacherTool } = useContext(AppStateContext);

const appTheme = pxt.appTarget?.appTheme;

const brandIconClick = () => {};
const onBrandIconClick = () => {
pxt.tickEvent(Ticks.BrandLink);
if (appTheme?.logoUrl) {
window.open(appTheme.logoUrl);
}
};

const onOrgClick = () => {
pxt.tickEvent(Ticks.OrgLink);
if (appTheme?.organizationUrl) {
window.open(appTheme.organizationUrl);
}
};

const getOrganizationLogo = () => {
return (
<div className={css["org"]}>
<div className={css["org"]} onClick={onOrgClick}>
{appTheme.organizationWideLogo || appTheme.organizationLogo ? (
<img
className={css["logo"]}
Expand All @@ -33,7 +50,7 @@ export const HeaderBar: React.FC<HeaderBarProps> = () => {
className={css["brand"]}
aria-label={lf("{0} Logo", appTheme.boardName)}
role="menuitem"
onClick={brandIconClick}
onClick={onBrandIconClick}
>
{appTheme.useTextLogo ? (
[
Expand All @@ -57,8 +74,17 @@ export const HeaderBar: React.FC<HeaderBarProps> = () => {
);
};

const getRubricName = (): JSX.Element | null => {
const rubricName = getSafeRubricName(teacherTool);
return rubricName ? (
<div className={css["rubric-name"]}>
<span>{rubricName}</span>
</div>
) : null;
};

const onHomeClicked = () => {
pxt.tickEvent("teacherTool.home");
pxt.tickEvent(Ticks.HomeLink);

// relprefix looks like "/beta---", need to chop off the hyphens and slash
let rel = pxt.webConfig?.relprefix.substr(0, pxt.webConfig.relprefix.length - 3);
Expand All @@ -77,13 +103,14 @@ export const HeaderBar: React.FC<HeaderBarProps> = () => {
<div className={css["left-menu"]}>
{getOrganizationLogo()}
{getTargetLogo()}
{getRubricName()}
</div>

<div className={css["right-menu"]}>
<Button
className="menu-button"
leftIcon="fas fa-home large"
title={lf("Return to the editor homepage")}
title={lf("Open the MakeCode editor")}
onClick={onHomeClicked}
/>
</div>
Expand Down
122 changes: 122 additions & 0 deletions teachertool/src/components/HomeScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import * as React from "react";
import css from "./styling/HomeScreen.module.scss";
import { Link } from "react-common/components/controls/Link";
import { Button } from "react-common/components/controls/Button";
import { classList } from "react-common/components/util";
import { showModal } from "../transforms/showModal";
import { resetRubricAsync } from "../transforms/resetRubricAsync";
import { Constants, Strings, Ticks } from "../constants";
import { Swiper, SwiperSlide } from "swiper/react";
import { Mousewheel, Navigation } from "swiper";

import "swiper/scss";
import "swiper/scss/navigation";
import "swiper/scss/mousewheel";

const Welcome: React.FC = () => {
return (
<div className={css.welcome}>
<h1>{lf("Welcome to MakeCode Project Insights!")}</h1>
<p>
{lf("This tool is designed to help you evaluate student projects using a rubric.")}{" "}
<Link target="_blank" href={Constants.LearnMoreLink}>
{lf("Learn More.")}
</Link>
</p>
</div>
);
};

interface CardProps {
title: string;
className?: string;
icon?: string;
onClick: () => void;
}

const Card: React.FC<CardProps> = ({ title, className, icon, onClick }) => {
return (
<div className={css.cardContainer}>
<Button className={classList(css.cardButton, className)} title={title} onClick={onClick}>
<div className={css.cardDiv}>
{icon && (
<div className={css.cardIcon}>
<i className={icon}></i>
</div>
)}
<div className={css.cardTitle}>
<h3>{title}</h3>
</div>
</div>
</Button>
</div>
);
};

interface CarouselProps extends React.PropsWithChildren<{}> {}

const Carousel: React.FC<CarouselProps> = ({ children }) => {
const cards = React.Children.toArray(children);

return (
<Swiper
spaceBetween={0}
slidesPerView={"auto"}
allowTouchMove={true}
slidesOffsetBefore={32}
navigation={true}
mousewheel={true}
modules={[Navigation, Mousewheel]}
className={css.swiperCarousel}
>
{cards.map((card, index) => (
<SwiperSlide key={index} className={css.swiperSlide}>
{card}
</SwiperSlide>
))}
</Swiper>
);
};

const GetStarted: React.FC = () => {
const onNewRubricClickedAsync = async () => {
pxt.tickEvent(Ticks.NewRubric);
await resetRubricAsync();
};

const onImportRubricClicked = () => {
pxt.tickEvent(Ticks.ImportRubric);
showModal("import-rubric");
};

return (
<div className={css.carouselRow}>
<div className={css.rowTitle}>
<h2>{lf("Get Started")}</h2>
</div>
<Carousel>
<Card
title={Strings.NewRubric}
icon={"fas fa-plus-circle"}
className={css.newRubric}
onClick={onNewRubricClickedAsync}
/>
<Card
title={Strings.ImportRubric}
icon={"fas fa-file-upload"}
className={css.importRubric}
onClick={onImportRubricClicked}
/>
</Carousel>
</div>
);
};

export const HomeScreen: React.FC = () => {
return (
<div className={css.page}>
<Welcome />
<GetStarted />
</div>
);
};
1 change: 0 additions & 1 deletion teachertool/src/components/ImportRubricModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useContext, useEffect, useState } from "react";
import { AppStateContext } from "../state/appStateContext";
import { Modal } from "react-common/components/controls/Modal";
import { hideModal } from "../transforms/hideModal";
// eslint-disable-next-line import/no-internal-modules
import css from "./styling/ImportRubricModal.module.scss";
import { getRubricFromFileAsync } from "../transforms/getRubricFromFileAsync";
import { NoticeLabel } from "./NoticeLabel";
Expand Down
20 changes: 7 additions & 13 deletions teachertool/src/components/MainPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as React from "react";
// eslint-disable-next-line import/no-internal-modules
import css from "./styling/MainPanel.module.scss";

import { MakeCodeFrame } from "./MakecodeFrame";
import { SplitPane } from "./SplitPane";
import { RubricWorkspace } from "./RubricWorkspace";
import { ProjectWorkspace } from "./ProjectWorkspace";
Expand All @@ -12,16 +9,13 @@ interface IProps {}
export const MainPanel: React.FC<IProps> = () => {
return (
<div className={css["main-panel"]}>
<SplitPane split={"vertical"} defaultSize={"80%"} primary={"left"}>
{/* Left side */}
<>
<RubricWorkspace />
</>
{/* Right side */}
<>
<ProjectWorkspace />
</>
</SplitPane>
<SplitPane
split={"vertical"}
defaultSize={"80%"}
primary={"left"}
left={<RubricWorkspace />}
right={<ProjectWorkspace />}
/>
</div>
);
};
2 changes: 0 additions & 2 deletions teachertool/src/components/MakecodeFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/// <reference path="../../../localtypings/pxteditor.d.ts" />

// eslint-disable-next-line import/no-internal-modules
import css from "./styling/MakeCodeFrame.module.scss";

import { useContext, useEffect } from "react";
import { clearReady, setEditorRef } from "../services/makecodeEditorService";
import { AppStateContext } from "../state/appStateContext";
Expand Down
Loading

0 comments on commit 12b273d

Please sign in to comment.