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

Use toggle for account visibility #2001

Merged
merged 6 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion packages/common-components/src/ToggleSwitch/ToggleSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createStyles, ITheme, makeStyles } from "@chainsafe/common-theme"
import clsx from "clsx"
import React, { ReactNode, useCallback, useMemo, useState } from "react"
import React, { ReactNode, useCallback, useEffect, useMemo, useState } from "react"
import { Typography } from "../Typography"

interface IStyleProps {
Expand Down Expand Up @@ -120,6 +120,10 @@ const ToggleSwitch = ({ injectedClasses, disabled, left, right, onChange, value,
const classes = useStyles({ size: resolvedSize })
const [side, setSide] = useState<"left" | "right">(value && right.value === value ? "right" : "left")

useEffect(() => {
setSide(value && right.value === value ? "right" : "left")
}, [right.value, value])

const onToggle = useCallback(() => {
if (disabled) return
if (side === "left") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
useToasts,
TextInput,
CheckIcon,
CheckboxInput,
Divider
Divider,
ToggleSwitch
} from "@chainsafe/common-components"
import { makeStyles, createStyles, debounce } from "@chainsafe/common-theme"
import { CopyIcon } from "@chainsafe/common-components"
Expand Down Expand Up @@ -46,6 +46,7 @@ const useStyles = makeStyles(({ constants, breakpoints, palette }: CSFTheme) =>
walletAddressContainer: {
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: constants.generalUnit * 0.5
},
input: {
Expand Down Expand Up @@ -134,6 +135,9 @@ const useStyles = makeStyles(({ constants, breakpoints, palette }: CSFTheme) =>
[breakpoints.up("md")]: {
paddingLeft: constants.generalUnit * 2
}
},
lookupText: {
paddingLeft: constants.generalUnit
}
})
)
Expand Down Expand Up @@ -283,6 +287,7 @@ const ProfileView = () => {
<div className={classes.container}>
<div
id="profile"
data-cy="label-profile-header"
>
<Typography
variant="h3"
Expand All @@ -293,11 +298,31 @@ const ProfileView = () => {
</Typography>
<Divider />
<div className={classes.profileBox}>
{profile?.publicAddress &&
<div
className={classes.boxContainer}
data-cy="label-profile-header"
<div className={classes.boxContainer}>
<Typography
variant="h4"
component="h4"
className={classes.label}
>
<Trans>Account visibility</Trans>
</Typography>
<div className={classes.walletAddressContainer}>
<ToggleSwitch
left={{ value: false }}
right={{ value: true }}
testId="address-lookup"
onChange={toggleLookupConsent}
value={profile?.lookupConsent || false}
/>
<Typography className={classes.lookupText}>
<Trans>
Allow lookup by sharing key, wallet address, username or ENS
</Trans>
</Typography>
</div>
</div>
{profile?.publicAddress &&
<div className={classes.boxContainer}>
<div className={classes.walletAddressContainer}>
<Typography
variant="h4"
Expand Down Expand Up @@ -445,10 +470,6 @@ const ProfileView = () => {
}
</>
}
<CheckboxInput
label={t`Allow lookup by sharing key, wallet address, username or ENS`}
value={profile?.lookupConsent || false}
onChange={toggleLookupConsent} />
</div>
{/* <FormikProvider value={formik}>
<Form>
Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ msgstr "Konto"
msgid "Account is restricted"
msgstr ""

msgid "Account visibility"
msgstr ""

msgid "Add Card"
msgstr ""

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ msgstr "Account"
msgid "Account is restricted"
msgstr "Account is restricted"

msgid "Account visibility"
msgstr "Account visibility"

msgid "Add Card"
msgstr "Add Card"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ msgstr "Cuenta"
msgid "Account is restricted"
msgstr ""

msgid "Account visibility"
msgstr ""

msgid "Add Card"
msgstr ""

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ msgstr "Compte"
msgid "Account is restricted"
msgstr "Ce compte est limité"

msgid "Account visibility"
msgstr ""

msgid "Add Card"
msgstr "Ajouter une carte"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/no/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ msgstr "Konto"
msgid "Account is restricted"
msgstr ""

msgid "Account visibility"
msgstr ""

msgid "Add Card"
msgstr ""

Expand Down