Skip to content

Commit

Permalink
split out add notes button, added input for notes
Browse files Browse the repository at this point in the history
  • Loading branch information
srietkerk committed Feb 28, 2024
1 parent 5905c08 commit 05a48fb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
49 changes: 40 additions & 9 deletions teachertool/src/components/EvalResultDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from "react";
import { useContext } from "react";
import { useState, useContext } from "react";
import css from "./styling/EvalResultDisplay.module.scss";
import { AppStateContext } from "../state/appStateContext";
import { getCatalogCriteriaWithId } from "../state/helpers";
import { CriteriaEvaluationResult } from "../types/criteria";
import { classList } from "react-common/components/util";
import { Button } from "react-common/components/controls/Button";
import { Strings } from "../constants";
import { Strings, Ticks } from "../constants";
import { Input } from "react-common/components/controls/Input";


const ResultsHeader: React.FC = () => {
Expand All @@ -25,13 +26,48 @@ const ResultsHeader: React.FC = () => {
);
};

interface AddNotesButtonProps {
criteriaId: string;
setShowInput: (show: boolean) => void;
}

const AddNotesButton: React.FC<AddNotesButtonProps> = ({ criteriaId, setShowInput }) => {
const onAddNotesClicked = async () => {
pxt.tickEvent(Ticks.AddResultNotes, { criteriaId });
setShowInput(true);
};
return (
<Button
className={classList("inline", "add-button")}
label={Strings.AddNotes}
onClick={onAddNotesClicked}
title={Strings.AddNotes}
leftIcon="fas fa-plus-circle"
/>
);
}

const CriteriaResultNotes: React.FC<{}> = () => {
return (
<div>
<Input
placeholder={lf("Write your notes here")}
ariaLabel={lf("Notes regarding the criteria result")}
preserveValueOnBlur={true}
autoComplete={false}
/>
</div>
)
}

interface CriteriaResultProps {
criteriaId: string;
result: CriteriaEvaluationResult;
label: string;
}

const CriteriaResult: React.FC<CriteriaResultProps> = ({ criteriaId, result, label }) => {
const [showInput, setShowInput] = useState(false);
return (
<div className={css["result-block-id"]} key={criteriaId}>
<p className={css["block-id-label"]}>
Expand All @@ -47,13 +83,8 @@ const CriteriaResult: React.FC<CriteriaResultProps> = ({ criteriaId, result, lab
{result === CriteriaEvaluationResult.Pass && (
<p className={css["positive-text"]}>{lf("Looks Good!")}</p>
)}
<Button
className={classList("inline", "add-button")}
label={Strings.AddNotes}
onClick={() => console.log("Add notes getting clicked")}
title={Strings.AddNotes}
leftIcon="fas fa-plus-circle"
/>
{!showInput && <AddNotesButton criteriaId={criteriaId} setShowInput={setShowInput} />}
{showInput && <CriteriaResultNotes />}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions teachertool/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export namespace Ticks {
export const Autorun = "teachertool.autorun";
export const AddCriteria = "teachertool.addcriteria";
export const RemoveCriteria = "teachertool.removecriteria";
export const AddResultNotes = "teachertool.addresultnotes";
}

namespace Misc {
Expand Down

0 comments on commit 05a48fb

Please sign in to comment.