add stepper

This commit is contained in:
Barry Gitarts 2019-08-28 17:12:29 -04:00 committed by Barry G
parent c087dad9d2
commit 1e8f391f61
3 changed files with 172 additions and 4 deletions

View File

@ -103,10 +103,7 @@ module.exports = {
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-ternary": [
"error",
"never"
],
"multiline-ternary": "off",
"new-parens": "off",
"newline-after-var": "off",
"newline-before-return": "off",

View File

@ -22,6 +22,7 @@ import { getProfileById, pledgeLifetimeReceived } from './queries'
import styles from './styles/FundProject'
import Loading from '../base/Loading'
import BreadCrumb from '../base/BreadCrumb'
import FundStepper from './FundStepper'
const { addGiverAndDonate } = LiquidPledging.methods
@ -181,6 +182,7 @@ const SubmissionSection = ({ classes, projectData, projectId, profileData, start
<div className={classes.amountText}>{getTokenLabel(manifest.goalToken)}</div>
</div>
<Button type="submit" color="primary" variant="contained" className={classnames(classes.formButton)}>{isSubmitting ? 'Ethereum Submission In Progress' : buttonText}</Button>
<FundStepper />
</div>}
</form>
)

View File

@ -0,0 +1,169 @@
import React from 'react';
import PropTypes from 'prop-types';
import { makeStyles, withStyles } from '@material-ui/core/styles';
import clsx from 'clsx';
import Stepper from '@material-ui/core/Stepper';
import Step from '@material-ui/core/Step';
import StepLabel from '@material-ui/core/StepLabel';
import Check from '@material-ui/icons/Check';
import SettingsIcon from '@material-ui/icons/Settings';
import GroupAddIcon from '@material-ui/icons/GroupAdd';
import VideoLabelIcon from '@material-ui/icons/VideoLabel';
import StepConnector from '@material-ui/core/StepConnector';
const QontoConnector = withStyles({
alternativeLabel: {
top: 10,
left: 'calc(-50% + 16px)',
right: 'calc(50% + 16px)',
},
active: {
'& $line': {
borderColor: '#4360DF',
},
},
completed: {
'& $line': {
borderColor: '#4360DF',
},
},
line: {
borderColor: '#eaeaf0',
borderTopWidth: 3,
borderRadius: 1,
},
})(StepConnector);
const useQontoStepIconStyles = makeStyles({
root: {
color: '#eaeaf0',
display: 'flex',
height: 22,
alignItems: 'center',
},
active: {
color: '#4360DF',
},
circle: {
width: 8,
height: 8,
borderRadius: '50%',
backgroundColor: 'currentColor',
},
completed: {
color: '#4360DF',
zIndex: 1,
fontSize: 18,
},
});
function QontoStepIcon(props) {
const classes = useQontoStepIconStyles();
const { active, completed } = props;
return (
<div
className={clsx(classes.root, {
[classes.active]: active,
})}
>
{completed ? <Check className={classes.completed} /> : <div className={classes.circle} />}
</div>
);
}
QontoStepIcon.propTypes = {
active: PropTypes.bool,
completed: PropTypes.bool,
};
const useColorlibStepIconStyles = makeStyles({
root: {
backgroundColor: '#ccc',
zIndex: 1,
color: '#fff',
width: 50,
height: 50,
display: 'flex',
borderRadius: '50%',
justifyContent: 'center',
alignItems: 'center',
},
active: {
backgroundImage:
'linear-gradient( 136deg, rgb(242,113,33) 0%, rgb(233,64,87) 50%, rgb(138,35,135) 100%)',
boxShadow: '0 4px 10px 0 rgba(0,0,0,.25)',
},
completed: {
backgroundImage:
'linear-gradient( 136deg, rgb(242,113,33) 0%, rgb(233,64,87) 50%, rgb(138,35,135) 100%)',
},
});
function ColorlibStepIcon(props) {
const classes = useColorlibStepIconStyles();
const { active, completed } = props;
const icons = {
1: <SettingsIcon />,
2: <GroupAddIcon />,
3: <VideoLabelIcon />,
};
return (
<div
className={clsx(classes.root, {
[classes.active]: active,
[classes.completed]: completed,
})}
>
{icons[String(props.icon)]}
</div>
);
}
ColorlibStepIcon.propTypes = {
active: PropTypes.bool,
completed: PropTypes.bool,
icon: PropTypes.node,
};
const useStyles = makeStyles(theme => ({
root: {
gridColumn: '1 / 13',
},
stepper: {
background: '#FAFAFA',
padding: '2rem 0px'
},
button: {
marginRight: theme.spacing(1),
},
instructions: {
marginTop: theme.spacing(1),
marginBottom: theme.spacing(1),
},
}));
function getSteps() {
return ['Connect', 'Authorize Amount', 'Fund', 'Confirmation'];
}
export default function CustomizedSteppers() {
const classes = useStyles();
const [activeStep, setActiveStep] = React.useState(1);
console.log({setActiveStep})
const steps = getSteps();
return (
<div className={classes.root}>
<Stepper classes={{ root: classes.stepper }}alternativeLabel activeStep={activeStep} connector={<QontoConnector />}>
{steps.map(label => (
<Step key={label}>
<StepLabel StepIconComponent={QontoStepIcon}>{label}</StepLabel>
</Step>
))}
</Stepper>
</div>
);
}