-
Notifications
You must be signed in to change notification settings - Fork 580
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
teacher tool: add address bar #9839
Changes from 2 commits
763ab95
fe19910
4fc0d7b
5e9bbff
acc6df9
706b33f
fe42143
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from "react"; | ||
// eslint-disable-next-line import/no-internal-modules | ||
import css from "./styling/AddressBar.module.scss"; | ||
|
||
import { useContext, useState, useMemo, useCallback, useEffect } from "react"; | ||
import { AppStateContext } from "../state/appStateContext"; | ||
import { classList } from "react-common/components/util"; | ||
import { Input } from "react-common/components/controls/Input"; | ||
import { loadProjectMetadataAsync } from "../transforms/loadProjectMetadataAsync"; | ||
|
||
interface IProps { | ||
className?: string; | ||
} | ||
|
||
export const AddressBar: React.FC<IProps> = ({ className }) => { | ||
const { state: teacherTool } = useContext(AppStateContext); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason we wouldn't just name this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is a way of extracting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I'm following. Naming this projectMetadata would mean accessing the actual project metadata like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yeah, I was confused because the |
||
const { projectMetadata } = teacherTool; | ||
const [text, setText] = useState(""); | ||
const [iconVisible, setIconVisible] = useState(false); | ||
|
||
useEffect(() => { | ||
const shareId = pxt.Cloud.parseScriptId(text); | ||
setIconVisible(!!shareId && !(shareId === projectMetadata?.shortid || shareId === projectMetadata?.persistId)); | ||
}, [text, projectMetadata?.shortid, projectMetadata?.persistId]); | ||
|
||
const onTextChange = (str: string) => { | ||
setText(str); | ||
}; | ||
|
||
const onEnterKey = useCallback(() => { | ||
const shareId = pxt.Cloud.parseScriptId(text); | ||
if (!!shareId && !(shareId === projectMetadata?.shortid || shareId === projectMetadata?.persistId)) { | ||
loadProjectMetadataAsync(shareId); | ||
} | ||
}, [text, projectMetadata?.shortid, projectMetadata?.persistId]); | ||
|
||
const icon = useMemo(() => { | ||
return iconVisible ? "fas fa-arrow-right" : undefined; | ||
}, [iconVisible]); | ||
|
||
return ( | ||
<div className={classList(css["address-bar"], className)}> | ||
<Input | ||
placeholder={lf("Enter Project Link or Share ID")} | ||
ariaLabel={lf("Enter Project Link or Share ID")} | ||
icon={icon} | ||
onChange={onTextChange} | ||
onEnterKey={onEnterKey} | ||
preserveValueOnBlur={true} | ||
></Input> | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as React from "react"; | ||
// eslint-disable-next-line import/no-internal-modules | ||
import css from "./styling/ProjectWorkspace.module.scss"; | ||
|
||
import { Toolbar } from "./Toolbar"; | ||
import { AddressBar } from "./AddressBar"; | ||
import { MakeCodeFrame } from "./MakecodeFrame"; | ||
import { classes } from "../utils"; | ||
|
||
interface IProps {} | ||
|
||
export const ProjectWorkspace: React.FC<IProps> = () => { | ||
return ( | ||
<div className={classes(css, "panel", "h-full", "w-full", "flex", "flex-col")}> | ||
<Toolbar toolbarClass={css["grow-1"]}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is a placeholder, but I was wondering if the project view toggle we're going to fill in here is something we'll be able to do in v1? Is the toggle just so a teacher can look at a student's project in JavaScript? Would it be clear that they can't validate projects in JavaScript? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They actually can still validate a project even after switching to JS. It'll still validate the blocks, but it should all still work. It won't work well if a project was made in Javascript instead of blocks, but I think that's a different scenario. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm worried the toggle will give the impression that we support evaluating JavaScript-only projects, but this is an assumption. I imagine a scenario where a teacher sees the toggle, thinks "Oh, I can validate student projects in JavaScript, too", uploads a JavaScript-only project and then the evaluation doesn't work. But, if a teacher uploads a JavaScript project, that's something that we can know, right? And just error and tell the user "sorry, we cannot evaluate JavaScript-made projects at this time". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't worry about it too much for v1, but yes I think we can check the preferred editor and error if needed. I think there is value in having the toggle regardless, as one teacher did mention they like to switch to JS to search for things in the code, rather than scrolling through blocks, so there's a known use-case there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point Sarah. I'd like to leave this as an open design question for now. I'll add it to the work board to track. |
||
{/* Left */} | ||
<></> | ||
{/* Center */} | ||
<></> | ||
{/* Right */} | ||
<></> | ||
</Toolbar> | ||
<AddressBar className={css["grow-1"]} /> | ||
<MakeCodeFrame /> | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as React from "react"; | ||
// eslint-disable-next-line import/no-internal-modules | ||
import css from "./styling/RubricWorkspace.module.scss"; | ||
|
||
import { DebugInput } from "./DebugInput"; | ||
import { EvalResultDisplay } from "./EvalResultDisplay"; | ||
import { ActiveRubricDisplay } from "./ActiveRubricDisplay"; | ||
|
||
interface IProps {} | ||
|
||
export const RubricWorkspace: React.FC<IProps> = () => { | ||
return ( | ||
<> | ||
<DebugInput /> | ||
<ActiveRubricDisplay /> | ||
<EvalResultDisplay /> | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,18 +9,20 @@ interface IProps { | |
defaultSize: number | string; | ||
primary: "left" | "right"; | ||
children: React.ReactNode; | ||
leftPaneClass?: string; | ||
rightPaneClass?: string; | ||
} | ||
|
||
export const SplitPane: React.FC<IProps> = ({ className, split, children }) => { | ||
export const SplitPane: React.FC<IProps> = ({ className, split, children, leftPaneClass, rightPaneClass }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will something like the left or right pane class look like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose is to enable the parent to inject css into the div that wraps the panel content. I may end up removing it. This can be accomplished without adding a prop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed! |
||
const [left, right] = React.Children.toArray(children); | ||
|
||
return ( | ||
<div className={classList(css[`split-pane-${split}`], className)}> | ||
<div className={css[`left-${split}`]}>{left}</div> | ||
<div className={classList(css[`left-${split}`], leftPaneClass)}>{left}</div> | ||
<div className={css[`splitter-${split}`]}> | ||
<div className={css[`splitter-${split}-inner`]} /> | ||
</div> | ||
<div className={css[`right-${split}`]}>{right}</div> | ||
<div className={classList(css[`right-${split}`], rightPaneClass)}>{right}</div> | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from "react"; | ||
// eslint-disable-next-line import/no-internal-modules | ||
import css from "./styling/Toolbar.module.scss"; | ||
|
||
import { classList } from "react-common/components/util"; | ||
|
||
interface IProps { | ||
children: React.ReactNode; | ||
toolbarClass?: string; | ||
leftClass?: string; | ||
centerClass?: string; | ||
rightClass?: string; | ||
} | ||
|
||
export const Toolbar: React.FC<IProps> = ({ children, toolbarClass, leftClass, centerClass, rightClass }) => { | ||
const [left, center, right] = React.Children.toArray(children); | ||
return ( | ||
<div className={classList(css["toolbar"], toolbarClass)}> | ||
<div className={classList(css["left"], leftClass)}>{left}</div> | ||
<div className={classList(css["center"], centerClass)}>{center}</div> | ||
<div className={classList(css["right"], rightClass)}>{right}</div> | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.address-bar { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
height: 3.625rem; | ||
background-color: var(--pxt-content-background); | ||
color: var(--pxt-content-foreground); | ||
padding: 0 1rem 0 1rem; | ||
border-top: solid 1px var(--pxt-content-accent); | ||
|
||
div[class="common-input-wrapper"] { | ||
width: 100%; | ||
|
||
div[class="common-input-group"] { | ||
border-radius: 99px; | ||
border: solid 1px var(--pxt-content-accent); | ||
padding: 0 1rem 0 1rem; | ||
|
||
&:focus::after { | ||
outline: none; | ||
border-radius: 99px; | ||
border: solid 2px var(--pxt-headerbar-accent-smoke); | ||
} | ||
&:focus-within::after { | ||
outline: none; | ||
border-radius: 99px; | ||
border: solid 2px var(--pxt-headerbar-accent-smoke); | ||
} | ||
|
||
input { | ||
width: 100%; | ||
font-size: 1rem; | ||
padding-left: 0; | ||
|
||
&::placeholder { | ||
color: var(--pxt-content-accent); | ||
font-style: italic; | ||
text-align: center; | ||
} | ||
} | ||
|
||
i { | ||
background-color: var(--pxt-content-background); | ||
border-radius: 99px; | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
top: 0; | ||
bottom: 0; | ||
right: 0.25rem; | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
|
||
&::before { | ||
font-size: 1rem; | ||
line-height: 1.5rem; | ||
color: var(--pxt-content-foreground); | ||
filter: saturate(0%); | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.makecode-frame { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
border: none; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import "shared"; | ||
|
||
.panel { | ||
background-color: var(--pxt-headerbar-accent-smoke); | ||
|
||
iframe { | ||
flex: 1 1 0%; | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it valuable to create a styling module for something that's empty right now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It won't be empty for long. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is AddressBar the right name for this? I know that SearchBar isn't right, either, but when I read address bar, it took me a minute to understand that this is the component where the user submits the share link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose AddressBar because:
I am open to alternatives!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShareLinkInput would be the most descriptive, probably. But I'm fine with AddressBar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed!