From fc048a5fbef87deac4f36c63e71f969bc6301bee Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 4 Mar 2022 02:01:20 +0100 Subject: refactor(renderer): Location bar security label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since electron doesn't have an API to extract the current certificate, except in the case of certificate errors, there's no point in making the security warning / padlock icon clickable. We instead display a plain icon and a warning message. We will later display the certificate details in case of a validation error (when we have access to the certificate) as part of an error message. Also makes the security labels more visible to people with protanopia who use the dark mode of the UI. Signed-off-by: Kristóf Marussy --- .../src/components/locationBar/ButtonAdornment.tsx | 69 -------------- .../src/components/locationBar/GoAdornment.tsx | 43 --------- .../src/components/locationBar/GoButton.tsx | 51 +++++++++++ .../src/components/locationBar/IconAdornment.tsx | 41 --------- .../locationBar/LocationInputAdornment.tsx | 41 +++++++++ .../components/locationBar/LocationTextField.tsx | 14 ++- .../src/components/locationBar/SecurityLabel.tsx | 102 +++++++++++++++++++++ .../src/components/locationBar/UrlAdornment.tsx | 91 ------------------ .../src/components/locationBar/UrlOverlay.tsx | 3 +- .../src/components/locationBar/getAlertColor.ts | 28 ++++++ 10 files changed, 234 insertions(+), 249 deletions(-) delete mode 100644 packages/renderer/src/components/locationBar/ButtonAdornment.tsx delete mode 100644 packages/renderer/src/components/locationBar/GoAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/GoButton.tsx delete mode 100644 packages/renderer/src/components/locationBar/IconAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/LocationInputAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/SecurityLabel.tsx delete mode 100644 packages/renderer/src/components/locationBar/UrlAdornment.tsx create mode 100644 packages/renderer/src/components/locationBar/getAlertColor.ts (limited to 'packages/renderer/src') diff --git a/packages/renderer/src/components/locationBar/ButtonAdornment.tsx b/packages/renderer/src/components/locationBar/ButtonAdornment.tsx deleted file mode 100644 index 2cf230b..0000000 --- a/packages/renderer/src/components/locationBar/ButtonAdornment.tsx +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 deleted file mode 100644 index f049b8e..0000000 --- a/packages/renderer/src/components/locationBar/GoAdornment.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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, { MouseEventHandler } from 'react'; - -import ButtonAdornment, { NO_LABEL_BUTTON_CLASS_NAME } from './ButtonAdornment'; - -export default function GoAdornment({ - onClick, -}: { - onClick: MouseEventHandler; -}): JSX.Element { - return ( - -