mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 13:44:12 +00:00
feat: electron links open in browser
This commit is contained in:
committed by
Carlos Valente
parent
7f7691a452
commit
177c9a35ec
@@ -47,6 +47,8 @@ $button-size: 3rem;
|
|||||||
@include action-link;
|
@include action-link;
|
||||||
padding: 0.75rem 1.5rem;
|
padding: 0.75rem 1.5rem;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: $menu-hover-bg;
|
background-color: $menu-hover-bg;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { memo, useRef } from 'react';
|
import { memo, PropsWithChildren, useRef } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Drawer,
|
Drawer,
|
||||||
DrawerBody,
|
DrawerBody,
|
||||||
@@ -19,9 +19,12 @@ import { IoSwapVertical } from '@react-icons/all-files/io5/IoSwapVertical';
|
|||||||
|
|
||||||
import { navigatorConstants } from '../../../viewerConfig';
|
import { navigatorConstants } from '../../../viewerConfig';
|
||||||
import useClickOutside from '../../hooks/useClickOutside';
|
import useClickOutside from '../../hooks/useClickOutside';
|
||||||
|
import useElectronEvent from '../../hooks/useElectronEvent';
|
||||||
import { useClientStore } from '../../stores/clientStore';
|
import { useClientStore } from '../../stores/clientStore';
|
||||||
import { useViewOptionsStore } from '../../stores/viewOptions';
|
import { useViewOptionsStore } from '../../stores/viewOptions';
|
||||||
import { isKeyEnter } from '../../utils/keyEvent';
|
import { isKeyEnter } from '../../utils/keyEvent';
|
||||||
|
import { handleLinks } from '../../utils/linkUtils';
|
||||||
|
import { cx } from '../../utils/styleUtils';
|
||||||
import { RenameClientModal } from '../client-modal/RenameClientModal';
|
import { RenameClientModal } from '../client-modal/RenameClientModal';
|
||||||
|
|
||||||
import style from './NavigationMenu.module.scss';
|
import style from './NavigationMenu.module.scss';
|
||||||
@@ -40,6 +43,7 @@ function NavigationMenu(props: NavigationMenuProps) {
|
|||||||
const { isOpen: isOpenRename, onOpen: onRenameOpen, onClose: onCloseRename } = useDisclosure();
|
const { isOpen: isOpenRename, onOpen: onRenameOpen, onClose: onCloseRename } = useDisclosure();
|
||||||
const { fullscreen, toggle } = useFullscreen();
|
const { fullscreen, toggle } = useFullscreen();
|
||||||
const { toggleMirror } = useViewOptionsStore();
|
const { toggleMirror } = useViewOptionsStore();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const menuRef = useRef<HTMLDivElement | null>(null);
|
const menuRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
@@ -96,38 +100,29 @@ function NavigationMenu(props: NavigationMenuProps) {
|
|||||||
<hr className={style.separator} />
|
<hr className={style.separator} />
|
||||||
<Link
|
<Link
|
||||||
to='/editor'
|
to='/editor'
|
||||||
className={`${style.link} ${location.pathname === '/editor' ? style.current : ''}`}
|
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
|
className={`${style.link} ${location.pathname === '/editor' && style.current}`}
|
||||||
>
|
>
|
||||||
<IoLockClosedOutline />
|
<IoLockClosedOutline />
|
||||||
Editor
|
Editor
|
||||||
<IoArrowUp className={style.linkIcon} />
|
<IoArrowUp className={style.linkIcon} />
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<ClientLink to='cuesheet' current={location.pathname === '/cuesheet'}>
|
||||||
to='/cuesheet'
|
|
||||||
className={`${style.link} ${location.pathname === '/cuesheet' ? style.current : ''}`}
|
|
||||||
tabIndex={0}
|
|
||||||
>
|
|
||||||
<IoLockClosedOutline />
|
<IoLockClosedOutline />
|
||||||
Cuesheet
|
Cuesheet
|
||||||
<IoArrowUp className={style.linkIcon} />
|
<IoArrowUp className={style.linkIcon} />
|
||||||
</Link>
|
</ClientLink>
|
||||||
<Link to='/op' className={`${style.link} ${location.pathname === '/op' ? style.current : ''}`} tabIndex={0}>
|
<ClientLink to='op' current={location.pathname === '/op'}>
|
||||||
<IoLockClosedOutline />
|
<IoLockClosedOutline />
|
||||||
Operator
|
Operator
|
||||||
<IoArrowUp className={style.linkIcon} />
|
<IoArrowUp className={style.linkIcon} />
|
||||||
</Link>
|
</ClientLink>
|
||||||
<hr className={style.separator} />
|
<hr className={style.separator} />
|
||||||
{navigatorConstants.map((route) => (
|
{navigatorConstants.map((route) => (
|
||||||
<Link
|
<ClientLink key={route.url} to={route.url} current={location.pathname === `/${route.url}`}>
|
||||||
key={route.url}
|
|
||||||
to={route.url}
|
|
||||||
className={`${style.link} ${route.url === location.pathname ? style.current : undefined}`}
|
|
||||||
tabIndex={0}
|
|
||||||
>
|
|
||||||
{route.label}
|
{route.label}
|
||||||
<IoArrowUp className={style.linkIcon} />
|
<IoArrowUp className={style.linkIcon} />
|
||||||
</Link>
|
</ClientLink>
|
||||||
))}
|
))}
|
||||||
</DrawerBody>
|
</DrawerBody>
|
||||||
</DrawerContent>
|
</DrawerContent>
|
||||||
@@ -137,4 +132,30 @@ function NavigationMenu(props: NavigationMenuProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ClientLinkProps {
|
||||||
|
current: boolean;
|
||||||
|
to: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ClientLink(props: PropsWithChildren<ClientLinkProps>) {
|
||||||
|
const { current, to, children } = props;
|
||||||
|
const { isElectron } = useElectronEvent();
|
||||||
|
|
||||||
|
const classes = cx([style.link, current && style.current]);
|
||||||
|
|
||||||
|
if (isElectron) {
|
||||||
|
return (
|
||||||
|
<button className={classes} tabIndex={0} onClick={(event) => handleLinks(event, to)}>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link to={`/${to}`} className={classes} tabIndex={0}>
|
||||||
|
{children}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default memo(NavigationMenu);
|
export default memo(NavigationMenu);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
export const navigatorConstants = [
|
export const navigatorConstants = [
|
||||||
{ url: '/timer', label: 'Timer' },
|
{ url: 'timer', label: 'Timer' },
|
||||||
{ url: '/clock', label: 'Clock' },
|
{ url: 'clock', label: 'Clock' },
|
||||||
{ url: '/minimal', label: 'Minimal Timer' },
|
{ url: 'minimal', label: 'Minimal Timer' },
|
||||||
{ url: '/backstage', label: 'Backstage' },
|
{ url: 'backstage', label: 'Backstage' },
|
||||||
{ url: '/timeline', label: 'Timeline (beta)' },
|
{ url: 'timeline', label: 'Timeline (beta)' },
|
||||||
{ url: '/public', label: 'Public' },
|
{ url: 'public', label: 'Public' },
|
||||||
{ url: '/lower', label: 'Lower Thirds' },
|
{ url: 'lower', label: 'Lower Thirds' },
|
||||||
{ url: '/studio', label: 'Studio Clock' },
|
{ url: 'studio', label: 'Studio Clock' },
|
||||||
{ url: '/countdown', label: 'Countdown' },
|
{ url: 'countdown', label: 'Countdown' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// default time format to use for users in 12 hour clocks
|
// default time format to use for users in 12 hour clocks
|
||||||
|
|||||||
Reference in New Issue
Block a user