aboutsummaryrefslogtreecommitdiffstats
path: root/packages/renderer/src/components/locationBar
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-02-16 01:09:27 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-02-24 00:53:06 +0100
commit39231032ef9abfc3a90af7bf0460037aa220ce11 (patch)
tree0159913431d04689c5a988eb4d69e001486d9bac /packages/renderer/src/components/locationBar
parentchore(deps): Bump dependencies (diff)
downloadsophie-39231032ef9abfc3a90af7bf0460037aa220ce11.tar.gz
sophie-39231032ef9abfc3a90af7bf0460037aa220ce11.tar.zst
sophie-39231032ef9abfc3a90af7bf0460037aa220ce11.zip
feat: Basic location bar
Still needs adding event handlers to actually navigate the browser. Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/renderer/src/components/locationBar')
-rw-r--r--packages/renderer/src/components/locationBar/LocationBar.tsx54
-rw-r--r--packages/renderer/src/components/locationBar/LocationTextField.tsx59
-rw-r--r--packages/renderer/src/components/locationBar/NavigationButtons.tsx75
3 files changed, 188 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..e1f470d
--- /dev/null
+++ b/packages/renderer/src/components/locationBar/LocationBar.tsx
@@ -0,0 +1,54 @@
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
21import { styled } from '@mui/material/styles';
22import { observer } from 'mobx-react-lite';
23import React from 'react';
24
25import { useStore } from '../StoreProvider';
26
27import LocationTextField from './LocationTextField';
28import NavigationButtons from './NavigationButtons';
29
30const LocationBarRoot = styled('header', {
31 name: 'LocationBar',
32 slot: 'Root',
33})(({ theme, hidden }) => ({
34 display: hidden ? 'none' : 'flex',
35 flexDirection: 'row',
36 padding: theme.spacing(1),
37 gap: theme.spacing(1),
38 borderBottom: `1px solid ${theme.palette.divider}`,
39}));
40
41function LocationBar(): JSX.Element {
42 const {
43 settings: { selectedService, showLocationBar },
44 } = useStore();
45
46 return (
47 <LocationBarRoot id="locationBar" hidden={!showLocationBar}>
48 <NavigationButtons service={selectedService} />
49 <LocationTextField service={selectedService} />
50 </LocationBarRoot>
51 );
52}
53
54export default observer(LocationBar);
diff --git a/packages/renderer/src/components/locationBar/LocationTextField.tsx b/packages/renderer/src/components/locationBar/LocationTextField.tsx
new file mode 100644
index 0000000..a618bf6
--- /dev/null
+++ b/packages/renderer/src/components/locationBar/LocationTextField.tsx
@@ -0,0 +1,59 @@
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
21import IconGlobe from '@mui/icons-material/Public';
22import FilledInput from '@mui/material/FilledInput';
23import InputAdornment from '@mui/material/InputAdornment';
24import { Service } from '@sophie/shared';
25import { observer } from 'mobx-react-lite';
26import React from 'react';
27
28function LocationTextField({
29 service,
30}: {
31 service: Service | undefined;
32}): JSX.Element {
33 return (
34 <FilledInput
35 aria-label="Location"
36 inputProps={{
37 spellCheck: false,
38 }}
39 size="small"
40 fullWidth
41 hiddenLabel
42 disableUnderline
43 sx={(theme) => ({
44 borderRadius: 1,
45 '&.Mui-focused': {
46 outline: `2px solid ${theme.palette.primary.main}`,
47 },
48 })}
49 startAdornment={
50 <InputAdornment position="start">
51 <IconGlobe fontSize="small" />
52 </InputAdornment>
53 }
54 value={service?.currentUrl ?? ''}
55 />
56 );
57}
58
59export default observer(LocationTextField);
diff --git a/packages/renderer/src/components/locationBar/NavigationButtons.tsx b/packages/renderer/src/components/locationBar/NavigationButtons.tsx
new file mode 100644
index 0000000..82ed657
--- /dev/null
+++ b/packages/renderer/src/components/locationBar/NavigationButtons.tsx
@@ -0,0 +1,75 @@
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
21import IconArrowBack from '@mui/icons-material/ArrowBack';
22import IconArrowForward from '@mui/icons-material/ArrowForward';
23import IconStop from '@mui/icons-material/Close';
24import IconHome from '@mui/icons-material/HomeOutlined';
25import IconRefresh from '@mui/icons-material/Refresh';
26import Box from '@mui/material/Box';
27import IconButton from '@mui/material/IconButton';
28import { Service } from '@sophie/shared';
29import { observer } from 'mobx-react-lite';
30import React from 'react';
31
32function NavigationButtons({
33 service,
34}: {
35 service: Service | undefined;
36}): JSX.Element {
37 return (
38 <Box
39 sx={{
40 display: 'flex',
41 flexDirection: 'row',
42 }}
43 >
44 <IconButton
45 aria-label="Go back"
46 disabled={service === undefined || !service.canGoBack}
47 >
48 <IconArrowBack />
49 </IconButton>
50 <IconButton
51 aria-label="Go forward"
52 disabled={service === undefined || !service.canGoForward}
53 >
54 <IconArrowForward />
55 </IconButton>
56 {service?.state === 'loading' ? (
57 <IconButton aria-label="Stop">
58 <IconStop />
59 </IconButton>
60 ) : (
61 <IconButton aria-label="Refresh" disabled={service === undefined}>
62 <IconRefresh />
63 </IconButton>
64 )}
65 <IconButton
66 aria-label="Go to service homepage"
67 disabled={service === undefined}
68 >
69 <IconHome />
70 </IconButton>
71 </Box>
72 );
73}
74
75export default observer(NavigationButtons);