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

Changes assets -> home, updates styles, adds kernel links #24

Merged
merged 5 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 7 additions & 7 deletions packages/wallet/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import NotFound from 'views/NotFound.jsx'
import 'App.css'

const Wallet = lazy(() => import('views/Wallet.jsx'))
const Assets = lazy(() => import('views/Assets.jsx'))
const Home = lazy(() => import('views/Home.jsx'))
const Register = lazy(() => import('views/Register.jsx'))
const Create = lazy(() => import('components/Create.jsx'))
const Import = lazy(() => import('components/Import.jsx'))
Expand All @@ -25,13 +25,13 @@ const App = () => {
<Suspense fallback={<NotFound />}>
<Routes>
<Route path='/' element={<Wallet />} />
<Route path='/assets' element={<Navigate to='/assets/overview' replace />} />
<Route path='/assets/overview' element={<Assets />} />
<Route path='/home' element={<Navigate to='/home/overview' replace />} />
<Route path='/home/overview' element={<Home />} />
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any problem with just having the one /home route and deleting /home/overview?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll want more pages under home so I feel comfortable leaving this here.


<Route path='/assets/transactions' element={<Navigate to='/assets/overview' replace />} />
<Route path='/assets/nfts' element={<Navigate to='/assets/overview' replace />} />
<Route path='/assets/tokens' element={<Navigate to='/assets/overview' replace />} />
<Route path='/assets/contracts' element={<Navigate to='/assets/overview' replace />} />
<Route path='/home/transactions' element={<Navigate to='/home/overview' replace />} />
<Route path='/home/nfts' element={<Navigate to='/home/overview' replace />} />
<Route path='/home/tokens' element={<Navigate to='/home/overview' replace />} />
<Route path='/home/contracts' element={<Navigate to='/home/overview' replace />} />

<Route path='/register' element={<Register />}>
<Route path='create' element={<Create />} />
Expand Down
3 changes: 2 additions & 1 deletion packages/wallet/src/components/Import.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const env = process.env.REACT_APP_DEPLOY_TARGET || 'PROD'
const endpoint = process.env[`REACT_APP_AUTH_ENDPOINT_${env}`]

const WALLET_STORE_VERSION = '1'
const SUCCESS_TO = '/assets'
const SUCCESS_TO = '/home'

const authClient = async (jwtFn) =>
rpcClient.build({ rpcEndpoint: endpoint, jwtFn })
Expand Down Expand Up @@ -97,6 +97,7 @@ const Import = () => {
Encrypted Wallet
</label>
<input
className='w-full'
type='file'
accept='.json'
onChange={(e) => readFile(e)}
Expand Down
119 changes: 0 additions & 119 deletions packages/wallet/src/views/Assets.jsx

This file was deleted.

190 changes: 190 additions & 0 deletions packages/wallet/src/views/Home.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/**
* Copyright (c) Kernel
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import { ethers } from 'ethers'
import { useEffect, useState } from 'react'
import { linesVector } from '@kernel/common'

import Page from 'components/Page'

const WALLET_STORE_VERSION = '1'

const getItem = (k) => JSON.parse(localStorage.getItem(k))

const loadWallet = () => {
const wallet = getItem('wallet')
if (wallet.version !== WALLET_STORE_VERSION) {
throw new Error('unsupported wallet')
}
return wallet
}

const everyoneCards = [
{
title: 'Claim',
description: 'Get set up with some test ETH',
url: '/claim',
active: false
},
{
title: 'Transact',
description: 'Understand how transactions work',
url: '/transact',
active: false
},
{
title: 'Deploy',
description: 'Create your own token now',
url: '/deploy',
active: false
},
{
title: 'Mint',
description: 'Create an NFT in one go',
url: '/mint',
active: false
},
{
title: 'Contact',
description: 'Keep your friends\' addresses safe',
url: '/contact',
active: false
},
{
title: 'Contribute',
description: 'Learn how to improve this with us',
url: '/contribute',
active: false
},
{
title: 'Interact',
description: 'Explore all the best contracts',
url: '/interact',
active: false
},
{
title: 'Develop',
description: 'Write your own code!',
url: '/develop',
active: false
}
]

const kernelCards = [
Copy link
Contributor

Choose a reason for hiding this comment

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

We should keep in mind this is not specific to the Kernel. The concepts we use is different roles represented by a single number visualized by concentric circles.

What you are trying to express in this model is showing different links based on a user's role, but there is no concept of the Kernel in the code base.

The intended way to use this is there's some threshold where you graduate to an outer circle represented as a decrease in the number that is your role.

We are still missing the application and review apps which will be the primary way to move members from the permissionless, open Web3 role to a member role.

Therefore, this should be renamed as memberCards.

{
title: 'UnProfile',
description: 'Unprofile yourself',
url: 'https://staging.unprofile.kernel.community/',
Copy link
Contributor

Choose a reason for hiding this comment

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

This url is going to cause issues when deploying to a different environment other than staging.

There is an environment variable REACT_APP_DEPLOY_TARGET that will tell you what the target environment is.

We should make the URLs dependent on the target.

There's an open issue to update the footer to include links to the apps and the code should be shared across both use cases. #19

Copy link
Contributor

Choose a reason for hiding this comment

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

@andytudhope you may beat Alon to this, so if you want to use the guidance in #19 ("How to get the correct domains") to create a helper that returns the correct url for each app, go ahead. just let him know so that he can reuse it for the footer.

active: true
},
{
title: 'Adventure',
description: 'Heed the call to adventure',
url: 'https://staging.adventures.kernel.community/',
active: true
},
{
title: 'Explore',
description: 'Connect with other Fellows',
url: 'https://staging.explore.kernel.community/',
active: true
},
{
title: 'Chat',
description: 'Horizontal conversations',
url: 'https://staging.chat.kernel.community/',
active: false
}
]

const Home = () => {
const wallet = loadWallet()
const [address] = useState(wallet.address)
const [nickname] = useState(wallet.nickname)
/* eslint-disable no-unused-vars */
const [signer, setSigner] = useState(null)
/* eslint-disable no-unused-vars */
const [balance, setBalance] = useState(0)

useEffect(() => {
// TODO: pass in context
const defaultProvider = new ethers.providers.CloudflareProvider()
const voidSigner = new ethers.VoidSigner(address, defaultProvider)
setSigner(voidSigner)
voidSigner.getBalance().then((e) => setBalance(ethers.utils.formatEther(e)))
}, [address])

return (
<Page>
<div className='relative'>
<div className='hidden lg:block lg:fixed lg:-top-24 lg:-left-52 lg:z-0'>
<img alt='kernel fingerprint' src={linesVector} width={383} height={412} />
</div>
<div className='hidden lg:block lg:fixed lg:-top-12 lg:-right-52 lg:z-0'>
<img alt='kernel fingerprint' src={linesVector} width={442} height={476} />
</div>
</div>
<div className='mt-32 mx-8 sm:mx-24 xl:mx-48'>
<div className='text-center'>
<div className='font-heading lg:text-5xl text-5xl text-primary lg:py-5'>
Welcome, {nickname}.
</div>
<hr />
<div className='text-2xl my-4 text-secondary'>
You are already valuable, just as you are.
</div>
<div className='my-4 text-secondary'>
This portal will help you learn how to realize some of that value in the
world of web3. We're so happy you're with us.
</div>
</div>

<div className='my-4 px-4 grid grid-cols-1 md:grid-cols-2 md:my-16 md:px-16'>
<div>
<h3 className='font-heading text-center text-3xl text-primary py-5'>For Everyone</h3>
<div className='grid grid-cols-1 md:grid-cols-2 md:gap-x-8 gap-y-8 border-0 md:border-r border-kernel-grey md:pr-12'>
{everyoneCards.map((everyoneCard, index) => {
return (
<a key={index} href={`${everyoneCard.active ? everyoneCard.url : '#'}`}>
<div className={
`${everyoneCard.active ? 'bg-kernel-dark text-kernel-white' : 'bg-kernel-grey'} p-5 rounded shadow-md`
}
>
<div className='text-xl mb-2'>{everyoneCard.title}</div>
<div className='text-base mb-1'>{everyoneCard.description}</div>
</div>
</a>
)
})}
</div>
</div>
<div>
<h3 className='font-heading text-center text-3xl text-primary py-5'>Kernel Additions</h3>
<div className='grid grid-cols-1 gap-y-8'>
{kernelCards.map((kernelCard, index) => {
return (
<a key={index} href={`${kernelCard.active ? kernelCard.url : '#'}`} className='w-full md:w-72 my-0 mx-auto'>
<div className={
`${kernelCard.active ? 'bg-kernel-dark text-kernel-white' : 'bg-kernel-grey'} p-5 rounded shadow-md`
}
>
<div className='text-xl mb-2'>{kernelCard.title}</div>
<div className='text-base mb-1'>{kernelCard.description}</div>
</div>
</a>
)
})}
Copy link
Contributor

@rorysaur rorysaur May 26, 2022

Choose a reason for hiding this comment

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

Since this is now being duplicated, you can break out this returned component into a named component defined at the top level, like

const LinkCard = (cardConfig, index) => {
  ...
}

</div>
</div>
</div>
</div>
</Page>
)
}

export default Home
2 changes: 1 addition & 1 deletion packages/wallet/src/views/Wallet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Wallet = () => {
</span>
</Link>
&nbsp;or&nbsp;
<Link to='/assets'>
<Link to='/home'>
<span className='pl-2 before:block before:absolute before:-inset-1 before:skew-y-3 before:bg-kernel-yellow-light relative inline-block cursor-pointer'>
<span className='relative text-primary'>
<span className='underline decoration-dotted'>
Expand Down
1 change: 1 addition & 0 deletions packages/wallet/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
colors: {
kernel: {
white: '#ffffff',
grey: '#eee',
dark: '#212144',
highlight: '#CBF0C1',
yellow: {
Expand Down