summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-06-29 15:09:04 +0200
committerOskar Nyberg <oskar@mullvad.net>2021-07-01 11:37:59 +0200
commitd8ef9a4b86d402d3d4191c0275f6f1007f3eeb1b (patch)
treea05e106ba78eb1c9a9f856af9b6498acd4db35dd /gui/src
parent93f6361d14031d9644d6677c8eb51bf67e288666 (diff)
downloadmullvadvpn-d8ef9a4b86d402d3d4191c0275f6f1007f3eeb1b.tar.xz
mullvadvpn-d8ef9a4b86d402d3d4191c0275f6f1007f3eeb1b.zip
Removed now unused transition rules and helper methods
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/renderer/components/TransitionContainer.tsx6
-rw-r--r--gui/src/renderer/lib/transition-rule.ts42
-rw-r--r--gui/src/renderer/transitions.ts116
3 files changed, 3 insertions, 161 deletions
diff --git a/gui/src/renderer/components/TransitionContainer.tsx b/gui/src/renderer/components/TransitionContainer.tsx
index 5e12acbb56..1d177319c2 100644
--- a/gui/src/renderer/components/TransitionContainer.tsx
+++ b/gui/src/renderer/components/TransitionContainer.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import styled from 'styled-components';
-import { ITransitionGroupProps } from '../transitions';
+import { ITransitionSpecification } from '../lib/history';
interface ITransitioningViewProps {
viewId: string;
@@ -10,10 +10,10 @@ type TransitioningView = React.ReactElement<ITransitioningViewProps>;
interface ITransitionQueueItem {
view: TransitioningView;
- transition: ITransitionGroupProps;
+ transition: ITransitionSpecification;
}
-interface IProps extends ITransitionGroupProps {
+interface IProps extends ITransitionSpecification {
children: TransitioningView;
onTransitionEnd: () => void;
}
diff --git a/gui/src/renderer/lib/transition-rule.ts b/gui/src/renderer/lib/transition-rule.ts
deleted file mode 100644
index 91d5cd6d4c..0000000000
--- a/gui/src/renderer/lib/transition-rule.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { Action } from 'history';
-
-export interface ITransitionDescriptor {
- name: string;
- duration: number;
-}
-
-export interface ITransitionFork {
- forward: ITransitionDescriptor;
- backward: ITransitionDescriptor;
-}
-
-export interface ITransitionMatch {
- direction: 'forward' | 'backward';
- descriptor: ITransitionDescriptor;
-}
-
-export default class TransitionRule {
- constructor(private from: string | null, private to: string, private fork: ITransitionFork) {}
-
- public match(
- fromRoute: string | null,
- toRoute: string,
- action?: Action,
- ): ITransitionMatch | null {
- if (action !== 'POP' && (!this.from || this.from === fromRoute) && this.to === toRoute) {
- return {
- direction: 'forward',
- descriptor: this.fork.forward,
- };
- }
-
- if (action !== 'PUSH' && (!this.from || this.from === toRoute) && this.to === fromRoute) {
- return {
- direction: 'backward',
- descriptor: this.fork.backward,
- };
- }
-
- return null;
- }
-}
diff --git a/gui/src/renderer/transitions.ts b/gui/src/renderer/transitions.ts
deleted file mode 100644
index cddf8c57a2..0000000000
--- a/gui/src/renderer/transitions.ts
+++ /dev/null
@@ -1,116 +0,0 @@
-import { Action } from 'history';
-import TransitionRule, { ITransitionDescriptor, ITransitionFork } from './lib/transition-rule';
-
-export interface ITransitionGroupProps {
- name: string;
- duration: number;
-}
-
-interface ITransitionMap {
- [name: string]: ITransitionFork;
-}
-
-/**
- * Transition descriptors
- */
-const transitions: ITransitionMap = {
- slide: {
- forward: {
- name: 'slide-up',
- duration: 450,
- },
- backward: {
- name: 'slide-down',
- duration: 450,
- },
- },
- push: {
- forward: {
- name: 'push',
- duration: 450,
- },
- backward: {
- name: 'pop',
- duration: 450,
- },
- },
-};
-
-/**
- * Transition rules
- * (null) is used to indicate any route.
- */
-const transitionRules = [
- r('/settings', '/settings/language', transitions.push),
- r('/settings', '/settings/account', transitions.push),
- r('/settings', '/settings/preferences', transitions.push),
- r('/settings', '/settings/advanced', transitions.push),
- r('/settings/advanced', '/settings/advanced/wireguard-keys', transitions.push),
- r('/settings/advanced', '/settings/advanced/linux-split-tunneling', transitions.push),
- r('/settings', '/settings/support', transitions.push),
- r('/main', '/main/voucher/redeem', transitions.push),
- r('/main/voucher/redeem', '/main/voucher/success', transitions.push),
- r('/main/voucher/success', '/main/setup-finished', transitions.push),
- r('/main/voucher/success', '/main', transitions.push),
- r('/main/time-added', '/main/setup-finished', transitions.push),
- r('/main/time-added', '/main', transitions.push),
- r('/main', '/main/time-added', transitions.push),
- r('/main/setup-finished', '/main', transitions.push),
- r(null, '/settings', transitions.slide),
- r(null, '/select-location', transitions.slide),
-];
-
-/**
- * Calculate TransitionGroup props.
- *
- * @param {string} [fromRoute] - source route
- * @param {string} toRoute - target route
- */
-export function getTransitionProps(
- fromRoute: string | null,
- toRoute: string,
- action?: Action,
-): ITransitionGroupProps {
- // ignore initial transition and transition between the same routes
- if (!fromRoute || fromRoute === toRoute) {
- return noTransitionProps();
- }
-
- for (const rule of transitionRules) {
- const match = rule.match(fromRoute, toRoute, action);
- if (match) {
- return toTransitionGroupProps(match.descriptor);
- }
- }
-
- return noTransitionProps();
-}
-
-/**
- * Integrate ITransitionDescriptor into ITransitionGroupProps
- * @param {ITransitionDescriptor} descriptor
- */
-function toTransitionGroupProps(descriptor: ITransitionDescriptor): ITransitionGroupProps {
- const { name, duration } = descriptor;
- return {
- name,
- duration,
- };
-}
-
-/**
- * Returns default props with no animation
- */
-function noTransitionProps(): ITransitionGroupProps {
- return {
- name: '',
- duration: 0,
- };
-}
-
-/**
- * Shortcut to create TransitionRule
- */
-function r(from: string | null, to: string, fork: ITransitionFork): TransitionRule {
- return new TransitionRule(from, to, fork);
-}