From 55c402db472d99075a75eed2ea61747540847d9d Mon Sep 17 00:00:00 2001 From: bgptr <52497040+bgptr@users.noreply.github.com> Date: Wed, 2 Feb 2022 23:46:35 +0100 Subject: [PATCH] [redesign] Settings view (#3631) --- app/actions/SettingsActions.js | 7 + app/components/buttons/index.js | 11 +- .../inputs/AccountsSelect/AccountsSelect.jsx | 82 +-- .../AccountsSelect/AccountsSelect.module.css | 15 +- .../DetailedAccountsSelect.jsx | 104 ++-- .../DetailedAccountsSelect.module.css | 5 +- app/components/inputs/Input/Input.module.css | 8 +- .../inputs/LEGACY_StakePoolSelect.jsx | 29 +- .../LanguageSelectInput.jsx | 81 +-- .../LanguageSelectInput.module.css | 25 +- .../inputs/ReceiveAccountsSelect.jsx | 11 +- app/components/inputs/Select.jsx | 74 +++ app/components/inputs/SettingsInput.jsx | 61 +-- app/components/inputs/SettingsTextInput.jsx | 19 +- app/components/inputs/VSPSelect/VSPSelect.jsx | 55 +- app/components/inputs/index.js | 1 + .../layout/TabbedPage/TabbedPage.jsx | 10 +- .../layout/TitleHeader/TitleHeader.jsx | 8 +- .../AutoBuyerSettingsModal.jsx | 4 +- .../AutoBuyerSettingsModal.module.css | 3 - .../ListUTXOsModal/ListUTXOsModal.module.css | 1 - .../SyncVSPFailedTickets.jsx | 6 +- .../modals/TrezorModals/TrezorWordModal.jsx | 37 +- .../PurchaseTicketsForm.jsx | 14 +- .../PurchaseTicketsForm.module.css | 1 - .../CreateDexAcctPage/CreateDexAcctPage.jsx | 2 +- .../SendOutputRow/SendOutputRow.jsx | 3 +- .../ExistingSeed/Form/Form.jsx | 1 + .../helpers/SeedWord/SeedWord.jsx | 4 +- .../helpers/SeedWord/SeedWord.module.css | 1 - .../helpers/SeedWordEntry/SeedWordEntry.jsx | 66 ++- .../helpers/SeedWordEntry/SeedWordSelect.css | 58 -- .../LanguageSelectPage/Page/Page.jsx | 3 +- .../LanguageSelectPage/Page/Page.module.css | 5 + .../CustomPrivacyOptions.jsx | 2 +- .../CustomPrivacyOptions.module.css | 3 +- .../GetStartedPage/Settings/Settings.jsx | 205 +++---- .../Settings/Settings.module.css | 134 ++--- .../CreateLNWallet/CreateLNWallet.jsx | 12 +- .../SendOutputRow/SendOutputRow.jsx | 3 +- .../ConnectivitySettings.jsx | 55 ++ .../ConnectivitySettings.module.css | 3 + .../ConnectivitySettingsTab.jsx | 55 ++ .../NetworkSettings/NetworkSettings.jsx | 152 ++++++ .../NetworkSettings.module.css | 19 + .../NetworkSettings/index.js | 0 .../ProxySettings/ProxySettings.jsx | 61 +++ .../ProxySettings/ProxySettings.module.css | 15 + .../ProxySettings/index.js | 0 .../ConnectivitySettingsTab/index.js | 1 + .../GeneralSettingsTab/GeneralSettings.jsx | 72 +++ .../GeneralSettings.module.css | 30 ++ .../GeneralSettingsTab/GeneralSettingsTab.jsx | 69 +++ .../MiscSettings/MiscSettings.jsx | 75 +++ .../MiscSettings/MiscSettings.module.css | 12 + .../MiscSettings/index.js | 0 .../TimezoneSettings/TimezoneSettings.jsx | 21 +- .../TimezoneSettings.module.css | 27 + .../TimezoneSettings/index.js | 0 .../UISettings/UISettings.jsx | 111 ++++ .../UISettings/UISettings.module.css | 26 + .../UISettings/index.js | 0 .../SettingsPage/GeneralSettingsTab/index.js | 1 + .../PrivacySettings/PrivacySettings.jsx | 145 +++++ .../PrivacySettings.module.css | 17 + .../PrivacySettings/index.js | 0 .../PrivacyandSecuritySettings.jsx | 73 +++ .../PrivacyandSecuritySettings.module.css | 19 + .../PrivacyandSecuritySettingsTab.jsx | 39 ++ .../PrivatePassphraseSettings.jsx | 39 ++ .../PrivatePassphraseSettings.module.css | 10 + .../PrivatePassphraseSettings/index.js | 1 + .../PrivacyandSecuritySettingsTab/index.js | 1 + .../views/SettingsPage/SettingsPage.jsx | 32 +- .../SettingsPage/SettingsPage.module.css | 4 +- .../SettingsPage/SettingsTab/Settings.jsx | 174 ------ .../SettingsTab/Settings.module.css | 74 --- .../SettingsPage/SettingsTab/SettingsTab.jsx | 52 -- .../groups/MiscSettings/MiscSettings.jsx | 84 --- .../MiscSettings/MiscSettings.module.css | 7 - .../NetworkSettings/NetworkSettings.jsx | 146 ----- .../NetworkSettings.module.css | 11 - .../PrivacySettings/PrivacySettings.jsx | 199 ------- .../PrivacySettings.module.css | 110 ---- .../groups/ProxySettings/ProxySettings.jsx | 64 --- .../ProxySettings/ProxySettings.module.css | 11 - .../TimezoneSettings.module.css | 7 - .../groups/UISettings/UISettings.jsx | 100 ---- .../groups/UISettings/UISettings.module.css | 11 - .../SettingsPage/SettingsTab/groups/index.js | 6 - .../SettingsTab/helpers/Column/Column.jsx | 13 - .../helpers/Column/Column.module.css | 27 - .../SettingsTab/helpers/Column/index.js | 1 - .../helpers/ColumnTitle/ColumnTitle.jsx | 11 - .../ColumnTitle/ColumnTitle.module.css | 6 - .../SettingsTab/helpers/ColumnTitle/index.js | 1 - .../helpers/ColumnWrapper/ColumnWrapper.jsx | 11 - .../ColumnWrapper/ColumnWrapper.module.css | 35 -- .../helpers/ColumnWrapper/index.js | 1 - .../SettingsTab/helpers/Group/Group.jsx | 13 - .../helpers/Group/Group.module.css | 37 -- .../SettingsTab/helpers/Group/index.js | 1 - .../helpers/Label/Label.module.css | 10 - .../SettingsTab/helpers/Row/Row.jsx | 13 - .../SettingsTab/helpers/Row/Row.module.css | 5 - .../SettingsTab/helpers/Row/index.js | 1 - .../SettingsTab/helpers/Wrapper/Wrapper.jsx | 11 - .../helpers/Wrapper/Wrapper.module.css | 33 -- .../SettingsPage/SettingsTab/helpers/index.js | 7 - .../views/SettingsPage/SettingsTab/index.js | 1 - .../views/SettingsPage/helpers/Box/Box.jsx | 13 + .../SettingsPage/helpers/Box/Box.module.css | 11 + .../views/SettingsPage/helpers/Box/index.js | 1 + .../helpers/ConfirmRestartModal.jsx | 20 + .../views/SettingsPage/helpers/Group.jsx | 9 + .../{SettingsTab => }/helpers/Label/Label.jsx | 0 .../helpers/Label/Label.module.css | 7 + .../{SettingsTab => }/helpers/Label/index.js | 0 .../SettingsPage/helpers/Wrapper/Wrapper.jsx | 12 + .../helpers/Wrapper/Wrapper.module.css | 18 + .../helpers/Wrapper/index.js | 0 .../views/SettingsPage/helpers/index.js | 5 + .../ExportTab/ExportPage/ExportPage.jsx | 18 +- .../TransactionsPage/ExportTab/helpers.js | 20 +- .../ReceiveTab/ReceivePage/ReceivePage.jsx | 50 +- .../ReceivePage/ReceivePage.module.css | 9 +- .../SendTab/SendOutputRow/SendOutputRow.jsx | 9 +- app/hooks/useSettings.js | 8 +- app/index.js | 1 - app/reducers/snackbar.js | 6 + app/style/ReactSelectGlobal.css | 507 ------------------ app/style/icons/changepasswordDefault.svg | 12 - app/style/themes/icons.js | 3 - package.json | 1 - .../LEGACY_PurchasePage.spec.js | 16 +- .../views/GetStaredPage/CreateWallet.spec.js | 214 ++++---- .../GetStaredPage/GetStartedPage.spec.js | 24 +- .../GetStaredPage/LanguageSelectPage.spec.js | 19 +- .../views/SettingsPage/SettingsPage.spec.js | 127 +++-- .../TransactionsPage/SendTab/SendTab.spec.js | 4 +- yarn.lock | 20 +- 141 files changed, 2113 insertions(+), 2704 deletions(-) create mode 100644 app/components/inputs/Select.jsx delete mode 100644 app/components/views/GetStartedPage/CreateWalletPage/helpers/SeedWordEntry/SeedWordSelect.css create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/ConnectivitySettings.jsx create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/ConnectivitySettings.module.css create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/ConnectivitySettingsTab.jsx create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/NetworkSettings/NetworkSettings.jsx create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/NetworkSettings/NetworkSettings.module.css rename app/components/views/SettingsPage/{SettingsTab/groups => ConnectivitySettingsTab}/NetworkSettings/index.js (100%) create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/ProxySettings/ProxySettings.jsx create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/ProxySettings/ProxySettings.module.css rename app/components/views/SettingsPage/{SettingsTab/groups => ConnectivitySettingsTab}/ProxySettings/index.js (100%) create mode 100644 app/components/views/SettingsPage/ConnectivitySettingsTab/index.js create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/GeneralSettings.jsx create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/GeneralSettings.module.css create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/GeneralSettingsTab.jsx create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/MiscSettings/MiscSettings.jsx create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/MiscSettings/MiscSettings.module.css rename app/components/views/SettingsPage/{SettingsTab/groups => GeneralSettingsTab}/MiscSettings/index.js (100%) rename app/components/views/SettingsPage/{SettingsTab/groups => GeneralSettingsTab}/TimezoneSettings/TimezoneSettings.jsx (67%) create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/TimezoneSettings/TimezoneSettings.module.css rename app/components/views/SettingsPage/{SettingsTab/groups => GeneralSettingsTab}/TimezoneSettings/index.js (100%) create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/UISettings/UISettings.jsx create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/UISettings/UISettings.module.css rename app/components/views/SettingsPage/{SettingsTab/groups => GeneralSettingsTab}/UISettings/index.js (100%) create mode 100644 app/components/views/SettingsPage/GeneralSettingsTab/index.js create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivacySettings/PrivacySettings.jsx create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivacySettings/PrivacySettings.module.css rename app/components/views/SettingsPage/{SettingsTab/groups => PrivacyandSecuritySettingsTab}/PrivacySettings/index.js (100%) create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivacyandSecuritySettings.jsx create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivacyandSecuritySettings.module.css create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivacyandSecuritySettingsTab.jsx create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivatePassphraseSettings/PrivatePassphraseSettings.jsx create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivatePassphraseSettings/PrivatePassphraseSettings.module.css create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/PrivatePassphraseSettings/index.js create mode 100644 app/components/views/SettingsPage/PrivacyandSecuritySettingsTab/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/Settings.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/Settings.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/SettingsTab.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/MiscSettings/MiscSettings.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/MiscSettings/MiscSettings.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/NetworkSettings/NetworkSettings.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/NetworkSettings/NetworkSettings.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/PrivacySettings/PrivacySettings.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/PrivacySettings/PrivacySettings.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/ProxySettings/ProxySettings.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/ProxySettings/ProxySettings.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/TimezoneSettings/TimezoneSettings.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/UISettings/UISettings.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/UISettings/UISettings.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/groups/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Column/Column.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Column/Column.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Column/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/ColumnTitle/ColumnTitle.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/ColumnTitle/ColumnTitle.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/ColumnTitle/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/ColumnWrapper/ColumnWrapper.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/ColumnWrapper/ColumnWrapper.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/ColumnWrapper/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Group/Group.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Group/Group.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Group/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Label/Label.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Row/Row.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Row/Row.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Row/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Wrapper/Wrapper.jsx delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/Wrapper/Wrapper.module.css delete mode 100644 app/components/views/SettingsPage/SettingsTab/helpers/index.js delete mode 100644 app/components/views/SettingsPage/SettingsTab/index.js create mode 100644 app/components/views/SettingsPage/helpers/Box/Box.jsx create mode 100644 app/components/views/SettingsPage/helpers/Box/Box.module.css create mode 100644 app/components/views/SettingsPage/helpers/Box/index.js create mode 100644 app/components/views/SettingsPage/helpers/ConfirmRestartModal.jsx create mode 100644 app/components/views/SettingsPage/helpers/Group.jsx rename app/components/views/SettingsPage/{SettingsTab => }/helpers/Label/Label.jsx (100%) create mode 100644 app/components/views/SettingsPage/helpers/Label/Label.module.css rename app/components/views/SettingsPage/{SettingsTab => }/helpers/Label/index.js (100%) create mode 100644 app/components/views/SettingsPage/helpers/Wrapper/Wrapper.jsx create mode 100644 app/components/views/SettingsPage/helpers/Wrapper/Wrapper.module.css rename app/components/views/SettingsPage/{SettingsTab => }/helpers/Wrapper/index.js (100%) create mode 100644 app/components/views/SettingsPage/helpers/index.js delete mode 100644 app/style/ReactSelectGlobal.css delete mode 100644 app/style/icons/changepasswordDefault.svg diff --git a/app/actions/SettingsActions.js b/app/actions/SettingsActions.js index e3814044dc..e02eefc958 100644 --- a/app/actions/SettingsActions.js +++ b/app/actions/SettingsActions.js @@ -181,6 +181,13 @@ export function updateStateSettingsChanged(settings, norestart) { }; } +export const resetSettingsState = () => { + return (dispatch, getState) => { + const { currentSettings } = getState().settings; + dispatch({ tempSettings: currentSettings, type: SETTINGS_UNCHANGED }); + }; +}; + export const updateStateVoteSettingsChanged = (settings) => ( dispatch, getState diff --git a/app/components/buttons/index.js b/app/components/buttons/index.js index 85cd0d1f41..bd09414569 100644 --- a/app/components/buttons/index.js +++ b/app/components/buttons/index.js @@ -118,8 +118,17 @@ export const InfoDocFieldModalButton = mbb( styles.infoFieldModalButton, DocumentationInfoModal ); +export const InfoDocFieldModalInvisibleButton = mbb( + null, + DocumentationInfoModal, + InvisibleButton +); export const DiscoverUsageButton = mbb(null, DiscoverUsageModal); -export const ChangePassphraseButton = mbb(null, ChangePassphraseModal); +export const ChangePassphraseButton = mbb( + null, + ChangePassphraseModal, + PiUiButton +); export const InvisiblePassphraseModalButton = mbb( null, PassphraseModal, diff --git a/app/components/inputs/AccountsSelect/AccountsSelect.jsx b/app/components/inputs/AccountsSelect/AccountsSelect.jsx index 98bf9c365b..45583920b2 100644 --- a/app/components/inputs/AccountsSelect/AccountsSelect.jsx +++ b/app/components/inputs/AccountsSelect/AccountsSelect.jsx @@ -1,24 +1,24 @@ -import Select from "react-select"; import { useAccountsSelect } from "./hooks"; import { Balance } from "shared"; import styles from "./AccountsSelect.module.css"; import { classNames } from "pi-ui"; +import { Select } from "inputs"; import LinkToAccounts from "./LinkToAccounts"; +import { components } from "react-select"; const AccountsSelect = ({ accountsType, className, selectClassName, showAccountsButton, - disabled, hideSpendable, filterAccounts, account: accountProp, + customStyles, + customComponents, onChange, - onKeyDown, - valueRenderer, - optionRenderer, - searchable + selectWithBigFont, + ...props }) => { const { account, accounts, placeholder } = useAccountsSelect({ accountProp, @@ -27,49 +27,54 @@ const AccountsSelect = ({ onChange }); - const selectKeyDown = (e) => { - switch (e.keyCode) { - case 8: - case 46: - e.preventDefault(); - break; - } - onKeyDown?.(e); + const SingleValue = (props) => { + return ( + +
+
{props.data.name}
+ {!hideSpendable && ( +
+ +
+ )} +
+
+ ); }; - if (!valueRenderer) { - valueRenderer = (option) => ( -
-
{option.name}
- {!hideSpendable && ( -
- -
- )} -
+ const Option = (props) => { + return ( + +
+
{props.data.name}
+ {!hideSpendable && ( +
+ +
+ )} +
+
); - } + }; return (
); }; -LanguageSelectInput.propTypes = { - className: PropTypes.string -}; - -export default injectIntl(LanguageSelectInput); +export default LanguageSelectInput; diff --git a/app/components/inputs/LanguageSelectInput/LanguageSelectInput.module.css b/app/components/inputs/LanguageSelectInput/LanguageSelectInput.module.css index 336d84f93d..5c814fad14 100644 --- a/app/components/inputs/LanguageSelectInput/LanguageSelectInput.module.css +++ b/app/components/inputs/LanguageSelectInput/LanguageSelectInput.module.css @@ -1,24 +1,13 @@ -.input { - width: 200px; - margin-right: 0.5em; -} - .label { display: flex; } -.label .flag { - margin: 5px 5px 0 0; -} - .flag { - flex-grow: 2; background-repeat: no-repeat; - background-size: 20px; - width: 20px; - height: 20px; - margin-left: 10px; - margin-top: 2px; + background-size: 20px 13px; + width: 25px; + min-width: 25px; + background-position: left center; } .flag.ar { @@ -61,6 +50,7 @@ background-image: var(--flag-pl); } +.flag.dev, .flag.pt-BR { background-image: var(--flag-ptbr); } @@ -73,9 +63,8 @@ background-image: var(--flag-hk); } -.name { - flex-grow: 4; - width: 100px; +.option, +.singleValue { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; diff --git a/app/components/inputs/ReceiveAccountsSelect.jsx b/app/components/inputs/ReceiveAccountsSelect.jsx index cd2f05e469..b56b8f8399 100644 --- a/app/components/inputs/ReceiveAccountsSelect.jsx +++ b/app/components/inputs/ReceiveAccountsSelect.jsx @@ -6,11 +6,9 @@ import * as sel from "selectors"; function ReceiveAccountsSelect({ onChange, - className, - selectClassName, showAccountsButton, - disabled, - account + account, + ...props }) { const dispatch = useDispatch(); const mixedAccount = useSelector(sel.getMixedAccount); @@ -38,8 +36,6 @@ function ReceiveAccountsSelect({ ); diff --git a/app/components/inputs/Select.jsx b/app/components/inputs/Select.jsx new file mode 100644 index 0000000000..341be7f841 --- /dev/null +++ b/app/components/inputs/Select.jsx @@ -0,0 +1,74 @@ +import { Select as PiUiSelect } from "pi-ui"; + +const Select = ({ styles, selectWithBigFont, ariaLabelledBy, ...props }) => { + const customStyles = { + valueContainer: () => ({ + padding: `0 0 0 ${selectWithBigFont ? 0 : "0.5rem"}` + }), + placeholder: (provided) => ({ + margin: 0, + color: "var(--grey-5)", + fontSize: selectWithBigFont ? "1.6rem" : provided.fontSize, + lineHeight: selectWithBigFont ? "2.1rem" : provided.lineHeight + }), + control: (_, state) => ({ + borderBottomColor: "var(--select-stroke-color)", + borderRadius: "none", + borderLeft: "none", + borderRight: "none", + borderTop: "none", + minHeight: "initial", + "&:hover": { + borderBottomColor: "var(--accent-blue)" + }, + backgroundColor: state.isDisabled + ? "var(--disabled-background-color)" + : "transparent" + }), + container: () => ({ + padding: 0 + }), + singleValue: (provided) => ({ + margin: 0, + fontSize: selectWithBigFont ? "1.6rem" : provided.fontSize, + lineHeight: selectWithBigFont ? "2.1rem" : provided.lineHeight, + color: "var(--main-dark-blue)" + }), + option: (_, state) => ({ + color: "var(--main-dark-blue)", + backgroundColor: state.isFocused + ? "var(--background-hovered)" + : "var(--card-background)" + }), + menu: () => ({ + marginTop: 0 + }), + dropdownIndicator: () => ({ + paddingRight: 0 + }), + input: () => ({ + paddingTop: 0, + paddingBottom: 0, + marginTop: 0, + marginBottom: 0 + }), + ...styles + }; + + return ( + + ); +}; + +Select.propTypes = { + styles: PropTypes.object, + selectWithBigFont: PropTypes.bool, + ariaLabelledBy: PropTypes.string +}; + +export default Select; diff --git a/app/components/inputs/SettingsInput.jsx b/app/components/inputs/SettingsInput.jsx index bb5462276d..d1a029de46 100644 --- a/app/components/inputs/SettingsInput.jsx +++ b/app/components/inputs/SettingsInput.jsx @@ -1,53 +1,44 @@ -import Select from "react-select"; -import { injectIntl } from "react-intl"; -import { useState } from "react"; +import { Select } from "inputs"; +import { isString } from "lodash"; const SettingsInput = ({ - className, value, + options, valueKey, labelKey, - options, - disabled, ariaLabelledBy, - onChange + className, + ...props }) => { - const [inputValue, setInputValue] = useState(value ?? null); - - const selectKeyDown = (e) => { - switch (e.keyCode) { - case 8: - case 46: - e.preventDefault(); - break; - } + const normalizeOption = (option) => { + if (!option) return null; + return { + ...option, + value: option[valueKey], + label: option[labelKey] + }; }; - const onChangeSelect = (value) => { - setInputValue(value); - onChange?.(value); - }; + const normalizedValue = isString(value) + ? normalizeOption( + options.find((option) => option[valueKey]?.toString() === value) + ) + : value; + + const normalizedOptions = options?.map((option) => normalizeOption(option)); return (
; +export default ({ onChange, value, ...props }) => { + const [inputValue, setInputValue] = useState(value); + + const onSubmit = () => { + onChange?.(inputValue); + }; + + return ( + setInputValue(e.target.value)} + onKeyDownSubmit={onSubmit} + onBlur={onSubmit} + {...props} + /> + ); +}; diff --git a/app/components/inputs/VSPSelect/VSPSelect.jsx b/app/components/inputs/VSPSelect/VSPSelect.jsx index f7247d860d..d6d9b13061 100644 --- a/app/components/inputs/VSPSelect/VSPSelect.jsx +++ b/app/components/inputs/VSPSelect/VSPSelect.jsx @@ -1,10 +1,10 @@ -import { Creatable } from "react-select"; import { injectIntl, defineMessages } from "react-intl"; import { useEffect, useState, useMemo } from "react"; import { useVSPSelect } from "./hooks"; import { FormattedMessage as T } from "react-intl"; import { Tooltip } from "pi-ui"; import styles from "./VSPSelect.modules.css"; +import { Select } from "inputs"; const messages = defineMessages({ placeholder: { @@ -30,7 +30,15 @@ const getError = (error) => { return String(error); }; -function VSPSelect({ onChange, options, intl, value, isDisabled, setVspFee }) { +function VSPSelect({ + onChange, + options, + intl, + value, + isDisabled, + setVspFee, + selectWithBigFont +}) { const { send, state, selectedOption, vspInfo, availableVSPs } = useVSPSelect( options, value, @@ -93,13 +101,17 @@ function VSPSelect({ onChange, options, intl, value, isDisabled, setVspFee }) { // push new value if it is a new vsp option. if (value.newOption) { const host = value.host; - newOptions.push({ - host, - label: host, - value: host - }); - - setNewOptions(newOptions); + setNewOptions((opts) => [ + ...opts, + { + value: { + host, + label: host, + value: host + }, + label: host + } + ]); } isRetry ? send({ type: "RETRY", value }) : send({ type: "FETCH", value }); }; @@ -114,21 +126,24 @@ function VSPSelect({ onChange, options, intl, value, isDisabled, setVspFee }) { const getSelect = (isRetry) => { return ( - handleOnChange(option, isRetry)} value={selectedOption} - newOptionCreator={() => { - return { - value: { host: newOption, label: newOption }, - label: newOption, - host: newOption, - newOption: true - }; - }} - disabled={isDisabled} + onCreateOption={(option) => + handleOnChange( + { + value: { host: option, label: option, newOption: true } + }, + isRetry + ) + } + isDisabled={isDisabled} onInputChange={(input) => onSetNewOption(input)} isValidNewOption={() => !!newOption} /> diff --git a/app/components/inputs/index.js b/app/components/inputs/index.js index c89537d391..7f95d9e0f5 100644 --- a/app/components/inputs/index.js +++ b/app/components/inputs/index.js @@ -24,3 +24,4 @@ export { default as InlineField } from "./InlineField"; export { default as SettingsTextInput } from "./SettingsTextInput"; export { default as VSPSelect } from "./VSPSelect"; export { default as SeedHexEntry } from "./SeedHexEntry"; +export { default as Select } from "./Select"; diff --git a/app/components/layout/TabbedPage/TabbedPage.jsx b/app/components/layout/TabbedPage/TabbedPage.jsx index e0ecb70f02..41fabb0bb1 100644 --- a/app/components/layout/TabbedPage/TabbedPage.jsx +++ b/app/components/layout/TabbedPage/TabbedPage.jsx @@ -26,7 +26,9 @@ const TabbedPage = ({ const onSelectTab = (index) => { setActiveTabIndex(index); - history.push(tabs[index].path); + if (tabs[index].path) { + history.push(tabs[index].path); + } }; useEffect(() => { @@ -60,7 +62,7 @@ const TabbedPage = ({ contentAnimation={uiAnimations ? "slide" : "none"}> {tabs .filter(({ disabled }) => !disabled) - .map(({ label, content, path, props }) => { + .map(({ label, content, path, props, key }) => { const element = React.isValidElement(content) ? k(content, { ...props, @@ -70,8 +72,8 @@ const TabbedPage = ({ // before send, otherwise they will be undfined. h(content, { ...props }, null); return ( - -
{element}
+ +
{element}
); })} diff --git a/app/components/layout/TitleHeader/TitleHeader.jsx b/app/components/layout/TitleHeader/TitleHeader.jsx index d1d8375264..a1918dbba7 100644 --- a/app/components/layout/TitleHeader/TitleHeader.jsx +++ b/app/components/layout/TitleHeader/TitleHeader.jsx @@ -4,9 +4,11 @@ import styles from "./TitleHeader.module.css"; const TitleHeader = ({ title, iconType, optionalButton }) => (
-
-
-
+ {iconType && ( +
+
+
+ )}
{title}
diff --git a/app/components/modals/AutoBuyerSettingsModal/AutoBuyerSettingsModal.jsx b/app/components/modals/AutoBuyerSettingsModal/AutoBuyerSettingsModal.jsx index 02f39419ab..932c250080 100644 --- a/app/components/modals/AutoBuyerSettingsModal/AutoBuyerSettingsModal.jsx +++ b/app/components/modals/AutoBuyerSettingsModal/AutoBuyerSettingsModal.jsx @@ -59,15 +59,15 @@ const AutoBuyerSettingsModal = ({ placeholder={intl.formatMessage(messages.balanceToMaintainPlaceholder)} label={intl.formatMessage(messages.balanceToMaintainLabel)} /> -