Skip to content

Commit

Permalink
refactor: add nif to navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
cpvalente committed Oct 19, 2024
1 parent ea2330e commit de51e18
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
.linkIcon {
margin-left: $element-inner-spacing;
display: inline-block;
transform: rotate(45deg);
@include rotate-fourty-five;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,27 @@ $button-size: 3rem;

.linkIcon {
margin-left: auto;
transform: rotate(45deg);
@include rotate-fourty-five;
}

.separator {
border-color: $border-color-ondark;
}

.sectionHeader {
font-size: calc(1rem - 2px);
margin-left: 1rem;
color: $gray-700;
}

.bottom {
margin-top: auto;
margin-bottom: 1rem;
}

.interfaces {
padding: 0.5rem 1rem;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ import { IoLockClosedOutline } from '@react-icons/all-files/io5/IoLockClosedOutl
import { IoSwapVertical } from '@react-icons/all-files/io5/IoSwapVertical';

import { navigatorConstants } from '../../../viewerConfig';
import { isLocalhost, serverPort } from '../../api/constants';
import useClickOutside from '../../hooks/useClickOutside';
import useElectronEvent from '../../hooks/useElectronEvent';
import useInfo from '../../hooks-query/useInfo';
import { useClientStore } from '../../stores/clientStore';
import { useViewOptionsStore } from '../../stores/viewOptions';
import { isKeyEnter } from '../../utils/keyEvent';
import { handleLinks } from '../../utils/linkUtils';
import { handleLinks, openLink } from '../../utils/linkUtils';
import { cx } from '../../utils/styleUtils';
import { RenameClientModal } from '../client-modal/RenameClientModal';
import CopyTag from '../copy-tag/CopyTag';

import style from './NavigationMenu.module.scss';

Expand Down Expand Up @@ -59,7 +62,7 @@ function NavigationMenu(props: NavigationMenuProps) {
<DrawerCloseButton size='lg' />
Ontime
</DrawerHeader>
<DrawerBody padding={0}>
<DrawerBody>
<div className={style.buttonsContainer}>
<div
className={style.link}
Expand Down Expand Up @@ -120,6 +123,7 @@ function NavigationMenu(props: NavigationMenuProps) {
{route.label}
</ClientLink>
))}
{isLocalhost && <OtherAddresses currentLocation={location.pathname} />}
</DrawerBody>
</DrawerContent>
</Drawer>
Expand All @@ -128,6 +132,45 @@ function NavigationMenu(props: NavigationMenuProps) {
);
}

interface OtherAddressesProps {
currentLocation: string;
}

function OtherAddresses(props: OtherAddressesProps) {
const { currentLocation } = props;
const { data } = useInfo();

// there is no point showing this if we only have one interface
if (data.networkInterfaces.length < 2) {
return null;
}

return (
<div className={style.bottom}>
<div className={style.sectionHeader}>Accessible on external networks</div>
<div className={style.interfaces}>
{data?.networkInterfaces?.map((nif) => {
if (nif.name === 'localhost') {
return null;
}

const address = `http://${nif.address}:${serverPort}${currentLocation}`;
return (
<CopyTag
key={nif.name}
copyValue={address}
onClick={() => openLink(address)}
label='Copy IP or navigate to address'
>
{nif.address} <IoArrowUp className={style.fourtyfive} />
</CopyTag>
);
})}
</div>
</div>
);
}

interface ClientLinkProps {
current: boolean;
to: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
}

.goIcon {
transform: rotate(45deg);
@include rotate-fourty-five;
margin-left: 0.25rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

.corner {
transform: rotate(45deg);
@include rotate-fourty-five;

position: absolute;
top: 0.5rem;
Expand Down
8 changes: 8 additions & 0 deletions apps/client/src/theme/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@
overflow: hidden;
text-overflow: ellipsis;
}

@mixin rotate-fourty-five {
transform: rotate(45deg);
}

.fourtyfive {
@include rotate-fourty-five;
}
2 changes: 1 addition & 1 deletion apps/client/src/theme/_viewerDefs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ $external-color: rgba(white, 85%); // --external-color-override

// properties of other timers (clock and countdown)
$timer-label-size: clamp(16px, 1.5vw, 24px);
$timer-value-size: clamp(2rem, 3.5vw, 3.5rem);
$timer-value-size: clamp(2rem, 3.5vw, 3.5rem);
6 changes: 6 additions & 0 deletions apps/client/src/theme/ontimeDrawer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
export const ontimeDrawer = {
dialog: {
maxWidth: '300px',
},
header: {
color: '#fefefe', // $gray-50
backgroundColor: '#202020', // $gray-1250
},
body: {
padding: 0,
display: 'flex',
flexDirection: 'column',
color: '#fefefe', // $gray-50
backgroundColor: '#202020', // $gray-1250
},
Expand Down

0 comments on commit de51e18

Please sign in to comment.