Skip to content

Commit

Permalink
Merge pull request #59 from supabase/chore/show-links-prop
Browse files Browse the repository at this point in the history
Update localization files and types
  • Loading branch information
silentworks authored Nov 3, 2022
2 parents b6dd13c + e5c2e53 commit c4fa7ce
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 73 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-radios-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@supabase/auth-ui-react': patch
---

Add showLinks prop to hide links at the bottom of the forms
5 changes: 5 additions & 0 deletions .changeset/proud-poems-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@supabase/auth-ui-react': patch
---

Update to expose getCssText for SSR rendering the component
5 changes: 5 additions & 0 deletions .changeset/quiet-flies-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@supabase/auth-ui-react': patch
---

Update localization files and types
5 changes: 5 additions & 0 deletions packages/react/common/lib/Localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
"sign_up": {
"email_label": "Email address",
"password_label": "Create a Password",
"email_input_placeholder": "Your email address",
"password_input_placeholder": "Your password",
"button_label": "Sign up",
"social_provider_text": "Sign in with",
"link_text": "Don't have an account? Sign up"
},
"sign_in": {
"email_label": "Email address",
"password_label": "Your Password",
"email_input_placeholder": "Your email address",
"password_input_placeholder": "Your password",
"button_label": "Sign in",
"social_provider_text": "Sign in with",
"link_text": "Already have an account? Sign in"
Expand All @@ -22,6 +26,7 @@
"forgotten_password": {
"email_label": "Email address",
"password_label": "Your Password",
"email_input_placeholder": "Your email address",
"button_label": "Send reset password instructions",
"link_text": "Forgot your password?"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/react/common/lib/Localization/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
"sign_up": {
"email_label": "電子メールアドレス",
"password_label": "パスワードを作成",
"email_input_placeholder": "Your email address",
"password_input_placeholder": "Your password",
"button_label": "サインアップ",
"social_provider_text": "に登録する",
"link_text": "アカウントをお持ちではありませんか?サインアップ"
},
"sign_in": {
"email_label": "電子メールアドレス",
"password_label": "あなたのパスワード",
"email_input_placeholder": "Your email address",
"password_input_placeholder": "Your password",
"button_label": "サインイン",
"social_provider_text": "に登録する",
"link_text": "Already have an account? Sign in"
Expand All @@ -22,6 +26,7 @@
"forgotten_password": {
"email_label": "Email address",
"password_label": "Your Password",
"email_input_placeholder": "Your email address",
"button_label": "Send reset password instructions",
"link_text": "パスワードをお忘れの方"
},
Expand Down
13 changes: 11 additions & 2 deletions packages/react/src/components/Auth/Auth.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,22 @@ export const withSocialAuthHorizontal = (args: any) => (
)
export const updatePassword = (args: any) => (
<Container {...args}>
<Auth.UpdatePassword {...args} dark={useDarkMode() ? true : false} />
<Auth
{...args}
dark={useDarkMode() ? true : false}
view="update_password"
/>
</Container>
)

export const magicLink = (args: any) => (
<Container {...args}>
<Auth.MagicLink {...args} dark={useDarkMode() ? true : false} />
<Auth
{...args}
dark={useDarkMode() ? true : false}
view="magic_link"
showLinks={false}
/>
</Container>
)

Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import * as _defaultLocalization from '../../../common/lib/Localization'

const defaultLocalization: Localization = { ..._defaultLocalization }

export const { getCssText } = createStitches()

function Auth({
supabaseClient,
socialLayout = 'vertical',
Expand All @@ -25,6 +27,7 @@ function Auth({
redirectTo,
onlyThirdPartyProviders = false,
magicLink = false,
showLinks = true,
appearance,
theme = 'default',
localization = { lang: 'en' },
Expand Down Expand Up @@ -150,6 +153,7 @@ function Auth({
setDefaultPassword,
redirectTo,
magicLink,
showLinks,
i18n,
}

Expand Down Expand Up @@ -178,6 +182,7 @@ function Auth({
setDefaultPassword={setDefaultPassword}
redirectTo={redirectTo}
magicLink={magicLink}
showLinks={showLinks}
i18n={i18n}
/>
</Container>
Expand All @@ -190,6 +195,7 @@ function Auth({
supabaseClient={supabaseClient}
setAuthView={setAuthView}
redirectTo={redirectTo}
showLinks={showLinks}
i18n={i18n}
/>
</Container>
Expand All @@ -203,6 +209,7 @@ function Auth({
supabaseClient={supabaseClient}
setAuthView={setAuthView}
redirectTo={redirectTo}
showLinks={showLinks}
i18n={i18n}
/>
</Container>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Auth/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as Auth } from './Auth'
export { default as Auth, getCssText } from './Auth'
export * from './interfaces'
105 changes: 55 additions & 50 deletions packages/react/src/components/Auth/interfaces/EmailAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface EmailAuthProps {
setDefaultEmail: (email: string) => void
setDefaultPassword: (password: string) => void
supabaseClient: SupabaseClient
showLinks?: boolean
redirectTo?: RedirectTo
magicLink?: boolean
i18n: I18nVariables
Expand All @@ -41,6 +42,7 @@ function EmailAuth({
setDefaultEmail,
setDefaultPassword,
supabaseClient,
showLinks = true,
redirectTo,
magicLink,
i18n,
Expand All @@ -49,7 +51,6 @@ function EmailAuth({
const isMounted = useRef<boolean>(true)
const [email, setEmail] = useState(defaultEmail)
const [password, setPassword] = useState(defaultPassword)
const [rememberMe, setRememberMe] = useState(false)
const [error, setError] = useState('')
const [loading, setLoading] = useState(false)
const [message, setMessage] = useState('')
Expand Down Expand Up @@ -120,6 +121,7 @@ function EmailAuth({
<Input
type="email"
name="email"
placeholder={i18n?.[authView]?.email_input_placeholder}
defaultValue={email}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setEmail(e.target.value)
Expand All @@ -135,6 +137,7 @@ function EmailAuth({
<Input
type="password"
name="password"
placeholder={i18n?.[authView]?.password_input_placeholder}
defaultValue={password}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setPassword(e.target.value)
Expand All @@ -156,55 +159,57 @@ function EmailAuth({
{i18n?.[authView]?.button_label}
</Button>

<Container direction="vertical" gap="small" appearance={appearance}>
{authView === VIEWS.SIGN_IN && magicLink && (
<Anchor
href="#auth-magic-link"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.MAGIC_LINK)
}}
appearance={appearance}
>
{i18n?.magic_link?.link_text}
</Anchor>
)}
{authView === VIEWS.SIGN_IN && (
<Anchor
href="#auth-forgot-password"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.FORGOTTEN_PASSWORD)
}}
appearance={appearance}
>
{i18n?.forgotten_password?.link_text}
</Anchor>
)}
{authView === VIEWS.SIGN_IN ? (
<Anchor
href="#auth-sign-up"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
handleViewChange(VIEWS.SIGN_UP)
}}
appearance={appearance}
>
{i18n?.sign_up?.link_text}
</Anchor>
) : (
<Anchor
href="#auth-sign-in"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
handleViewChange(VIEWS.SIGN_IN)
}}
appearance={appearance}
>
{i18n?.sign_in?.link_text}
</Anchor>
)}
</Container>
{showLinks && (
<Container direction="vertical" gap="small" appearance={appearance}>
{authView === VIEWS.SIGN_IN && magicLink && (
<Anchor
href="#auth-magic-link"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.MAGIC_LINK)
}}
appearance={appearance}
>
{i18n?.magic_link?.link_text}
</Anchor>
)}
{authView === VIEWS.SIGN_IN && (
<Anchor
href="#auth-forgot-password"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.FORGOTTEN_PASSWORD)
}}
appearance={appearance}
>
{i18n?.forgotten_password?.link_text}
</Anchor>
)}
{authView === VIEWS.SIGN_IN ? (
<Anchor
href="#auth-sign-up"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
handleViewChange(VIEWS.SIGN_UP)
}}
appearance={appearance}
>
{i18n?.sign_up?.link_text}
</Anchor>
) : (
<Anchor
href="#auth-sign-in"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
handleViewChange(VIEWS.SIGN_IN)
}}
appearance={appearance}
>
{i18n?.sign_in?.link_text}
</Anchor>
)}
</Container>
)}
</Container>
{message && <Message appearance={appearance}>{message}</Message>}
{error && (
Expand Down
25 changes: 15 additions & 10 deletions packages/react/src/components/Auth/interfaces/ForgottenPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ function ForgottenPassword({
redirectTo,
i18n,
appearance,
showLinks,
}: {
setAuthView: any
supabaseClient: SupabaseClient
redirectTo?: RedirectTo
i18n: I18nVariables
appearance?: Appearance
showLinks?: boolean
}) {
const [email, setEmail] = useState('')
const [error, setError] = useState('')
Expand Down Expand Up @@ -46,6 +48,7 @@ function ForgottenPassword({
<Input
name="email"
type="email"
placeholder={i18n?.forgotten_password?.email_input_placeholder}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setEmail(e.target.value)
}
Expand All @@ -61,16 +64,18 @@ function ForgottenPassword({
{i18n?.forgotten_password?.button_label}
</Button>
</Container>
<Anchor
href="#auth-sign-in"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.SIGN_IN)
}}
appearance={appearance}
>
{i18n?.sign_in?.link_text}
</Anchor>
{showLinks && (
<Anchor
href="#auth-sign-in"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.SIGN_IN)
}}
appearance={appearance}
>
{i18n?.sign_in?.link_text}
</Anchor>
)}
{message && <Message appearance={appearance}>{message}</Message>}
{error && (
<Message color="danger" appearance={appearance}>
Expand Down
24 changes: 14 additions & 10 deletions packages/react/src/components/Auth/interfaces/MagicLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ function MagicLink({
redirectTo,
i18n,
appearance,
showLinks,
}: {
setAuthView: any
supabaseClient: SupabaseClient
redirectTo?: RedirectTo
i18n: I18nVariables
appearance?: Appearance
showLinks?: boolean
}) {
const [email, setEmail] = useState('')
const [error, setError] = useState('')
Expand Down Expand Up @@ -62,16 +64,18 @@ function MagicLink({
{i18n?.magic_link?.button_label}
</Button>
</Container>
<Anchor
href="#auth-sign-in"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.SIGN_IN)
}}
appearance={appearance}
>
{i18n?.sign_in?.link_text}
</Anchor>
{showLinks && (
<Anchor
href="#auth-sign-in"
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
setAuthView(VIEWS.SIGN_IN)
}}
appearance={appearance}
>
{i18n?.sign_in?.link_text}
</Anchor>
)}
{message && <Message appearance={appearance}>{message}</Message>}
{error && (
<Message color="danger" appearance={appearance}>
Expand Down
Loading

0 comments on commit c4fa7ce

Please sign in to comment.