Skip to content

Commit fdd65eb

Browse files
committed
refactor: improve layout
1 parent 3a8e733 commit fdd65eb

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

examples/gauge/Components/InterfaceSample.css

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
width: 100%;
44
height: 100%;
55
position: relative;
6-
top: 100px;
76
}
87

98
.button {
@@ -19,16 +18,21 @@
1918
}
2019

2120
.qr-code {
22-
width: 300px;
23-
height: 300px;
21+
margin-top: 10px;
22+
width: 250px;
23+
height: 250px;
2424
display: none;
25+
background: white;
26+
padding: 10px;
27+
border-radius: 5px;
2528
}
2629

2730
.horizontal {
2831
display: flex;
2932
flex-direction: row;
30-
justify-content: center;
31-
align-items: center;
33+
justify-content: space-evenly;
34+
align-items: flex-start;
35+
padding: 2rem;
3236
}
3337

3438
.vertical {
@@ -49,3 +53,16 @@
4953
justify-content: center;
5054
align-items: center;
5155
}
56+
57+
pre {
58+
background: #272727;
59+
border-radius: 6px;
60+
padding: 10px;
61+
62+
min-width: 300px;
63+
min-height: 200px;
64+
}
65+
66+
h4 {
67+
margin-bottom: 15px;
68+
}

examples/gauge/Components/InterfaceSample.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
2424
private readonly downloadButtonRef = FSComponent.createRef<HTMLButtonElement>()
2525
private readonly executeButtonRef = FSComponent.createRef<HTMLButtonElement>()
2626
private readonly inputRef = FSComponent.createRef<Input>()
27+
private readonly outputRef = FSComponent.createRef<HTMLPreElement>()
2728

2829
private cancelSource = CancelToken.source()
2930

@@ -59,21 +60,32 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
5960
<div class="auth-container">
6061
<div class="horizontal">
6162
<div class="vertical">
63+
<h4>Step 1 - Sign in</h4>
6264
<div ref={this.textRef}>Loading</div>
6365
<div ref={this.loginButtonRef} class="button" />
6466
<div ref={this.navigationDataTextRef} />
6567
<img ref={this.qrCodeRef} class="qr-code" />
6668
</div>
6769
<div class="vertical">
70+
<h4>Step 2 - Select Database</h4>
6871
<Dropdown ref={this.dropdownRef} />
6972
<div ref={this.downloadButtonRef} class="button">
7073
Download
7174
</div>
75+
</div>
76+
</div>
77+
78+
<h4 style="text-align: center;">Step 3 - Query the database</h4>
79+
<div class="horizontal">
80+
<div class="vertical">
7281
<Input ref={this.inputRef} type="text" value="ESSA" class="text-field" />
7382
<div ref={this.executeButtonRef} class="button">
7483
Fetch Airport
7584
</div>
7685
</div>
86+
<pre ref={this.outputRef} id="output">
87+
The output of the query will show up here
88+
</pre>
7789
</div>
7890
</div>
7991
)
@@ -89,7 +101,11 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
89101
console.time("query")
90102
this.navigationDataInterface
91103
.get_airport(this.inputRef.instance.value)
92-
.then(airport => console.info(airport))
104+
.then(airport => {
105+
console.info(airport)
106+
107+
this.outputRef.instance.textContent = JSON.stringify(airport, null, 2)
108+
})
93109
.catch(e => console.error(e))
94110
.finally(() => console.timeEnd("query"))
95111
})
@@ -100,6 +116,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
100116
this.qrCodeRef.instance.style.display = "none"
101117
this.loginButtonRef.instance.textContent = "Log out"
102118
this.textRef.instance.textContent = `Welcome, ${user.preferred_username}`
119+
this.displayMessage("")
103120

104121
this.handleLogin()
105122
} else {
@@ -115,6 +132,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
115132
await AuthService.signOut()
116133
} else {
117134
this.cancelSource = CancelToken.source() // Reset any previous cancellations
135+
this.displayMessage("Authenticating.. Scan code (or click it) to sign in")
118136
await AuthService.signIn(p => {
119137
if (p) {
120138
this.qrCodeRef.instance.src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${p.verification_uri_complete}`
@@ -126,6 +144,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
126144
}, this.cancelSource.token)
127145
}
128146
} catch (err) {
147+
this.qrCodeRef.instance.style.display = "none"
129148
if (err instanceof Error) this.displayError(err.message)
130149
else this.displayError(`Unknown error: ${String(err)}`)
131150
}

0 commit comments

Comments
 (0)