Skip to content

implement UX fixes and design for mnemonic phrase views#9

Merged
piyalbasu merged 7 commits intomasterfrom
piyal-dev
May 28, 2020
Merged

implement UX fixes and design for mnemonic phrase views#9
piyalbasu merged 7 commits intomasterfrom
piyal-dev

Conversation

@piyalbasu
Copy link
Contributor

No description provided.

const dispatch = useDispatch();
const words = useRef(shuffle(mnemonicPhrase.split(" ")));
const words = shuffle(mnemonicPhrase.split(" "));
const wordState = useRef(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this form starts to get more complicated bc we're introducing a "clear field" button. we need to create an object to store all the values of each form input so we can clear em all at once when needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the initial state. setting all the checkboxes to false (AKA, not checked)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to switch to Formik or another form tool sooner rather than later. I know that Formik gives you "reset form" out of the box

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, been looking at some form libraries. The next iteration of this will be using one

words.reduce(
(obj, current, i) => ({
...obj,
[`${current}-${i}`]: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to create a unique key bc evidently a mnemonic phrase can repeat the same word at different pts


const wordBubbles = () =>
words.current.map((word) => (
wordStateArr.map(([wordKey, value]) => (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grab each "word/checked" state and create a checkbox from it

wordStateArr.map(([wordKey, value]) => (
<CheckButton
onChange={(e) => {
setCheckboxState((prev) => ({ ...prev, [wordKey]: !value }));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the form state to track changing values

icon: [src, alt],
children,
}: {
back?: () => void;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to name function props with the naming pattern on{Action} (in this case, onBack) to make it obvious that it's a function that's called when something happens. Otherwise, back could easily seem like a React node, or a bool, or anything else. In fact, we should add this to the product conventions style guide...

<Header />

<Wrapper>
<H1>Woo, you're in!</H1>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth getting used to using correct typographic characters everywhere there's user-facing text: this should be an apostrophe, , not a single quote, '. It's annoying but looks way better, and the only way to get used to it is to always do it for ellipses, single and double quote marks, etc. See also https://github.com/stellar/product-conventions/blob/master/STYLEGUIDE.md#use-the-right-symbols

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, “‘”’ can by typed on a mac with alt-[, -] and alt-shift-[, -]. with alt-;

const Fullscreen = ({
back,
header,
icon: [src, alt],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This icon format is really specific. I can see an inattentive developer making any of these mistakes the way this is designed:

  • Passing a React node
  • Passing a string just for the src
  • Reversing the order of src and alt
  • Not providing an alt (which obviously is fine, but here it's typed to be required)

Some ways to add some affordance to this design:

  • Take an object with the shape { src: string; alt?: string; }
  • Take a ReactNode
  • ???

import { Button } from "styles/Basics";
import Header from "./Header";

const H1 = styled.h1`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to name styled components a little more deliberately:

@piyalbasu piyalbasu merged commit f2d6ee2 into master May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants