Skip to content

Commit

Permalink
Merge pull request #507 from 1Hive/onboarding-garden-type
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziovigevani committed Jun 24, 2021
2 parents feae859 + 5488a96 commit 634d2a1
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 12 deletions.
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
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

0 comments on commit 634d2a1

Please sign in to comment.