diff --git a/src/client/app.js b/src/client/app.js index a5d3476b..9d1f82be 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -20,6 +20,7 @@ import Article from './components/Article' import ArticlePageControl from './components/ArticlePageControl' import Album from './components/Album' import Parallax from './components/Parallax' +import ThemeSelector from './components/ThemeSelector' import Page from './components/CloudPage' import PageSchool from './components/PageSchool' @@ -48,6 +49,7 @@ import Ext from './filters/Ext' import IOService from './services/io' import MenuService from './services/menu' import API from './services/api' +import Theme from './services/theme' import {sortByPattern} from '../utils/sort' import {documentsSortPattern, collectiveSortPattern} from './config' @@ -260,6 +262,7 @@ app.run(($location, $rootScope, $http) => { API, IOService, MenuService, + Theme, RemoveHashtags, RemoveNewline, Strip, @@ -301,5 +304,6 @@ app.run(($location, $rootScope, $http) => { ScheduleSlider, ScheduleSlide, ScheduleRecord, - FooterLinks + FooterLinks, + ThemeSelector ].map(i => i(app)) diff --git a/src/client/components/ThemeSelector.js b/src/client/components/ThemeSelector.js new file mode 100644 index 00000000..375c4950 --- /dev/null +++ b/src/client/components/ThemeSelector.js @@ -0,0 +1,22 @@ +export default function (app) { + app.component('themeSelector', { + template: ` +
+ + +
+ `, + controller: ($scope, theme) => { + const update = () => { + $scope.isMainTheme = theme.currentTheme === theme.mainTheme + } + + $scope.toggleTheme = () => { + theme.toggle() + update() + } + + update() + }, + }) +}; diff --git a/src/client/services/theme.js b/src/client/services/theme.js new file mode 100644 index 00000000..c3b80004 --- /dev/null +++ b/src/client/services/theme.js @@ -0,0 +1,32 @@ +const themes = { + main: 'style.css', + accessibility: 'style-accessibility.css', +} + +const defaultTheme = 'main' + +class Theme { + constructor($rootScope) { + this.mainTheme = defaultTheme + this.currentTheme = null + + const getTheme = value => themes[value] + const setTheme = value => { + const theme = value in themes ? value : defaultTheme + localStorage.setItem('theme', theme) + this.currentTheme = theme + $rootScope.theme = getTheme(theme) + } + + setTheme(localStorage.getItem('theme')) + + this.toggle = () => { + const t = this.currentTheme === 'main' ? 'accessibility' : 'main' + setTheme(t) + } + } +} + +export default function (app) { + app.service('theme', Theme) +} diff --git a/src/style/components/navigation.scss b/src/style/components/navigation.scss index 246b9354..28845560 100644 --- a/src/style/components/navigation.scss +++ b/src/style/components/navigation.scss @@ -19,7 +19,7 @@ .navigation__right { color: $dark-color; - font-size: $smaller-font-size; + font-size: $normal-font-size; margin-right: 1em; z-index: 1000; diff --git a/src/style/variables.scss b/src/style/variables.scss index c2a293e8..4971234c 100644 --- a/src/style/variables.scss +++ b/src/style/variables.scss @@ -55,7 +55,7 @@ $biggest-font-size: 2.5rem; //MENU $menu-thickness: 2.5em; -$menu-colored-mark-thickness: 2px; +$menu-colored-mark-thickness: 4px; $menu-inactive-item-color: hsl(0, 0%, 50%); //ANIMATION diff --git a/src/templates/components/navigation.html b/src/templates/components/navigation.html index f596953e..83507cfa 100644 --- a/src/templates/components/navigation.html +++ b/src/templates/components/navigation.html @@ -2,6 +2,6 @@