Skip to content

Commit 01e898e

Browse files
committed
Extract Toolbar from DebugPane.tsx
1 parent 57f4d36 commit 01e898e

6 files changed

Lines changed: 82 additions & 79 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "./DebugPaneToolbar.scss";
2+
import { State, Actions } from "../api";
3+
export interface DebugPaneToolbarProps {
4+
state: State;
5+
actions: Actions;
6+
}
7+
export declare function DebugPaneToolbar(props: DebugPaneToolbarProps): JSX.Element;

src/components/DebugPane.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
border: 1px solid black;
88
color: black;
99

10-
.debug-toolbar {
11-
display: flex;
12-
justify-content: space-between;
13-
flex-shrink: 0;
14-
width: 100%;
15-
border-bottom: 1px solid black;
16-
17-
.close-button {
18-
margin: 0.4rem;
19-
}
20-
}
21-
2210
.debug-content {
2311
flex-grow: 1;
2412

src/components/DebugPane.tsx

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,10 @@ import { h } from "hyperapp"
33
import { State, Actions, PaneDisplay } from "../api"
44

55
import { DebuggerOptions } from "./DebuggerOptions"
6+
import { DebugPaneToolbar } from "./DebugPaneToolbar"
67

78
import "./DebugPane.scss"
89

9-
interface ToolbarProps {
10-
state: State
11-
actions: Actions
12-
}
13-
14-
function Toolbar(props: ToolbarProps) {
15-
const { state, actions } = props
16-
return (
17-
<div class="debug-toolbar">
18-
<div class="dropdown">
19-
<button class="btn btn-link dropdown-toggle">View</button>
20-
<ul class="menu">
21-
<li class="menu-item">
22-
<a
23-
href=""
24-
onclick={e => {
25-
actions.setPaneDisplay("fullscreen")
26-
e.preventDefault()
27-
}}
28-
>
29-
Full Screen
30-
</a>
31-
</li>
32-
<li class="menu-item">
33-
<a
34-
href=""
35-
onclick={e => {
36-
actions.setPaneDisplay("right")
37-
e.preventDefault()
38-
}}
39-
>
40-
Align Right
41-
</a>
42-
</li>
43-
<li class="menu-item">
44-
<a
45-
href=""
46-
onclick={e => {
47-
actions.setPaneDisplay("bottom")
48-
e.preventDefault()
49-
}}
50-
>
51-
Align Bottom
52-
</a>
53-
</li>
54-
</ul>
55-
</div>
56-
<span class="float-right">
57-
<button
58-
class="btn btn-clear close-button"
59-
onclick={() => actions.showPane(false)}
60-
/>
61-
</span>
62-
</div>
63-
)
64-
}
65-
6610
export interface DebugPaneProps {
6711
state: State
6812
actions: Actions
@@ -73,7 +17,7 @@ export function DebugPane(props: DebugPaneProps) {
7317

7418
return (
7519
<div class="debug-pane">
76-
{Toolbar({ state, actions })}
20+
{DebugPaneToolbar({ state, actions })}
7721
{DebuggerOptions({ state, actions })}
7822
<div class="debug-content scrollable">
7923
<pre class="scrollable-content">{JSON.stringify(state, null, 2)}</pre>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.debug-pane-toolbar {
2+
display: flex;
3+
justify-content: space-between;
4+
flex-shrink: 0;
5+
width: 100%;
6+
border-bottom: 1px solid black;
7+
8+
.close-button {
9+
margin: 0.4rem;
10+
}
11+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { h } from "hyperapp"
2+
3+
import "./DebugPaneToolbar.scss"
4+
5+
import { State, Actions } from "../api"
6+
7+
export interface DebugPaneToolbarProps {
8+
state: State
9+
actions: Actions
10+
}
11+
12+
export function DebugPaneToolbar(props: DebugPaneToolbarProps) {
13+
const { state, actions } = props
14+
return (
15+
<div class="debug-pane-toolbar">
16+
<div class="dropdown">
17+
<button class="btn btn-link dropdown-toggle">View</button>
18+
<ul class="menu">
19+
<li class="menu-item">
20+
<a
21+
href=""
22+
onclick={e => {
23+
actions.setPaneDisplay("fullscreen")
24+
e.preventDefault()
25+
}}
26+
>
27+
Full Screen
28+
</a>
29+
</li>
30+
<li class="menu-item">
31+
<a
32+
href=""
33+
onclick={e => {
34+
actions.setPaneDisplay("right")
35+
e.preventDefault()
36+
}}
37+
>
38+
Align Right
39+
</a>
40+
</li>
41+
<li class="menu-item">
42+
<a
43+
href=""
44+
onclick={e => {
45+
actions.setPaneDisplay("bottom")
46+
e.preventDefault()
47+
}}
48+
>
49+
Align Bottom
50+
</a>
51+
</li>
52+
</ul>
53+
</div>
54+
<span class="float-right">
55+
<button
56+
class="btn btn-clear close-button"
57+
onclick={() => actions.showPane(false)}
58+
/>
59+
</span>
60+
</div>
61+
)
62+
}

src/components/DebuggerOptions.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,3 @@ export function DebuggerOptions(props: DebuggerOptionsProps) {
3838
</div>
3939
)
4040
}
41-
42-
/* <label class="form-checkbox">
43-
<input
44-
type="checkbox"
45-
checked={state.showFullState}
46-
onchange={actions.toggleShowFullState}
47-
/>
48-
<i class="form-icon" /> Show full state
49-
</label> */

0 commit comments

Comments
 (0)