mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 01:15:03 +03:00
239 lines
9.1 KiB
TypeScript
239 lines
9.1 KiB
TypeScript
import { useState } from 'react'
|
|
import { createClient, Provider } from '@supabase/supabase-js'
|
|
|
|
import DefaultLayout from '~/components/Layouts/Default'
|
|
import CodeBlock from '~/components/CodeBlock/CodeBlock'
|
|
import {
|
|
Button,
|
|
// Auth,
|
|
Card,
|
|
Checkbox,
|
|
Divider,
|
|
Radio,
|
|
Select,
|
|
Space,
|
|
Tabs,
|
|
Input,
|
|
Toggle,
|
|
IconCode,
|
|
IconZoomIn,
|
|
IconCopy,
|
|
IconColumns,
|
|
} from '@supabase/ui'
|
|
|
|
import AuthStyles from './Auth.module.css'
|
|
|
|
function AuthPage() {
|
|
const supabase = createClient(
|
|
'https://rsnibhkhsbfnncjmwnkj.supabase.co',
|
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxNTIxNDE1MywiZXhwIjoxOTMwNzkwMTUzfQ.OQEbAaTfgDdLCCht251P2JRD3QDnui6nsU8N-tZA_Mc'
|
|
)
|
|
|
|
type SizeProps = 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'
|
|
type LayoutProps = 'horizontal' | 'vertical'
|
|
|
|
const [companyName, setCompanyName] = useState('Acme Company')
|
|
const [widgetSize, setWidgetSize] = useState<SizeProps>('tiny')
|
|
const [socialLogins, setSocialLogins] = useState(true)
|
|
const [socialLoginLayout, setSocialLoginLayout] = useState<LayoutProps>('horizontal')
|
|
const [socialColors, setSocialColors] = useState(false)
|
|
|
|
const socials: Provider[] = ['facebook', 'google', 'bitbucket', 'github', 'gitlab']
|
|
|
|
const formSize = 'small'
|
|
const formLayout = 'vertical'
|
|
|
|
return (
|
|
<DefaultLayout>
|
|
<div className="container relative mx-auto px-8 py-32 sm:px-16 xl:px-20">
|
|
<div className="grid grid-cols-12">
|
|
<div className="col-span-8">
|
|
<h2 className="mb-4">ReactJS Auth Widget</h2>
|
|
<p>
|
|
An API built from the groud up just for Storage.With powerful library clients coming
|
|
soon that allow for asset optimasation and image transformation
|
|
</p>
|
|
</div>
|
|
<div className="col-span-8">
|
|
<div
|
|
className={`relative border-t border-l border-b bg-white py-2 pb-16 dark:border-gray-600 dark:bg-gray-800 ${AuthStyles['auth-container']}`}
|
|
>
|
|
<div className="left-0 top-2 h-full w-full">
|
|
<Tabs
|
|
size="medium"
|
|
defaultActiveId="panel-1"
|
|
type="underlined"
|
|
tabBarStyle={{ padding: '0 16px' }}
|
|
addOnAfter={[
|
|
<Space>
|
|
<Button type="outline" icon={<IconCopy />}>
|
|
Copy code
|
|
</Button>
|
|
<Button type="outline" icon={<IconColumns />}>
|
|
Customise
|
|
</Button>
|
|
</Space>,
|
|
]}
|
|
>
|
|
<Tabs.Panel label="Preview" id="panel-1" icon={<IconZoomIn />}>
|
|
<div style={{ maxWidth: '420px', margin: '0 auto' }}>
|
|
<Card>
|
|
<Space size={8} direction="vertical">
|
|
<div>
|
|
<Space size={3} direction="vertical">
|
|
<img
|
|
src="https://app.supabase.com/img/supabase-dark.svg"
|
|
width="96"
|
|
/>
|
|
<h3>{companyName}</h3>
|
|
</Space>
|
|
</div>
|
|
{/* <Auth
|
|
providers={socialLogins ? socials : []}
|
|
socialButtonSize={widgetSize}
|
|
socialLayout={socialLoginLayout}
|
|
supabaseClient={supabase}
|
|
socialColors={socialColors}
|
|
/> */}
|
|
</Space>
|
|
</Card>
|
|
</div>
|
|
</Tabs.Panel>
|
|
<Tabs.Panel label="Code" icon={<IconCode />} id="panel-2">
|
|
<div className="h-full">
|
|
<CodeBlock
|
|
hideCopy
|
|
children={`// Auth example
|
|
|
|
import React, { useState } from 'react'
|
|
import { Auth } from './'
|
|
import { createClient } from '@supabase/supabase-js'
|
|
// @ts-ignore
|
|
import { Button, Space } from '../../index'
|
|
|
|
export default function app() {
|
|
|
|
const supabase = createClient(
|
|
'https://YOUR-PROJECT-ID.supabase.co',
|
|
'YOUR-PUBLIC-ANON-KEY'
|
|
)
|
|
|
|
return (
|
|
<Auth.UserContextProvider {...args}>
|
|
<Container {...args}>
|
|
<Auth {...args} />
|
|
</Container>
|
|
</Auth.UserContextProvider>
|
|
)
|
|
}
|
|
`}
|
|
lang="js"
|
|
/>
|
|
</div>
|
|
</Tabs.Panel>
|
|
</Tabs>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="col-span-4">
|
|
<div className="h-full rounded rounded-l-none border bg-white dark:border-gray-600 dark:bg-gray-800">
|
|
<div className={`p-8`}>
|
|
<Space size={12} direction="vertical">
|
|
<div>
|
|
<h3>Customise your login form</h3>
|
|
<p>Our ReactJS Auth form will help you get going even quicker </p>
|
|
</div>
|
|
<Divider light />
|
|
<Input
|
|
size={formSize}
|
|
layout={formLayout}
|
|
label="Name of app"
|
|
value={companyName}
|
|
onChange={(e) => setCompanyName(e.target.value)}
|
|
/>
|
|
{/* @ts-ignore */}
|
|
<Space size={8} direction="vertical">
|
|
<Card>
|
|
<Space size={8} direction="vertical">
|
|
<Checkbox
|
|
size={formSize}
|
|
label="Show social logins"
|
|
description=" "
|
|
checked={socialLogins}
|
|
onChange={() => setSocialLogins(!socialLogins)}
|
|
/>
|
|
{socialLogins && (
|
|
<>
|
|
<Divider light />
|
|
{/* @ts-ignore */}
|
|
<Radio.Group
|
|
size={formSize}
|
|
type="cards"
|
|
label="Social button layout"
|
|
layout={formLayout}
|
|
name="layout-group"
|
|
value={socialLoginLayout}
|
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
|
// @ts-ignore
|
|
setSocialLoginLayout(e.target.value)
|
|
}
|
|
>
|
|
<Radio
|
|
name="layout-group"
|
|
key={'horizontal'}
|
|
label={'horizontal'}
|
|
value={'horizontal'}
|
|
/>
|
|
<Radio
|
|
name="layout-group"
|
|
key={'vertical'}
|
|
label={'vertical'}
|
|
value={'vertical'}
|
|
/>
|
|
</Radio.Group>
|
|
<Toggle
|
|
size={formSize}
|
|
layout="vertical"
|
|
align="right"
|
|
labelOptional="Use brand colors on buttons"
|
|
label="Social colors"
|
|
// descriptionText="Show the brand colors of the social logins in the buttons"
|
|
checked={socialColors}
|
|
onChange={() => setSocialColors(!socialColors)}
|
|
/>
|
|
</>
|
|
)}
|
|
</Space>
|
|
</Card>
|
|
</Space>
|
|
<Radio.Group
|
|
size={formSize}
|
|
type="cards"
|
|
label="Form size"
|
|
labelOptional="This is an optional label"
|
|
descriptionText="This controls the button sizes and form input sizes"
|
|
layout={formLayout}
|
|
name="size-group"
|
|
value={widgetSize}
|
|
/* @ts-ignore */
|
|
onChange={(e) => setWidgetSize(e.target.value)}
|
|
>
|
|
<Radio name="size-group" key={1} label={'tiny'} value={'tiny'} />
|
|
<Radio name="size-group" key={2} label={'small'} value={'small'} />
|
|
<Radio name="size-group" key={3} label={'medium'} value={'medium'} />
|
|
<Radio name="size-group" key={3} label={'large'} value={'large'} />
|
|
<Radio name="size-group" key={3} label={'xlarge'} value={'xlarge'} />
|
|
</Radio.Group>
|
|
</Space>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</DefaultLayout>
|
|
)
|
|
}
|
|
|
|
export default AuthPage
|