Skip to content

Commit

Permalink
WIP: Hide menu bar and fix assets
Browse files Browse the repository at this point in the history
* Use the CCW fork of the scratch-gui project so that we can set the
  `menuBarHidden` property to hide the menu bar.

* Don't set `backpackVisible` or `backpackHost` properties, because we
  probably don't want to display this. TODO: Check whether CS First
  displays it.

* Don't set `canEditTitle`, `showComingSoon` or `onClickLogo`
  properties, because they all relate to things that are displayed in
  the menu bar.

* Remove the code relating to `simulateScratchDesktop` - I don't think
  we need it! TODO: Check this!

* Copy the relevant assets from the scratch-gui package so that they are
  made available at the expected URLs. Note that the location of the
  assets has changed in newer versions of the scratch-gui package.

* Remove files in the `scratch/dist` directory from the git repo and
  ignore files in that directory.
  • Loading branch information
floehopper committed Jan 9, 2025
1 parent a0153b1 commit 1cf3ab1
Show file tree
Hide file tree
Showing 7 changed files with 1,792 additions and 144 deletions.
1 change: 1 addition & 0 deletions scratch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
2 changes: 0 additions & 2 deletions scratch/dist/main.js

This file was deleted.

29 changes: 0 additions & 29 deletions scratch/dist/main.js.LICENSE.txt

This file was deleted.

1 change: 1 addition & 0 deletions scratch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"watch": "webpack --watch"
},
"dependencies": {
"@raspberrypifoundation/scratch-gui": "0.1.0-raspberrypifoundation.20230606092831",
"scratch-gui": "^5.1.27"
},
"devDependencies": {
Expand Down
65 changes: 33 additions & 32 deletions scratch/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React from 'react';
import ReactDOM from 'react-dom';
import {compose} from 'redux';

import { AppStateHOC } from 'scratch-gui';
import GUI from 'scratch-gui';
import { AppStateHOC } from '@raspberrypifoundation/scratch-gui';
import GUI from '@raspberrypifoundation/scratch-gui';
// import { HashParserHOC } from 'scratch-gui';
// import log from '../lib/log.js';

Expand Down Expand Up @@ -45,21 +45,21 @@ document.body.appendChild(appTarget);
)(GUI);

// TODO a hack for testing the backpack, allow backpack host to be set by url param
const backpackHostMatches = window.location.href.match(/[?&]backpack_host=([^&]*)&?/);
const backpackHost = backpackHostMatches ? backpackHostMatches[1] : null;
// const backpackHostMatches = window.location.href.match(/[?&]backpack_host=([^&]*)&?/);
// const backpackHost = backpackHostMatches ? backpackHostMatches[1] : null;

const scratchDesktopMatches = window.location.href.match(/[?&]isScratchDesktop=([^&]+)/);
let simulateScratchDesktop;
if (scratchDesktopMatches) {
try {
// parse 'true' into `true`, 'false' into `false`, etc.
simulateScratchDesktop = JSON.parse(scratchDesktopMatches[1]);
} catch {
// it's not JSON so just use the string
// note that a typo like "falsy" will be treated as true
simulateScratchDesktop = scratchDesktopMatches[1];
}
}
// const scratchDesktopMatches = window.location.href.match(/[?&]isScratchDesktop=([^&]+)/);
// let simulateScratchDesktop;
// if (scratchDesktopMatches) {
// try {
// // parse 'true' into `true`, 'false' into `false`, etc.
// simulateScratchDesktop = JSON.parse(scratchDesktopMatches[1]);
// } catch {
// // it's not JSON so just use the string
// // note that a typo like "falsy" will be treated as true
// simulateScratchDesktop = scratchDesktopMatches[1];
// }
// }

if (process.env.NODE_ENV === 'production' && typeof window === 'object') {
// Warn before navigating away
Expand All @@ -68,23 +68,24 @@ document.body.appendChild(appTarget);

ReactDOM.render(
// important: this is checking whether `simulateScratchDesktop` is truthy, not just defined!
simulateScratchDesktop ?
<WrappedGui
canEditTitle
isScratchDesktop
showTelemetryModal
canSave={false}
onTelemetryModalCancel={handleTelemetryModalCancel}
onTelemetryModalOptIn={handleTelemetryModalOptIn}
onTelemetryModalOptOut={handleTelemetryModalOptOut}
/> :
// simulateScratchDesktop ?
// <WrappedGui
// canEditTitle
// isScratchDesktop
// showTelemetryModal
// canSave={false}
// onTelemetryModalCancel={handleTelemetryModalCancel}
// onTelemetryModalOptIn={handleTelemetryModalOptIn}
// onTelemetryModalOptOut={handleTelemetryModalOptOut}
// /> :
<WrappedGui
canEditTitle
backpackVisible
showComingSoon
backpackHost={backpackHost}
menuBarHidden
// canEditTitle
// backpackVisible
// showComingSoon
// backpackHost={backpackHost}
canSave={false}
onClickLogo={onClickLogo}
// onClickLogo={onClickLogo}
/>,
appTarget);
// };
// };
Loading

0 comments on commit 1cf3ab1

Please sign in to comment.