From 036717ea842ec382c9c1f73c418fb95bfa1418a6 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 13 Jul 2020 12:03:08 +0200 Subject: [PATCH] forms are fun --- src/components/atoms/Button.module.css | 2 +- .../atoms/Input/InputGroup.module.css | 50 ++++++++++++------- src/components/atoms/Input/InputGroup.tsx | 4 +- .../molecules/FilesInput/Input.module.css | 3 ++ src/components/molecules/FilesInput/Input.tsx | 30 +++++------ src/components/molecules/SearchBar.module.css | 46 +---------------- src/components/molecules/SearchBar.tsx | 5 +- 7 files changed, 57 insertions(+), 83 deletions(-) create mode 100644 src/components/molecules/FilesInput/Input.module.css diff --git a/src/components/atoms/Button.module.css b/src/components/atoms/Button.module.css index 24c6ffff9..c84caabd6 100644 --- a/src/components/atoms/Button.module.css +++ b/src/components/atoms/Button.module.css @@ -46,7 +46,7 @@ .button:disabled { cursor: not-allowed; pointer-events: none; - opacity: 0.5; + background: var(--brand-grey-lighter); } .primary, diff --git a/src/components/atoms/Input/InputGroup.module.css b/src/components/atoms/Input/InputGroup.module.css index c6890c540..8c72c3956 100644 --- a/src/components/atoms/Input/InputGroup.module.css +++ b/src/components/atoms/Input/InputGroup.module.css @@ -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%; } } diff --git a/src/components/atoms/Input/InputGroup.tsx b/src/components/atoms/Input/InputGroup.tsx index e525b28b5..07034f068 100644 --- a/src/components/atoms/Input/InputGroup.tsx +++ b/src/components/atoms/Input/InputGroup.tsx @@ -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 => (
{children}
) diff --git a/src/components/molecules/FilesInput/Input.module.css b/src/components/molecules/FilesInput/Input.module.css new file mode 100644 index 000000000..1b82548a2 --- /dev/null +++ b/src/components/molecules/FilesInput/Input.module.css @@ -0,0 +1,3 @@ +.input { + composes: input from '../../atoms/Input/InputElement.module.css'; +} diff --git a/src/components/molecules/FilesInput/Input.tsx b/src/components/molecules/FilesInput/Input.tsx index 62927f51d..e0363ad8e 100644 --- a/src/components/molecules/FilesInput/Input.tsx +++ b/src/components/molecules/FilesInput/Input.tsx @@ -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 ( - <> - + + - + ) } diff --git a/src/components/molecules/SearchBar.module.css b/src/components/molecules/SearchBar.module.css index 8ee36fe6b..8ba370db4 100644 --- a/src/components/molecules/SearchBar.module.css +++ b/src/components/molecules/SearchBar.module.css @@ -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; - } -} diff --git a/src/components/molecules/SearchBar.tsx b/src/components/molecules/SearchBar.tsx index 6cc109f9b..e706e306b 100644 --- a/src/components/molecules/SearchBar.tsx +++ b/src/components/molecules/SearchBar.tsx @@ -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 (
-
+ ) => startSearch(e)}> {searchStarted ? : 'Search'} -
+ {filters &&
Type, Price
}