Skip to content

Commit

Permalink
Split view margin spacing into vertical and horizontal variant
Browse files Browse the repository at this point in the history
  • Loading branch information
olmoh authored and raksooo committed Nov 28, 2024
1 parent 6768b02 commit 8b6311b
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const AccountRows = styled.div({
});

export const AccountRow = styled.div({
padding: `0 ${measurements.viewMargin}`,
padding: `0 ${measurements.horizontalViewMargin}`,
marginBottom: measurements.rowVerticalMargin,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components';
import { useHistory } from '../lib/history';
import { useBoolean } from '../lib/utility-hooks';
import * as AppButton from './AppButton';
import { measurements } from './common-styles';
import { measurements, spacings } from './common-styles';
import { BackAction } from './KeyboardNavigation';
import { Layout, SettingsContainer } from './Layout';
import {
Expand All @@ -24,7 +24,7 @@ const StyledContent = styled.div({
});

const StyledButtonGroup = styled.div({
margin: measurements.viewMargin,
margin: `${spacings.spacing6} ${measurements.horizontalViewMargin}`,
});

export default function Debug() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const StyledBody = styled.div({
display: 'flex',
flexDirection: 'column',
flex: 1,
padding: `0 ${measurements.viewMargin}`,
padding: `0 ${measurements.horizontalViewMargin}`,
});

export const StyledStatusIcon = styled.div({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Subtitle = styled.span({
fontFamily: 'Open Sans',
fontSize: '14px',
lineHeight: '20px',
margin: `0 ${measurements.viewMargin}`,
margin: `0 ${measurements.horizontalViewMargin}`,
color: colors.white40,
textAlign: 'center',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const StyledBody = styled.div({
display: 'flex',
flexDirection: 'column',
flex: 1,
padding: `0 ${measurements.viewMargin}`,
padding: `0 ${measurements.horizontalViewMargin}`,
paddingBottom: 'auto',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const StyledBody = styled.div({
display: 'flex',
flexDirection: 'column',
flex: 1,
padding: `0 ${measurements.viewMargin}`,
padding: `0 ${measurements.horizontalViewMargin}`,
});

export const StyledTitle = styled.span(hugeText, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import * as AppButton from './AppButton';
import { measurements, tinyText } from './common-styles';
import ErrorView from './ErrorView';
import { Footer } from './Layout';
import { ModalAlert, ModalMessage, ModalMessageList } from './Modal';
import { ModalAlertType } from './Modal';
import { ModalAlert, ModalAlertType, ModalMessage, ModalMessageList } from './Modal';

export default function Launch() {
const daemonAllowed = useSelector((state) => state.userInterface.daemonAllowed);
Expand All @@ -28,7 +27,6 @@ export default function Launch() {

const StyledFooter = styled(Footer)({
backgroundColor: colors.blue,
padding: `0 14px ${measurements.viewMargin}`,
transition: 'opacity 250ms ease-in-out',
});

Expand Down
14 changes: 12 additions & 2 deletions desktop/packages/mullvad-vpn/src/renderer/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const SettingsContent = styled.div({
flexDirection: 'column',
flex: 1,
overflow: 'visible',
marginBottom: measurements.viewMargin,
marginBottom: measurements.verticalViewMargin,
});

export const SettingsStack = styled.div({
Expand All @@ -50,7 +50,7 @@ export const Footer = styled.div({
display: 'flex',
flexDirection: 'column',
flex: 0,
padding: measurements.viewMargin,
padding: `${spacings.spacing6} ${measurements.horizontalViewMargin} ${measurements.verticalViewMargin}`,
[`${SettingsContent} &&`]: {
paddingBottom: 0,
},
Expand All @@ -59,3 +59,13 @@ export const Footer = styled.div({
export const Spacing = styled.div<{ height: string }>((props) => ({
height: props.height,
}));

export const ButtonStack = styled.div({
display: 'flex',
flexDirection: 'column',
gap: spacings.spacing5,
margin: `0 ${spacings.spacing6}`,
[`${Footer} &&`]: {
margin: `0 ${spacings.spacing3}`,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const StyledLoginForm = styled.div({
flex: '0 1 225px',
flexDirection: 'column',
overflow: 'visible',
padding: `0 ${measurements.viewMargin}`,
padding: `0 ${measurements.horizontalViewMargin}`,
});

interface IStyledAccountInputGroupProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const StyledForm = styled.div({
display: 'flex',
flex: 1,
flexDirection: 'column',
margin: `0 ${measurements.viewMargin}`,
margin: `0 ${measurements.horizontalViewMargin}`,
});

export const StyledFormEmailRow = styled.div({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { useAppContext } from '../context';
import { useHistory } from '../lib/history';
import { RoutePath } from '../lib/routes';
import { useSelector } from '../redux/store';
import { RedButton } from './AppButton';
import * as Cell from './cell';
import { BackAction } from './KeyboardNavigation';
import {
ButtonStack,
Footer,
Layout,
SettingsContainer,
Expand All @@ -19,7 +21,7 @@ import {
} from './Layout';
import { NavigationBar, NavigationContainer, NavigationItems, TitleBarItem } from './NavigationBar';
import SettingsHeader, { HeaderTitle } from './SettingsHeader';
import { StyledCellIcon, StyledQuitButton } from './SettingsStyles';
import { StyledCellIcon } from './SettingsStyles';

export default function Support() {
const history = useHistory();
Expand Down Expand Up @@ -91,7 +93,9 @@ export default function Support() {
)}
</SettingsStack>
<Footer>
<QuitButton />
<ButtonStack>
<QuitButton />
</ButtonStack>
</Footer>
</SettingsContent>
</SettingsNavigationScrollbars>
Expand Down Expand Up @@ -278,10 +282,10 @@ function QuitButton() {
const tunnelState = useSelector((state) => state.connection.status);

return (
<StyledQuitButton onClick={quit}>
<RedButton onClick={quit}>
{tunnelState.state === 'disconnected'
? messages.gettext('Quit')
: messages.gettext('Disconnect & quit')}
</StyledQuitButton>
</RedButton>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Content = styled.div({
});

const StyledSmallButtonGrid = styled(SmallButtonGrid)({
margin: `0 ${measurements.viewMargin}`,
margin: `0 ${measurements.horizontalViewMargin}`,
});

type ImportStatus = { successful: boolean } & ({ type: 'file'; name: string } | { type: 'text' });
Expand Down Expand Up @@ -221,7 +221,7 @@ export default function SettingsImport() {
const StyledStatusContainer = styled.div({
display: 'flex',
flexDirection: 'column',
margin: `18px ${measurements.viewMargin}`,
margin: `18px ${measurements.horizontalViewMargin}`,
});

const StyledStatusTitle = styled.div(normalText, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import styled from 'styled-components';

import * as AppButton from './AppButton';
import * as Cell from './cell';
import { measurements, spacings } from './common-styles';
import { spacings } from './common-styles';

export const StyledCellIcon = styled(Cell.UntintedIcon)({
marginRight: spacings.spacing3,
});

export const StyledQuitButton = styled(AppButton.RedButton)({
margin: `0 ${measurements.viewMargin}`,
});
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const StyledListContainer = styled.div({
});

export const StyledBrowseButton = styled(AppButton.BlueButton)({
margin: `0 ${measurements.viewMargin} ${measurements.viewMargin}`,
margin: `0 ${measurements.horizontalViewMargin} ${measurements.verticalViewMargin}`,
});

export const StyledCellContainer = styled(Cell.Container)({
Expand Down Expand Up @@ -124,8 +124,8 @@ export const StyledMiniTitle = styled.span({
});

export const StyledSearchBar = styled(SearchBar)({
marginLeft: measurements.viewMargin,
marginRight: measurements.viewMargin,
marginLeft: measurements.horizontalViewMargin,
marginRight: measurements.horizontalViewMargin,
marginBottom: measurements.buttonVerticalMargin,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const StyledStatusIcon = styled.div({

const StyledTitle = styled.span(bigText, {
lineHeight: '38px',
margin: `0 ${measurements.viewMargin} 8px`,
margin: `0 ${measurements.horizontalViewMargin} 8px`,
color: colors.white,
});

Expand All @@ -58,7 +58,7 @@ const StyledLabel = styled.span({
fontWeight: 600,
lineHeight: '20px',
color: colors.white,
margin: `0 ${measurements.viewMargin} 18px`,
margin: `0 ${measurements.horizontalViewMargin} 18px`,
});

const StyledSpacer = styled.div({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import styled from 'styled-components';

import { colors } from '../../../config.json';
import { measurements, spacings, tinyText } from '../common-styles';
import { spacings, tinyText } from '../common-styles';

export const CellFooter = styled.div({
margin: `${spacings.spacing1} ${measurements.viewMargin} 0px`,
margin: `${spacings.spacing1} ${spacings.spacing6} 0px`,
});

export const CellFooterText = styled.span(tinyText, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const Row = styled.div.withConfig({
alignItems: 'center',
backgroundColor: colors.blue,
minHeight: measurements.rowMinHeight,
paddingLeft: measurements.viewMargin,
paddingRight: measurements.viewMargin,
paddingLeft: measurements.horizontalViewMargin,
paddingRight: measurements.horizontalViewMargin,
marginBottom: '1px',
[`${Group} > &&:last-child`]: {
marginBottom: props.includeMarginBottomOnLast ? '1px' : '0px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const StyledTitle = styled.h2(tinyText, {
display: 'flex',
alignItems: 'center',
color: colors.white80,
margin: `0 ${measurements.viewMargin} 8px`,
margin: `0 ${measurements.horizontalViewMargin} 8px`,
lineHeight: '17px',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const StyledSettingsRow = styled.label<{ $invalid: boolean }>((props) => ({
display: 'flex',
alignItems: 'center',

margin: `0 ${measurements.viewMargin} ${measurements.rowVerticalMargin}`,
margin: `0 ${measurements.horizontalViewMargin} ${measurements.rowVerticalMargin}`,
padding: '0 8px',
minHeight: '36px',
backgroundColor: colors.blue60,
Expand Down Expand Up @@ -59,7 +59,7 @@ const StyledInputContainer = styled.div({
const StyledSettingsRowErrorMessage = styled.div(tinyText, {
display: 'flex',
alignItems: 'center',
marginLeft: measurements.viewMargin,
marginLeft: measurements.horizontalViewMargin,
marginTop: '5px',
color: colors.white60,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { buttonColor, ButtonColors } from './styles';
export const SideButton = styled.button<ButtonColors>(buttonColor, {
position: 'relative',
alignSelf: 'stretch',
paddingLeft: measurements.viewMargin,
paddingRight: measurements.viewMargin,
paddingLeft: measurements.horizontalViewMargin,
paddingRight: measurements.horizontalViewMargin,
border: 0,

'&&::before': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export const spacings = {

export const measurements = {
rowMinHeight: spacings.spacing9,
viewMargin: spacings.spacing6,
horizontalViewMargin: spacings.spacing5,
verticalViewMargin: spacings.spacing6,
rowVerticalMargin: spacings.spacing6,
buttonVerticalMargin: spacings.spacing5,
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const StyledInputContainer = styled.div({
alignItems: 'center',
flex: 1,
backgroundColor: colors.blue,
paddingLeft: measurements.viewMargin,
paddingLeft: measurements.horizontalViewMargin,
height: measurements.rowMinHeight,
});

const StyledHeaderLabel = styled(Cell.Label)({
display: 'block',
flex: 1,
backgroundColor: colors.blue,
paddingLeft: measurements.viewMargin,
paddingLeft: measurements.horizontalViewMargin,
margin: 0,
height: measurements.rowMinHeight,
lineHeight: measurements.rowMinHeight,
Expand Down

0 comments on commit 8b6311b

Please sign in to comment.