Skip to content

Commit 6913240

Browse files
author
Andy O'Neill
committed
feat: high contrast support
1 parent 01ae8ad commit 6913240

File tree

13 files changed

+8143
-3610
lines changed

13 files changed

+8143
-3610
lines changed

.circleci/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,7 @@ commands:
209209
steps:
210210
- run:
211211
command: npm run distDev
212-
environment: *clear_context
212+
environment:
213+
<<: *clear_context
214+
# increased Node memory needed for macOS build
215+
NODE_OPTIONS: --max-old-space-size=4096

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Let's assume that you want to make a new release, version `3.999.0`, correspondi
2222
1. `cd scratch-desktop`
2323
2. `git pull --all --tags`
2424
3. `git checkout develop`
25-
4. `npm install --save-dev 'scratch-gui@github:LLK/scratch-gui#scratch-desktop-v3.999.0'`
25+
4. `npm install --save-dev 'scratch-gui@github:scratchfoundation/scratch-gui#scratch-desktop-v3.999.0'`
2626
5. `git add package.json package-lock.json`
2727
6. Make sure the app works, the diffs look reasonable, etc.
2828
7. `git commit -m "bump scratch-gui to scratch-desktop-v3.999.0"`

package-lock.json

Lines changed: 7893 additions & 3588 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
3333
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
3434
"@babel/plugin-transform-async-to-generator": "^7.8.3",
35+
"@babel/plugin-transform-nullish-coalescing-operator": "^7.22.5",
36+
"@babel/plugin-transform-optional-chaining": "^7.22.6",
3537
"@babel/preset-env": "^7.9.6",
3638
"@babel/preset-react": "^7.9.4",
3739
"async": "^3.2.0",
@@ -40,8 +42,8 @@
4042
"babel-loader": "^8.1.0",
4143
"babel-plugin-react-intl": "^7.5.7",
4244
"copy-webpack-plugin": "^5.1.1",
43-
"electron": "^15.3.1",
44-
"electron-builder": "^22.13.1",
45+
"electron": "^25.2.0",
46+
"electron-builder": "^24.4.0",
4547
"electron-devtools-installer": "^3.2.0",
4648
"electron-notarize": "^1.1.1",
4749
"electron-store": "^8.0.1",
@@ -66,7 +68,7 @@
6668
"react-redux": "5.1.2",
6769
"redux": "3.7.2",
6870
"rimraf": "^3.0.2",
69-
"scratch-gui": "github:LLK/scratch-gui#scratch-desktop-v3.29.0",
71+
"scratch-gui": "github:scratchfoundation/scratch-gui#scratch-desktop-v3.30.1",
7072
"uuid": "^8.0.0",
7173
"webpack": "^4.43.0",
7274
"webpack-merge": "4.2.2"

src/main/index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,52 @@ const createPrivacyWindow = () => {
230230
return window;
231231
};
232232

233+
const createUsbWindow = () => {
234+
const window = createWindow({
235+
width: 400,
236+
height: 300,
237+
parent: _windows.main,
238+
search: 'route=usb',
239+
modal: true,
240+
frame: false
241+
});
242+
243+
// Filters from navigator.usb.requestDevice do not appear to be available here.
244+
// Hard code to micro:bit since that is the only device that currently uses this api.
245+
const getIsMicroBit = device => device.vendorId === 0x0d28 && device.productId === 0x0204;
246+
let deviceList = [];
247+
let selectedDeviceCallback;
248+
249+
_windows.main.webContents.session.on('select-usb-device', (event, details, callback) => {
250+
deviceList = details.deviceList.filter(getIsMicroBit);
251+
selectedDeviceCallback = callback;
252+
253+
window.webContents.send('usb-device-list', deviceList);
254+
window.show();
255+
256+
event.preventDefault();
257+
});
258+
259+
_windows.main.webContents.session.on('usb-device-added', (_event, device) => {
260+
if (!getIsMicroBit(device)) return;
261+
deviceList.push(device);
262+
window.webContents.send('usb-device-list', deviceList);
263+
});
264+
265+
_windows.main.webContents.session.on('usb-device-removed', (_event, device) => {
266+
if (!getIsMicroBit(device)) return;
267+
deviceList = deviceList.filter(existing => existing.deviceId !== device.deviceId);
268+
window.webContents.send('usb-device-list', deviceList);
269+
});
270+
271+
ipcMain.on('usb-device-selected', (_event, message) => {
272+
selectedDeviceCallback(message);
273+
window.hide();
274+
});
275+
276+
return window;
277+
};
278+
233279
const getIsProjectSave = downloadItem => {
234280
switch (downloadItem.getMimeType()) {
235281
case 'application/x.scratch.sb3':
@@ -398,6 +444,8 @@ app.on('ready', () => {
398444
event.preventDefault();
399445
_windows.privacy.hide();
400446
});
447+
448+
_windows.usb = createUsbWindow();
401449
});
402450

403451
ipcMain.on('open-about-window', () => {

src/renderer/about.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
html, body {
2-
background-color: #4D97FF;
2+
background-color: #855CD6;
33
color: white;
44
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
55
font-weight: bolder;

src/renderer/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<style>
66
body {
7-
background-color: #4D97FF;
7+
background-color: #855CD6;
88
}
99
.splash {
1010
color: white;

src/renderer/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ case 'about':
2424
case 'privacy':
2525
routeModulePromise = import('./privacy.jsx');
2626
break;
27+
case 'usb':
28+
routeModulePromise = import('./usb.jsx');
29+
break;
2730
}
2831

2932
routeModulePromise.then(routeModule => {

src/renderer/privacy.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
html, body {
2-
background-color: #4D97FF;
2+
background-color: #855CD6;
33
color: white;
44
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
55
font-weight: normal;
66
line-height: 150%;
77
}
88

9+
a:active, a:hover, a:link, a:visited {
10+
color: #855CD6;
11+
}
12+
913
.privacyBox {
1014
background-color: white;
1115
color: #575e75;

src/renderer/usb.css

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
html, body {
2+
background-color: white;
3+
color: #575E75;
4+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
5+
font-weight: normal;
6+
line-height: 150%;
7+
margin: 0;
8+
}
9+
10+
html, body, :global(#app), main {
11+
height: 100%;
12+
}
13+
14+
:global(#app) {
15+
box-sizing: border-box;
16+
padding: 1rem;
17+
}
18+
19+
main {
20+
display: flex;
21+
flex-direction: column;
22+
}
23+
24+
.devices {
25+
border: 1px solid hsla(0, 0%, 0%, 0.15);
26+
flex-grow: 1;
27+
margin-block: 1em;
28+
overflow-y: auto;
29+
padding: 0;
30+
}
31+
32+
.device.selected {
33+
background-color: #855CD6;
34+
color: white;
35+
}
36+
37+
.device input[type="radio"] {
38+
/* Hide the radio button but keep it accessible for keyboard */
39+
opacity: 0;
40+
position: absolute;
41+
}
42+
43+
.device label {
44+
box-sizing: border-box;
45+
display: block;
46+
padding-inline: .5em;
47+
}
48+
49+
.buttons {
50+
align-self: flex-end;
51+
}
52+
53+
button {
54+
border-radius: .25rem;
55+
cursor: pointer;
56+
font-weight: 600;
57+
margin: 0.25rem;
58+
padding: 0.6rem 0.75rem;
59+
}
60+
61+
.cancelButton {
62+
background: white;
63+
border: 1px solid #855CD6;
64+
color: #855CD6;
65+
}
66+
67+
.connectButton {
68+
background: #855CD6;
69+
border: 1px solid #855CD6;
70+
color: white;
71+
}
72+
73+
.connectButton:disabled {
74+
opacity: 50%;
75+
}

0 commit comments

Comments
 (0)