From bd89e046e7cbffa3b98bf81630b8c8fe71df0408 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 24 Nov 2021 15:19:07 +0300 Subject: [PATCH] [mobile] adapt skeleton for dark theme --- apps/common/mobile/utils/htmlutils.js | 10 ++++++++++ apps/documenteditor/mobile/src/index_dev.html | 12 +++--------- apps/presentationeditor/mobile/src/index_dev.html | 5 +++++ apps/spreadsheeteditor/mobile/src/index_dev.html | 5 +++++ vendor/framework7-react/build/webpack.config.js | 1 + 5 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 apps/common/mobile/utils/htmlutils.js diff --git a/apps/common/mobile/utils/htmlutils.js b/apps/common/mobile/utils/htmlutils.js new file mode 100644 index 0000000000..377c4c755a --- /dev/null +++ b/apps/common/mobile/utils/htmlutils.js @@ -0,0 +1,10 @@ + +let obj = !localStorage ? {id: 'theme-light', type: 'light'} : JSON.parse(localStorage.getItem("ui-theme")); +if ( !obj ) { + if ( window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ) { + obj = {id: 'theme-dark', type: 'dark'}; + localStorage && localStorage.setItem("ui-theme", JSON.stringify(obj)); + } +} + +document.body.classList.add(`theme-type-${obj.type}`); diff --git a/apps/documenteditor/mobile/src/index_dev.html b/apps/documenteditor/mobile/src/index_dev.html index b769d12cc4..d8d9786707 100644 --- a/apps/documenteditor/mobile/src/index_dev.html +++ b/apps/documenteditor/mobile/src/index_dev.html @@ -32,17 +32,11 @@ + <% if ( htmlWebpackPlugin.options.skeleton.htmlscript ) { %> + <% } %>
diff --git a/apps/presentationeditor/mobile/src/index_dev.html b/apps/presentationeditor/mobile/src/index_dev.html index 56c8e52349..11d4ab3294 100644 --- a/apps/presentationeditor/mobile/src/index_dev.html +++ b/apps/presentationeditor/mobile/src/index_dev.html @@ -32,6 +32,11 @@ + <% if ( htmlWebpackPlugin.options.skeleton.htmlscript ) { %> + + <% } %>
diff --git a/apps/spreadsheeteditor/mobile/src/index_dev.html b/apps/spreadsheeteditor/mobile/src/index_dev.html index bde42801ca..9fc57b6f48 100644 --- a/apps/spreadsheeteditor/mobile/src/index_dev.html +++ b/apps/spreadsheeteditor/mobile/src/index_dev.html @@ -32,6 +32,11 @@ + <% if ( htmlWebpackPlugin.options.skeleton.htmlscript ) { %> + + <% } %>
diff --git a/vendor/framework7-react/build/webpack.config.js b/vendor/framework7-react/build/webpack.config.js index 19b1aa3449..301c213fa6 100644 --- a/vendor/framework7-react/build/webpack.config.js +++ b/vendor/framework7-react/build/webpack.config.js @@ -211,6 +211,7 @@ module.exports = { } : false, skeleton: { stylesheet: env === 'development' ? undefined : fs.readFileSync(`../../apps/common/mobile/resources/css/skeleton.css`), + htmlscript: fs.readFileSync(`../../apps/common/mobile/utils/htmlutils.js`), }, system: { env: {