Skip to content

Commit

Permalink
set module css pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Jan 26, 2024
1 parent 12fffd4 commit 40b7189
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 24 deletions.
2 changes: 1 addition & 1 deletion react-common/components/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function fireClickOnEnter(e: React.KeyboardEvent<HTMLElement>) {
}
}

export function classList(...classes: string[]) {
export function classList(...classes: (string | undefined)[]) {
return classes
.filter(c => typeof c === "string")
.reduce((prev, c) => prev.concat(c.split(" ")), [] as string[])
Expand Down
16 changes: 4 additions & 12 deletions teachertool/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import { downloadTargetConfigAsync } from "./services/backendRequests";
import { logDebug } from "./services/loggingService";

import HeaderBar from "./components/HeaderBar";
import MainPanel from "./components/MainPanel";
import Notifications from "./components/Notifications";
import DebugInput from "./components/DebugInput";
import { MakeCodeFrame } from "./components/MakecodeFrame";
import EvalResultDisplay from "./components/EvalResultDisplay";
import ActiveRubricDisplay from "./components/ActiveRubricDisplay";
import CatalogModal from "./components/CatalogModal";

import { postNotification } from "./transforms/postNotification";
Expand Down Expand Up @@ -54,17 +51,12 @@ function App() {
<div className="ui large main loader msft"></div>
</div>
) : (
<div className="app-container">
<>
<HeaderBar />
<div className="inner-app-container">
<DebugInput />
<ActiveRubricDisplay />
<EvalResultDisplay />
<MakeCodeFrame />
</div>
<MainPanel />
<CatalogModal />
<Notifications />
</div>
</>
);
}

Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/components/HeaderBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MenuBar } from "react-common/components/controls/MenuBar";

interface HeaderBarProps {}

export const HeaderBar: React.FC<HeaderBarProps> = () => {
const HeaderBar: React.FC<HeaderBarProps> = () => {
const appTheme = pxt.appTarget?.appTheme;

const brandIconClick = () => {};
Expand Down
31 changes: 31 additions & 0 deletions teachertool/src/components/MainPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from "react";
import css from "./styling/MainPanel.module.css";

Check failure on line 2 in teachertool/src/components/MainPanel.tsx

View workflow job for this annotation

GitHub Actions / buildpush

Reaching to "./styling/MainPanel.module.css" is not allowed

Check failure on line 2 in teachertool/src/components/MainPanel.tsx

View workflow job for this annotation

GitHub Actions / buildmain

Reaching to "./styling/MainPanel.module.css" is not allowed

Check failure on line 2 in teachertool/src/components/MainPanel.tsx

View workflow job for this annotation

GitHub Actions / buildpr

Reaching to "./styling/MainPanel.module.css" is not allowed

import DebugInput from "./DebugInput";
import MakeCodeFrame from "./MakecodeFrame";
import EvalResultDisplay from "./EvalResultDisplay";
import ActiveRubricDisplay from "./ActiveRubricDisplay";
import SplitPane from "./SplitPane";

interface IProps {}

const MainPanel: React.FC<IProps> = () => {
return (
<div className={css["main-panel"]}>
<SplitPane split={"vertical"} defaultSize={"80%"} primary={"left"}>
{/* Left side */}
<>
<DebugInput />
<ActiveRubricDisplay />
<EvalResultDisplay />
</>
{/* Right side */}
<>
<MakeCodeFrame />
</>
</SplitPane>
</div>
);
};

export default MainPanel;
5 changes: 4 additions & 1 deletion teachertool/src/components/MakecodeFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { AppStateContext } from "../state/appStateContext";
import { getEditorUrl } from "../utils";

interface MakeCodeFrameProps {}
export const MakeCodeFrame: React.FC<MakeCodeFrameProps> = () => {

const MakeCodeFrame: React.FC<MakeCodeFrameProps> = () => {
const { state: teacherTool } = useContext(AppStateContext);

function createIFrameUrl(shareId: string): string {
Expand Down Expand Up @@ -40,3 +41,5 @@ export const MakeCodeFrame: React.FC<MakeCodeFrameProps> = () => {
);
/* eslint-enable @microsoft/sdl/react-iframe-missing-sandbox */
};

export default MakeCodeFrame;
27 changes: 27 additions & 0 deletions teachertool/src/components/SplitPane.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from "react";
import css from "./styling/SplitPane.module.css";

Check failure on line 2 in teachertool/src/components/SplitPane.tsx

View workflow job for this annotation

GitHub Actions / buildpush

Reaching to "./styling/SplitPane.module.css" is not allowed

Check failure on line 2 in teachertool/src/components/SplitPane.tsx

View workflow job for this annotation

GitHub Actions / buildmain

Reaching to "./styling/SplitPane.module.css" is not allowed

Check failure on line 2 in teachertool/src/components/SplitPane.tsx

View workflow job for this annotation

GitHub Actions / buildpr

Reaching to "./styling/SplitPane.module.css" is not allowed
import { classList } from "react-common/components/util";

interface IProps {
className?: string;
split: "horizontal" | "vertical";
defaultSize: number | string;
primary: "left" | "right";
children: React.ReactNode;
}

const VerticalSplit: React.FC<IProps> = ({ className, split, children }) => {
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={css[`splitter-${split}`]}>
<div className={css[`splitter-${split}-inner`]} />
</div>
<div className={css[`right-${split}`]}>{right}</div>
</div>
);
};

export default VerticalSplit;
8 changes: 8 additions & 0 deletions teachertool/src/components/styling/MainPanel.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


.main-panel {
display: flex;
flex-direction: column;
min-height: 100%;
width: 100%;
}
66 changes: 66 additions & 0 deletions teachertool/src/components/styling/SplitPane.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

/* Vertical split pane */

.split-pane-vertical {
display: flex;
flex-direction: row;
height: 100%;
width: 100%;
}

.left-vertical {
flex: 1;
overflow: auto;
}

.right-vertical {
flex: 1;
overflow: auto;
}

.splitter-vertical {
background-color: #ccc;
width: 1px;
}

.splitter-vertical-inner {
position: relative;
background-color: transparent;
transition: background-color 0.2s ease;
left: -3px;
width: 6px;
height: 100%;
cursor: ew-resize;
}

.splitter-vertical-inner:hover {
background-color: #000000aa;
transition: background-color 0.2s ease;
transition-delay: 0.2s;
}

/* Horizontal split pane */

.split-pane-horizontal {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
}

.left-horizontal {
flex: 1;
overflow: auto;
}

.right-horizontal {
flex: 1;
overflow: auto;
}

.splitter-horizontal {
flex: 0 0 1px;
background-color: #ccc;
height: 5px;
cursor: ns-resize;
}
16 changes: 7 additions & 9 deletions teachertool/src/teacherTool.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
--high-contrast-hyperlink: #807FFF;
}

* {
min-height: initial;
min-width: initial;
}

body {
-webkit-font-smoothing: antialiased;
Expand All @@ -55,19 +59,12 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

.app-container {
#root {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: auto;
}

.inner-app-container {
display: flex;
flex-direction: column;
min-height: 100%;
width: 100%;
overflow: hidden;
}

.noclick {
Expand Down Expand Up @@ -96,6 +93,7 @@ code {
flex-grow: 0;
flex-shrink: 0;
z-index: var(--above-frame-zindex);
margin: 0;
}

.header-left, .header-right {
Expand Down

0 comments on commit 40b7189

Please sign in to comment.