Skip to content

Commit

Permalink
fix: dbot dark_mode production (#7885)
Browse files Browse the repository at this point in the history
* fix: dbot dark_mode production

* fix: removed unused hook

* fix: review comments

---------

Co-authored-by: Jim Daniels Wasswa <104334373+jim-deriv@users.noreply.github.com>
  • Loading branch information
rupato-deriv and jim-deriv authored Mar 30, 2023
1 parent 873b920 commit 711a54e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 66 deletions.
2 changes: 0 additions & 2 deletions packages/bot-skeleton/src/scratch/dbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getSavedWorkspaces, saveWorkspaceToRecent } from '../utils/local-storag
import { observer as globalObserver } from '../utils/observer';
import ApiHelpers from '../services/api/api-helpers';
import Interpreter from '../services/tradeEngine/utils/interpreter';
import { setColors } from './hooks/colours';
import { api_base } from '../services/api/api-base';

class DBot {
Expand All @@ -24,7 +23,6 @@ class DBot {
*/
async initWorkspace(public_path, store, api_helpers_store, is_mobile) {
const recent_files = await getSavedWorkspaces();
setColors();
return new Promise((resolve, reject) => {
__webpack_public_path__ = public_path; // eslint-disable-line no-global-assign
ApiHelpers.setInstance(api_helpers_store);
Expand Down
120 changes: 56 additions & 64 deletions packages/bot-skeleton/src/scratch/hooks/colours.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,65 @@
const isDarkModeEnabled = () => {
const ui_store = localStorage.getItem('ui_store');
const darkMode = () => {
const workspace = Blockly;
workspace.Colours.RootBlock = {
colour: '#183046',
colourSecondary: '#F2F3F5',
colourTertiary: '#151717',
};
workspace.Colours.Base = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#0e0e0e',
};

if (ui_store && ui_store.length > 0) {
return JSON.parse(ui_store).is_dark_mode_on || false;
}
return false;
};

export const setColors = () => {
if (isDarkModeEnabled()) {
Blockly.Colours.RootBlock = {
colour: '#183046',
colourSecondary: '#F2F3F5',
colourTertiary: '#151717',
};
Blockly.Colours.Base = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#0e0e0e',
};
workspace.Colours.Special1 = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#6d7278',
};

Blockly.Colours.Special1 = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#6d7278',
};
workspace.Colours.Special2 = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#D27954',
};

Blockly.Colours.Special2 = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#D27954',
};
workspace.Colours.Special3 = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#D27954',
};
};

Blockly.Colours.Special3 = {
colour: '#C2C2C2',
colourSecondary: '#0e0e0e',
colourTertiary: '#D27954',
};
} else {
Blockly.Colours.RootBlock = {
colour: '#064e72',
colourSecondary: '#064e72',
colourTertiary: '#6d7278',
};
const lightMode = () => {
const workspace = Blockly;
workspace.Colours.RootBlock = {
colour: '#064e72',
colourSecondary: '#064e72',
colourTertiary: '#6d7278',
};

Blockly.Colours.Base = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};
workspace.Colours.Base = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};

Blockly.Colours.Special1 = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};
workspace.Colours.Special1 = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};

Blockly.Colours.Special2 = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};
workspace.Colours.Special2 = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};

Blockly.Colours.Special3 = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};
}
workspace.Colours.Special3 = {
colour: '#e5e5e5',
colourSecondary: '#ffffff',
colourTertiary: '#6d7278',
};
};

setColors();
export const setColors = is_dark_mode => (is_dark_mode ? darkMode() : lightMode());
8 changes: 8 additions & 0 deletions packages/bot-web-ui/src/app/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import RootStore from 'Stores';
import GTM from 'Utils/gtm';
import './app.scss';
import Dashboard from 'Components/dashboard';
import { setColors } from '../../../bot-skeleton/src/scratch/hooks/colours';

const App = ({ passthrough }) => {
const { root_store, WS } = passthrough;
Expand All @@ -29,6 +30,13 @@ const App = ({ passthrough }) => {
const root_store_instance = React.useRef(new RootStore(root_store, WS, DBot));
const { app, common, core } = root_store_instance.current;
const { onMount, onUnmount, showDigitalOptionsMaltainvestError } = app;
const {
ui: { is_dark_mode_on },
} = root_store;

React.useEffect(() => {
setColors(is_dark_mode_on);
}, []);

React.useEffect(() => {
/**
Expand Down

1 comment on commit 711a54e

@vercel
Copy link

@vercel vercel bot commented on 711a54e Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-app – ./

binary.sx
deriv-app.binary.sx
deriv-app-git-master.binary.sx
deriv-app.vercel.app

Please sign in to comment.