77
77
font-size : 18px ;
78
78
}
79
79
80
+ .section {
81
+ display : none;
82
+ opacity : 0 ;
83
+ transform : translateY (20px );
84
+ transition : opacity var (--transition-speed ), transform var (--transition-speed );
85
+ }
86
+
87
+ .section .active {
88
+ display : block;
89
+ opacity : 1 ;
90
+ transform : translateY (0 );
91
+ }
92
+
80
93
</ style >
81
94
</ head >
82
95
< body >
85
98
< button onclick ="showSection('ordering') "> Ordering</ button >
86
99
< button onclick ="showSection('rules') "> Rules</ button >
87
100
< button onclick ="showSection('settings') "> Settings</ button >
88
- < button > < a href =" https://scratch-coding-hut.github.io/ account" id =" account-link " style =" color: inherit; text-decoration: none; " > My Account</ a > </ button >
101
+ < button onclick =" showSection(' account') " > My Account</ button >
89
102
</ div >
90
103
91
104
< div class ="auth-status " id ="authStatus "> Checking login status...</ div >
92
105
93
- < div id ="home " class ="section ">
106
+ < div id ="home " class ="section active ">
94
107
< h1 > Welcome to Coding Hut</ h1 >
95
108
< p > The best coding shop of Scratch</ p >
96
109
</ div >
@@ -103,7 +116,7 @@ <h1>Rules:</h1>
103
116
< li > Be respectful to customers and employees.</ li >
104
117
</ ol >
105
118
</ div >
106
- < div id ="settings " class ="section " style =" display:none; " >
119
+ < div id ="settings " class ="section ">
107
120
< h2 > Settings</ h2 >
108
121
< div class ="settings ">
109
122
< label >
@@ -116,30 +129,42 @@ <h2>Settings</h2>
116
129
</ div >
117
130
</ div >
118
131
132
+ < div id ="account " class ="section ">
133
+ < h2 > My Account</ h2 >
134
+ < p > Welcome, < span id ="accountUser "> </ span > !</ p >
135
+ </ div >
136
+
119
137
< script >
120
138
function showSection ( sectionId ) {
121
139
document . querySelectorAll ( '.section' ) . forEach ( section => {
122
- section . style . display = 'none' ;
140
+ section . classList . remove ( 'active' ) ;
123
141
} ) ;
124
- document . getElementById ( sectionId ) . style . display = 'block' ;
142
+ document . getElementById ( sectionId ) . classList . add ( 'active' ) ;
125
143
}
126
144
127
145
function toggleDarkMode ( ) {
128
146
document . body . classList . toggle ( 'dark-mode' ) ;
147
+ localStorage . setItem ( 'darkMode' , document . body . classList . contains ( 'dark-mode' ) ) ;
129
148
}
130
149
131
150
function updateAuthStatus ( ) {
132
151
const storedUser = localStorage . getItem ( "loggedInUser" ) ;
133
152
const authStatus = document . getElementById ( "authStatus" ) ;
134
153
if ( storedUser ) {
135
154
authStatus . innerText = `Logged in as: ${ storedUser } ` ;
136
- document . getElementById ( "account-link " ) . innerText = `My Account ( ${ storedUser } )` ;
155
+ document . getElementById ( "accountUser " ) . innerText = storedUser ;
137
156
} else {
138
157
authStatus . innerText = "Not logged in" ;
139
158
}
140
159
}
141
160
142
- window . onload = updateAuthStatus ;
161
+ window . onload = function ( ) {
162
+ updateAuthStatus ( ) ;
163
+ if ( localStorage . getItem ( 'darkMode' ) === 'true' ) {
164
+ document . body . classList . add ( 'dark-mode' ) ;
165
+ document . getElementById ( 'darkModeToggle' ) . checked = true ;
166
+ }
167
+ } ;
143
168
</ script >
144
169
</ body >
145
170
</ html >
0 commit comments