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

⚙️ Add the first page for the menu/settings tab #342

Merged
merged 6 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
43 changes: 43 additions & 0 deletions ui/components/Shared/SharedToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { useState, ReactElement } from "react"
import classNames from "classnames"

export default function SharedToggleButton(): ReactElement {
const [isActive, setIsActive] = useState(false)

return (
<button
type="button"
className={classNames("container", { is_active: isActive })}
onClick={() => {
setIsActive(!isActive)
}}
>
<div className="bulb" />
<style jsx>
{`
.container {
width: 40px;
height: 24px;
border-radius: 20px;
background-color: var(--green-80);
box-sizing: border-box;
padding: 4px;
cursor: pointer;
display: flex;
}
.bulb {
width: 16px;
height: 16px;
border-radius: 20px;
background-color: var(--green-40);
transition: 0.2s ease-in-out;
}
.is_active .bulb {
transform: translateX(16px);
background-color: var(--trophy-gold);
}
`}
</style>
</button>
)
}
148 changes: 138 additions & 10 deletions ui/pages/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,150 @@
import React, { ReactElement } from "react"
import React, { useState, ReactElement } from "react"
import classNames from "classnames"
import CorePage from "../components/Core/CorePage"
import SharedButton from "../components/Shared/SharedButton"
import SharedToggleButton from "../components/Shared/SharedToggleButton"

function SettingRow(props: { title: string; action: any }): ReactElement {
const { title, action } = props

return (
<li>
<div className="left">{title}</div>
<div className="right">{action()}</div>
<style jsx>
{`
li {
height: 50px;
display: flex;
justify-content: space-between;
align-items: center;
}
.left {
color: var(--green-20);
font-size: 18px;
font-weight: 600;
line-height: 24px;
}
`}
</style>
</li>
)
}

function ArrowRightIcon() {
return (
<div className="icon_chevron_left">
<style jsx>
{`
.icon_chevron_left {
mask-image: url("./images/chevron_down.svg");
mask-size: 15px 8px;
width: 15px;
height: 8px;
margin-top: 2px;
background-color: var(--green-40);
transform: rotate(-90deg);
}
`}
</style>
</div>
)
}

const settings = [
{
title: "Main Currency",
action: () => {
return (
<>
<SharedButton size="medium" type="secondary" icon="chevron">
USD
</SharedButton>
</>
)
},
},
{
title: "Hide asset balance under $2",
action: SharedToggleButton,
},
{
title: "Use Tally as default wallet",
action: SharedToggleButton,
},
{
title: "Token list",
action: ArrowRightIcon,
},
{
title: "Show testnet networks",
action: SharedToggleButton,
},
{
title: "Contracts deployed by users",
action: ArrowRightIcon,
},
]

export default function Menu(): ReactElement {
return (
<>
<CorePage>
<span className="title">Menu</span>
<CorePage hasTopBar={false}>
<section className="standard_width_padded">
<h1>Settings</h1>
<div className="icon_lock" />
<h3>General</h3>
<ul>
{settings.slice(0, 4).map((setting) => {
Copy link
Contributor

@greg-nagy greg-nagy Oct 19, 2021

Choose a reason for hiding this comment

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

Is this a common pattern in react?
It might be easier to follow using the values inline in the template instead of using settings array and slice on it.

The Main Currency action might be a good candidate for putting it in a separate function though

return (
<>
<SettingRow title={setting.title} action={setting.action} />
</>
)
})}
</ul>
<hr />
<h3>Developer</h3>
<ul>
{settings.slice(4, 6).map((setting) => {
return (
<>
<SettingRow title={setting.title} action={setting.action} />
</>
)
})}
</ul>
</section>
</CorePage>
<style jsx>
{`
.title {
width: 375px;
height: 46px;
color: #fefefc;
font-family: "Quincy CF";
font-size: 38px;
h1 {
color: #fff;
font-size: 22px;
font-weight: 500;
line-height: 32px;
}
.icon_lock {
background: url("./images/lock@2x.png");
background-size: cover;
width: 24px;
height: 24px;
position: absolute;
top: 16px;
right: 16px;
}
h3 {
color: var(--green-40);
font-size: 16px;
font-weight: 400;
text-align: center;
line-height: 24px;
}
hr {
width: 100%;
height: 1px;
background-color: var(--green-80);
border: unset;
margin: 25px 0px 30px 0px;
}
`}
</style>
Expand Down
Binary file added ui/public/images/lock@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.