-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(elements): Introduce Strategies (#2497)
* feat(elements): First Factor interim commit * feat(elements): Introduce Strategies * chore(elements): Introduce Strategies * chore(elements): Cleanup commented code * chore(elements): Remove actor wrapper around determineStartingSignInFactor --------- Co-authored-by: Bryce Kalow <bryce@clerk.dev>
- Loading branch information
Showing
18 changed files
with
464 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { ComponentPropsWithoutRef } from 'react'; | ||
|
||
export const H1 = (props: ComponentPropsWithoutRef<'h1'>) => ( | ||
<h1 // eslint-disable-line jsx-a11y/heading-has-content | ||
className='text-xl mb-6 font-mono' | ||
{...props} | ||
/> | ||
); | ||
|
||
export const H2 = (props: ComponentPropsWithoutRef<'h2'>) => ( | ||
<h2 // eslint-disable-line jsx-a11y/heading-has-content | ||
className='text-l mb-4 font-mono' | ||
{...props} | ||
/> | ||
); | ||
|
||
export const H3 = (props: ComponentPropsWithoutRef<'h3'>) => ( | ||
<h3 // eslint-disable-line jsx-a11y/heading-has-content | ||
className='text-m mb-3 font-mono' | ||
{...props} | ||
/> | ||
); | ||
|
||
export const P = (props: ComponentPropsWithoutRef<'p'>) => ( | ||
<p | ||
className='text-sm font-mono' | ||
{...props} | ||
/> | ||
); | ||
|
||
export const HR = (props: ComponentPropsWithoutRef<'hr'>) => ( | ||
<hr | ||
className='w-full border-foreground opacity-10' | ||
{...props} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { FormProps } from '@radix-ui/react-form'; | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
import { useSignInFlowSelector } from '../internals/machines/sign-in.context'; | ||
import { Form } from './form'; | ||
|
||
// ================= STRATEGIES ================= // | ||
|
||
type StrategiesProps = FormProps; | ||
const Strategies = Form; | ||
|
||
// ================= STRATEGY ================= // | ||
|
||
type StrategyProps = PropsWithChildren<{ name: string }>; | ||
|
||
function Strategy({ children, name }: StrategyProps) { | ||
// TODO: Make generic | ||
const active = useSignInFlowSelector(state => state.context.currentFactor?.strategy === name); | ||
return active ? children : null; | ||
} | ||
|
||
// ================= EXPORTS ================= // | ||
|
||
export { Strategies, Strategy }; | ||
export type { StrategiesProps, StrategyProps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.