1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00

forms are fun

This commit is contained in:
Matthias Kretschmann 2020-07-13 12:03:08 +02:00
parent ff3e15eb43
commit 036717ea84
Signed by: m
GPG Key ID: 606EEEF3C479A91F
7 changed files with 57 additions and 83 deletions

View File

@ -46,7 +46,7 @@
.button:disabled {
cursor: not-allowed;
pointer-events: none;
opacity: 0.5;
background: var(--brand-grey-lighter);
}
.primary,

View File

@ -1,31 +1,43 @@
.inputGroup {
width: 100%;
.inputGroup input {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
@media screen and (min-width: $break-point--small) {
.inputGroup button {
border-top-left-radius: 0;
border-top-right-radius: 0;
margin-top: -1px;
width: 100%;
}
.inputGroup button:hover,
.inputGroup button:focus,
.inputGroup input:focus + button:hover,
.inputGroup input:focus + button:focus {
background: var(--brand-gradient);
transform: none;
box-shadow: none;
}
@media screen and (min-width: 30rem) {
.inputGroup {
display: flex;
}
}
.inputGroup > input {
@media screen and (min-width: $break-point--small) {
width: 75%;
.inputGroup input {
border-bottom-left-radius: var(--border-radius);
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
}
.inputGroup > button {
width: 100%;
position: absolute;
left: 0;
bottom: -120%;
@media screen and (min-width: $break-point--small) {
position: relative;
bottom: auto;
width: 25%;
height: 100%;
.inputGroup button {
border-top-right-radius: var(--border-radius);
border-top-left-radius: 0;
border-bottom-left-radius: 0;
box-shadow: none;
margin-top: 0;
margin-left: -1px;
width: fit-content;
min-width: 20%;
}
}

View File

@ -1,7 +1,7 @@
import React from 'react'
import React, { ReactElement, ReactNode } from 'react'
import styles from './InputGroup.module.css'
const InputGroup = ({ children }: { children: any }) => (
const InputGroup = ({ children }: { children: ReactNode }): ReactElement => (
<div className={styles.inputGroup}>{children}</div>
)

View File

@ -0,0 +1,3 @@
.input {
composes: input from '../../atoms/Input/InputElement.module.css';
}

View File

@ -5,22 +5,22 @@ import { useField } from 'formik'
import Loader from '../../atoms/Loader'
import InputElement from '../../atoms/Input/InputElement'
import { InputProps } from '../../atoms/Input'
import styles from './Input.module.css'
import InputGroup from '../../atoms/Input/InputGroup'
export default function FileInput(
{
handleButtonClick,
isLoading
}: {
handleButtonClick(e: React.SyntheticEvent, data: string): void
isLoading: boolean
},
props: InputProps
): ReactElement {
const [field, meta] = useField(props)
export default function FileInput({
handleButtonClick,
isLoading,
...props
}: {
handleButtonClick(e: React.SyntheticEvent, data: string): void
isLoading: boolean
}): ReactElement {
const [field, meta] = useField(props as InputProps)
return (
<>
<InputElement {...field} {...props} type="url" />
<InputGroup>
<input className={styles.input} {...props} type="url" />
<Button
size="small"
@ -28,11 +28,11 @@ export default function FileInput(
disabled={
!field.value ||
// weird static page build fix so is-url-superb won't error
isUrl(typeof field.value === 'string' ? field.value : '')
!isUrl(typeof field.value === 'string' ? field.value : '')
}
>
{isLoading ? <Loader /> : 'Add File'}
</Button>
</>
</InputGroup>
)
}

View File

@ -2,52 +2,10 @@
margin-bottom: var(--spacer);
}
.inputGroup > div {
.form > div > div {
margin: 0;
}
.inputGroup label {
.form label {
display: none;
}
.inputGroup input {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.inputGroup button {
border-top-left-radius: 0;
border-top-right-radius: 0;
margin-top: -1px;
width: 100%;
}
.inputGroup button:hover,
.inputGroup button:focus,
.inputGroup input:focus + button:hover,
.inputGroup input:focus + button:focus {
background: var(--brand-gradient);
transform: none;
box-shadow: none;
}
@media screen and (min-width: 30rem) {
.inputGroup {
display: flex;
}
.inputGroup input {
border-bottom-left-radius: var(--border-radius);
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.inputGroup button {
border-top-right-radius: var(--border-radius);
border-top-left-radius: 0;
border-bottom-left-radius: 0;
margin-top: 0;
margin-left: -1px;
width: auto;
}
}

View File

@ -4,6 +4,7 @@ import styles from './SearchBar.module.css'
import Loader from '../atoms/Loader'
import Button from '../atoms/Button'
import Input from '../atoms/Input'
import InputGroup from '../atoms/Input/InputGroup'
export default function SearchBar({
placeholder,
@ -35,7 +36,7 @@ export default function SearchBar({
return (
<form className={styles.form}>
<div className={styles.inputGroup}>
<InputGroup>
<Input
type="search"
name="search"
@ -47,7 +48,7 @@ export default function SearchBar({
<Button onClick={(e: FormEvent<HTMLButtonElement>) => startSearch(e)}>
{searchStarted ? <Loader /> : 'Search'}
</Button>
</div>
</InputGroup>
{filters && <fieldset className={styles.filters}>Type, Price</fieldset>}
</form>