diff options
Diffstat (limited to 'packages/renderer/src/components/locationBar/LocationBar.tsx')
-rw-r--r-- | packages/renderer/src/components/locationBar/LocationBar.tsx | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/packages/renderer/src/components/locationBar/LocationBar.tsx b/packages/renderer/src/components/locationBar/LocationBar.tsx new file mode 100644 index 0000000..fd7dcbb --- /dev/null +++ b/packages/renderer/src/components/locationBar/LocationBar.tsx | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2022 Kristóf Marussy <kristof@marussy.com> | ||
3 | * | ||
4 | * This file is part of Sophie. | ||
5 | * | ||
6 | * Sophie is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Affero General Public License as | ||
8 | * published by the Free Software Foundation, version 3. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * SPDX-License-Identifier: AGPL-3.0-only | ||
19 | */ | ||
20 | |||
21 | import { styled } from '@mui/material/styles'; | ||
22 | import { observer } from 'mobx-react-lite'; | ||
23 | import React from 'react'; | ||
24 | |||
25 | import type RendererStore from '../../stores/RendererStore.js'; | ||
26 | import type Service from '../../stores/Service.js'; | ||
27 | |||
28 | import ExtraButtons from './ExtraButtons.js'; | ||
29 | import LocationTextField from './LocationTextField.js'; | ||
30 | import NavigationButtons from './NavigationButtons.js'; | ||
31 | |||
32 | export function getLocaltionBarID(service: Service): string { | ||
33 | return `Sophie-${service.id}-LocationBar`; | ||
34 | } | ||
35 | |||
36 | const LocationBarRoot = styled('header', { | ||
37 | name: 'LocationBar', | ||
38 | slot: 'Root', | ||
39 | })(({ theme, hidden }) => ({ | ||
40 | display: hidden ? 'none' : 'flex', | ||
41 | flexDirection: 'row', | ||
42 | padding: theme.spacing(1), | ||
43 | gap: theme.spacing(1), | ||
44 | borderBottom: `1px solid ${theme.palette.divider}`, | ||
45 | })); | ||
46 | |||
47 | function LocationBar({ | ||
48 | store: { | ||
49 | settings: { showLocationBar }, | ||
50 | }, | ||
51 | service, | ||
52 | }: { | ||
53 | store: RendererStore; | ||
54 | service: Service; | ||
55 | }): JSX.Element { | ||
56 | const { alwaysShowLocationBar } = service; | ||
57 | const locationBarVisible = showLocationBar || alwaysShowLocationBar; | ||
58 | |||
59 | return ( | ||
60 | <LocationBarRoot | ||
61 | id={getLocaltionBarID(service)} | ||
62 | hidden={!locationBarVisible} | ||
63 | > | ||
64 | <NavigationButtons service={service} /> | ||
65 | <LocationTextField service={service} /> | ||
66 | <ExtraButtons service={service} /> | ||
67 | </LocationBarRoot> | ||
68 | ); | ||
69 | } | ||
70 | |||
71 | export default observer(LocationBar); | ||