mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
basic nav styling and interactions
This commit is contained in:
parent
b28f7992dd
commit
458a7bf736
@ -1,7 +1,11 @@
|
|||||||
.actions {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-top: var(--spacer);
|
padding-top: var(--spacer);
|
||||||
border-top: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actions button {
|
||||||
|
margin: 0 calc(var(--spacer) / 2);
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { FormEvent, ReactElement } from 'react'
|
import React, { FormEvent, ReactElement, Ref, RefObject } from 'react'
|
||||||
import { useOcean } from '@context/Ocean'
|
import { useOcean } from '@context/Ocean'
|
||||||
import Button from '@shared/atoms/Button'
|
import Button from '@shared/atoms/Button'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
@ -6,7 +6,11 @@ import { FormikContextType, useFormikContext } from 'formik'
|
|||||||
import { FormPublishData } from '../_types'
|
import { FormPublishData } from '../_types'
|
||||||
import { wizardSteps } from '../_constants'
|
import { wizardSteps } from '../_constants'
|
||||||
|
|
||||||
export default function Actions(): ReactElement {
|
export default function Actions({
|
||||||
|
scrollToRef
|
||||||
|
}: {
|
||||||
|
scrollToRef: RefObject<any>
|
||||||
|
}): ReactElement {
|
||||||
const { ocean, account } = useOcean()
|
const { ocean, account } = useOcean()
|
||||||
const {
|
const {
|
||||||
status,
|
status,
|
||||||
@ -18,16 +22,18 @@ export default function Actions(): ReactElement {
|
|||||||
function handleNext(e: FormEvent) {
|
function handleNext(e: FormEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setFieldValue('step', values.step + 1)
|
setFieldValue('step', values.step + 1)
|
||||||
|
scrollToRef.current.scrollIntoView()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePrevious(e: FormEvent) {
|
function handlePrevious(e: FormEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setFieldValue('step', values.step - 1)
|
setFieldValue('step', values.step - 1)
|
||||||
|
scrollToRef.current.scrollIntoView()
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer className={styles.actions}>
|
<footer className={styles.actions}>
|
||||||
<Button onClick={handlePrevious}>Back</Button>
|
{values.step > 1 && <Button onClick={handlePrevious}>Back</Button>}
|
||||||
|
|
||||||
{values.step < wizardSteps.length ? (
|
{values.step < wizardSteps.length ? (
|
||||||
<Button style="primary" onClick={handleNext}>
|
<Button style="primary" onClick={handleNext}>
|
||||||
|
@ -1,11 +1,57 @@
|
|||||||
.navigation {
|
.navigation {
|
||||||
background: red;
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
margin-bottom: var(--spacer);
|
||||||
|
margin-top: -1rem;
|
||||||
|
padding: calc(var(--spacer) / 2) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 40rem) {
|
||||||
|
.navigation {
|
||||||
|
margin-top: -2rem;
|
||||||
|
padding: var(--spacer) 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation ol {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
counter-reset: list-number;
|
||||||
|
overflow-y: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navigation li {
|
.navigation li {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
margin: 0 var(--spacer);
|
||||||
|
padding: 0 calc(var(--spacer) / 2);
|
||||||
|
counter-increment: list-number;
|
||||||
|
font-weight: var(--font-weight-bold);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation li:before {
|
||||||
|
content: counter(list-number);
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 2rem;
|
||||||
|
height: 2rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
|
||||||
|
margin-right: calc(var(--spacer) / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.current {
|
.current {
|
||||||
font-weight: var(--font-weight-bold);
|
font-weight: var(--font-weight-bold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.current:before {
|
||||||
|
color: var(--brand-white);
|
||||||
|
background: var(--brand-black);
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
@ -5,12 +5,8 @@ import { wizardSteps } from '../_constants'
|
|||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
|
|
||||||
export default function Navigation(): ReactElement {
|
export default function Navigation(): ReactElement {
|
||||||
const {
|
const { values, setFieldValue }: FormikContextType<FormPublishData> =
|
||||||
isValid,
|
useFormikContext()
|
||||||
values,
|
|
||||||
resetForm,
|
|
||||||
setFieldValue
|
|
||||||
}: FormikContextType<FormPublishData> = useFormikContext()
|
|
||||||
|
|
||||||
function handleStepClick(step: number) {
|
function handleStepClick(step: number) {
|
||||||
setFieldValue('step', step)
|
setFieldValue('step', step)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { ReactElement, useState, useEffect } from 'react'
|
import React, { ReactElement, useState, useEffect, useRef } from 'react'
|
||||||
import { Form, Formik, FormikState } from 'formik'
|
import { Form, Formik, FormikState } from 'formik'
|
||||||
import { usePublish } from '@hooks/usePublish'
|
import { usePublish } from '@hooks/usePublish'
|
||||||
import { initialValues, validationSchema, wizardSteps } from './_constants'
|
import { initialValues, validationSchema, wizardSteps } from './_constants'
|
||||||
@ -35,6 +35,7 @@ export default function PublishPage({
|
|||||||
const { publish, publishError, isLoading, publishStepText } = usePublish()
|
const { publish, publishError, isLoading, publishStepText } = usePublish()
|
||||||
const [success, setSuccess] = useState<string>()
|
const [success, setSuccess] = useState<string>()
|
||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
|
const scrollToRef = useRef()
|
||||||
|
|
||||||
// async function handleSubmit(
|
// async function handleSubmit(
|
||||||
// values: Partial<FormPublishData>,
|
// values: Partial<FormPublishData>,
|
||||||
@ -103,10 +104,10 @@ export default function PublishPage({
|
|||||||
{({ values }) => {
|
{({ values }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form className={styles.form}>
|
<Form className={styles.form} ref={scrollToRef}>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
<Steps step={values.step} />
|
<Steps step={values.step} />
|
||||||
<Actions />
|
<Actions scrollToRef={scrollToRef} />
|
||||||
</Form>
|
</Form>
|
||||||
<Debug values={values} />
|
<Debug values={values} />
|
||||||
</>
|
</>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user