Skip to content

Commit bb25fdd

Browse files
authored
Merge pull request #20 from kingjosht/small-bug-fixes
small bug fixes
2 parents 26b5c94 + fbd180f commit bb25fdd

4 files changed

Lines changed: 34 additions & 9 deletions

File tree

src/lib/default-project/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ const defaultProject = translator => {
3838
dataFormat: 'SVG',
3939
data: encoder.encode(backdrop)
4040
}, {
41-
id: '927d672925e7b99f7813735c484c6922',
41+
id: '3ffb86585ebbb654fbc092ea9b0a41b3',
4242
assetType: 'ImageVector',
4343
dataFormat: 'SVG',
4444
data: encoder.encode(costume1)
4545
},
4646
{
47-
id: 'f1b8a0c2e3e4f5a6b7c8d9e0f1a2b3c4',
47+
id: '2e11410044fca296f1623ae28a7abff4',
4848
assetType: 'ImageVector',
4949
dataFormat: 'SVG',
5050
data: encoder.encode(costume2)

src/lib/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import defaultProject from './default-project';
44

55
// eslint-disable-next-line import/no-commonjs
66
const {TRUSTED_IFRAME_HOST} = require('./brand.js');
7-
const isStandAlone = process.env.IS_STANDLALONE === 'true';
7+
const isStandAlone = process.env.IS_STANDALONE === 'true';
88

99
/**
1010
* Wrapper for ScratchStorage which adds default web sources.

src/lib/themes/themePersistance.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {BLOCKS_CUSTOM, Theme} from '.';
22

3+
const STORAGE_KEY = 'ct:theme';
4+
35
const matchMedia = query => (window.matchMedia ? window.matchMedia(query) : null);
46
const PREFERS_HIGH_CONTRAST_QUERY = matchMedia('(prefers-contrast: more)');
57
const PREFERS_DARK_QUERY = matchMedia('(prefers-color-scheme: dark)');
@@ -11,19 +13,20 @@ const systemPreferencesTheme = () => {
1113
// Check for URL search parameters first (highest priority)
1214
const urlParams = new URLSearchParams(window.location.search);
1315
const modeParam = urlParams.get('mode');
14-
16+
1517
// Check for mode parameter on any page
1618
if (modeParam === 'dark') {
1719
return Theme.dark;
1820
} else if (modeParam === 'light') {
1921
return Theme.light;
2022
}
21-
23+
2224
// If on home page, default to light theme
23-
if (window.location.pathname === "/" || window.location.pathname.includes("/index.html") || window.location.pathname === "/build/") {
25+
// eslint-disable-next-line max-len
26+
if (window.location.pathname === '/' || window.location.pathname.includes('/index.html') || window.location.pathname === '/build/') {
2427
return Theme.light;
2528
}
26-
29+
2730
if (PREFERS_HIGH_CONTRAST_QUERY && PREFERS_HIGH_CONTRAST_QUERY.matches) {
2831
return Theme.highContrast;
2932
}
@@ -62,7 +65,29 @@ const onSystemPreferenceChange = onChange => {
6265
*/
6366
const detectTheme = () => {
6467
const systemPreferences = systemPreferencesTheme();
65-
return systemPreferences;
68+
let theme = systemPreferences;
69+
70+
try {
71+
const stored = localStorage.getItem(STORAGE_KEY);
72+
if (stored) {
73+
const parsed = JSON.parse(stored);
74+
if (parsed) {
75+
if (parsed.accent) {
76+
theme = theme.set('accent', parsed.accent);
77+
}
78+
if (parsed.gui) {
79+
theme = theme.set('gui', parsed.gui);
80+
}
81+
if (parsed.blocks && parsed.blocks !== BLOCKS_CUSTOM) {
82+
theme = theme.set('blocks', parsed.blocks);
83+
}
84+
}
85+
}
86+
} catch (e) {
87+
// ignore
88+
}
89+
90+
return theme;
6691
};
6792

6893
/**

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ module.exports = [
197197
'process.env.FORCE_EMBED': JSON.stringify(process.env.FORCE_EMBED || 'true'),
198198
'process.env.COLLABORATION_HOST': JSON.stringify(process.env.COLLABORATION_HOST || 'wss://collaborator.codetorch.net/'),
199199
'process.env.COLLABORATION_DEV_MODE': JSON.stringify(process.env.COLLABORATION_DEV_MODE || 'false'),
200-
'process.env.IS_STANDLALONE': JSON.stringify(process.env.IS_STANDLALONE || 'false')
200+
'process.env.IS_STANDALONE': JSON.stringify(process.env.IS_STANDALONE || 'false')
201201
}),
202202
new HtmlWebpackPlugin({
203203
chunks: ['editor'],

0 commit comments

Comments
 (0)