Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical line on onion path modal #1735

Merged
merged 3 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions stylesheets/_session.scss
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ label {
}
&__close > div {
float: left;
padding: $session-margin-xs;
margin: 0px;
}
&__icons > div {
Expand Down Expand Up @@ -1203,21 +1204,49 @@ input {
flex-direction: column;
margin: $session-margin-sm;
align-items: flex-start;
position: relative;

.onion__node {
display: flex;
flex-grow: 1;
align-items: center;
margin: $session-margin-xs;

* {
margin: $session-margin-sm;
&:nth-child(2) {
margin-top: 0;
}

&:nth-last-child(2) {
margin-bottom: 0;
}

.session-icon-button {
margin: $session-margin-sm !important;
}
}

.onion__node-list-lights {
position: relative;
}
.onion__node__country {
margin: $session-margin-sm;
}

.onion__growing-icon {
flex-grow: 1;
display: flex;
align-items: center;
}

.onion__vertical-line {
background: $onionPathLineColor;
position: absolute;
height: calc(100% - 2 * 15px);
margin: 15px calc(100% / 2 - 1px);

width: 1px;
// z-index: -1;
}
}

.session-nickname-wrapper {
Expand Down
2 changes: 2 additions & 0 deletions stylesheets/themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ $borderLightTheme: #f1f1f1; // search for references on ts TODO: make this expos
$borderDarkTheme: rgba($white, 0.06);
$inputBackgroundColor: #8e8e93;

$onionPathLineColor: rgba(#7a7a7a, 0.6);

$borderAvatarColor: unquote(
'#00000059'
); // search for references on ts TODO: make this exposed on ts
Expand Down
90 changes: 48 additions & 42 deletions ts/components/OnionStatusPathDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Electron from 'electron';
const { shell } = Electron;

import { useDispatch, useSelector } from 'react-redux';
import { StateType } from '../state/reducer';
import { SessionIcon, SessionIconButton, SessionIconSize, SessionIconType } from './session/icon';

import { SessionWrapperModal } from './session/SessionWrapperModal';
Expand All @@ -27,6 +26,7 @@ import {
// tslint:disable-next-line: no-submodule-imports
import useNetworkState from 'react-use/lib/useNetworkState';
import { SessionSpinner } from './session/SessionSpinner';
import { Flex } from './basic/Flex';

export type StatusLightType = {
glowStartDelay: number;
Expand Down Expand Up @@ -56,53 +56,57 @@ const OnionPathModalInner = () => {
<>
<p className="onion__description">{window.i18n('onionPathIndicatorDescription')}</p>
<div className="onion__node-list">
{nodes.map((snode: Snode | any, index: number) => {
return (
<OnionNodeStatusLight
glowDuration={glowDuration}
glowStartDelay={index}
label={snode.label}
snode={snode}
key={index}
/>
);
})}
<Flex container={true}>
<div className="onion__node-list-lights">
<div className="onion__vertical-line" />

<Flex container={true} flexDirection="column" alignItems="center" height="100%">
{nodes.map((_snode: Snode | any, index: number) => {
return (
<OnionNodeStatusLight
glowDuration={glowDuration}
glowStartDelay={index}
key={index}
/>
);
})}
</Flex>
</div>
<Flex container={true} flexDirection="column" alignItems="flex-start">
{nodes.map((snode: Snode | any, index: number) => {
let labelText = snode.label
? snode.label
: countryLookup.byIso(ip2country(snode.ip))?.country;
if (!labelText) {
labelText = window.i18n('unknownCountry');
}
return labelText ? <div className="onion__node__country">{labelText}</div> : null;
})}
</Flex>
</Flex>
</div>
</>
);
};

export type OnionNodeStatusLightType = {
snode: Snode;
label?: string;
glowStartDelay: number;
glowDuration: number;
};

/**
* Component containing a coloured status light and an adjacent country label.
* Component containing a coloured status light.
*/
export const OnionNodeStatusLight = (props: OnionNodeStatusLightType): JSX.Element => {
const { snode, label, glowStartDelay, glowDuration } = props;
const { glowStartDelay, glowDuration } = props;
const theme = useTheme();

let labelText = label ? label : countryLookup.byIso(ip2country(snode.ip))?.country;
if (!labelText) {
labelText = window.i18n('unknownCountry');
}
return (
<div className="onion__node">
<ModalStatusLight
glowDuration={glowDuration}
glowStartDelay={glowStartDelay}
color={theme.colors.accent}
/>
{labelText ? (
<>
<div className="onion-node__country">{labelText}</div>
</>
) : null}
</div>
<ModalStatusLight
glowDuration={glowDuration}
glowStartDelay={glowStartDelay}
color={theme.colors.accent}
/>
);
};

Expand All @@ -114,15 +118,17 @@ export const ModalStatusLight = (props: StatusLightType) => {
const theme = useSelector(getTheme);

return (
<SessionIcon
borderRadius={50}
iconColor={color}
glowDuration={glowDuration}
glowStartDelay={glowStartDelay}
iconType={SessionIconType.Circle}
iconSize={SessionIconSize.Small}
theme={theme}
/>
<div className="onion__growing-icon">
<SessionIcon
borderRadius={50}
iconColor={color}
glowDuration={glowDuration}
glowStartDelay={glowStartDelay}
iconType={SessionIconType.Circle}
iconSize={SessionIconSize.Tiny}
theme={theme}
/>
</div>
);
};

Expand Down Expand Up @@ -154,7 +160,7 @@ export const ActionPanelOnionStatusLight = (props: {

return (
<SessionIconButton
iconSize={SessionIconSize.Medium}
iconSize={SessionIconSize.Small}
iconType={SessionIconType.Circle}
iconColor={iconColor}
onClick={handleClick}
Expand Down
8 changes: 6 additions & 2 deletions ts/components/session/icon/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ export const icons = {
ratio: 1,
},
[SessionIconType.Circle]: {
path: 'M 100, 100m -75, 0a 75,75 0 1,0 150,0a 75,75 0 1,0 -150,0',
viewBox: '0 0 200 200',
path: '\
M 0, 50\
a 50,50 0 1,1 100,0\
a 50,50 0 1,1 -100,0\
',
viewBox: '0 0 100 100',
ratio: 1,
},
[SessionIconType.CircleCheck]: {
Expand Down