Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetStarted & Settings Pages: functional components, css module & custom hooks #2537

Merged
merged 26 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
28592de
Settings page refactor: custom hooks instead of hooks
amass01 Jun 16, 2020
305025c
pass custom hooks vars down & re-add settings connector
amass01 Jun 16, 2020
3405896
add missing props & fix actions
amass01 Jun 16, 2020
575def9
settings.less madness: part1
amass01 Jun 17, 2020
cdcec51
delete settings.less - part1
amass01 Jun 17, 2020
c07bf2c
ditch settings.less partX
amass01 Jun 18, 2020
bc03044
ditch GetStarted.less
amass01 Jun 19, 2020
64b73b3
use GetStarted.module.css - wip
amass01 Jun 20, 2020
054dd96
css modules big bang!
amass01 Jun 21, 2020
462a309
dust cleaning
amass01 Jun 21, 2020
910b343
revert text change
amass01 Jun 21, 2020
147f7a7
fix wallet name alignment
amass01 Jun 22, 2020
eedc972
create new wallet fixes
amass01 Jun 23, 2020
b0d33bd
fix close wallet btn
amass01 Jun 23, 2020
7933fb1
ditch logs.less and fix settings title, back btn
amass01 Jun 23, 2020
c4e7071
tutorial polish
amass01 Jun 23, 2020
925dafb
fix restore wallet words
amass01 Jun 23, 2020
e4fbd39
loading progress fixes
amass01 Jun 23, 2020
f9453e0
fix settings scroll
amass01 Jun 24, 2020
ec708c7
fix settings scroll & select fields
amass01 Jun 24, 2020
27a83cd
fix timezone section alignement
amass01 Jun 24, 2020
df1d524
settings: fix privacy section alignment
amass01 Jun 24, 2020
4259f26
fix language select
amass01 Jun 24, 2020
c401a65
fix change password icon
amass01 Jun 24, 2020
533ac3e
comment explains animations classes
amass01 Jun 25, 2020
3131821
fix linear progress component alignment
amass01 Jun 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/buttons/EnableExternalRequestButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { settings } from "connectors";
import { settings } from "connectors"; // use useSettings hook
import KeyBlueButton from "./KeyBlueButton";

const EnableExternalRequestButton = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { HeaderTimeMsg } from "views/GetStartedPage/messages";
import { FormattedRelative } from "shared";
import { FormattedMessage as T } from "react-intl";
import ReactTimeout from "react-timeout";
import { classNames } from "pi-ui";
import styles from "./indicators.module.css";

@autobind
class AnimatedLinearProgressFull extends React.Component {
Expand Down Expand Up @@ -49,10 +51,9 @@ class AnimatedLinearProgressFull extends React.Component {
);
}
const { lastDcrwalletLogLine } = this.state;

return (
<>
<div className={"linear-progress " + animationType}>
<div className={classNames("linear-progress", animationType)}>
{getDaemonSynced || isSPV ? (
<div
className={"linear-progress-bar " + (error ? "error" : null)}
Expand Down Expand Up @@ -110,12 +111,12 @@ class AnimatedLinearProgressFull extends React.Component {
</div>
<div>
{getCurrentBlockCount && !getDaemonSynced && (
<div className="loader-bar-estimation">
<div className={styles.loaderBarEstimation}>
<T
id="getStarted.chainLoading.syncEstimation"
m="Blockchain download estimated complete: "
/>
<span className="bold">
<span className={styles.bold}>
{finishDateEstimation && (
<FormattedRelative value={finishDateEstimation} />
)}
Expand All @@ -124,18 +125,16 @@ class AnimatedLinearProgressFull extends React.Component {
</div>
)}
{selectedWalletSelector && syncFetchHeadersLastHeaderTime && (
<div className="loader-bar-estimation">
<div className={styles.loaderBarEstimation}>
<HeaderTimeMsg />
<span className="bold">
<span className={styles.bold}>
<FormattedRelative value={syncFetchHeadersLastHeaderTime} />
</span>
</div>
)}
{selectedWalletSelector && lastDcrwalletLogLine && (
<div className="get-started-last-log-lines">
<div className="last-dcrwallet-log-line">
{lastDcrwalletLogLine}
</div>
<div className={styles.lastLogLines}>
<div>{lastDcrwalletLogLine}</div>
</div>
)}
</div>
Expand Down
20 changes: 20 additions & 0 deletions app/components/indicators/indicators.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,23 @@
font-size: 120%;
padding: 1em;
}

.lastLogLines {
font-size: 9px;
}

.loaderBarEstimation {
text-align: left;
font-size: 9px;
}

.loaderBarEstimation .bold {
opacity: 1;
font-weight: 700;
}

@media screen and (max-width: 768px) {
.loaderBarEstimation {
display: none;
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Select from "react-select";
import { injectIntl } from "react-intl";
import "style/Input.less";
import "style/Input.less"; // XXXXXX: consider ditching this dep isit still working with the new css module ? :thinking:
import { classNames } from "pi-ui";
import styles from "./LanguageSelectInput.module.css";

// XXX: functional component

@autobind
class SettingsInput extends React.Component {
class LanguageSelectInput extends React.Component {
static propTypes = {
className: PropTypes.string
};
Expand All @@ -23,10 +27,10 @@ class SettingsInput extends React.Component {
}

render() {
const { className, valueKey, labelKey, options } = this.props;
const { valueKey, labelKey, options } = this.props;

return (
<div className={className}>
<div className={styles.input}>
<Select
clearable={false}
multi={false}
Expand Down Expand Up @@ -54,9 +58,9 @@ class SettingsInput extends React.Component {

valueRenderer(option) {
return (
<div className="language-label">
<div className={"flag " + option.language} />
<div className="name">{option.description}</div>
<div className={styles.label}>
<div className={classNames(styles.flag, styles[option.language])} />
<div className={styles.name}>{option.description}</div>
</div>
);
}
Expand All @@ -67,4 +71,4 @@ class SettingsInput extends React.Component {
}
}

export default injectIntl(SettingsInput);
export default injectIntl(LanguageSelectInput);
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.input {
width: 200px;
margin-right: 0.5em;
}

.input .selectControl {
border: 1px solid var(--select-border);
border-radius: 5px;
height: 29px;
padding-top: 5px;
padding-right: 5px;
}

.input .selectControl:hover {
border: 1px solid var(--disabled-color);
}

.button {
padding: 5px 16px 10px 16px;
}

.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;
}

.flag.en-AU {
background-image: var(--flag-au);
}

.flag.de {
background-image: var(--flag-de);
}

.flag.en {
background-image: var(--flag-en);
}

.flag.en-GB {
background-image: var(--flag-gb);
}

.flag.es {
background-image: var(--flag-es);
}

.flag.fr {
background-image: var(--flag-fr);
}

.flag.ja {
background-image: var(--flag-ja);
}

.flag.pt-BR {
background-image: var(--flag-ptbr);
}

.flag.zh {
background-image: var(--flag-zh);
}

.name {
flex-grow: 4;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { useCallback } from "react";
import AccountsSelect from "./AccountsSelect";
import { useSelector, useDispatch } from "react-redux";
import * as ca from "actions/ControlActions";
import * as sel from "selectors";

function ReceiveAccountsSelect({ onChange }) {
const dispatch = useDispatch();
const getNextAddressAttempt = (value) =>
dispatch(ca.getNextAddressAttempt(value));
const mixedAccount = useSelector(sel.getMixedAccount);
const account = useSelector(sel.nextAddressAccount);
const onChangeAccount = (account) => {
onChange && onChange(account);
getNextAddressAttempt(account.value);
};

const getNextAddressAttempt = useCallback(
(value) => dispatch(ca.getNextAddressAttempt(value)),
[dispatch]
);
const onChangeAccount = useCallback(
(account) => {
onChange && onChange(account);
getNextAddressAttempt(account.value);
},
[getNextAddressAttempt, onChange]
);

return (
<AccountsSelect
Expand Down
2 changes: 1 addition & 1 deletion app/components/inputs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { default as BlocksInput } from "./BlocksInput";
export { default as DcrInput } from "./DcrInput";
export { default as FeeInput } from "./FeeInput";
export { default as Input } from "./Input";
export { default as LanguageSelect } from "./LanguageSelect";
export { default as LanguageSelectInput } from "./LanguageSelectInput/LanguageSelectInput";
export { default as NumericInput } from "./NumericInput";
export { default as NumTicketsInput } from "./NumTicketsInput";
export { default as PasswordInput } from "./PasswordInput";
Expand Down
24 changes: 24 additions & 0 deletions app/components/shared/CreatePassPhrase/CreatePassPhrase.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.passphraseRow {
height: 50px;
}

.passphrase .confirmSeedLabel {
margin-top: 1px;
}

.confirmSeedLabel {
margin-top: 8px;
margin-right: 10px;
font-size: 13px;
line-height: 17px;
width: 150px;
margin-left: -160px;
color: var(--wallet-tutorial-text);
justify-content: flex-end;
text-align: right;
}

.inputPrivatePassword {
width: 288px;
padding-bottom: 3px;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FormattedMessage as T, injectIntl, defineMessages } from "react-intl";
import { PasswordInput } from "inputs";
import { InfoDocFieldModalButton } from "buttons";
import "style/CreateWalletForm.less";
import { classNames } from "pi-ui";
import styles from "./CreatePassPhrase.module.css";

const messages = defineMessages({
passphrasePlaceholder: {
Expand Down Expand Up @@ -46,15 +47,20 @@ const PassPhraseInputs = ({
isValid
}) => (
<>
<div className="is-row passphrase">
<div className="confirm-seed-label-text passphrase is-row">
<div className={classNames("is-row", styles.passphraseRow)}>
<div
className={classNames(
"is-row",
styles.confirmSeedLabel,
styles.passphraseRow
)}>
<InfoDocFieldModalButton document="PassphraseInfo" />
<div>{passPhraseLabel}</div>
</div>
<form>
<PasswordInput
required
className="input-private-password"
className={styles.inputPrivatePassword}
placeholder={intl.formatMessage(messages.passphrasePlaceholder)}
value={passPhrase}
onKeyDown={onKeyDown}
Expand All @@ -64,13 +70,14 @@ const PassPhraseInputs = ({
/>
</form>
</div>
<div className="is-row passphrase">
<div className="confirm-seed-label-text passphrase">
<div className={classNames("is-row", styles.passphraseRow)}>
<div
className={classNames(styles.confirmSeedLabel, styles.passphraseRow)}>
{passPhraseVerificationLabel}
</div>
<form>
<PasswordInput
className="input-private-password"
className={styles.inputPrivatePassword}
invalid={!isValid}
invalidMessage={passPhraseVerificationError}
placeholder={intl.formatMessage(messages.verifyPassphrasePlaceholder)}
Expand Down
6 changes: 0 additions & 6 deletions app/components/shared/Subtitle.js

This file was deleted.

8 changes: 8 additions & 0 deletions app/components/shared/Subtitle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { classNames } from "pi-ui";

export default ({ title, children, className }) => (
<div className={classNames("tabbed-page-subtitle", className)}>
{title}
{children}
</div>
);
2 changes: 1 addition & 1 deletion app/components/shared/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export { default as PoliteiaLink } from "./PoliteiaLink";
export { default as WatchOnlyWarnNotification } from "./WatchOnlyWarnNotification";
export { default as Subtitle } from "./Subtitle";
export { default as FormattedRelative } from "./FormattedRelative";
export { default as CreatePassPhrase } from "./CreatePassPhrase";
export { default as CreatePassPhrase } from "./CreatePassPhrase/CreatePassPhrase";
export { default as UnsignedTx } from "./UnsignedTx";
export { default as TxHistory } from "./TxHistory/TxHistory";
export { default as LoadingError } from "./LoadingError";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
setRemoteCredentials
} from "config.js";

// XXX: FIUNCTIONAL COMPONENT!!!

@autobind
class AdvancedStartupHeader extends React.Component {
render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { classNames } from "pi-ui";
import { FormattedMessage as T, defineMessages } from "react-intl";
import { PathBrowseInput } from "inputs";
import styles from "../GetStarted.module.css";

const messages = defineMessages({
appdataFieldPlaceholder: {
Expand All @@ -15,11 +17,11 @@ const AppDataForm = ({
intl
}) => (
<>
<div className="advanced-daemon-row appdataform">
<div className="advanced-daemon-label">
<div className={classNames(styles.advancedDeamonRow, styles.dataForm)}>
<div className={styles.daemonLabel}>
<T id="login.form.appdata.label" m="Daemon Data Directory" />:
</div>
<div className="advanced-daemon-input">
<div className={styles.daemonInput}>
<PathBrowseInput
required
type="directory"
Expand Down
Loading