Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
🎨 Implement proper color scheme context + fix color switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
acollierr17 committed Feb 20, 2021
1 parent f6a6eee commit 8021776
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Tags will be separated with a comma, before it was separated with a space.
stay up to date https://trello.com/b/l4zH3Ne2/menudocs-written-guide

- [x] Remove Auto or actually make it work.
- [ ] Accent colours.
- [x] Accent colours.
- [ ] Stripping Unnecessary code back.
- [ ] Removal of loading pacman.
- [ ] Improve Colours on Categories and Tags.
Expand Down
6 changes: 6 additions & 0 deletions accents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"red": "#de3636",
"blue": "#2196f3",
"purple": "#a846eb",
"green": "#2ecc71"
}
22 changes: 16 additions & 6 deletions components/Mode/ModePicker.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<template>
<div class="mode-options">
<h4 class="title">Choose Colour (WIP)</h4>
<h4 class="title">Choose Colour</h4>
<ul class="color-accent-options">
<li
v-for="(color, index) in accentColors"
:key="index"
:class="getClass(color.color, 'color')"
:style="cssVars"
@click="selectColor(color.color)"
>{{ color.title }}</li>
</ul>
Expand All @@ -16,6 +17,7 @@
v-for="(mode, index) in modeOptions"
:key="index"
:class="getClass(mode.mode, 'mode')"
:style="cssVars"
@click="selectMode(mode.mode)"
>{{ mode.title }}</li>
</ul>
Expand All @@ -24,13 +26,14 @@

<script>
import applyMode from './applyMode'
import accents from '../../accents.json'
export default {
name: 'ModeOptions',
data () {
return {
accentColors: [
accentColors: [
{ color: "red", title: "Red" },
{ color: "blue", title: "Blue" },
{ color: "green", title: "Green" },
Expand All @@ -41,14 +44,21 @@ export default {
{ mode: 'auto', title: 'Auto' },
{ mode: 'light', title: 'Light' }
],
currentColor: null,
currentColor: 'blue',
currentMode: 'auto'
}
},
computed: {
cssVars() {
return {
'--accent-color': accents[this.currentColor]
}
}
},
mounted () {
// modePicker 开启时默认使用用户主动设置的模式
this.currentMode = localStorage.getItem('mode') || this.$themeConfig.mode || 'auto'
this.currentColor = localStorage.getItem('accent-color') || 'blue'
// Dark and Light autoswitches
// 为了避免在 server-side 被执行,故在 Vue 组件中设置监听器
Expand Down Expand Up @@ -123,7 +133,7 @@ export default {
background-color: $accentColor;
color #fff
&.active
background-color: $accentColor;
background-color: var(--accent-color);
color #fff
&:not(.mode)
border-right 1px solid #666
Expand All @@ -150,7 +160,7 @@ export default {
background-color: $accentColor;
color #fff
&.active
background-color: $accentColor;
background-color: var(--accent-color);
color #fff
&:not(.color)
border-right 1px solid #666
Expand Down
12 changes: 12 additions & 0 deletions styles/themes/green.styl
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,16 @@
.sw-update-popup {
border-color: $greenAccentColor;
}

.md-logo {
fill: $greenAccentColor;
}
}

.reco-theme-green::-webkit-scrollbar-thumb:vertical {
background-color: $greenAccentColor;
}

.reco-theme-green::-webkit-scrollbar-thumb:horizontal {
background-color: $greenAccentColor;
}
13 changes: 13 additions & 0 deletions styles/themes/purple.styl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '../variables.styl';

.reco-theme-purple {

a,
p a code,
.theme-default-content a code {
Expand Down Expand Up @@ -144,4 +145,16 @@
.sw-update-popup {
border-color: $purpleAccentColor;
}

.md-logo {
fill: $purpleAccentColor;
}
}

.reco-theme-purple::-webkit-scrollbar-thumb:vertical {
background-color: $purpleAccentColor;
}

.reco-theme-purple::-webkit-scrollbar-thumb:horizontal {
background-color: $purpleAccentColor;
}
14 changes: 13 additions & 1 deletion styles/themes/red.styl
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,16 @@
.sw-update-popup {
border-color: $redAccentColor;
}
}

.md-logo {
fill: $redAccentColor;
}
}

.reco-theme-red::-webkit-scrollbar-thumb:vertical {
background-color: $redAccentColor;
}

.reco-theme-red::-webkit-scrollbar-thumb:horizontal {
background-color: $redAccentColor;
}
11 changes: 7 additions & 4 deletions styles/variables.styl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// accents.json
accents = json('../accents.json', { hash: true });

// overwrites
$contentWidth = 920px;

Expand All @@ -11,16 +14,16 @@ $darkBorderColor = alpha(#fff, 0.1);
$purple = #dd6efd;

// red theme colors
$redAccentColor = #de3636;
$redAccentColor = accents.red;

// blue theme colors
$blueAccentColor = #2196f3;
$blueAccentColor = accents.blue;

// purple theme colors
$purpleAccentColor = #a846eb;
$purpleAccentColor = accents.purple;

// green theme colors
$greenAccentColor = #2ecc71;
$greenAccentColor = accents.green;

// content block colors
$tipGreen = #42b983;
Expand Down

0 comments on commit 8021776

Please sign in to comment.