From 2efa902d42733abafcfcacd6ae8efcea4afe59ae Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Thu, 17 Feb 2022 03:17:49 +0100 Subject: design: Location bar and other UI styling InputBase paddings are idiosyncratic if there is both a start and an end adornment. To simplify the styles, we override the styling from InputBase and compute our own paddings. The animated color change when switching from a secure site to an insecure one was distracting, so we disable color animations in the location bar. --- packages/renderer/src/components/ThemeProvider.tsx | 12 +++ .../src/components/locationBar/ButtonAdornment.tsx | 69 +++++++++++++ .../src/components/locationBar/GoAdornment.tsx | 38 +++++++ .../src/components/locationBar/IconAdornment.tsx | 41 ++++++++ .../src/components/locationBar/LocationBar.tsx | 6 +- .../locationBar/LocationOverlayInput.tsx | 110 +++++++++++++++++++++ .../components/locationBar/LocationTextField.tsx | 85 +++++++++++++--- .../components/locationBar/NavigationButtons.tsx | 16 +-- .../src/components/locationBar/UrlAdornment.tsx | 91 +++++++++++++++++ .../src/components/locationBar/UrlOverlay.tsx | 70 +++++++++++++ .../src/components/locationBar/splitUrl.ts | 62 ++++++++++++ .../src/components/sidebar/ServiceSwitcher.tsx | 5 +- .../renderer/src/components/sidebar/Sidebar.tsx | 19 ++-- .../components/sidebar/ToggleLocationBarButton.tsx | 31 ++++-- 14 files changed, 615 insertions(+), 40 deletions(-) create mode 100644 packages/renderer/src/components/locationBar/ButtonAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/GoAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/IconAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/LocationOverlayInput.tsx create mode 100644 packages/renderer/src/components/locationBar/UrlAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/UrlOverlay.tsx create mode 100644 packages/renderer/src/components/locationBar/splitUrl.ts (limited to 'packages/renderer/src') diff --git a/packages/renderer/src/components/ThemeProvider.tsx b/packages/renderer/src/components/ThemeProvider.tsx index 3943371..5fc1f33 100644 --- a/packages/renderer/src/components/ThemeProvider.tsx +++ b/packages/renderer/src/components/ThemeProvider.tsx @@ -37,6 +37,18 @@ export default observer( palette: { mode: shouldUseDarkColors ? 'dark' : 'light', }, + components: { + MuiBadge: { + styleOverrides: { + standard: { + // Reduce badge with to make the unread message badge with "99+" unread messages + // fit within the sidebar. Applied for all badges for consistency. + paddingLeft: 4, + paddingRight: 4, + }, + }, + }, + }, }); return {children}; diff --git a/packages/renderer/src/components/locationBar/ButtonAdornment.tsx b/packages/renderer/src/components/locationBar/ButtonAdornment.tsx new file mode 100644 index 0000000..2cf230b --- /dev/null +++ b/packages/renderer/src/components/locationBar/ButtonAdornment.tsx @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import InputAdornment from '@mui/material/InputAdornment'; +import { styled } from '@mui/material/styles'; + +export const NO_LABEL_BUTTON_CLASS_NAME = 'ButtonAdornment-NoLabel'; + +const ButtonAdornment = styled(InputAdornment, { + name: 'ButtonAdornment', +})(({ theme, position }) => { + const { direction } = theme; + const left = direction === 'ltr' ? 'start' : 'end'; + return { + ...(position === left + ? { + marginRight: 2, + marginLeft: -8, + } + : { + marginLeft: 2, + marginRight: -8, + }), + '.MuiButton-root': { + minWidth: 32, + height: 32, + paddingLeft: 6, + paddingRight: 6, + borderRadius: 16, + }, + ...(direction === 'ltr' + ? { + '.MuiButton-startIcon': { + marginLeft: 0, + }, + [`.${NO_LABEL_BUTTON_CLASS_NAME} .MuiButton-startIcon`]: { + marginRight: 0, + }, + } + : { + '.MuiButton-startIcon': { + marginRight: 0, + marginLeft: theme.spacing(1), + }, + [`.${NO_LABEL_BUTTON_CLASS_NAME} .MuiButton-startIcon`]: { + marginLeft: 0, + }, + }), + }; +}); + +export default ButtonAdornment; diff --git a/packages/renderer/src/components/locationBar/GoAdornment.tsx b/packages/renderer/src/components/locationBar/GoAdornment.tsx new file mode 100644 index 0000000..43c8b7b --- /dev/null +++ b/packages/renderer/src/components/locationBar/GoAdornment.tsx @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import IconGo from '@mui/icons-material/Send'; +import Button from '@mui/material/Button'; +import React from 'react'; + +import ButtonAdornment, { NO_LABEL_BUTTON_CLASS_NAME } from './ButtonAdornment'; + +export default function GoAdornment(): JSX.Element { + return ( + +