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

feat: Accounts Tab #50

Merged
merged 2 commits into from
Apr 17, 2024
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
64 changes: 64 additions & 0 deletions frontend/src/tabs/Account.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.Account__flex {
display: flex;
margin: 8px 4px;
}

.Account__flex--center {
align-items: center;
}

.Account__wrap {
text-overflow: ellipsis;
overflow: hidden;
}

.Account__list {
padding-left: 20px;
list-style-type: none;
}

.Account__list li {
margin-bottom: 10px;
text-indent: -8px;
}

.Account__list li:before {
content: "-";
text-indent: -8px;
}

.Account__input {
width: 100%;
padding: 6px 10px;
}

.Account__input:focus {
border: 1px solid black;
outline: black;
}

.Account__button {
background-color: black;
color: #efefef;
border: 1px solid black;
text-transform: uppercase;
cursor: pointer;
border-radius: 6px;
}

.Account__button--edit {
padding: 2px 8px;
font-size: 8px;
}

.Account__button--submit {
padding: 8px 16px;
font-size: 10px;
}

.Account__user {
display: flex;
gap: 10px;
justify-content: space-between;
width: 100%;
}
78 changes: 73 additions & 5 deletions frontend/src/tabs/Account.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,81 @@
import React from 'react'
import './Account.css';
import BasicTab from './BasicTab.js';
import React, { useState, useEffect } from "react";
import "./Account.css";
import BasicTab from "./BasicTab.js";

const Account = props => {
const Account = (props) => {
// TODO: Create the account tab w/ wallet address, username, pixel info, top X % users ( pixels placed? ), ...
const [username, setUsername] = useState("");
const [pixelCount, setPixelCount] = useState(2572);
const [accountRank, setAccountRank] = useState("");
const [isUsernameSaved, saveUsername] = useState(false);

const handleSubmit = (event) => {
event.preventDefault();
setUsername(username);
saveUsername(true);
};

const editUsername = (e) => {
saveUsername(false);
}

useEffect(() => {
if (pixelCount >= 5000) {
setAccountRank("Champion");
} else if (pixelCount >= 3000) {
setAccountRank("Platinum");
} else if (pixelCount >= 2000) {
setAccountRank("Gold");
} else if (pixelCount >= 1000) {
setAccountRank("Silver");
} else {
setAccountRank("Bronze");
}
});
return (
<BasicTab title="Account">
<div className="Account__flex">
<p>Address:</p>
<p className="Account__wrap">
b-j-roberts marked this conversation as resolved.
Show resolved Hide resolved
0x0000000000000000000000000000000000000000000000000000000000000000
</p>
</div>
<div className="Account__flex Account__flex--center">
<p>Username:</p>
{isUsernameSaved ? (
b-j-roberts marked this conversation as resolved.
Show resolved Hide resolved
<div className="Account__user">
<p>{username}</p>
<button className="Account__button Account__button--edit" type="button" onClick={editUsername}>
edit
</button>
</div>
) : (
<form className="Account__user" onSubmit={handleSubmit}>
<label>
<input
className="Account__input"
type="text"
value={username}
required
onChange={(e) => setUsername(e.target.value)}
/>
</label>
<button className="Account__button Account__button--submit" type="submit">
update
</button>
</form>
)}
</div>
<div className="Account__flex">
<p>Pixel count:</p>
<p>{pixelCount}</p>
</div>
<div className="Account__flex">
<p>Current Rank:</p>
<p>{accountRank}</p>
</div>
</BasicTab>
);
}
};

export default Account;