fix: format
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
FC,
|
FC,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
@@ -8,9 +8,9 @@ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
|||||||
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
|
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
|
||||||
|
|
||||||
import { NavBarButton } from '../atoms/buttons/buttons';
|
import { NavBarButton } from '../atoms/buttons/buttons';
|
||||||
import { UrlForm } from './UrlForm';
|
import { UrlForm } from './UrlForm';
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import {useSocketStore} from "../../context/socket";
|
import { useSocketStore } from "../../context/socket";
|
||||||
import { getCurrentUrl } from "../../api/recording";
|
import { getCurrentUrl } from "../../api/recording";
|
||||||
|
|
||||||
const StyledNavBar = styled.div<{ browserWidth: number }>`
|
const StyledNavBar = styled.div<{ browserWidth: number }>`
|
||||||
@@ -21,8 +21,8 @@ const StyledNavBar = styled.div<{ browserWidth: number }>`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
interface NavBarProps {
|
interface NavBarProps {
|
||||||
browserWidth: number;
|
browserWidth: number;
|
||||||
handleUrlChanged: (url: string) => void;
|
handleUrlChanged: (url: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const BrowserNavBar: FC<NavBarProps> = ({
|
const BrowserNavBar: FC<NavBarProps> = ({
|
||||||
@@ -34,11 +34,11 @@ const BrowserNavBar: FC<NavBarProps> = ({
|
|||||||
|
|
||||||
const [currentUrl, setCurrentUrl] = useState<string>('https://');
|
const [currentUrl, setCurrentUrl] = useState<string>('https://');
|
||||||
|
|
||||||
const handleRefresh = useCallback(() : void => {
|
const handleRefresh = useCallback((): void => {
|
||||||
socket?.emit('input:refresh');
|
socket?.emit('input:refresh');
|
||||||
}, [socket]);
|
}, [socket]);
|
||||||
|
|
||||||
const handleGoTo = useCallback((address: string) : void => {
|
const handleGoTo = useCallback((address: string): void => {
|
||||||
socket?.emit('input:url', address);
|
socket?.emit('input:url', address);
|
||||||
}, [socket]);
|
}, [socket]);
|
||||||
|
|
||||||
@@ -69,54 +69,54 @@ const BrowserNavBar: FC<NavBarProps> = ({
|
|||||||
}
|
}
|
||||||
}, [socket, handleCurrentUrlChange])
|
}, [socket, handleCurrentUrlChange])
|
||||||
|
|
||||||
const addAddress = (address: string) => {
|
const addAddress = (address: string) => {
|
||||||
if (socket) {
|
if (socket) {
|
||||||
handleUrlChanged(address);
|
handleUrlChanged(address);
|
||||||
handleGoTo(address);
|
handleGoTo(address);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledNavBar browserWidth={browserWidth}>
|
<StyledNavBar browserWidth={browserWidth}>
|
||||||
<NavBarButton
|
<NavBarButton
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
socket?.emit('input:back');
|
socket?.emit('input:back');
|
||||||
}}
|
}}
|
||||||
disabled={false}
|
disabled={false}
|
||||||
>
|
>
|
||||||
<ArrowBackIcon/>
|
<ArrowBackIcon />
|
||||||
</NavBarButton>
|
</NavBarButton>
|
||||||
|
|
||||||
<NavBarButton
|
<NavBarButton
|
||||||
type="button"
|
type="button"
|
||||||
onClick={()=>{
|
onClick={() => {
|
||||||
socket?.emit('input:forward');
|
socket?.emit('input:forward');
|
||||||
}}
|
}}
|
||||||
disabled={false}
|
disabled={false}
|
||||||
>
|
>
|
||||||
<ArrowForwardIcon/>
|
<ArrowForwardIcon />
|
||||||
</NavBarButton>
|
</NavBarButton>
|
||||||
|
|
||||||
<NavBarButton
|
<NavBarButton
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (socket) {
|
if (socket) {
|
||||||
handleRefresh()
|
handleRefresh()
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={false}
|
disabled={false}
|
||||||
>
|
>
|
||||||
<ReplayIcon/>
|
<ReplayIcon />
|
||||||
</NavBarButton>
|
</NavBarButton>
|
||||||
|
|
||||||
<UrlForm
|
<UrlForm
|
||||||
currentAddress={currentUrl}
|
currentAddress={currentUrl}
|
||||||
handleRefresh={handleRefresh}
|
handleRefresh={handleRefresh}
|
||||||
setCurrentAddress={addAddress}
|
setCurrentAddress={addAddress}
|
||||||
/>
|
/>
|
||||||
</StyledNavBar>
|
</StyledNavBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BrowserNavBar;
|
export default BrowserNavBar;
|
||||||
|
|||||||
Reference in New Issue
Block a user