File tree Expand file tree Collapse file tree 6 files changed +142
-9
lines changed Expand file tree Collapse file tree 6 files changed +142
-9
lines changed Original file line number Diff line number Diff line change 7
7
< link rel ="icon " href ="./favicon.png " />
8
8
< title > < %= htmlWebpackPlugin.options.title %> </ title >
9
9
</ head >
10
- < body >
10
+ < body id =" app-theme " class =" app-theme " >
11
11
< noscript >
12
12
< strong
13
13
> We're sorry but < %= htmlWebpackPlugin.options.title %> doesn't
Original file line number Diff line number Diff line change 2
2
* Vuejs & TailwindCSS Portfolio Main Styling CSS File
3
3
* Powered by: @NangialaiStoman
4
4
*/
5
+
6
+ .theme-light {
7
+ --bg-background-primary : white;
8
+ --bg-background-secondary : # f7fafc ;
9
+ --bg-background-tertiary : # e2e8f0 ;
10
+
11
+ --bg-background-form : white;
12
+
13
+ --text-copy-primary : # 2d3748 ;
14
+ --text-copy-secondary : # 4a5568 ;
15
+
16
+ --border-border-color-primary : white;
17
+ }
18
+
19
+ .theme-light .search-highlighted {
20
+ background : # f0fff4 ;
21
+ }
22
+
23
+ .theme-light .search-hover : hover {
24
+ background : # f0fff4 ;
25
+ }
26
+
27
+ .theme-dark .markdown-body {
28
+ color : # 24292e ;
29
+ }
30
+
31
+ .theme-dark .search-highlighted {
32
+ background : # 2d3748 ;
33
+ }
34
+
35
+ .theme-dark .search-hover : hover {
36
+ background : # 2d3748 ;
37
+ }
38
+
39
+ .theme-dark {
40
+ --bg-background-primary : # 0d2438 ;
41
+ --bg-background-secondary : # 102c44 ;
42
+ --bg-background-tertiary : # 1e3951 ;
43
+
44
+ --bg-background-form : # 1a202c ;
45
+
46
+ --text-copy-primary : # cbd5e0 ;
47
+ --text-copy-secondary : # e2e8f0 ;
48
+
49
+ --border-border-color-primary : # 1a202c ;
50
+ }
51
+
52
+ .theme-dark .markdown-body {
53
+ color : # cbd5e0 ;
54
+ }
55
+
56
+ .theme-dark nav .active {
57
+ @apply border-white border-b;
58
+ }
59
+
60
+ .content-wrapper {
61
+ transition : background-color 0.25s ;
62
+ }
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <a href =" #" @click.prevent =" toggleTheme" >
3
+ <i
4
+ v-if =" theme === 'light'"
5
+ data-feather =" moon"
6
+ class =" text-liText-ternary-dark hover:text-gray-400 dark:text-liText-ternary-light dark:hover:text-liBorder-primary-light w-5"
7
+ ></i >
8
+ <i
9
+ v-else
10
+ data-feather =" sun"
11
+ class =" text-gray-200 hover:text-gray-50 w-5"
12
+ ></i >
13
+ </a >
14
+ </template >
15
+
16
+ <script >
17
+ export default {
18
+ props: {
19
+ theme: {
20
+ type: String ,
21
+ required: true ,
22
+ },
23
+ },
24
+ methods: {
25
+ toggleTheme () {
26
+ const newTheme = this .theme === ' light' ? ' dark' : ' light' ;
27
+ localStorage .setItem (' theme' , newTheme);
28
+ this .$emit (' themeChanged' , newTheme);
29
+ this .$router .go ();
30
+ },
31
+ },
32
+ };
33
+ </script >
Original file line number Diff line number Diff line change 53
53
</button >
54
54
</div >
55
55
<div
56
- class =" sm: ml-7 bg-gray-50 p-2 rounded-lg shadow-sm cursor-pointer"
56
+ class =" ml-8 bg-gray-50 p-3 shadow-sm rounded-xl cursor-pointer"
57
57
>
58
- <a href =" #"
59
- ><i
60
- data-feather =" moon"
61
- class =" text-gray-500 hover:text-gray-400"
62
- ></i
63
- ></a >
58
+ <theme-switcher
59
+ :theme =" theme"
60
+ @themeChanged =" updateTheme"
61
+ />
64
62
</div >
65
63
</div >
66
64
</div >
67
65
</nav >
68
66
</template >
69
67
70
68
<script >
69
+ import ThemeSwitcher from ' ../ThemeSwitcher' ;
71
70
import feather from ' feather-icons' ;
71
+
72
72
export default {
73
+ components: {
74
+ ThemeSwitcher,
75
+ },
76
+ data () {
77
+ return {
78
+ isOpen: false ,
79
+ theme: ' ' ,
80
+ };
81
+ },
82
+
83
+ created () {
84
+ this .theme = localStorage .getItem (' theme' ) || ' light' ;
85
+ },
73
86
mounted () {
74
87
feather .replace ();
88
+ this .theme = localStorage .getItem (' theme' ) || ' light' ;
89
+ },
90
+ methods: {
91
+ updateTheme (theme ) {
92
+ this .theme = theme;
93
+ },
75
94
},
76
95
updated () {
77
96
feather .replace ();
Original file line number Diff line number Diff line change @@ -2,10 +2,22 @@ import { createApp } from 'vue';
2
2
import App from './App.vue' ;
3
3
import router from './router' ;
4
4
import './assets/css/tailwind.css' ;
5
+ import './assets/css/app.css' ;
5
6
6
7
const feather = require ( 'feather-icons' ) ;
7
8
feather . replace ( ) ;
8
9
9
10
createApp ( App )
10
11
. use ( router )
11
12
. mount ( '#app' ) ;
13
+
14
+ const appTheme = localStorage . getItem ( 'theme' ) ;
15
+
16
+ if (
17
+ appTheme === 'dark' &&
18
+ document . querySelector ( 'body' ) . classList . contains ( 'app-theme' )
19
+ ) {
20
+ document . querySelector ( 'body' ) . classList . add ( 'bg-background-primary-dark' ) ;
21
+ } else {
22
+ document . querySelector ( 'body' ) . classList . add ( 'bg-background-primary-light' ) ;
23
+ }
Original file line number Diff line number Diff line change @@ -2,7 +2,18 @@ module.exports = {
2
2
purge : { content : [ './public/**/*.html' , './src/**/*.vue' ] } ,
3
3
darkMode : false , // or 'media' or 'class'
4
4
theme : {
5
- extend : { } ,
5
+ extend : {
6
+ colors : {
7
+ background : {
8
+ 'primary-light' : '#F7F8FC' ,
9
+ 'secondary-light' : '#FFFFFF' ,
10
+ 'ternary-light' : '#f6f7f8' ,
11
+ 'primary-dark' : '#0D2438' ,
12
+ 'secondary-dark' : '#102D44' ,
13
+ 'ternary-dark' : '#1E3851' ,
14
+ } ,
15
+ } ,
16
+ } ,
6
17
container : {
7
18
padding : {
8
19
DEFAULT : '1rem' ,
You can’t perform that action at this time.
0 commit comments