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

Onboarding: Garden type selection screen #507

Merged
merged 4 commits into from
Jun 24, 2021
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
141 changes: 130 additions & 11 deletions src/components/Onboarding/Screens/GardenTypeSelector.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,139 @@
import React from 'react'
import React, { useCallback, useState } from 'react'
import { GU, textStyle, useTheme } from '@1hive/1hive-ui'
import { useOnboardingState } from '@providers/Onboarding'
import Navigation from '../Navigation'

function GardenTypeSelector({ title }) {
const { onBack, onNext, step, steps } = useOnboardingState()
import { BYOT_TYPE, NATIVE_TYPE } from '../constants'
import defaultGardenLogo from '@assets/defaultGardenLogo.png'

function GardenTypeSelector() {
const theme = useTheme()
const { config, onConfigChange, onNext } = useOnboardingState()
const [selectedType] = useState(config.garden.type)

const handleNext = useCallback(
selectedType => {
onConfigChange('garden', { type: selectedType })
onNext()
},
[onConfigChange, onNext]
)

const handleSelectNative = useCallback(() => {
handleNext(NATIVE_TYPE)
}, [handleNext])

const handleSelectBYOT = useCallback(() => {
handleNext(BYOT_TYPE)
}, [handleNext])

return (
<div>
{title}
<Navigation
backEnabled={false}
nextEnabled
nextLabel={`Next: ${steps[step + 1].title}`}
onBack={onBack}
onNext={onNext}
<div
css={`
margin-bottom: ${6 * GU}px;
text-align: center;
`}
>
<h1
css={`
${textStyle('title1')};
margin-bottom: ${3 * GU}px;
`}
>
Garden type
</h1>
<div>
<p
css={`
${textStyle('body1')};
color: ${theme.contentSecondary};
`}
>
Choose which type of garden you'd like to launch.
</p>
</div>
</div>
<div
css={`
display: flex;
align-items: center;
justify-content: space-around;
margin-bottom: ${6 * GU}px;
`}
>
<Card
Copy link
Member

Choose a reason for hiding this comment

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

Wonder what you think of also add the handleNext handler to the onSelect prop of each Card?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes i thought about it but wasn't sure, let's do it 👍

icon={defaultGardenLogo}
paragraph="Launch garden with new token"
onSelect={handleSelectNative}
selected={selectedType === NATIVE_TYPE}
title="Native"
/>
<Card
icon={defaultGardenLogo}
paragraph="Launch garden with existing token"
onSelect={handleSelectBYOT}
selected={selectedType === BYOT_TYPE}
title="BYOT"
/>
</div>
</div>
)
}

function Card({ icon, title, onSelect, paragraph, selected }) {
const theme = useTheme()
return (
<div
css={`
cursor: pointer;
padding: ${5 * GU}px;
background: ${theme.surface};
border: 1px solid ${theme.border};
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.1);
transition: box-shadow 0.3s ease;
${selected
? `
box-shadow: 0px 0px 7px 1px ${theme.accentStart};
background: linear-gradient(
268deg,
${theme.accentEnd},
${theme.accentStart}
);
`
: ` &:hover {
box-shadow: 0px 0px 7px 1px rgba(0, 0, 0, 0.2);
}`}
`}
onClick={onSelect}
>
<img
src={icon}
alt=""
height="100"
width="100"
css={`
margin-bottom: ${2 * GU}px;
`}
/>
<div
css={`
margin-bottom: ${3 * GU}px;
${textStyle('title2')};
`}
>
{title}
</div>
<div
css={`
color: ${theme.contentSecondary};
${textStyle('body1')};
`}
>
{paragraph}
</div>
</div>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Onboarding/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const NATIVE_TYPE = 0
export const BYOT_TYPE = 1
2 changes: 1 addition & 1 deletion src/providers/Onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DEFAULT_CONFIG = {
documentation: [],
community: [],
},
type: null,
type: -1,
},
agreement: {
title: '',
Expand Down