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

Convert config.json to constants #7497

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ If you're using GNOME, try installing one of these GNOME Shell extensions:
- **app.tsx** - Entry file for the renderer process
- **routes.tsx** - Routes configurator
- **transitions.ts** - Transition rules between views
- **config.json** - App color definitions and URLs to external resources
- **tasks/** - Gulp tasks used to build app and watch for changes during development
- **distribution.js** - Configuration for `electron-builder`
- **test/** - Electron GUI tests
Expand Down
48 changes: 0 additions & 48 deletions desktop/packages/mullvad-vpn/src/config.json

This file was deleted.

4 changes: 2 additions & 2 deletions desktop/packages/mullvad-vpn/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import fs from 'fs';
import * as path from 'path';
import util from 'util';

import config from '../config.json';
import { hasExpired } from '../shared/account-expiry';
import {
ISplitTunnelingApplication,
ISplitTunnelingAppListRetriever,
} from '../shared/application-types';
import { links } from '../shared/constants';
import {
AccessMethodSetting,
DaemonEvent,
Expand Down Expand Up @@ -855,7 +855,7 @@ class ApplicationMain

IpcMainEventChannel.app.handleQuit(() => this.disconnectAndQuit());
IpcMainEventChannel.app.handleOpenUrl(async (url) => {
if (Object.values(config.links).find((link) => url.startsWith(link))) {
if (Object.values(links).find((link) => url.startsWith(link))) {
await shell.openExternal(url);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect } from 'react';

import { links } from '../../config.json';
import { formatDate, hasExpired } from '../../shared/account-expiry';
import { links } from '../../shared/constants';
import { messages } from '../../shared/gettext';
import { useAppContext } from '../context';
import { useHistory } from '../lib/history';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components';

import { colors } from '../../config.json';
import { Colors } from '../lib/foundations';
import { measurements, normalText, tinyText } from './common-styles';

export const AccountContainer = styled.div({
Expand Down Expand Up @@ -28,20 +28,20 @@ const AccountRowText = styled.span({
export const AccountRowLabel = styled(AccountRowText)(tinyText, {
lineHeight: '20px',
marginBottom: '5px',
color: colors.white60,
color: Colors.white60,
});

export const AccountRowValue = styled(AccountRowText)(normalText, {
fontWeight: 600,
color: colors.white,
color: Colors.white,
});

export const DeviceRowValue = styled(AccountRowValue)({
textTransform: 'capitalize',
});

export const AccountOutOfTime = styled(AccountRowValue)({
color: colors.red,
color: Colors.red,
});

export const StyledDeviceNameRow = styled.div({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { useCallback, useMemo } from 'react';
import { sprintf } from 'sprintf-js';
import styled from 'styled-components';

import { colors } from '../../config.json';
import { AccessMethodSetting } from '../../shared/daemon-rpc-types';
import { messages } from '../../shared/gettext';
import { useAppContext } from '../context';
import { useApiAccessMethodTest } from '../lib/api-access-methods';
import { Container, Flex } from '../lib/components';
import { Spacings } from '../lib/foundations';
import { Colors, Spacings } from '../lib/foundations';
import { useHistory } from '../lib/history';
import { generateRoutePath } from '../lib/routeHelpers';
import { RoutePath } from '../lib/routes';
Expand Down Expand Up @@ -50,7 +49,7 @@ const StyledTestResultCircle = styled.div<{ $result: boolean }>((props) => ({
width: '10px',
height: '10px',
borderRadius: '50%',
backgroundColor: props.$result ? colors.green : colors.red,
backgroundColor: props.$result ? Colors.green : Colors.red,
marginRight: Spacings.spacing2,
}));

Expand Down Expand Up @@ -300,8 +299,8 @@ function ApiAccessMethod(props: ApiAccessMethodProps) {
<ContextMenuTrigger>
<StyledMethodTriggerImage
source="icon-more"
tintColor={colors.white}
tintHoverColor={colors.white80}
tintColor={Colors.white}
tintHoverColor={Colors.white80}
height={36}
width={36}
/>
Expand Down
24 changes: 12 additions & 12 deletions desktop/packages/mullvad-vpn/src/renderer/components/AppButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useCallback, useContext, useMemo, useState } from 'react';
import styled from 'styled-components';

import { colors } from '../../config.json';
import log from '../../shared/logging';
import { Colors } from '../lib/foundations';
import { useMounted } from '../lib/utility-hooks';
import {
StyledButtonContent,
Expand Down Expand Up @@ -32,7 +32,7 @@ interface IIconProps {
}

export function Icon(props: IIconProps) {
return <ImageView {...props} tintColor={colors.white} />;
return <ImageView {...props} tintColor={Colors.white} />;
}

export interface IProps extends React.HTMLAttributes<HTMLButtonElement> {
Expand Down Expand Up @@ -157,37 +157,37 @@ export function BlockingButton(props: IBlockingProps) {
}

export const RedButton = styled(BaseButton)({
backgroundColor: colors.red,
backgroundColor: Colors.red,
'&&:not(:disabled):hover': {
backgroundColor: colors.red95,
backgroundColor: Colors.red95,
},
});

export const GreenButton = styled(BaseButton)({
backgroundColor: colors.green,
backgroundColor: Colors.green,
'&&:not(:disabled):hover': {
backgroundColor: colors.green90,
backgroundColor: Colors.green90,
},
});

export const BlueButton = styled(BaseButton)({
backgroundColor: colors.blue80,
backgroundColor: Colors.blue80,
'&&:not(:disabled):hover': {
backgroundColor: colors.blue60,
backgroundColor: Colors.blue60,
},
});

export const TransparentButton = styled(BaseButton)(transparentButton, {
backgroundColor: colors.white20,
backgroundColor: Colors.white20,
'&&:not(:disabled):hover': {
backgroundColor: colors.white40,
backgroundColor: Colors.white40,
},
});

export const RedTransparentButton = styled(BaseButton)(transparentButton, {
backgroundColor: colors.red60,
backgroundColor: Colors.red60,
'&&:not(:disabled):hover': {
backgroundColor: colors.red80,
backgroundColor: Colors.red80,
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import styled from 'styled-components';

import { colors } from '../../config.json';
import { Colors } from '../lib/foundations';
import { Icon } from './cell/Label';

interface IProps extends React.HTMLAttributes<HTMLButtonElement> {
Expand All @@ -25,8 +25,8 @@ export default function ChevronButton(props: IProps) {
return (
<Button {...otherProps}>
<StyledIcon
tintColor={colors.white80}
tintHoverColor={colors.white}
tintColor={Colors.white80}
tintHoverColor={Colors.white}
source={up ? 'icon-chevron-up' : 'icon-chevron-down'}
height={24}
width={24}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useCallback } from 'react';
import styled from 'styled-components';

import { colors } from '../../config.json';
import { messages } from '../../shared/gettext';
import log from '../../shared/logging';
import { useScheduler } from '../../shared/scheduler';
import { Colors } from '../lib/foundations';
import { useBoolean } from '../lib/utility-hooks';
import ImageView from './ImageView';

Expand Down Expand Up @@ -80,8 +80,8 @@ export default function ClipboardLabel(props: IProps) {
}>
<ImageView
source={obscured ? 'icon-unobscure' : 'icon-obscure'}
tintColor={colors.white}
tintHoverColor={colors.white80}
tintColor={Colors.white}
tintHoverColor={Colors.white80}
width={24}
/>
</StyledButton>
Expand All @@ -95,8 +95,8 @@ export default function ClipboardLabel(props: IProps) {
}>
<ImageView
source={justCopied ? 'icon-tick' : 'icon-copy'}
tintColor={justCopied ? colors.green : colors.white}
tintHoverColor={justCopied ? colors.green : colors.white80}
tintColor={justCopied ? Colors.green : Colors.white}
tintHoverColor={justCopied ? Colors.green : Colors.white80}
width={justCopied ? 22 : 24}
/>
</StyledCopyButton>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useContext, useEffect, useMemo } from 'react';
import styled from 'styled-components';

import { colors } from '../../config.json';
import { Colors } from '../lib/foundations';
import { useBoolean, useStyledRef } from '../lib/utility-hooks';
import { smallText } from './common-styles';
import { BackAction } from './KeyboardNavigation';
Expand Down Expand Up @@ -117,7 +117,7 @@ const StyledMenu = styled.div<StyledMenuProps>((props) => {
right: props.$align === 'left' ? 'auto' : iconMargin,
padding: '7px 4px',
background: 'rgb(36, 53, 78)',
border: `1px solid ${colors.darkBlue}`,
border: `1px solid ${Colors.darkBlue}`,
borderRadius: '8px',
zIndex: 1,
};
Expand All @@ -130,17 +130,17 @@ const StyledMenuItem = styled.button(smallText, (props) => ({
background: 'transparent',
border: 'none',
textAlign: 'left',
color: props.disabled ? colors.white50 : colors.white,
color: props.disabled ? Colors.white50 : Colors.white,

'&&:hover': {
background: props.disabled ? 'transparent' : colors.blue,
background: props.disabled ? 'transparent' : Colors.blue,
},
}));

const StyledSeparator = styled.hr({
height: '1px',
border: 'none',
backgroundColor: colors.darkBlue,
backgroundColor: Colors.darkBlue,
margin: '4px 9px',
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';

import { colors } from '../../config.json';
import { messages } from '../../shared/gettext';
import { useAppContext } from '../context';
import { Colors } from '../lib/foundations';
import { formatHtml } from '../lib/html-formatter';
import { IpAddress } from '../lib/ip';
import { useBoolean, useMounted, useStyledRef } from '../lib/utility-hooks';
Expand Down Expand Up @@ -255,8 +255,8 @@ export default function CustomDnsSettings() {
source="icon-add"
width={18}
height={18}
tintColor={colors.white40}
tintHoverColor={colors.white60}
tintColor={Colors.white40}
tintHoverColor={Colors.white60}
tabIndex={-1}
/>
</StyledAddCustomDnsButton>
Expand Down Expand Up @@ -369,7 +369,7 @@ function CellListItem(props: ICellListItemProps) {
source="icon-close"
width={18}
height={18}
tintColor={editing ? colors.black : colors.white40}
tintColor={editing ? Colors.black : Colors.white40}
/>
</StyledRemoveButton>
</AriaDescribed>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components';

import { colors } from '../../config.json';
import { Colors } from '../lib/foundations';
import * as Cell from './cell';
import ImageView from './ImageView';

Expand All @@ -9,7 +9,7 @@ export const StyledCustomDnsFooter = styled(Cell.CellFooter)({
});

export const StyledAddCustomDnsButton = styled(Cell.CellButton)({
backgroundColor: colors.blue40,
backgroundColor: Colors.blue40,
});

export const StyledAddCustomDnsLabel = styled(Cell.Label)<{ $paddingLeft?: number }>((props) => ({
Expand All @@ -25,7 +25,7 @@ export const StyledAddCustomDnsLabel = styled(Cell.Label)<{ $paddingLeft?: numbe

export const StyledContainer = styled(Cell.Container)({
display: 'flex',
backgroundColor: colors.blue40,
backgroundColor: Colors.blue40,
});

export const StyledButton = styled.button({
Expand Down Expand Up @@ -57,6 +57,6 @@ export const StyledRemoveButton = styled.button({

export const StyledRemoveIcon = styled(ImageView)({
[StyledRemoveButton + ':hover &&']: {
backgroundColor: colors.white80,
backgroundColor: Colors.white80,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback } from 'react';
import { sprintf } from 'sprintf-js';
import styled from 'styled-components';

import { strings } from '../../config.json';
import { strings } from '../../shared/constants';
import { messages } from '../../shared/gettext';
import { useAppContext } from '../context';
import { Flex } from '../lib/components';
Expand Down
Loading
Loading