File tree Expand file tree Collapse file tree
src/BikeTracking.Frontend/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .app-header {
2+ position : sticky;
3+ top : 0 ;
4+ z-index : 100 ;
5+ background : # fff ;
6+ border-bottom : 1px solid # d4dbe5 ;
7+ box-shadow : 0 1px 3px rgb (15 23 42 / 8% );
8+ }
9+
10+ .app-header-inner {
11+ max-width : 64rem ;
12+ margin : 0 auto;
13+ padding : 0 1.25rem ;
14+ height : 3.5rem ;
15+ display : flex;
16+ align-items : center;
17+ gap : 1.5rem ;
18+ }
19+
20+ .app-header-brand {
21+ font-size : 1rem ;
22+ font-weight : 700 ;
23+ color : # 152238 ;
24+ text-decoration : none;
25+ white-space : nowrap;
26+ flex-shrink : 0 ;
27+ }
28+
29+ .app-header-brand : hover {
30+ color : # 1d4ed8 ;
31+ }
32+
33+ .app-header-nav {
34+ display : flex;
35+ align-items : center;
36+ gap : 0.25rem ;
37+ flex : 1 ;
38+ }
39+
40+ .nav-link {
41+ padding : 0.4rem 0.75rem ;
42+ border-radius : 0.375rem ;
43+ font-size : 0.9rem ;
44+ font-weight : 500 ;
45+ color : # 374151 ;
46+ text-decoration : none;
47+ transition :
48+ background 0.15s ,
49+ color 0.15s ;
50+ }
51+
52+ .nav-link : hover {
53+ background : # f3f4f6 ;
54+ color : # 0f172a ;
55+ }
56+
57+ .nav-link--active {
58+ background : # eff6ff ;
59+ color : # 1d4ed8 ;
60+ }
61+
62+ .app-header-user {
63+ display : flex;
64+ align-items : center;
65+ gap : 0.75rem ;
66+ flex-shrink : 0 ;
67+ }
68+
69+ .app-header-username {
70+ font-size : 0.875rem ;
71+ font-weight : 600 ;
72+ color : # 374151 ;
73+ }
74+
75+ .header-logout-btn {
76+ padding : 0.4rem 0.85rem ;
77+ border : 1px solid # d4dbe5 ;
78+ border-radius : 0.375rem ;
79+ background : transparent;
80+ color : # 374151 ;
81+ font-size : 0.85rem ;
82+ font-weight : 600 ;
83+ cursor : pointer;
84+ transition : background 0.15s ;
85+ }
86+
87+ .header-logout-btn : hover {
88+ background : # f3f4f6 ;
89+ }
90+
91+ @media (width <= 480px) {
92+ .app-header-username {
93+ display : none;
94+ }
95+
96+ .app-header-brand {
97+ font-size : 0.875rem ;
98+ }
99+ }
Original file line number Diff line number Diff line change 1+ import { NavLink } from 'react-router-dom'
2+ import { useAuth } from '../../context/auth-context'
3+ import './app-header.css'
4+
5+ export function AppHeader ( ) {
6+ const { user, logout } = useAuth ( )
7+
8+ return (
9+ < header className = "app-header" >
10+ < div className = "app-header-inner" >
11+ < NavLink to = "/miles" className = "app-header-brand" >
12+ Commute Bike Tracker
13+ </ NavLink >
14+
15+ < nav className = "app-header-nav" aria-label = "Main navigation" >
16+ < NavLink
17+ to = "/miles"
18+ className = { ( { isActive } ) =>
19+ isActive ? 'nav-link nav-link--active' : 'nav-link'
20+ }
21+ >
22+ Dashboard
23+ </ NavLink >
24+ < NavLink
25+ to = "/rides/record"
26+ className = { ( { isActive } ) =>
27+ isActive ? 'nav-link nav-link--active' : 'nav-link'
28+ }
29+ >
30+ Record Ride
31+ </ NavLink >
32+ </ nav >
33+
34+ < div className = "app-header-user" >
35+ < span className = "app-header-username" > { user ?. userName } </ span >
36+ < button type = "button" className = "header-logout-btn" onClick = { logout } >
37+ Log out
38+ </ button >
39+ </ div >
40+ </ div >
41+ </ header >
42+ )
43+ }
Original file line number Diff line number Diff line change 11import { Navigate , Outlet } from 'react-router-dom'
22import { useAuth } from '../context/auth-context'
3+ import { AppHeader } from './app-header/app-header'
34
45export function ProtectedRoute ( ) {
56 const { user } = useAuth ( )
6- return user ? < Outlet /> : < Navigate to = "/login" replace />
7+ if ( ! user ) return < Navigate to = "/login" replace />
8+ return (
9+ < >
10+ < AppHeader />
11+ < Outlet />
12+ </ >
13+ )
714}
Original file line number Diff line number Diff line change 3939 font-size : 1rem ;
4040}
4141
42- .logout-btn {
43- border : 1px solid # d4dbe5 ;
44- border-radius : 0.4rem ;
45- padding : 0.65rem 1rem ;
46- background : transparent;
47- color : # 374151 ;
48- font-size : 0.9rem ;
49- font-weight : 600 ;
50- cursor : pointer;
51- justify-self : start;
52- }
53-
54- .logout-btn : hover {
55- background : # f3f4f6 ;
56- }
57-
5842@media (width <= 640px) {
5943 .miles-shell {
6044 margin : 1.5rem auto;
Original file line number Diff line number Diff line change @@ -2,16 +2,13 @@ import { useAuth } from '../../context/auth-context'
22import './miles-shell-page.css'
33
44export function MilesShellPage ( ) {
5- const { user, logout } = useAuth ( )
5+ const { user } = useAuth ( )
66
77 return (
88 < main className = "miles-shell" >
99 < div className = "miles-welcome" >
1010 < h1 > Welcome, { user ?. userName } .</ h1 >
1111 < p > Your miles dashboard is coming soon.</ p >
12- < button type = "button" className = "logout-btn" onClick = { logout } >
13- Log out
14- </ button >
1512 </ div >
1613
1714 < div className = "miles-placeholder" aria-label = "Miles content placeholder" >
You can’t perform that action at this time.
0 commit comments