Skip to content

Commit

Permalink
extract strings
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Feb 12, 2024
1 parent a27188a commit 2f98d27
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
8 changes: 4 additions & 4 deletions teachertool/src/components/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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, { Ticks } from "../constants";
import { Constants, Strings, Ticks } from "../constants";
import { Swiper, SwiperSlide } from "swiper/react";
import { Mousewheel, Navigation } from "swiper";

Expand Down Expand Up @@ -60,7 +60,7 @@ const Carousel: React.FC<CarouselProps> = ({ children }) => {

return (
<Swiper
spaceBetween={10}
spaceBetween={0}
slidesPerView={"auto"}
allowTouchMove={true}
slidesOffsetBefore={32}
Expand Down Expand Up @@ -96,13 +96,13 @@ const GetStarted: React.FC = () => {
</div>
<Carousel>
<Card
title={lf("New Rubric")}
title={Strings.NewRubric}
icon={"fas fa-plus-circle"}
className={css.newRubric}
onClick={onNewRubricClickedAsync}
/>
<Card
title={lf("Import Rubric")}
title={Strings.ImportRubric}
icon={"fas fa-file-upload"}
className={css.importRubric}
onClick={onImportRubricClicked}
Expand Down
26 changes: 19 additions & 7 deletions teachertool/src/components/RubricWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { writeRubricToFile } from "../services/fileSystemService";
import { showModal } from "../transforms/showModal";
import { isProjectLoaded } from "../state/helpers";
import { setAutorun } from "../transforms/setAutorun";
import { Ticks } from "../constants";
import { Strings, Ticks } from "../constants";
import { resetRubricAsync } from "../transforms/resetRubricAsync";

function handleImportRubricClicked() {
pxt.tickEvent(Ticks.ImportRubric);
Expand All @@ -28,6 +29,11 @@ function handleExportRubricClicked() {
writeRubricToFile(teacherTool.rubric);
}

async function handleNewRubricClickedAsync() {
pxt.tickEvent(Ticks.NewRubric);
await resetRubricAsync(true);
}

async function handleEvaluateClickedAsync() {
pxt.tickEvent(Ticks.Evaluate);
await runEvaluateAsync(true);
Expand Down Expand Up @@ -70,15 +76,21 @@ function getActionMenuItems(tab: TabName): MenuItem[] {
case "rubric":
items.push(
{
title: lf("Import Rubric"),
label: lf("Import Rubric"),
ariaLabel: lf("Import Rubric"),
title: Strings.NewRubric,
label: Strings.NewRubric,
ariaLabel: Strings.NewRubric,
onClick: handleNewRubricClickedAsync,
},
{
title: Strings.ImportRubric,
label: Strings.ImportRubric,
ariaLabel: Strings.ImportRubric,
onClick: handleImportRubricClicked,
},
{
title: lf("Export Rubric"),
label: lf("Export Rubric"),
ariaLabel: lf("Export Rubric"),
title: Strings.ExportRubric,
label: Strings.ExportRubric,
ariaLabel: Strings.ExportRubric,
onClick: handleExportRubricClicked,
}
);
Expand Down
7 changes: 5 additions & 2 deletions teachertool/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ export namespace Strings {
export const ConfirmReplaceRubric = lf("This will replace your current rubric. Continue?");
export const UntitledProject = lf("Untitled Project");
export const UntitledRubric = lf("Untitled Rubric");
export const NewRubric = lf("New Rubric");
export const ImportRubric = lf("Import Rubric");
export const ExportRubric = lf("Export Rubric");
}

export namespace Ticks {
Expand All @@ -19,8 +22,8 @@ export namespace Ticks {
export const RemoveCriteria = "teachertool.removecriteria";
}

namespace Constants {
namespace Misc {
export const LearnMoreLink = "https://makecode.com/teachertool"; // TODO: Replace with gwlink or aka.ms link
}

export default Constants;
export const Constants = Object.assign(Misc, { Strings, Ticks });

0 comments on commit 2f98d27

Please sign in to comment.