From bcf0a0586d206fa8707916d62c01db3238a186d3 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Jul 2020 09:28:03 -0700 Subject: [PATCH] Support textareas and cleanup API page --- .../dashboard/AccountApiContainer.tsx | 42 ++++++++++--------- .../dashboard/forms/CreateApiKeyForm.tsx | 34 +++++++-------- .../scripts/components/elements/Input.tsx | 6 ++- .../components/elements/PageContentBlock.tsx | 4 +- tailwind.config.js | 8 ++++ 5 files changed, 53 insertions(+), 41 deletions(-) diff --git a/resources/scripts/components/dashboard/AccountApiContainer.tsx b/resources/scripts/components/dashboard/AccountApiContainer.tsx index 3d952ac2f..d478f26ac 100644 --- a/resources/scripts/components/dashboard/AccountApiContainer.tsx +++ b/resources/scripts/components/dashboard/AccountApiContainer.tsx @@ -14,6 +14,8 @@ import FlashMessageRender from '@/components/FlashMessageRender'; import { httpErrorToHuman } from '@/api/http'; import format from 'date-fns/format'; import PageContentBlock from '@/components/elements/PageContentBlock'; +import tw from 'twin.macro'; +import GreyRowBox from '@/components/elements/GreyRowBox'; export default () => { const [ deleteIdentifier, setDeleteIdentifier ] = useState(''); @@ -48,18 +50,18 @@ export default () => { return ( - -
- + +
+ setKeys(s => ([ ...s!, key ]))}/> - + {deleteIdentifier && { doDeletion(deleteIdentifier); setDeleteIdentifier(''); @@ -72,38 +74,38 @@ export default () => { } { keys.length === 0 ? -

+

{loading ? 'Loading...' : 'No API keys exist for this account.'}

: - keys.map(key => ( -
( + 0 && tw`mt-2` ]} > - -
-

{key.description}

-

- Last - used: {key.lastUsedAt ? format(key.lastUsedAt, 'MMM Do, YYYY HH:mm') : 'Never'} + +

+

{key.description}

+

+ Last used:  + {key.lastUsedAt ? format(key.lastUsedAt, 'MMM do, yyyy HH:mm') : 'Never'}

-

- +

+ {key.identifier}

-
+
)) } diff --git a/resources/scripts/components/dashboard/forms/CreateApiKeyForm.tsx b/resources/scripts/components/dashboard/forms/CreateApiKeyForm.tsx index cf1a596bf..4e8fae1d5 100644 --- a/resources/scripts/components/dashboard/forms/CreateApiKeyForm.tsx +++ b/resources/scripts/components/dashboard/forms/CreateApiKeyForm.tsx @@ -9,6 +9,9 @@ import { ApplicationStore } from '@/state'; import { httpErrorToHuman } from '@/api/http'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import { ApiKey } from '@/api/account/getApiKeys'; +import tw from 'twin.macro'; +import Button from '@/components/elements/Button'; +import Input, { Textarea } from '@/components/elements/Input'; interface Values { description: string; @@ -44,22 +47,21 @@ export default ({ onKeyCreated }: { onKeyCreated: (key: ApiKey) => void }) => { closeOnEscape={false} closeOnBackground={false} > -

Your API Key

-

+

Your API Key

+

The API key you have requested is shown below. Please store this in a safe location, it will not be shown again.

-
-                    {apiKey}
+                
+                    {apiKey}
                 
-
- +
void }) => { label={'Description'} name={'description'} description={'A description of this API key.'} - className={'mb-6'} + css={tw`mb-6`} > - + - + -
- +
+
)} diff --git a/resources/scripts/components/elements/Input.tsx b/resources/scripts/components/elements/Input.tsx index a0f412c7e..066d980a0 100644 --- a/resources/scripts/components/elements/Input.tsx +++ b/resources/scripts/components/elements/Input.tsx @@ -16,7 +16,7 @@ const light = css` } `; -const Input = styled.input` +const inputStyle = css` // Reset to normal styling. ${tw`appearance-none w-full min-w-0`}; ${tw`p-3 border rounded text-sm transition-all duration-150`}; @@ -43,4 +43,8 @@ const Input = styled.input` ${props => props.isLight && light}; `; +const Input = styled.input`${inputStyle}`; +const Textarea = styled.textarea`${inputStyle}`; + +export { Textarea }; export default Input; diff --git a/resources/scripts/components/elements/PageContentBlock.tsx b/resources/scripts/components/elements/PageContentBlock.tsx index 656facf95..c9a7018f9 100644 --- a/resources/scripts/components/elements/PageContentBlock.tsx +++ b/resources/scripts/components/elements/PageContentBlock.tsx @@ -3,7 +3,7 @@ import ContentContainer from '@/components/elements/ContentContainer'; import { CSSTransition } from 'react-transition-group'; import tw from 'twin.macro'; -export default ({ children }): React.FC => ( +const PageContentBlock: React.FC = ({ children }) => ( <> @@ -25,3 +25,5 @@ export default ({ children }): React.FC => ( ); + +export default PageContentBlock; diff --git a/tailwind.config.js b/tailwind.config.js index 775ecbd27..ce51fe6f7 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -112,5 +112,13 @@ module.exports = { 900: 'hsl(125, 97%, 14%)', }, }, + extend: { + fontSize: { + '2xs': '0.625rem', + }, + borderColor: theme => ({ + default: theme('colors.neutral.400', 'cuurrentColor'), + }), + }, }, };