1+ import React from 'react' ;
2+ import styled from 'styled-components' ;
3+ import { useDispatch } from 'react-redux' ;
4+ import { useTheme } from '../../hooks/useTheme' ;
5+ import { showModal } from '../../store/slices/uiSlice' ;
6+ import { ThemeName } from '../../themes/themes' ;
7+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
8+ import { faCog , faHome , faSignInAlt , faSignOutAlt } from '@fortawesome/free-solid-svg-icons' ;
9+ import { ThemeMenu } from "./ThemeMenu" ;
10+
11+ const MenuContainer = styled . div `
12+ display: flex;
13+ justify-content: space-between;
14+ padding: ${ ( { theme} ) => theme . sizing . spacing . sm } ;
15+ background-color: ${ ( { theme} ) => theme . colors . surface } ;
16+ border-bottom: 1px solid ${ ( { theme} ) => theme . colors . border } ;
17+ ` ;
18+
19+ const ToolbarLeft = styled . div `
20+ display: flex;
21+ gap: ${ ( { theme} ) => theme . sizing . spacing . md } ;
22+ ` ;
23+
24+ const Dropdown = styled . div `
25+ position: relative;
26+ display: inline-block;
27+
28+ &:hover .dropdown-content {
29+ display: block;
30+ }
31+ ` ;
32+
33+ const DropButton = styled . a `
34+ color: ${ ( { theme} ) => theme . colors . text . primary } ;
35+ padding: ${ ( { theme} ) => theme . sizing . spacing . sm } ;
36+ text-decoration: none;
37+ cursor: pointer;
38+
39+ &:hover {
40+ background-color: ${ ( { theme} ) => theme . colors . primary } ;
41+ color: white;
42+ }
43+ ` ;
44+
45+ const DropdownContent = styled . div `
46+ display: none;
47+ position: absolute;
48+ background-color: ${ ( { theme} ) => theme . colors . surface } ;
49+ min-width: 160px;
50+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
51+ z-index: 1;
52+ ` ;
53+
54+ const DropdownItem = styled . a `
55+ color: ${ ( { theme} ) => theme . colors . text . primary } ;
56+ padding: ${ ( { theme} ) => theme . sizing . spacing . sm } ;
57+ text-decoration: none;
58+ display: block;
59+ cursor: pointer;
60+
61+ &:hover {
62+ background-color: ${ ( { theme} ) => theme . colors . primary } ;
63+ color: white;
64+ }
65+ ` ;
66+
67+ export const Menu : React . FC = ( ) => {
68+ const dispatch = useDispatch ( ) ;
69+ const [ , setTheme ] = useTheme ( ) ;
70+
71+ const handleThemeChange = ( theme : ThemeName ) => {
72+ setTheme ( theme ) ;
73+ } ;
74+
75+ const handleModalOpen = ( modalType : string ) => {
76+ dispatch ( showModal ( modalType ) ) ;
77+ } ;
78+
79+ return (
80+ < MenuContainer >
81+ < ToolbarLeft >
82+ < DropButton href = "/" >
83+ < FontAwesomeIcon icon = { faHome } /> Home
84+ </ DropButton >
85+
86+ < Dropdown >
87+ < DropButton > App</ DropButton >
88+ < DropdownContent >
89+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'sessions' ) } > Session List</ DropdownItem >
90+ < DropdownItem href = "" > New</ DropdownItem >
91+ </ DropdownContent >
92+ </ Dropdown >
93+
94+ < Dropdown >
95+ < DropButton >
96+ < FontAwesomeIcon icon = { faCog } /> Session
97+ </ DropButton >
98+ < DropdownContent >
99+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'settings' ) } > Settings</ DropdownItem >
100+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'files' ) } > Files</ DropdownItem >
101+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'usage' ) } > Usage</ DropdownItem >
102+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'threads' ) } > Threads</ DropdownItem >
103+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'share' ) } > Share</ DropdownItem >
104+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'cancel' ) } > Cancel</ DropdownItem >
105+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'delete' ) } > Delete</ DropdownItem >
106+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'verbose' ) } > Show Verbose</ DropdownItem >
107+ </ DropdownContent >
108+ </ Dropdown >
109+
110+ < ThemeMenu />
111+
112+ < Dropdown >
113+ < DropButton > About</ DropButton >
114+ < DropdownContent >
115+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'privacy' ) } > Privacy Policy</ DropdownItem >
116+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'tos' ) } > Terms of Service</ DropdownItem >
117+ </ DropdownContent >
118+ </ Dropdown >
119+ </ ToolbarLeft >
120+
121+ < Dropdown >
122+ < DropButton >
123+ < FontAwesomeIcon icon = { faSignInAlt } /> Login
124+ </ DropButton >
125+ < DropdownContent >
126+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'user-settings' ) } > Settings</ DropdownItem >
127+ < DropdownItem onClick = { ( ) => handleModalOpen ( 'user-usage' ) } > Usage</ DropdownItem >
128+ < DropdownItem >
129+ < FontAwesomeIcon icon = { faSignOutAlt } /> Logout
130+ </ DropdownItem >
131+ </ DropdownContent >
132+ </ Dropdown >
133+ </ MenuContainer >
134+ ) ;
135+ } ;
0 commit comments