1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

restore Ocean loader

This commit is contained in:
Matthias Kretschmann 2020-07-09 13:42:06 +02:00
parent 8159b66a52
commit c73cc97e44
Signed by: m
GPG Key ID: 606EEEF3C479A91F
11 changed files with 53 additions and 81 deletions

View File

@ -1,57 +1,27 @@
.loaderWrap { .loaderWrap {
display: inline-block; display: flex;
font-size: var(--font-size-small); align-items: center;
color: var(--brand-grey);
}
.loader,
.loader:before,
.loader:after {
background: var(--brand-grey);
border-radius: var(--border-radius);
animation: load1 0.7s infinite ease-in-out;
font-size: var(--font-size-base);
width: 0.3em;
height: 1em;
display: block;
} }
.loader { .loader {
margin: 0.6em auto; display: block;
position: relative; width: 20px;
transform: translateZ(0); height: 20px;
animation-delay: -0.16s; border-radius: 50%;
} border: 2px solid var(--brand-purple);
.loaderHorizontal { border-top-color: var(--brand-violet);
composes: loader; animation: loader 0.6s linear infinite;
display: inline-block;
margin: 0 1.5em 0 0.7em;
vertical-align: middle;
} }
.loader:before, .message {
.loader:after { font-size: var(--font-size-small);
position: absolute; color: var(--brand-grey-light);
top: 0; display: block;
content: ''; margin-left: calc(var(--spacer) / 4);
} }
.loader:before { @keyframes loader {
left: -0.6em; to {
animation-delay: -0.32s; transform: rotate(360deg);
}
.loader:after {
left: 0.6em;
}
@keyframes load1 {
0%,
80%,
100% {
transform: scaleY(0.5);
}
40% {
transform: scaleY(1.3);
} }
} }

View File

@ -2,18 +2,14 @@ import React, { ReactElement } from 'react'
import styles from './Loader.module.css' import styles from './Loader.module.css'
export default function Loader({ export default function Loader({
message, message
isHorizontal
}: { }: {
message?: string message?: string
isHorizontal?: boolean
}): ReactElement { }): ReactElement {
return ( return (
<div className={styles.loaderWrap}> <div className={styles.loaderWrap}>
<span <span className={styles.loader} />
className={isHorizontal ? styles.loaderHorizontal : styles.loader} {message && <span className={styles.message}>{message}</span>}
/>
{message || null}
</div> </div>
) )
} }

View File

@ -1,4 +1,4 @@
import React from 'react' import React, { ReactElement, ReactNode } from 'react'
import isUrl from 'is-url-superb' import isUrl from 'is-url-superb'
import Loader from '../../../atoms/Loader' import Loader from '../../../atoms/Loader'
import Button from '../../../atoms/Button' import Button from '../../../atoms/Button'
@ -11,12 +11,12 @@ const FileInput = ({
children, children,
i i
}: { }: {
children: any children: ReactNode
i: number i: number
formData: string[] formData: string[]
handleButtonClick(e: React.SyntheticEvent, data: string): void handleButtonClick(e: React.SyntheticEvent, data: string): void
isLoading: boolean isLoading: boolean
}) => ( }): ReactElement => (
<> <>
{children} {children}
{formData[i] && ( {formData[i] && (

View File

@ -1,4 +1,4 @@
import React, { useState, ChangeEvent, FormEvent } from 'react' import React, { useState, ChangeEvent, FormEvent, ReactElement } from 'react'
import { useNavigate } from '@reach/router' import { useNavigate } from '@reach/router'
import styles from './SearchBar.module.css' import styles from './SearchBar.module.css'
import Loader from '../atoms/Loader' import Loader from '../atoms/Loader'
@ -15,7 +15,7 @@ export default function SearchBar({
initialValue?: string initialValue?: string
filters?: boolean filters?: boolean
large?: true large?: true
}) { }): ReactElement {
const navigate = useNavigate() const navigate = useNavigate()
const [value, setValue] = useState(initialValue || '') const [value, setValue] = useState(initialValue || '')
const [searchStarted, setSearchStarted] = useState(false) const [searchStarted, setSearchStarted] = useState(false)

View File

@ -1,22 +1,26 @@
import React from 'react' import React, { ReactElement } from 'react'
import Compute from './Compute' import Compute from './Compute'
import ddo from '../../../../tests/unit/__fixtures__/ddo' import ddo from '../../../../tests/unit/__fixtures__/ddo'
import web3Mock from '../../../../tests/unit/__mocks__/web3' import web3Mock from '../../../../tests/unit/__mocks__/web3'
import { DDO } from '@oceanprotocol/squid' import squidMock from '../../../../tests/unit/__mocks__/@oceanprotocol/squid'
import oceanMock from '../../../tests/unit/__mocks__/ocean-mock'
import { context } from '../../../../tests/unit/__mocks__/web3provider' import { context } from '../../../../tests/unit/__mocks__/web3provider'
export default { export default {
title: 'Organisms/Consumejob', title: 'Organisms/Consume',
decorators: [ decorators: [
(storyFn: () => React.FC) => ( (storyFn: () => React.FC): ReactElement => (
<div style={{ maxWidth: '40rem', margin: 'auto' }}>{storyFn()}</div> <div style={{ maxWidth: '40rem', margin: 'auto' }}>{storyFn()}</div>
) )
] ]
} }
export const Default = () => ( export const Default = (): ReactElement => (
<context.Provider value={web3Mock}> <context.Provider value={web3Mock}>
<Compute ddo={ddo as DDO} ocean={oceanMock as any} balance="1000000" /> <Compute
did={ddo.id}
ocean={squidMock.ocean as any}
metadata={ddo.findServiceByType('metadata').attributes as any}
balance="1000000"
/>
</context.Provider> </context.Provider>
) )

View File

@ -1,21 +1,23 @@
import React from 'react' import React, { ReactElement } from 'react'
import Consume from './Consume' import Consume from './Consume'
import ddo from '../../../../tests/unit/__fixtures__/ddo' import ddo from '../../../../tests/unit/__fixtures__/ddo'
import web3Mock from '../../../../tests/unit/__mocks__/web3' import web3Mock from '../../../../tests/unit/__mocks__/web3'
import { DDO } from '@oceanprotocol/squid'
import { context } from '../../../../tests/unit/__mocks__/web3provider' import { context } from '../../../../tests/unit/__mocks__/web3provider'
export default { export default {
title: 'Organisms/Consume', title: 'Organisms/Consume',
decorators: [ decorators: [
(storyFn: () => React.FC) => ( (storyFn: () => React.FC): ReactElement => (
<div style={{ maxWidth: '40rem', margin: 'auto' }}>{storyFn()}</div> <div style={{ maxWidth: '40rem', margin: 'auto' }}>{storyFn()}</div>
) )
] ]
} }
export const PricedAsset = () => ( export const PricedAsset = (): ReactElement => (
<context.Provider value={web3Mock}> <context.Provider value={web3Mock}>
<Consume ddo={ddo as DDO} /> <Consume
did={ddo.id}
metadata={ddo.findServiceByType('metadata').attributes as any}
/>
</context.Provider> </context.Provider>
) )

View File

@ -33,7 +33,7 @@ export default function Consume({
} }
return isLoading ? ( return isLoading ? (
<Loader message={consumeStepText} isHorizontal /> <Loader message={consumeStepText} />
) : ( ) : (
<Button <Button
style="primary" style="primary"

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState, ReactElement } from 'react'
import Loader from '../atoms/Loader' import Loader from '../atoms/Loader'
import { import {
useOcean, useOcean,
@ -39,7 +39,7 @@ const consumedColumns = [
} }
] ]
export default function ConsumedList() { export default function ConsumedList(): ReactElement {
const { ocean, status, accountId, account } = useOcean() const { ocean, status, accountId, account } = useOcean()
const [consumedList, setConsumedList] = useState<any>([]) const [consumedList, setConsumedList] = useState<any>([])
const { getConsumedList } = useSearch() const { getConsumedList } = useSearch()

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState, ReactElement } from 'react'
import Loader from '../atoms/Loader' import Loader from '../atoms/Loader'
import { import {
useOcean, useOcean,
@ -68,7 +68,7 @@ const columns = [
} }
] ]
export default function JobsList() { export default function JobsList(): ReactElement {
const { ocean, status, accountId } = useOcean() const { ocean, status, accountId } = useOcean()
const [jobList, setJobList] = useState<any[]>([]) const [jobList, setJobList] = useState<any[]>([])

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState, ReactElement } from 'react'
import Loader from '../atoms/Loader' import Loader from '../atoms/Loader'
import { MetaDataMain } from '@oceanprotocol/squid' import { MetaDataMain } from '@oceanprotocol/squid'
import { import {
@ -39,7 +39,7 @@ const publishedColumns = [
} }
] ]
export default function PublishedList() { export default function PublishedList(): ReactElement {
const { ocean, status, account, accountId } = useOcean() const { ocean, status, account, accountId } = useOcean()
const { getPublishedList } = useSearch() const { getPublishedList } = useSearch()
const [publishedList, setPublishedList] = useState<any[]>([]) const [publishedList, setPublishedList] = useState<any[]>([])

View File

@ -14,14 +14,14 @@ body {
html { html {
font-size: var(--font-size-root); font-size: var(--font-size-root);
scroll-behavior: smooth; /* scroll-behavior: smooth; */
} }
@media screen and (prefers-reduced-motion: reduce) { /* @media screen and (prefers-reduced-motion: reduce) {
html { html {
scroll-behavior: auto; scroll-behavior: auto;
} }
} } */
body { body {
color: var(--brand-grey); color: var(--brand-grey);