diff --git a/packages/extension-polkagate/src/components/AccountIcons.tsx b/packages/extension-polkagate/src/components/AccountIcons.tsx index 6e4a004ae..18de05bf9 100644 --- a/packages/extension-polkagate/src/components/AccountIcons.tsx +++ b/packages/extension-polkagate/src/components/AccountIcons.tsx @@ -54,7 +54,7 @@ function AccountIcons ({ address, identiconTheme, isSubId, judgements, prefix }: judgement={judgements} prefix={prefix} size={40} - value={formatted} + value={formatted || address} /> diff --git a/packages/extension-polkagate/src/components/Identicon.tsx b/packages/extension-polkagate/src/components/Identicon.tsx index 286a4946c..368797e85 100644 --- a/packages/extension-polkagate/src/components/Identicon.tsx +++ b/packages/extension-polkagate/src/components/Identicon.tsx @@ -1,8 +1,6 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck -import type { ThemeProps } from '@polkadot/extension-polkagate/types'; import type { IconTheme } from '@polkadot/react-identicon/types'; import type { AccountId } from '@polkadot/types/interfaces/runtime'; @@ -14,7 +12,7 @@ import Icon from '@polkadot/react-identicon'; interface Props { className?: string; - iconTheme?: IconTheme | string; + iconTheme?: IconTheme; isSubId?: boolean; judgement?: RegExpMatchArray | null | undefined; onCopy?: () => void; @@ -23,7 +21,7 @@ interface Props { value?: AccountId | string | null; } -function Identicon({ className, iconTheme, isSubId, judgement, onCopy, prefix, size, value }: Props): React.ReactElement { +function Identicon ({ className, iconTheme, isSubId, judgement, onCopy, prefix, size, value }: Props): React.ReactElement { return (
@@ -70,7 +68,7 @@ function Identicon({ className, iconTheme, isSubId, judgement, onCopy, prefix, s ); } -export default React.memo(styled(Identicon)(({ theme }: ThemeProps) => ` +export default React.memo(styled(Identicon)(() => ` background: rgba(192, 192, 292, 0.25); border-radius: 50%; display: flex; diff --git a/packages/extension-polkagate/src/components/Main.tsx b/packages/extension-polkagate/src/components/Main.tsx index 80df317e3..5ebe56862 100644 --- a/packages/extension-polkagate/src/components/Main.tsx +++ b/packages/extension-polkagate/src/components/Main.tsx @@ -1,7 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck - import React from 'react'; @@ -10,30 +8,10 @@ interface Props { className?: string; } -export default function Main({ children, className }: Props): React.ReactElement { +export default function Main ({ children, className }: Props): React.ReactElement { return (
{children}
); -} - -// export default styled(Main)(({ theme }: ThemeProps) => ` -// display: flex; -// flex-direction: column; -// height: calc(100vh - 2px); -// background: ${theme.background}; -// color: ${theme.textColor}; -// font-size: ${theme.fontSize}; -// line-height: ${theme.lineHeight}; -// border: 1px solid ${theme.inputBorderColor}; - -// * { -// font-family: ${theme.fontFamily}; -// } - -// > * { -// padding-left: 20px; -// padding-right: 20px; -// } -// `); +} \ No newline at end of file diff --git a/packages/extension-polkagate/src/components/VaadinIcon.tsx b/packages/extension-polkagate/src/components/VaadinIcon.tsx index 3bfafc5d7..e43e959fe 100644 --- a/packages/extension-polkagate/src/components/VaadinIcon.tsx +++ b/packages/extension-polkagate/src/components/VaadinIcon.tsx @@ -1,16 +1,51 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck -import React from 'react'; import '@vaadin/icons'; +import React, { useEffect } from 'react'; + interface VaadinIconProps extends React.HTMLAttributes { icon: string; + spin?: boolean; + float?: boolean; } -const VaadinIcon: React.FC = ({ icon, ...props }) => { - return ; +const VaadinIcon: React.FC = ({ float = false, icon, spin = false, style, ...props }) => { + const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; + + useEffect(() => { + // Check if the animations are already injected + if (!document.getElementById('vaadin-icon-animation-keyframes')) { + const styleSheet = document.createElement('style'); + + styleSheet.id = 'vaadin-icon-animation-keyframes'; + styleSheet.innerText = ` + @keyframes vaadinSpin { + from { transform: rotate(0deg); } + to { transform: rotate(360deg); } + } + @keyframes float { + 0%, 100% { transform: translateY(0); } + 50% { transform: translateY(-4px); } + } + `; + document.head.appendChild(styleSheet); + } + }, []); + + // Combine inline styles with the animations if enabled + const combinedStyles: React.CSSProperties = { + animation: `${spin && !prefersReducedMotion ? 'vaadinSpin 3s linear infinite' : ''} ${float && !prefersReducedMotion ? 'float 2s ease-in-out infinite' : ''}`, + ...style + }; + + // @ts-ignore + return ; }; export default VaadinIcon; diff --git a/packages/extension-polkagate/src/fullscreen/accountDetails/components/AccountSetting.tsx b/packages/extension-polkagate/src/fullscreen/accountDetails/components/AccountSetting.tsx index 8e9b14dd1..620cf2bd0 100644 --- a/packages/extension-polkagate/src/fullscreen/accountDetails/components/AccountSetting.tsx +++ b/packages/extension-polkagate/src/fullscreen/accountDetails/components/AccountSetting.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -21,7 +20,7 @@ interface Props { setDisplayPopup: React.Dispatch>; } -export default function AccountSetting({ address, setDisplayPopup }: Props): React.ReactElement { +export default function AccountSetting ({ address, setDisplayPopup }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); const { account, chain } = useInfo(address); @@ -77,7 +76,7 @@ export default function AccountSetting({ address, setDisplayPopup }: Props): Rea /> - + void; secondaryIconType: 'popup' | 'page'; - noBorderButton?: boolean; - disabled?: boolean; + text: string; show?: boolean; - mr?: string; - loading?: boolean; } export const openOrFocusTab = (relativeUrl: string, closeCurrentTab?: boolean): void => { @@ -69,7 +70,7 @@ export const openOrFocusTab = (relativeUrl: string, closeCurrentTab?: boolean): }); }; -export const TaskButton = ({ disabled, icon, loading, mr = '25px', noBorderButton = false, onClick, secondaryIconType, show = true, text }: TaskButtonProps) => { +export const TaskButton = ({ disabled, dividerWidth = '66%', icon, loading, mr = '25px', noBorderButton = false, onClick, secondaryIconType, show = true, text }: TaskButtonProps) => { const theme = useTheme(); return ( @@ -99,7 +100,8 @@ export const TaskButton = ({ disabled, icon, loading, mr = '25px', noBorderButto /> } - {!noBorderButton && + {!noBorderButton && + } } diff --git a/packages/extension-polkagate/src/fullscreen/governance/partials/ThemeChanger.tsx b/packages/extension-polkagate/src/fullscreen/governance/partials/ThemeChanger.tsx index 9f8adb2b9..dd798e6d8 100644 --- a/packages/extension-polkagate/src/fullscreen/governance/partials/ThemeChanger.tsx +++ b/packages/extension-polkagate/src/fullscreen/governance/partials/ThemeChanger.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -10,7 +9,7 @@ import React, { useCallback, useContext } from 'react'; import { ColorContext } from '../../../components'; -function ThemeChanger(): React.ReactElement { +function ThemeChanger ({ color = 'white', left = '7px', noBorder }: {color?: string, left?: string, noBorder?: boolean}): React.ReactElement { const theme = useTheme(); const colorMode = useContext(ColorContext); @@ -51,9 +50,9 @@ function ThemeChanger(): React.ReactElement { const themeIconsStyle = { animationDuration: '250ms', animationFillMode: 'forwards', - color: 'white', + color, fontSize: '27px', - left: '7px', + left, m: 'auto', position: 'absolute', top: 0 @@ -62,7 +61,7 @@ function ThemeChanger(): React.ReactElement { const toggleTheme = useCallback(() => colorMode.toggleColorMode(), [colorMode]); return ( - + diff --git a/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/HomeMenu.tsx b/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/HomeMenu.tsx index f378e7172..464d6606d 100644 --- a/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/HomeMenu.tsx +++ b/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/HomeMenu.tsx @@ -53,7 +53,9 @@ export const TaskButton = ({ children, disabled, extra, hasChildren, icon, isSub {extra} - {!noBorderButton && } + {!noBorderButton && + + } {children} @@ -118,7 +120,7 @@ export default function HomeMenu(): React.ReactElement { + } onClick={onImportClick} secondaryIconType='page' @@ -139,7 +141,7 @@ export default function HomeMenu(): React.ReactElement { + } noBorderButton onClick={onSettingClick} diff --git a/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/ImportAccSubMenuFullScreen.tsx b/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/ImportAccSubMenuFullScreen.tsx index 287764e3a..4f0ff7482 100644 --- a/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/ImportAccSubMenuFullScreen.tsx +++ b/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/ImportAccSubMenuFullScreen.tsx @@ -1,19 +1,16 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ -import { faSitemap } from '@fortawesome/free-solid-svg-icons'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { ArrowForwardIos as ArrowForwardIosIcon } from '@mui/icons-material'; import { Collapse, Grid, useTheme } from '@mui/material'; import React, { useCallback } from 'react'; import settings from '@polkadot/ui-settings'; -import { useTranslation } from '../../../hooks'; import { VaadinIcon } from '../../../components'; +import { useTranslation } from '../../../hooks'; import { openOrFocusTab } from '../../accountDetails/components/CommonTasks'; import { TaskButton } from './HomeMenu'; @@ -22,7 +19,7 @@ interface Props { show: boolean; } -function ImportAccSubMenuFullScreen({ show, toggleSettingSubMenu }: Props): React.ReactElement { +function ImportAccSubMenuFullScreen ({ show, toggleSettingSubMenu }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); diff --git a/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/SettingSubMenuFullScreen.tsx b/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/SettingSubMenuFullScreen.tsx index e821533da..72fa0d292 100644 --- a/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/SettingSubMenuFullScreen.tsx +++ b/packages/extension-polkagate/src/fullscreen/homeFullScreen/partials/SettingSubMenuFullScreen.tsx @@ -93,7 +93,7 @@ export default function SettingSubMenuFullScreen({ show }: Props): React.ReactEl <> <> - + theme.palette.mode === 'dark', [theme.palette.mode]); const poolState = useMemo(() => pool?.bondedPool?.state?.toString(), [pool?.bondedPool?.state]); const canChangeState = useMemo(() => pool?.bondedPool && formatted && [String(pool?.bondedPool?.roles?.root), String(pool?.bondedPool?.roles?.bouncer)].includes(String(formatted)), [pool?.bondedPool, formatted]); const poolRoot = useMemo(() => pool?.bondedPool && formatted && String(pool?.bondedPool?.roles?.root) === (String(formatted)), [pool?.bondedPool, formatted]); @@ -115,6 +113,7 @@ export default function PoolCommonTasks({ address }: Props): React.ReactElement - + { +function ImportAccSubMenu ({ show, toggleSettingSubMenu }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); const onAction = useContext(ActionContext); @@ -54,8 +53,8 @@ function ImportAccSubMenu({ show, toggleSettingSubMenu }: Props): React.ReactEle return ( - - + + { +const Div = () => ; + +function Menu ({ setShowMenu, theme }: Props): React.ReactElement { const { t } = useTranslation(); const onAction = useContext(ActionContext); + const [collapsedMenu, setCollapsedMenu] = useState(COLLAPSIBLE_MENUS.SETTING); const [isTestnetEnableConfirmed, setIsTestnetEnableConfirmed] = useState(); const [showWarning, setShowWarning] = useState(); @@ -117,7 +121,7 @@ function Menu({ setShowMenu, theme }: Props): React.ReactElement { ? <> + } onClick={toggleNewAccountSubMenu} showSubMenu={collapsedMenu === COLLAPSIBLE_MENUS.NEW_ACCOUNT} @@ -126,10 +130,10 @@ function Menu({ setShowMenu, theme }: Props): React.ReactElement { > - +
+ } onClick={toggleImportSubMenu} showSubMenu={collapsedMenu === COLLAPSIBLE_MENUS.IMPORT_ACCOUNT} @@ -138,7 +142,7 @@ function Menu({ setShowMenu, theme }: Props): React.ReactElement { > - +
@@ -147,10 +151,10 @@ function Menu({ setShowMenu, theme }: Props): React.ReactElement { text={t('Export all accounts')} withHoverEffect /> - +
+ } onClick={toggleSettingSubMenu} showSubMenu={collapsedMenu === COLLAPSIBLE_MENUS.SETTING} diff --git a/packages/extension-polkagate/src/partials/NewAccountSubMenu.tsx b/packages/extension-polkagate/src/partials/NewAccountSubMenu.tsx index 74f88d4ee..b68eec6ce 100644 --- a/packages/extension-polkagate/src/partials/NewAccountSubMenu.tsx +++ b/packages/extension-polkagate/src/partials/NewAccountSubMenu.tsx @@ -1,6 +1,5 @@ // Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors // SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck /* eslint-disable react/jsx-max-props-per-line */ @@ -15,7 +14,7 @@ interface Props { show: boolean; } -function NewAccountSubMenu({ show }: Props): React.ReactElement { +function NewAccountSubMenu ({ show }: Props): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); const onAction = useContext(ActionContext); @@ -31,8 +30,8 @@ function NewAccountSubMenu({ show }: Props): React.ReactElement { return ( - - + + { - colorMode.toggleColorMode(); - }, [colorMode]); - const onManageLoginPassword = useCallback(() => { onAction('/login-password'); }, [onAction]); @@ -89,35 +85,35 @@ export default function SettingSubMenu ({ isTestnetEnabledChecked, onChange, set return ( - - - - + + + + - + + + + + {isLoginEnabled && <> - + - + - + @@ -126,9 +122,9 @@ export default function SettingSubMenu ({ isTestnetEnabledChecked, onChange, set {isPopup && <> - + - + } @@ -168,7 +164,7 @@ export default function SettingSubMenu ({ isTestnetEnabledChecked, onChange, set + } onClick={onManageLoginPassword} py='2px' diff --git a/packages/extension-polkagate/src/popup/home/AiBackgroundImage.tsx b/packages/extension-polkagate/src/popup/home/AiBackgroundImage.tsx index b25d3d141..763ff7a83 100644 --- a/packages/extension-polkagate/src/popup/home/AiBackgroundImage.tsx +++ b/packages/extension-polkagate/src/popup/home/AiBackgroundImage.tsx @@ -73,10 +73,10 @@ export default function AiBackgroundImage ({ bgImage, setBgImage }: Props): Reac useEffect(() => { /** initiate background image on load and UI theme change */ chrome.storage.local.get('backgroundImage', (res) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access - const imgUrl = res?.['backgroundImage']?.[mode] as string; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + const imgUrl = res?.['backgroundImage']?.[mode] as string | undefined; - tryToApplyImg(imgUrl); + imgUrl && tryToApplyImg(imgUrl); }); }, [tryToApplyImg, mode]); diff --git a/packages/extension-ui/src/types.ts b/packages/extension-ui/src/types.ts deleted file mode 100644 index 4cbb3a99b..000000000 --- a/packages/extension-ui/src/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors -// SPDX-License-Identifier: Apache-2.0 -// @ts-nocheck - -import { Theme } from './components/themes'; - -export { Theme }; - -export interface ThemeProps { - theme: Theme; -} diff --git a/packages/extension/public/locales/en/translation.json b/packages/extension/public/locales/en/translation.json index 11530058c..4877e35c8 100644 --- a/packages/extension/public/locales/en/translation.json +++ b/packages/extension/public/locales/en/translation.json @@ -1409,5 +1409,6 @@ "No identity": "", "Recoverable": "", "Not recoverable": "", - "No proxy": "" + "No proxy": "", + "Switch Theme": "" }