Skip to content

Commit 971c93a

Browse files
committed
Add components for runs
1 parent 01e898e commit 971c93a

8 files changed

Lines changed: 73 additions & 0 deletions

File tree

dist/src/components/RunsPane.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import "./RunsPane.scss";
2+
import { State, Actions, Run } from "../api";
3+
export interface RunsPaneProps {
4+
state: State;
5+
actions: Actions;
6+
runs: Run[];
7+
}
8+
export declare function RunsPane(props: RunsPaneProps): JSX.Element;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import "./RunsPaneItem.scss";
2+
import { State, Actions, Run } from "../api";
3+
export interface RunsPaneItemProps {
4+
state: State;
5+
actions: Actions;
6+
run: Run;
7+
current: boolean;
8+
}
9+
export declare function RunsPaneItem(props: RunsPaneItemProps): JSX.Element;

dist/src/selectors.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { State, Run } from "./api";
2+
export declare function getRuns(state: State): Run[];

src/components/RunsPane.scss

Whitespace-only changes.

src/components/RunsPane.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { h } from "hyperapp"
2+
3+
import "./RunsPane.scss"
4+
5+
import { State, Actions, Run } from "../api"
6+
import { RunsPaneItem } from "./RunsPaneItem"
7+
8+
export interface RunsPaneProps {
9+
state: State
10+
actions: Actions
11+
runs: Run[]
12+
}
13+
14+
export function RunsPane(props: RunsPaneProps) {
15+
const { state, actions, runs } = props
16+
const items = []
17+
const lastId = runs.length - 1
18+
runs.forEach((run, i) => {
19+
items.unshift(RunsPaneItem({ state, actions, run, current: i === lastId }))
20+
})
21+
return (
22+
<div class="scrollable">
23+
<ul class="scrollable-content">{runs}</ul>
24+
</div>
25+
)
26+
}

src/components/RunsPaneItem.scss

Whitespace-only changes.

src/components/RunsPaneItem.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { h } from "hyperapp"
2+
3+
import "./RunsPaneItem.scss"
4+
5+
import { State, Actions, Run } from "../api"
6+
7+
export interface RunsPaneItemProps {
8+
state: State
9+
actions: Actions
10+
run: Run
11+
current: boolean
12+
}
13+
14+
export function RunsPaneItem(props: RunsPaneItemProps) {
15+
const { state, actions, run, current } = props
16+
return <li>Run {run.timestamp}</li>
17+
}

src/selectors.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { State, Run } from "./api"
2+
3+
function compareRuns(r1: Run, r2: Run): number {
4+
return r1.timestamp - r2.timestamp
5+
}
6+
7+
export function getRuns(state: State): Run[] {
8+
return Object.keys(state.runs)
9+
.map(key => state.runs[key])
10+
.sort(compareRuns)
11+
}

0 commit comments

Comments
 (0)