File tree Expand file tree Collapse file tree 5 files changed +162
-11
lines changed
Expand file tree Collapse file tree 5 files changed +162
-11
lines changed Original file line number Diff line number Diff line change 22 * Vuejs & TailwindCSS Portfolio Main Styling CSS File
33 * Powered by: @NangialaiStoman
44*/
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
3+ href =" #"
4+ class =" text-copy-primary hover:text-gray-600"
5+ @click.prevent =" toggleTheme"
6+ data-cypress =" switchTheme"
7+ >
8+ <svg
9+ v-if =" theme === 'theme-light'"
10+ xmlns =" http://www.w3.org/2000/svg"
11+ width =" 24"
12+ height =" 24"
13+ fill =" none"
14+ stroke =" currentColor"
15+ stroke-width =" 2"
16+ stroke-linecap =" round"
17+ stroke-linejoin =" round"
18+ class =" feather feather-moon"
19+ >
20+ <path d =" M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
21+ </svg >
22+ <svg
23+ v-else
24+ xmlns =" http://www.w3.org/2000/svg"
25+ width =" 24"
26+ height =" 24"
27+ fill =" none"
28+ stroke =" currentColor"
29+ stroke-width =" 2"
30+ stroke-linecap =" round"
31+ stroke-linejoin =" round"
32+ class =" feather feather-sun"
33+ >
34+ <circle cx =" 12" cy =" 12" r =" 5" />
35+ <path
36+ d =" M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"
37+ />
38+ </svg >
39+ </a >
40+ </template >
41+
42+ <script >
43+ export default {
44+ props: {
45+ theme: {
46+ type: String ,
47+ required: true ,
48+ },
49+ },
50+ methods: {
51+ toggleTheme () {
52+ const newTheme =
53+ this .theme === ' theme-light' ? ' theme-dark' : ' theme-light' ;
54+ localStorage .setItem (' theme' , newTheme);
55+ this .$emit (' themeChanged' , newTheme);
56+ },
57+ },
58+ };
59+ </script >
Original file line number Diff line number Diff line change 11<template >
2- <nav id =" nav" class =" container mx-auto bg-white" >
2+ <nav id =" nav" class =" container mx-auto bg-white" :class = " theme " >
33 <div class =" md:flex items-center justify-between my-6" >
44 <div class =" flex justify-between items-center" >
55 <div class =" text-2xl font-bold text-gray-800 md:text-3xl" >
5252 Hire Me
5353 </button >
5454 </div >
55- <div
56- class =" sm:ml-7 bg-gray-50 p-2 rounded-lg shadow-sm cursor-pointer"
57- >
58- <a href =" #"
59- ><i
60- data-feather =" moon"
61- class =" text-gray-500 hover:text-gray-400"
62- ></i
63- ></a >
55+ <div >
56+ <theme-switcher
57+ :theme =" theme"
58+ @themeChanged =" updateTheme"
59+ />
6460 </div >
6561 </div >
6662 </div >
6965
7066<script >
7167import feather from ' feather-icons' ;
68+ import ThemeSwitcher from ' ../ThemeSwitcher.vue' ;
69+
7270export default {
71+ components: {
72+ ThemeSwitcher,
73+ },
74+ data () {
75+ return {
76+ isOpen: false ,
77+ theme: ' ' ,
78+ };
79+ },
80+ toggle () {
81+ this .isOpen = ! this .isOpen ;
82+ },
83+ updateTheme (theme ) {
84+ this .theme = theme;
85+ },
7386 mounted () {
7487 feather .replace ();
88+ this .theme = localStorage .getItem (' theme' ) || ' theme-light' ;
7589 },
7690 updated () {
7791 feather .replace ();
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { createApp } from 'vue';
22import App from './App.vue' ;
33import router from './router' ;
44import './assets/css/tailwind.css' ;
5+ import './assets/css/app.css' ;
56
67const feather = require ( 'feather-icons' ) ;
78feather . replace ( ) ;
Original file line number Diff line number Diff line change @@ -14,7 +14,26 @@ module.exports = {
1414 } ,
1515 } ,
1616 variants : {
17- extend : { } ,
17+ extend : {
18+ colors : {
19+ background : {
20+ primary : 'var(--bg-background-primary)' ,
21+ secondary : 'var(--bg-background-secondary)' ,
22+ tertiary : 'var(--bg-background-tertiary)' ,
23+
24+ form : 'var(--bg-background-form)' ,
25+ } ,
26+
27+ copy : {
28+ primary : 'var(--text-copy-primary)' ,
29+ secondary : 'var(--text-copy-hover)' ,
30+ } ,
31+
32+ 'border-color' : {
33+ primary : 'var(--border-border-color-primary)' ,
34+ } ,
35+ } ,
36+ } ,
1837 } ,
1938 plugins : [
2039 require ( '@tailwindcss/forms' ) ( {
You can’t perform that action at this time.
0 commit comments