From b51d4e3b4ef519bffb23eaff95ab12c05d0226e3 Mon Sep 17 00:00:00 2001 From: Rupin Khandelwal Date: Tue, 25 Oct 2022 16:46:28 -0500 Subject: [PATCH] Laying out Readwise Page and adding router on integrations page --- .../templates/integrations/Readwise.tsx | 120 ++++++++++++------ packages/web/pages/settings/integrations.tsx | 10 +- 2 files changed, 85 insertions(+), 45 deletions(-) diff --git a/packages/web/components/templates/integrations/Readwise.tsx b/packages/web/components/templates/integrations/Readwise.tsx index 7575be6f9..215cceb96 100644 --- a/packages/web/components/templates/integrations/Readwise.tsx +++ b/packages/web/components/templates/integrations/Readwise.tsx @@ -1,28 +1,28 @@ -import { SpanBox, VStack } from '../../elements/LayoutPrimitives' +import { useCallback, useState } from 'react' +import { styled } from '@stitches/react' +import { Toaster } from 'react-hot-toast' +import Link from 'next/link' + +import { PrimaryLayout } from '../PrimaryLayout' + +import { Box, VStack } from '../../elements/LayoutPrimitives' import { Button } from '../../elements/Button' import { StyledText } from '../../elements/StyledText' -import { useCallback, useEffect, useState } from 'react' import { FormInput } from '../../elements/FormElements' -import { styled } from '@stitches/react' + import { setIntegrationMutation } from '../../../lib/networking/mutations/setIntegrationMutation' -const BorderedFormInput = styled(FormInput, { - height: '40px', - paddingLeft: '6px', - borderRadius: '6px', - background: 'white', - color: '$omnivoreGray', - border: `1px solid 1px solid rgba(0, 0, 0, 0.06)`, -}) - -const FormLabel = styled('label', { - fontSize: '16px', - color: '$omnivoreGray', +// Styles +const Header = styled(Box, { + color: '$utilityTextDefault', + fontSize: 'x-large', + margin: '20px auto 20px auto', }) export function Readwise(): JSX.Element { const [token, setToken] = useState('') - const [errorMessage, setErrorMessage] = useState(undefined) + const [errorMessage, setErrorMessage] = + useState(undefined) const setReadwiseToken = useCallback(() => { setIntegrationMutation({ @@ -30,34 +30,72 @@ export function Readwise(): JSX.Element { type: 'READWISE', enabled: true, }) - console.log("SETTING READWISE TOKEN", token) + console.log('SETTING READWISE TOKEN', token) }, [token]) return ( - - - - - Enter your Readwise API token. You can get your token - {' '} - here. - - { e.preventDefault(); setToken(e.target.value); }} - /> - + + +
Readwise
+ +
+ Enter your API key from Readwise below. You can get your token{' '} + + here + +
+ { + e.preventDefault() + setToken(e.target.value) + }} + disabled={false} + hidden={false} + required={true} + css={{ + border: '1px solid $textNonessential', + borderRadius: '8px', + width: '60%', + bg: 'transparent', + fontSize: '16px', + textIndent: '8px', + margin: '20px auto 20px auto', + height: '38px', + color: '$grayTextContrast', + '&:focus': { + outline: 'none', + boxShadow: '0px 0px 2px 2px rgba(255, 234, 159, 0.56)', + }, + }} + min={200} + /> + {errorMessage && {errorMessage}} +
- - {errorMessage && ( - {errorMessage} - )} - -
+ ) } diff --git a/packages/web/pages/settings/integrations.tsx b/packages/web/pages/settings/integrations.tsx index f28b08877..47279928a 100644 --- a/packages/web/pages/settings/integrations.tsx +++ b/packages/web/pages/settings/integrations.tsx @@ -1,4 +1,5 @@ -import { useEffect, useMemo, useState } from 'react' +import { useEffect, useMemo, useState} from 'react' +import { useRouter } from 'next/router' import { styled } from '@stitches/react' import { Toaster } from 'react-hot-toast' import { DownloadSimple, Eye, Link } from 'phosphor-react' @@ -55,6 +56,7 @@ export default function Integrations(): JSX.Element { const [integrationsArray, setIntegrationsArray] = useState( Array() ) + const router = useRouter() const readwiseConnected = useMemo(() => { return integrations.some((i) => i.type == 'READWISE') @@ -71,7 +73,7 @@ export default function Integrations(): JSX.Element { text: `Install Logseq Plugin`, icon: , style: 'ctaDarkYellow', - action: () => alert('You may already have it'), + action: () => alert('New LInk required') }, }, { @@ -82,7 +84,7 @@ export default function Integrations(): JSX.Element { text: readwiseConnected ? 'Remove' : 'Connect to Readwise', icon: , style: readwiseConnected ? 'ctaWhite' : 'ctaDarkYellow', - action: () => alert('readwise'), + action: () => router.push("/settings/integrations/readwise") }, }, { @@ -93,7 +95,7 @@ export default function Integrations(): JSX.Element { text: 'View Webhooks', icon: , style: 'ctaWhite', - action: () => alert('readwise - Open new Page'), + action: () =>router.push("/settings/webhooks"), }, }, ])