mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
replace default input with url adding UI
This commit is contained in:
parent
5dd0d7f070
commit
dd15dba8c1
@ -16,18 +16,6 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"rows": 5
|
"rows": 5
|
||||||
},
|
},
|
||||||
"price": {
|
|
||||||
"label": "Price",
|
|
||||||
"placeholder": "i.e. 1000",
|
|
||||||
"type": "number",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"author": {
|
|
||||||
"label": "Author",
|
|
||||||
"placeholder": "i.e. Jelly McJellyfish",
|
|
||||||
"type": "text",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
"files": {
|
"files": {
|
||||||
"label": "Files",
|
"label": "Files",
|
||||||
"placeholder": "i.e. https://file.com/file.json",
|
"placeholder": "i.e. https://file.com/file.json",
|
||||||
@ -41,6 +29,12 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"options": ["Data set", "Algorithm", "Container", "Workflow", "Other"]
|
"options": ["Data set", "Algorithm", "Container", "Workflow", "Other"]
|
||||||
},
|
},
|
||||||
|
"author": {
|
||||||
|
"label": "Author",
|
||||||
|
"placeholder": "i.e. Jelly McJellyfish",
|
||||||
|
"type": "text",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
"license": {
|
"license": {
|
||||||
"label": "License",
|
"label": "License",
|
||||||
"type": "select",
|
"type": "select",
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
@import '../../../styles/variables';
|
@import '../../../styles/variables';
|
||||||
|
|
||||||
.linkType {
|
|
||||||
margin-left: $spacer / 4;
|
|
||||||
font-size: $font-size-small;
|
|
||||||
}
|
|
||||||
|
|
||||||
.linkUrl {
|
.linkUrl {
|
||||||
font-size: $font-size-mini;
|
font-size: $font-size-mini;
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -5,25 +5,6 @@
|
|||||||
margin-bottom: $spacer / 1.5;
|
margin-bottom: $spacer / 1.5;
|
||||||
padding-left: $spacer / 2;
|
padding-left: $spacer / 2;
|
||||||
|
|
||||||
> div {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.input-wrap) {
|
|
||||||
flex: 1 1 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.form__group) {
|
|
||||||
margin-bottom: $spacer / 2;
|
|
||||||
flex: 1 1 100%;
|
|
||||||
|
|
||||||
@media (min-width: $break-point--small) {
|
|
||||||
flex: 0 0 48%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
label,
|
label,
|
||||||
input,
|
input,
|
||||||
select,
|
select,
|
||||||
|
@ -6,6 +6,7 @@ import styles from './ItemForm.module.scss'
|
|||||||
|
|
||||||
interface ItemFormProps {
|
interface ItemFormProps {
|
||||||
addItem: any
|
addItem: any
|
||||||
|
placeholder: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ItemFormStates {
|
interface ItemFormStates {
|
||||||
@ -44,8 +45,8 @@ export default class ItemForm extends PureComponent<
|
|||||||
this.props.addItem(url)
|
this.props.addItem(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
public onChangeUrl = (e: Event) => {
|
public onChangeUrl = (e: React.FormEvent<HTMLInputElement>) => {
|
||||||
// this.setState({ url: e.target.value })
|
this.setState({ url: e.currentTarget.value })
|
||||||
this.clearErrors()
|
this.clearErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,13 +65,13 @@ export default class ItemForm extends PureComponent<
|
|||||||
name="url"
|
name="url"
|
||||||
required
|
required
|
||||||
type="url"
|
type="url"
|
||||||
placeholder="e.g. https://url.com/info"
|
placeholder={this.props.placeholder}
|
||||||
value={url}
|
value={url}
|
||||||
onChange={this.onChangeUrl}
|
onChange={this.onChangeUrl}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button onClick={(e: Event) => this.handleSubmit(e)}>
|
<Button onClick={(e: Event) => this.handleSubmit(e)}>
|
||||||
Add Link
|
Add File
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{hasError && (
|
{hasError && (
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
.newItems {
|
.newItems {
|
||||||
margin-top: $spacer / 2;
|
margin-top: $spacer / 2;
|
||||||
border-top: 1px solid $brand-grey-lighter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.itemsList {
|
.itemsList {
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import React, { PureComponent } from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import { CSSTransition, TransitionGroup } from 'react-transition-group'
|
import { CSSTransition, TransitionGroup } from 'react-transition-group'
|
||||||
import Button from '../../../components/atoms/Button'
|
import Button from '../../../components/atoms/Button'
|
||||||
|
import Help from '../../../components/atoms/Form/Help'
|
||||||
import ItemForm from './ItemForm'
|
import ItemForm from './ItemForm'
|
||||||
import Item from './Item'
|
import Item from './Item'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
interface FilesProps {
|
interface FilesProps {
|
||||||
files: any
|
files: any
|
||||||
|
placeholder: string
|
||||||
|
help: string
|
||||||
// resetForm: any
|
// resetForm: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,13 +40,16 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
const { isFormShown } = this.state
|
const { isFormShown } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<Help>{this.props.help}</Help>
|
||||||
<div className={styles.newItems}>
|
<div className={styles.newItems}>
|
||||||
{this.props.files && (
|
{this.props.files.length > 1 && (
|
||||||
<TransitionGroup
|
<TransitionGroup
|
||||||
component="ul"
|
component="ul"
|
||||||
className={styles.itemsList}
|
className={styles.itemsList}
|
||||||
>
|
>
|
||||||
{this.props.files.map((item: string, index: number) => (
|
{this.props.files.map(
|
||||||
|
(item: string, index: number) => (
|
||||||
<CSSTransition
|
<CSSTransition
|
||||||
key={index}
|
key={index}
|
||||||
timeout={400}
|
timeout={400}
|
||||||
@ -51,10 +57,13 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
>
|
>
|
||||||
<Item
|
<Item
|
||||||
item={item}
|
item={item}
|
||||||
removeItem={() => this.removeItem(index)}
|
removeItem={() =>
|
||||||
|
this.removeItem(index)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</CSSTransition>
|
</CSSTransition>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
</TransitionGroup>
|
</TransitionGroup>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -69,9 +78,13 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
unmountOnExit
|
unmountOnExit
|
||||||
onExit={() => this.setState({ isFormShown: false })}
|
onExit={() => this.setState({ isFormShown: false })}
|
||||||
>
|
>
|
||||||
<ItemForm addItem={this.addItem} />
|
<ItemForm
|
||||||
|
placeholder={this.props.placeholder}
|
||||||
|
addItem={this.addItem}
|
||||||
|
/>
|
||||||
</CSSTransition>
|
</CSSTransition>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import Route from '../../components/templates/Route'
|
|||||||
import Button from '../../components/atoms/Button'
|
import Button from '../../components/atoms/Button'
|
||||||
import Form from '../../components/atoms/Form/Form'
|
import Form from '../../components/atoms/Form/Form'
|
||||||
import Input from '../../components/atoms/Form/Input'
|
import Input from '../../components/atoms/Form/Input'
|
||||||
|
import Label from '../../components/atoms/Form/Label'
|
||||||
|
import Row from '../../components/atoms/Form/Row'
|
||||||
import { User } from '../../context/User'
|
import { User } from '../../context/User'
|
||||||
import AssetModel from '../../models/AssetModel'
|
import AssetModel from '../../models/AssetModel'
|
||||||
import Web3message from '../../components/Web3message'
|
import Web3message from '../../components/Web3message'
|
||||||
@ -57,6 +59,21 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
onChange = this.inputToArrayChange
|
onChange = this.inputToArrayChange
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key === 'files') {
|
||||||
|
return (
|
||||||
|
<Row key={key}>
|
||||||
|
<Label htmlFor={key} required>
|
||||||
|
{value.label}
|
||||||
|
</Label>
|
||||||
|
<Files
|
||||||
|
placeholder={value.placeholder}
|
||||||
|
help={value.help}
|
||||||
|
files={this.state.files}
|
||||||
|
/>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
key={key}
|
key={key}
|
||||||
@ -70,9 +87,6 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
rows={value.rows}
|
rows={value.rows}
|
||||||
value={(this.state as any)[key]}
|
value={(this.state as any)[key]}
|
||||||
additionalComponent={
|
|
||||||
key === 'files' && <Files files={this.state.files} />
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user