From 1c97dd4e2483d6a25ecfe19000fa19d686aac31a Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Jul 2020 14:34:43 -0700 Subject: [PATCH] Correctly center the spinner in buttons --- .../auth/LoginCheckpointContainer.tsx | 38 ++++++++----------- .../components/auth/LoginContainer.tsx | 6 +-- .../auth/ResetPasswordContainer.tsx | 38 +++++++++---------- .../scripts/components/elements/Button.tsx | 9 +++-- 4 files changed, 40 insertions(+), 51 deletions(-) diff --git a/resources/scripts/components/auth/LoginCheckpointContainer.tsx b/resources/scripts/components/auth/LoginCheckpointContainer.tsx index 006ccc06b..41af2ac20 100644 --- a/resources/scripts/components/auth/LoginCheckpointContainer.tsx +++ b/resources/scripts/components/auth/LoginCheckpointContainer.tsx @@ -5,12 +5,12 @@ import { httpErrorToHuman } from '@/api/http'; import LoginFormContainer from '@/components/auth/LoginFormContainer'; import { ActionCreator } from 'easy-peasy'; import { StaticContext } from 'react-router'; -import Spinner from '@/components/elements/Spinner'; import { useFormikContext, withFormik } from 'formik'; -import { object, string } from 'yup'; import useFlash from '@/plugins/useFlash'; import { FlashStore } from '@/state/flashes'; import Field from '@/components/elements/Field'; +import tw from 'twin.macro'; +import Button from '@/components/elements/Button'; interface Values { code: string; @@ -29,13 +29,10 @@ const LoginCheckpointContainer = () => { const [ isMissingDevice, setIsMissingDevice ] = useState(false); return ( - -
+ +
{ : 'Enter the two-factor token generated by your device.' } type={isMissingDevice ? 'text' : 'number'} - autoFocus={true} + autoFocus />
-
- + Continue +
-
+
{ setFieldValue('code', ''); setFieldValue('recoveryCode', ''); setIsMissingDevice(s => !s); }} - className={'cursor-pointer text-xs text-neutral-500 tracking-wide uppercase no-underline hover:text-neutral-700'} + css={tw`cursor-pointer text-xs text-neutral-500 tracking-wide uppercase no-underline hover:text-neutral-700`} > {!isMissingDevice ? 'I\'ve Lost My Device' : 'I Have My Device'}
-
+
Return to Login diff --git a/resources/scripts/components/auth/LoginContainer.tsx b/resources/scripts/components/auth/LoginContainer.tsx index b38f23a93..7b25c36d7 100644 --- a/resources/scripts/components/auth/LoginContainer.tsx +++ b/resources/scripts/components/auth/LoginContainer.tsx @@ -36,11 +36,7 @@ const LoginContainer = ({ isSubmitting, setFieldValue, values, submitForm, handl return ( {ref.current && ref.current.render()} - + & {}>; +import Input from '@/components/elements/Input'; +import tw from 'twin.macro'; +import Button from '@/components/elements/Button'; interface Values { password: string; passwordConfirmation: string; } -export default ({ match, history, location }: Props) => { +export default ({ match, location }: RouteComponentProps<{ token: string }>) => { const [ email, setEmail ] = useState(''); const { clearFlashes, addFlash } = useStoreActions((actions: Actions) => actions.flashes); @@ -62,46 +63,43 @@ export default ({ match, history, location }: Props) => { {({ isSubmitting }) => (
- +
-
+
-
+
-
- + Reset Password +
-
+
Return to Login diff --git a/resources/scripts/components/elements/Button.tsx b/resources/scripts/components/elements/Button.tsx index 787bb877b..276ad1b6b 100644 --- a/resources/scripts/components/elements/Button.tsx +++ b/resources/scripts/components/elements/Button.tsx @@ -1,6 +1,7 @@ import React from 'react'; import styled, { css } from 'styled-components/macro'; import tw from 'twin.macro'; +import Spinner from '@/components/elements/Spinner'; interface Props { isLoading?: boolean; @@ -10,9 +11,9 @@ interface Props { } const StyledButton = styled.button>` - ${tw`rounded p-2 uppercase tracking-wide text-sm transition-all duration-150`}; + ${tw`relative inline-block rounded p-2 uppercase tracking-wide text-sm transition-all duration-150`}; - ${props => props.isSecondary && css` + ${props => props.isSecondary && css` ${tw`border border-neutral-600 bg-transparent text-neutral-200`}; &:hover:not(:disabled) { @@ -79,8 +80,8 @@ type ComponentProps = Omit const Button: React.FC = ({ children, isLoading, ...props }) => ( {isLoading && -
-
+
+
}