Skip to content

Commit 9edf651

Browse files
committed
Enable scrolling content in popup window
1 parent 463d036 commit 9edf651

File tree

5 files changed

+61
-35
lines changed

5 files changed

+61
-35
lines changed

src/messaging/popup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function sendToPopup(message: PopupRequest): Promise<any> {
2424
top: anchor.top,
2525
left: anchor.left,
2626
width: 400,
27-
height: 400,
27+
height: 450,
2828
allowScriptsToClose: true,
2929
})
3030

src/ui/components/Common.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,31 @@ export type CommonProps = {
77
reject: (reason?: any) => void
88
} & PopupRequest
99

10+
export const MainContainer = styled.div`
11+
display: flex;
12+
flex-direction: column;
13+
height: 100%;
14+
`
15+
1016
export const MessageContainer = styled.div`
17+
flex: 0 0 auto;
18+
margin: 0 12px;
1119
position: relative;
1220
min-height: 40px;
1321
padding-right: 56px;
1422
`
1523

24+
export const MessageDivider = styled.hr`
25+
height: 2px;
26+
margin: 8px 12px 0;
27+
`
28+
29+
export const ListContainer = styled.div`
30+
flex: 1 1 auto;
31+
overflow: auto;
32+
padding: 8px 12px;
33+
`
34+
1635
export const ReloadButton = styled(Button)`
1736
position: absolute;
1837
top: 50%;
@@ -22,10 +41,7 @@ export const ReloadButton = styled(Button)`
2241

2342
export const ButtonContainer = styled.div`
2443
display: flex;
25-
position: absolute;
26-
bottom: 12px;
27-
left: 12px;
28-
right: 12px;
44+
padding: 12px;
2945
`
3046

3147
export const ButtonSpacer = styled.span`

src/ui/controls/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import styled from "styled-components"
33

44
const Container = styled.ul`
55
list-style-type: none;
6+
margin: -8px -8px;
67
padding: 0;
7-
margin: 0 -8px;
88
`
99

1010
const Item = styled.li<{ $active: boolean }>`

src/ui/index.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
html {
2+
height: 100%;
3+
}
4+
15
body {
26
width: 100%;
7+
height: 100%;
38
user-select: none;
49
}
510

611
#root {
7-
padding: 0 12px;
12+
height: 100%;
813
}
914

1015
h2,

src/ui/pages/PortChooser.tsx

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
ButtonMessage,
88
ButtonSpacer,
99
CommonProps,
10+
ListContainer,
11+
MainContainer,
1012
MessageContainer,
13+
MessageDivider,
1114
ReloadButton,
1215
} from "../components/Common"
1316
import { NativeInfo } from "../components/NativeInfo"
@@ -80,7 +83,7 @@ export class PortChooser extends React.Component<
8083
}
8184

8285
return (
83-
<div>
86+
<MainContainer>
8487
<MessageContainer>
8588
<h4>{hostname ?? "A website"}</h4>
8689
<small>
@@ -89,34 +92,36 @@ export class PortChooser extends React.Component<
8992
<ReloadButton icon="reload" onClick={this.handleRefresh} />
9093
</MessageContainer>
9194

92-
<hr />
95+
<MessageDivider />
9396

94-
{!this.state.params &&
95-
!this.state.ports &&
96-
!this.state.error && (
97-
<small>Looking for serial ports...</small>
98-
)}
99-
{this.state.params && !this.state.ports && (
100-
<NativeInstaller {...this.state.params} />
101-
)}
102-
{this.state.ports && (
103-
<List
104-
items={this.state.ports.map(
105-
(port) => port.description || port.name
97+
<ListContainer>
98+
{!this.state.params &&
99+
!this.state.ports &&
100+
!this.state.error && (
101+
<small>Looking for serial ports...</small>
106102
)}
107-
active={this.state.active}
108-
onClick={this.handleItemClick}
109-
/>
110-
)}
111-
{this.state.ports && this.state.ports.length == 0 && (
112-
<small>No serial ports found</small>
113-
)}
114-
{this.state.error && (
115-
<small>
116-
Failed to enumerate serial ports:{" "}
117-
{`${this.state.error}`}
118-
</small>
119-
)}
103+
{this.state.params && !this.state.ports && (
104+
<NativeInstaller {...this.state.params} />
105+
)}
106+
{this.state.ports && (
107+
<List
108+
items={this.state.ports.map(
109+
(port) => port.description || port.name
110+
)}
111+
active={this.state.active}
112+
onClick={this.handleItemClick}
113+
/>
114+
)}
115+
{this.state.ports && this.state.ports.length == 0 && (
116+
<small>No serial ports found</small>
117+
)}
118+
{this.state.error && (
119+
<small>
120+
Failed to enumerate serial ports:{" "}
121+
{`${this.state.error}`}
122+
</small>
123+
)}
124+
</ListContainer>
120125

121126
<ButtonContainer>
122127
<ButtonMessage>
@@ -135,7 +140,7 @@ export class PortChooser extends React.Component<
135140
onClick={this.handleOkClick}
136141
/>
137142
</ButtonContainer>
138-
</div>
143+
</MainContainer>
139144
)
140145
}
141146
}

0 commit comments

Comments
 (0)