generated from Seekra/repository-template
Add option to adapt color scheme to the system color scheme #61
@@ -16,17 +16,17 @@ limitations under the License.
|
|||||||
|
|
||||||
export const useColorTheme = function () {
|
export const useColorTheme = function () {
|
||||||
const getColorTheme = function () {
|
const getColorTheme = function () {
|
||||||
let colorTheme = localStorage.getItem('theme') || 'light';
|
let colorTheme = localStorage.getItem('theme') || 'auto';
|
||||||
if (!(colorTheme === 'dark' || colorTheme === 'light')) {
|
if (!(colorTheme === 'dark' || colorTheme === 'light' || colorTheme === 'auto')) {
|
||||||
colorTheme = 'light';
|
colorTheme = 'auto';
|
||||||
};
|
};
|
||||||
return colorTheme;
|
return colorTheme;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateColorTheme = function (newTheme) {
|
const updateColorTheme = function (newTheme) {
|
||||||
let actualNewTheme = newTheme;
|
let actualNewTheme = newTheme;
|
||||||
if (!(actualNewTheme === 'light' || actualNewTheme === 'dark')) {
|
if (!(actualNewTheme === 'dark' || actualNewTheme === 'light' || actualNewTheme === 'auto')) {
|
||||||
actualNewTheme = 'light';
|
actualNewTheme = 'auto';
|
||||||
};
|
};
|
||||||
|
|
||||||
localStorage.setItem('theme', actualNewTheme);
|
localStorage.setItem('theme', actualNewTheme);
|
||||||
|
|||||||
Reference in New Issue
Block a user