1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

progress styling, visually structure form, lots of tweaks

This commit is contained in:
Matthias Kretschmann 2019-02-20 12:33:04 +01:00
parent 73f479be22
commit ab315532c7
Signed by: m
GPG Key ID: 606EEEF3C479A91F
7 changed files with 119 additions and 24 deletions

View File

@ -2,6 +2,10 @@
.form { .form {
width: 100%; width: 100%;
background: $brand-white;
padding: $spacer;
border: 1px solid $brand-grey-lighter;
border-radius: $border-radius;
fieldset { fieldset {
border: 0; border: 0;

View File

@ -18,7 +18,7 @@
"placeholder": "i.e. https://file.com/file.json", "placeholder": "i.e. https://file.com/file.json",
"type": "text", "type": "text",
"required": true, "required": true,
"help": "Provide one or multiple links to your data files." "help": "Provide one or multiple urls to your data set files."
} }
} }
}, },
@ -73,7 +73,7 @@
} }
}, },
{ {
"title": "Credentials", "title": "Authorship",
"description": "A description about these credentials fields", "description": "A description about these credentials fields",
"fields": { "fields": {
"author": { "author": {
@ -103,6 +103,9 @@
] ]
} }
} }
},
{
"title": "Register"
} }
] ]
} }

View File

@ -0,0 +1,76 @@
@import '../../styles/variables';
.progress {
display: block;
padding: 0;
position: relative;
margin-top: $spacer * 1.5;
margin-bottom: $spacer;
}
.item {
display: inline-block;
width: 25%;
text-align: center;
color: $brand-grey-light;
&:before {
content: '';
display: block;
width: 60%;
height: .1rem;
background: $brand-grey-lighter;
position: absolute;
top: 20%;
left: -30%;
}
&:first-child {
&:before {
display: none;
}
}
span {
display: block;
}
}
.active {
composes: item;
font-family: $font-family-button;
font-weight: $font-weight-bold;
color: $brand-black;
.number {
background: $brand-black;
}
&:before {
background: $green;
}
}
.completed {
composes: active;
.number {
background: $green;
}
}
.label {
margin-top: $spacer / 8;
font-size: $font-size-small;
}
.number {
width: 1.6rem;
height: 1.6rem;
margin: auto;
border-radius: 50%;
background: $brand-grey-light;
color: $brand-white;
font-family: $font-family-button;
font-weight: $font-weight-bold;
}

View File

@ -1,25 +1,31 @@
import React from 'react' import React from 'react'
import styles from './Progress.module.scss'
const Progress = ({ const Progress = ({
currentStep, currentStep,
totalSteps,
steps steps
}: { }: {
currentStep: number currentStep: number
totalSteps: number
steps: any[] steps: any[]
}) => { }) => {
return ( return (
<aside> <ul className={styles.progress}>
<ul> {steps.map(({ title }, index) => (
{steps.map(({ title }, index) => ( <li
<li key={index}> key={index}
{index + 1} className={
{title} currentStep === index + 1
</li> ? styles.active
))} : currentStep > index + 1
</ul> ? styles.completed
</aside> : styles.item
}
>
<span className={styles.number}>{index + 1}</span>
<span className={styles.label}>{title}</span>
</li>
))}
</ul>
) )
} }

View File

@ -2,7 +2,6 @@
.header { .header {
margin-bottom: $spacer * 1.5; margin-bottom: $spacer * 1.5;
border-bottom: .1rem solid $brand-grey-lighter;
} }
.title { .title {
@ -19,7 +18,7 @@
justify-content: space-between; justify-content: space-between;
border-top: .1rem solid $brand-grey-lighter; border-top: .1rem solid $brand-grey-lighter;
padding-top: $spacer; padding-top: $spacer;
margin-top: $spacer * 2; margin-top: $spacer;
button:last-child { button:last-child {
min-width: 12rem; min-width: 12rem;

View File

@ -1,8 +1,9 @@
import React, { PureComponent, FormEvent } from 'react' import React, { PureComponent } from 'react'
import Input from '../../components/atoms/Form/Input' import Input from '../../components/atoms/Form/Input'
import Label from '../../components/atoms/Form/Label' import Label from '../../components/atoms/Form/Label'
import Row from '../../components/atoms/Form/Row' import Row from '../../components/atoms/Form/Row'
import Button from '../../components/atoms/Button' import Button from '../../components/atoms/Button'
import Web3message from '../../components/Web3message'
import { User } from '../../context/User' import { User } from '../../context/User'
import Files from './Files/' import Files from './Files/'
import styles from './Step.module.scss' import styles from './Step.module.scss'
@ -20,6 +21,7 @@ interface StepProps {
next: any next: any
prev: any prev: any
totalSteps: number totalSteps: number
component?: string
} }
export default class Step extends PureComponent<StepProps, {}> { export default class Step extends PureComponent<StepProps, {}> {
@ -56,13 +58,16 @@ export default class Step extends PureComponent<StepProps, {}> {
inputToArrayChange, inputToArrayChange,
files, files,
state, state,
totalSteps totalSteps,
component
} = this.props } = this.props
if (currentStep !== index + 1) { if (currentStep !== index + 1) {
return null return null
} }
const lastStep = currentStep === totalSteps
return ( return (
<> <>
<header className={styles.header}> <header className={styles.header}>
@ -112,11 +117,13 @@ export default class Step extends PureComponent<StepProps, {}> {
) )
})} })}
{lastStep && <Web3message />}
<div className={styles.actions}> <div className={styles.actions}>
{this.previousButton()} {this.previousButton()}
{this.nextButton()} {this.nextButton()}
{currentStep === totalSteps && ( {lastStep && (
<User.Consumer> <User.Consumer>
{states => {states =>
states.isLogged ? ( states.isLogged ? (

View File

@ -3,7 +3,6 @@ import { Logger } from '@oceanprotocol/squid'
import Route from '../../components/templates/Route' import Route from '../../components/templates/Route'
import Form from '../../components/atoms/Form/Form' import Form from '../../components/atoms/Form/Form'
import AssetModel from '../../models/AssetModel' import AssetModel from '../../models/AssetModel'
import Web3message from '../../components/Web3message'
import Step from './Step' import Step from './Step'
import Progress from './Progress' import Progress from './Progress'
@ -159,9 +158,10 @@ class Publish extends Component<{}, PublishState> {
public render() { public render() {
return ( return (
<Route title="Publish"> <Route
<Web3message /> title="Publish"
description="Publish a new data set into the Ocean Protocol Network."
>
{this.state.isPublishing ? ( {this.state.isPublishing ? (
this.publishingState() this.publishingState()
) : this.state.publishingError ? ( ) : this.state.publishingError ? (
@ -173,7 +173,6 @@ class Publish extends Component<{}, PublishState> {
<Progress <Progress
steps={form.steps} steps={form.steps}
currentStep={this.state.currentStep} currentStep={this.state.currentStep}
totalSteps={form.steps.length}
/> />
<Form onSubmit={this.registerAsset}> <Form onSubmit={this.registerAsset}>
@ -192,6 +191,7 @@ class Publish extends Component<{}, PublishState> {
next={this.next} next={this.next}
prev={this.prev} prev={this.prev}
totalSteps={form.steps.length} totalSteps={form.steps.length}
component={step.component}
/> />
))} ))}
</Form> </Form>