Skip to content

Commit c3b8b45

Browse files
committed
Use styled-components for global styles & adjust scroll bar
1 parent 5b84094 commit c3b8b45

5 files changed

Lines changed: 86 additions & 75 deletions

File tree

app/globalStyles.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { css, createGlobalStyle } from 'styled-components'
2+
3+
const commonStyles = css`
4+
html,
5+
body {
6+
font-family: monaco, Consolas, Lucida Console, monospace;
7+
overflow: hidden;
8+
font-size: 100%;
9+
margin: 0;
10+
padding: 0;
11+
width: 100%;
12+
height: 100%;
13+
background-color: rgb(53, 59, 70);
14+
}
15+
16+
#root {
17+
width: 100%;
18+
height: 100%;
19+
}
20+
#logs {
21+
position: fixed;
22+
top: 0;
23+
left: 0;
24+
white-space: pre;
25+
}
26+
#loading {
27+
color: #aaa;
28+
font-size: 30px;
29+
display: flex;
30+
height: 100%;
31+
justify-content: center;
32+
align-items: center;
33+
}
34+
35+
@media print {
36+
@page {
37+
size: auto;
38+
margin: 0;
39+
}
40+
body {
41+
position: static;
42+
}
43+
}
44+
.CodeMirror {
45+
font-family: monaco, Consolas, Lucida Console, monospace !important;
46+
}
47+
`
48+
49+
export const GlobalStyle =
50+
process.platform !== 'darwin'
51+
? createGlobalStyle`
52+
${commonStyles}
53+
::-webkit-scrollbar {
54+
width: 8px;
55+
height: 8px;
56+
background-color: #95959588;
57+
}
58+
::-webkit-scrollbar-thumb {
59+
background-color: #33333366;
60+
}
61+
`
62+
: createGlobalStyle`${commonStyles}`

app/index.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { invokeDevMethod } from './utils/devMenu'
1414
import { client, tryADBReverse } from './utils/adb'
1515
import config from './utils/config'
1616
import { toggleOpenInEditor, isOpenInEditorEnabled } from './utils/devtools'
17+
import { GlobalStyle } from './globalStyles'
1718

1819
const currentWindow = getCurrentWindow()
1920

@@ -38,21 +39,25 @@ const handleReady = () => {
3839
window.reactDevToolsPort = port
3940
const root = createRoot(document.getElementById('root'))
4041
root.render(
41-
<Provider store={store}>
42-
<PersistGate loading={null} persistor={persistor}>
43-
<App />
44-
</PersistGate>
45-
</Provider>,
42+
<>
43+
<GlobalStyle />
44+
<Provider store={store}>
45+
<PersistGate loading={null} persistor={persistor}>
46+
<App />
47+
</PersistGate>
48+
</Provider>
49+
</>,
4650
)
4751
})
48-
};
52+
}
4953

50-
({ store, persistor } = configureStore(handleReady))
54+
;({ store, persistor } = configureStore(handleReady))
5155

5256
// Provide for user
5357
window.adb = client
5458
window.adb.reverseAll = tryADBReverse
55-
window.adb.reversePackager = () => tryADBReverse(store.getState().debugger.location.port)
59+
window.adb.reversePackager = () =>
60+
tryADBReverse(store.getState().debugger.location.port)
5661

5762
window.checkWindowInfo = () => {
5863
const debuggerState = store.getState().debugger
@@ -63,13 +68,14 @@ window.checkWindowInfo = () => {
6368
}
6469
}
6570

66-
window.beforeWindowClose = () => new Promise((resolve) => {
67-
if (store.dispatch(beforeWindowClose())) {
68-
setTimeout(resolve, 200)
69-
} else {
70-
resolve()
71-
}
72-
})
71+
window.beforeWindowClose = () =>
72+
new Promise((resolve) => {
73+
if (store.dispatch(beforeWindowClose())) {
74+
setTimeout(resolve, 200)
75+
} else {
76+
resolve()
77+
}
78+
})
7379

7480
// For security, we should disable nodeIntegration when user use this open a website
7581
const originWindowOpen = window.open
@@ -92,9 +98,9 @@ window.invokeDevMethod = (name) => invokeDevMethod(name)()
9298
// we need fix it for ensure child process work
9399
// (like launchEditor of react-devtools)
94100
if (
95-
process.env.NODE_ENV === 'production'
96-
&& process.platform === 'darwin'
97-
&& process.env.PATH.indexOf('/usr/local/bin') === -1
101+
process.env.NODE_ENV === 'production' &&
102+
process.platform === 'darwin' &&
103+
process.env.PATH.indexOf('/usr/local/bin') === -1
98104
) {
99105
process.env.PATH = `${process.env.PATH}:/usr/local/bin`
100106
}

dist/app.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<meta charset=utf-8>
55
<title>React Native Debugger</title>
6-
<link href='css/style.css' rel="stylesheet" />
76
</head>
87
<body>
98
<div id="root">

dist/css/style.css

Lines changed: 0 additions & 55 deletions
This file was deleted.

electron/app.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<meta charset=utf-8>
55
<title>React Native Debugger</title>
6-
<link href='../dist/css/style.css' rel="stylesheet" />
76
</head>
87
<body>
98
<div id="root">

0 commit comments

Comments
 (0)