1
0
mirror of https://github.com/oceanprotocol/ipfs synced 2024-11-22 09:47:03 +01:00

more styling

This commit is contained in:
Matthias Kretschmann 2019-10-18 19:12:49 +02:00
parent fe8330ef63
commit a40028ca4e
Signed by: m
GPG Key ID: 606EEEF3C479A91F
8 changed files with 53 additions and 30 deletions

View File

@ -6,9 +6,3 @@
word-wrap: break-word; word-wrap: break-word;
word-break: break-all; word-break: break-all;
} }
.error {
font-size: var(--font-size-small);
color: var(--red);
margin-top: var(--spacer);
}

View File

@ -94,10 +94,8 @@ export default function Add() {
multiple={false} multiple={false}
handleOnDrop={handleOnDrop} handleOnDrop={handleOnDrop}
disabled={!isIpfsReady} disabled={!isIpfsReady}
error={error || ipfsError}
/> />
{(error || ipfsError) && (
<div className={styles.error}>{error || ipfsError}</div>
)}
</> </>
)} )}
</div> </div>

View File

@ -6,6 +6,7 @@
padding: calc(var(--spacer) * 2) var(--spacer); padding: calc(var(--spacer) * 2) var(--spacer);
transition: 0.2s ease-out; transition: 0.2s ease-out;
cursor: pointer; cursor: pointer;
text-align: center;
} }
.dropzone:hover, .dropzone:hover,
@ -22,10 +23,15 @@
.disabled { .disabled {
composes: dropzone; composes: dropzone;
opacity: 0.3; border-color: var(--brand-grey-dark);
pointer-events: none; pointer-events: none;
} }
.error {
font-size: var(--font-size-small);
color: var(--red);
}
.dropzone p { .dropzone p {
text-align: center; text-align: center;
margin-bottom: 0; margin-bottom: 0;

View File

@ -5,11 +5,13 @@ import styles from './Dropzone.module.css'
export default function Dropzone({ export default function Dropzone({
handleOnDrop, handleOnDrop,
disabled, disabled,
multiple multiple,
error
}: { }: {
handleOnDrop(files: File[]): void handleOnDrop(files: File[]): void
disabled?: boolean disabled?: boolean
multiple?: boolean multiple?: boolean
error?: string
}) { }) {
const onDrop = useCallback(acceptedFiles => handleOnDrop(acceptedFiles), [ const onDrop = useCallback(acceptedFiles => handleOnDrop(acceptedFiles), [
handleOnDrop handleOnDrop
@ -33,14 +35,15 @@ export default function Dropzone({
})} })}
> >
<input {...getInputProps({ multiple })} /> <input {...getInputProps({ multiple })} />
<p> {isDragActive && !isDragReject ? (
{isDragActive && !isDragReject `Drop it like it's hot!`
? `Drop it like it's hot!` ) : multiple ? (
: multiple `Drag 'n' drop some files here, or click to select files`
? `Drag 'n' drop some files here, or click to select files` ) : error ? (
: `Drag 'n' drop a file here, or click to select a file`} <div className={styles.error}>{error}</div>
{} ) : (
</p> `Drag 'n' drop a file here, or click to select a file`
)}
</div> </div>
) )
} }

View File

@ -2,7 +2,6 @@
.info { .info {
font-size: var(--font-size-small); font-size: var(--font-size-small);
text-align: left;
opacity: 0.8; opacity: 0.8;
overflow-wrap: break-word; overflow-wrap: break-word;
word-wrap: break-word; word-wrap: break-word;
@ -12,7 +11,7 @@
.info h2 { .info h2 {
font-size: var(--font-size-base); font-size: var(--font-size-base);
color: var(--brand-grey-light); color: var(--brand-grey-light);
margin-top: var(--spacer); margin-top: calc(var(--spacer) * 2);
} }
.info code { .info code {

View File

@ -10,6 +10,12 @@ export interface IpfsConfig {
port: string port: string
} }
function parseHTML(str: string) {
const tmp = document.implementation.createHTMLDocument()
tmp.body.innerHTML = str
return tmp.body.children
}
export default function useIpfsApi(config: IpfsConfig) { export default function useIpfsApi(config: IpfsConfig) {
const [isIpfsReady, setIpfsReady] = useState(Boolean(ipfs)) const [isIpfsReady, setIpfsReady] = useState(Boolean(ipfs))
const [ipfsError, setIpfsError] = useState('') const [ipfsError, setIpfsError] = useState('')
@ -24,7 +30,16 @@ export default function useIpfsApi(config: IpfsConfig) {
const version = await ipfs.version() const version = await ipfs.version()
ipfsVersion = version.version ipfsVersion = version.version
} catch (error) { } catch (error) {
setIpfsError(`IPFS connection error: ${error.message}`) let { message } = error
if (!error.status) {
const htmlData = parseHTML(error)
message = htmlData.item(0)
message = message.textContent
}
setIpfsError(`IPFS connection error: ${message}`)
setIpfsReady(false)
return return
} }
setIpfsReady(Boolean(await ipfs.id())) setIpfsReady(Boolean(await ipfs.id()))

View File

@ -2,25 +2,32 @@
.grid { .grid {
display: grid; display: grid;
gap: calc(var(--spacer) * 3); gap: calc(var(--spacer) * 2);
max-width: 40rem; max-width: 40rem;
margin-top: calc(var(--spacer) * 2) auto var(--spacer) auto; margin-top: calc(var(--spacer) * 2) auto var(--spacer) auto;
} }
@media screen and (min-width: 640px) {
.grid > div:first-child {
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
padding: calc(var(--spacer) * 2);
border-radius: var(--border-radius);
border-top: 1px solid var(--brand-black);
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
}
@media screen and (min-width: 1140px) { @media screen and (min-width: 1140px) {
.grid { .grid {
max-width: 70rem; max-width: 70rem;
text-align: left; text-align: left;
grid-template-columns: 2fr 1fr; grid-template-columns: 2fr 1fr;
} }
.grid > aside {
margin-top: calc(var(--spacer) * var(--line-height));
}
} }
.header { .header {
margin-bottom: calc(var(--spacer) * 2); margin-bottom: calc(var(--spacer) * 2);
text-align: center;
} }
.header svg { .header svg {
@ -29,6 +36,10 @@
} }
@media screen and (min-width: 1140px) { @media screen and (min-width: 1140px) {
.header {
text-align: left;
}
.header svg { .header svg {
margin-left: 0; margin-left: 0;
margin-right: 0; margin-right: 0;

View File

@ -9,7 +9,6 @@
html, html,
body { body {
width: 100%; width: 100%;
height: 100%;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
@ -28,8 +27,6 @@ body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
position: relative; position: relative;
margin: 0;
text-align: center;
} }
@media screen and (min-width: 640px) { @media screen and (min-width: 640px) {