diff --git a/packages/gui/src/components/loader/loader.css b/packages/gui/src/components/loader/loader.css index 8a6e47bc1..642ca3e31 100644 --- a/packages/gui/src/components/loader/loader.css +++ b/packages/gui/src/components/loader/loader.css @@ -14,6 +14,18 @@ color: white; } + +.scoped-loader { + z-index: calc(var(--clipcc-z-index-loader) - 1); + border-radius: 0.5rem; +} + +.scoped-loader .title { + font-size: 1.5rem; + margin: 0; +} + + .fullscreen { /* Break out of the layout using position: fixed to cover the whole screen */ position: fixed; diff --git a/packages/gui/src/components/loader/scoped-loader.tsx b/packages/gui/src/components/loader/scoped-loader.tsx new file mode 100644 index 000000000..2ea645729 --- /dev/null +++ b/packages/gui/src/components/loader/scoped-loader.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import classNames from 'classnames'; +import styles from './loader.css'; + +import topBlock from './top-block.svg'; +import middleBlock from './middle-block.svg'; +import bottomBlock from './bottom-block.svg'; + +export interface ScopedLoaderProps { + /** The text to display while loading */ + text?: string; +} + +export default function ScopedLoaderComponent (props: ScopedLoaderProps) { + return ( +
( localesOnly?: boolean ): React.ComponentType
{ class AppStateWrapper extends React.Component
{
- private store!: Store (
// browser modal
const reducers = {locales: localesReducer};
const initialState = {locales: initializedLocales};
- const enhancer: StoreEnhancer (
initPlayer,
initTelemetryModal
} = guiRedux;
- // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
- const {ScratchPaintReducer}: {ScratchPaintReducer: Reducer (
}
const reducers = {
locales: localesReducer,
- scratchGui: guiReducer,
- scratchPaint: ScratchPaintReducer
+ scratchGui: guiReducer
};
const initialState = {
locales: initializedLocales,
scratchGui: initializedGui
};
- const enhancer: StoreEnhancer ) {
if (localesOnly) return;
diff --git a/packages/gui/src/lib/backpack/block-to-image.js b/packages/gui/src/lib/backpack/block-to-image.js
index 64e1704b9..366b225b9 100644
--- a/packages/gui/src/lib/backpack/block-to-image.js
+++ b/packages/gui/src/lib/backpack/block-to-image.js
@@ -1,12 +1,13 @@
import computedStyleToInlineStyle from 'computed-style-to-inline-style';
-import * as ScratchBlocks from 'clipcc-block';
+import {getScratchBlocks} from '../blocks-loader';
/**
* Given a blockId, return a data-uri image that can be used to create a thumbnail.
* @param {string} blockId the ID of the block to imagify
* @returns {Promise} resolves to a data-url of a picture of the blocks
*/
-export default function (blockId) {
+export default async function (blockId) {
+ const ScratchBlocks = await getScratchBlocks();
// Not sure any better way to access the scratch-blocks workspace than this...
const block = ScratchBlocks.common.getMainWorkspace().getBlockById(blockId);
const blockSvg = block.getSvgRoot().cloneNode(true /* deep */);
diff --git a/packages/gui/src/lib/blocks-loader-hoc.tsx b/packages/gui/src/lib/blocks-loader-hoc.tsx
new file mode 100644
index 000000000..430b040f9
--- /dev/null
+++ b/packages/gui/src/lib/blocks-loader-hoc.tsx
@@ -0,0 +1,33 @@
+import React from 'react';
+import {getScratchBlocks} from './blocks-loader';
+import ScopedLoaderComponent from '../components/loader/scoped-loader';
+
+interface BlockLoaderProps {
+ blocks: typeof import('clipcc-block');
+}
+
+export function injectBlock (reducers: ReducerMap) {
+ initialReducers = reducers;
+}
+
+/**
+ * Set the Redux store instance. This is necessary for the injectReducer function to work,
+ * as it needs access to the store to replace the reducer.
+ * @param store The Redux store instance to set for dynamic reducer injection.
+ */
+export function setStore