Skip to content

Commit 67230f7

Browse files
committed
feat(cherrypick): new testing ui
1 parent a44777d commit 67230f7

17 files changed

+3003
-331
lines changed

examples/gauge/Components/Dropdown.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
padding: 0;
2525
margin: 0;
2626
width: 100%;
27+
height: 500px;
28+
overflow-y: scroll;
2729
}
2830

2931
.dropdown-menu li {

examples/gauge/Components/Input.tsx

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { ComponentProps, DisplayComponent, FSComponent, Subscribable, UUID, VNode } from "@microsoft/msfs-sdk"
1+
import {
2+
ComponentProps,
3+
DisplayComponent,
4+
FSComponent,
5+
Subscribable,
6+
SubscribableUtils,
7+
UUID,
8+
VNode,
9+
} from "@microsoft/msfs-sdk"
10+
import { InterfaceNavbarItemV2 } from "./Utils"
211

312
interface InputProps extends ComponentProps {
4-
value?: string
13+
value: Subscribable<string>
14+
setValue: (value: string) => void
15+
default?: Subscribable<string> | string
516
class?: string | Subscribable<string>
617
textarea?: boolean
718
}
@@ -10,13 +21,16 @@ export class Input extends DisplayComponent<InputProps> {
1021
private readonly inputId = UUID.GenerateUuid()
1122
private readonly inputRef = FSComponent.createRef<HTMLInputElement>()
1223

13-
get value() {
14-
return this.inputRef.instance.value
15-
}
16-
1724
onAfterRender(node: VNode): void {
1825
super.onAfterRender(node)
1926

27+
this.props.value.map(val => (this.inputRef.instance.value = val))
28+
SubscribableUtils.toSubscribable(this.props.default ?? "", true).map(val => {
29+
this.inputRef.instance.placeholder = val
30+
})
31+
32+
this.inputRef.instance.addEventListener("input", () => this.props.setValue(this.inputRef.instance.value ?? ""))
33+
2034
this.inputRef.instance.onfocus = this.onInputFocus
2135
this.inputRef.instance.onblur = this.onInputBlur
2236
}
@@ -54,3 +68,34 @@ export class Input extends DisplayComponent<InputProps> {
5468
return <input ref={this.inputRef} {...this.getInputProps()} />
5569
}
5670
}
71+
72+
interface CheckboxProps extends ComponentProps {
73+
value: Subscribable<string>
74+
setValue: (value: string) => void
75+
default?: Subscribable<string> | string
76+
class?: string
77+
}
78+
79+
export class Checkbox extends DisplayComponent<CheckboxProps> {
80+
private readonly isActive = this.props.value.map(val => (val == "true" ? true : false))
81+
82+
private onClick = () => {
83+
this.props.setValue(this.isActive.get() ? "false" : "true")
84+
}
85+
86+
render(): VNode {
87+
return (
88+
<InterfaceNavbarItemV2
89+
content={""}
90+
active={this.isActive}
91+
class={`h-full flex-grow bg-white text-black flex items-center justify-center hover:bg-gray-400 ${
92+
this.props.class ?? ""
93+
}`}
94+
activeClass="hover:!bg-green-700 !bg-green-500 !text-white"
95+
setActive={() => this.onClick()}
96+
>
97+
<span class="text-4xl">{this.isActive.map(val => (val ? "✔" : "X"))}</span>
98+
</InterfaceNavbarItemV2>
99+
)
100+
}
101+
}

examples/gauge/Components/InterfaceSample.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@
4545
padding: 2rem;
4646
}
4747

48+
.horizontal-no-pad {
49+
display: flex;
50+
flex-direction: row;
51+
justify-content: space-evenly;
52+
align-items: flex-start;
53+
}
54+
4855
.vertical {
4956
display: flex;
5057
flex-direction: column;
5158
justify-content: center;
5259
align-items: center;
5360
}
5461

62+
.scrollable {
63+
overflow: scroll;
64+
height: 400px;
65+
}
66+
5567
.text-field {
5668
width: fit-content;
5769
height: 50px;

0 commit comments

Comments
 (0)