tweak styles to try and match latest

This commit is contained in:
Samuel Newman
2025-07-17 21:33:57 +03:00
parent 1d0e0c8b47
commit b0e9545710
+50 -101
View File
@@ -17,19 +17,14 @@ import {
validateServiceHandle, validateServiceHandle,
} from '#/lib/strings/handles' } from '#/lib/strings/handles'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {useHandleAvailabilityQuery} from '#/state/queries/handle-availablility' import {useHandleAvailabilityQuery} from '#/state/queries/handle-availablility'
import {useAgent} from '#/state/session' import {useAgent} from '#/state/session'
import {ScreenTransition} from '#/screens/Login/ScreenTransition' import {ScreenTransition} from '#/screens/Login/ScreenTransition'
import {useSignupContext} from '#/screens/Signup/state' import {useSignupContext} from '#/screens/Signup/state'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, native, useTheme} from '#/alf'
import * as TextField from '#/components/forms/TextField' import * as TextField from '#/components/forms/TextField'
import {useThrottledValue} from '#/components/hooks/useThrottledValue' import {useThrottledValue} from '#/components/hooks/useThrottledValue'
import {At_Stroke2_Corner0_Rounded as AtIcon} from '#/components/icons/At' import {At_Stroke2_Corner0_Rounded as AtIcon} from '#/components/icons/At'
import {Circle_Stroke2_Corner0_Rounded as CircleIcon} from '#/components/icons/Circle'
import {CircleCheck_Stroke2_Corner0_Rounded as CircleCheckIcon} from '#/components/icons/CircleCheck'
import {CircleX_Stroke2_Corner0_Rounded as CircleXIcon} from '#/components/icons/CircleX'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {BackNextButtons} from './BackNextButtons' import {BackNextButtons} from './BackNextButtons'
@@ -130,11 +125,18 @@ export function StepHandle() {
) )
} }
const textFieldInvalid =
(!isLoading && isHandleAvailable && !isHandleAvailable.available) ||
!validCheck.frontLengthNotTooLong ||
!validCheck.handleChars ||
!validCheck.hyphenStartOrEnd ||
!validCheck.totalLength
return ( return (
<ScreenTransition> <ScreenTransition>
<View style={[a.gap_lg, a.pt_lg]}> <View style={[a.gap_sm, a.pt_lg]}>
<View> <View>
<TextField.Root> <TextField.Root isInvalid={textFieldInvalid}>
<TextField.Icon icon={AtIcon} /> <TextField.Icon icon={AtIcon} />
<TextField.Input <TextField.Input
testID="handleInput" testID="handleInput"
@@ -160,69 +162,47 @@ export function StepHandle() {
</TextField.Root> </TextField.Root>
</View> </View>
<LayoutAnimationConfig skipEntering skipExiting> <LayoutAnimationConfig skipEntering skipExiting>
<View style={[a.gap_sm]}> <View style={[a.gap_xs]}>
{state.error && ( {state.error && (
<Requirement fade> <Requirement>
<RequirementIcon state="invalid" />
<RequirementText>{state.error}</RequirementText> <RequirementText>{state.error}</RequirementText>
</Requirement> </Requirement>
)} )}
{(isHandleAvailable || isLoading) && validCheck.overall && ( {isHandleAvailable &&
<Requirement fade> !isHandleAvailable.available &&
<RequirementIcon validCheck.overall && (
state={ <Requirement>
isLoading <RequirementText>
? 'loading' {isHandleAvailable?.reason === 'taken' ? (
: isHandleAvailable?.available <Trans>
? 'valid' {createFullHandle(draftValue, state.userDomain)} is
: 'invalid' taken
} </Trans>
/> ) : (
<RequirementText> <Trans>
{isLoading ? ( {createFullHandle(draftValue, state.userDomain)} is
<Trans>Checking...</Trans> invalid
) : isHandleAvailable?.available ? ( </Trans>
<Trans>Available!</Trans> )}
) : isHandleAvailable?.reason === 'taken' ? ( </RequirementText>
<Trans>Taken</Trans> </Requirement>
) : ( )}
<Trans>Invalid</Trans> {(!validCheck.handleChars || !validCheck.hyphenStartOrEnd) && (
)} <Requirement>
</RequirementText> {!validCheck.hyphenStartOrEnd ? (
<RequirementText>
<Trans>Doesn't begin or end with a hyphen</Trans>
</RequirementText>
) : (
<RequirementText>
<Trans>Only contains letters, numbers, and hyphens</Trans>
</RequirementText>
)}
</Requirement> </Requirement>
)} )}
<Requirement> <Requirement>
<RequirementIcon {(!validCheck.frontLengthNotTooLong ||
state={ !validCheck.totalLength) && (
validCheck.handleChars && validCheck.hyphenStartOrEnd
? !validCheck.frontLengthNotTooShort
? 'initial'
: 'valid'
: 'invalid'
}
/>
{!validCheck.hyphenStartOrEnd ? (
<RequirementText>
<Trans>Doesn't begin or end with a hyphen</Trans>
</RequirementText>
) : (
<RequirementText>
<Trans>Only contains letters, numbers, and hyphens</Trans>
</RequirementText>
)}
</Requirement>
<Requirement>
<RequirementIcon
state={
!validCheck.frontLengthNotTooShort
? 'initial'
: validCheck.frontLengthNotTooLong && validCheck.totalLength
? 'valid'
: 'invalid'
}
/>
{!validCheck.frontLengthNotTooLong || !validCheck.totalLength ? (
<RequirementText> <RequirementText>
<Trans> <Trans>
No longer than{' '} No longer than{' '}
@@ -232,10 +212,6 @@ export function StepHandle() {
/> />
</Trans> </Trans>
</RequirementText> </RequirementText>
) : (
<RequirementText>
<Trans>At least 3 characters</Trans>
</RequirementText>
)} )}
</Requirement> </Requirement>
</View> </View>
@@ -251,19 +227,13 @@ export function StepHandle() {
) )
} }
function Requirement({ function Requirement({children}: {children: React.ReactNode}) {
children,
fade,
}: {
children: React.ReactNode
fade?: boolean
}) {
return ( return (
<Animated.View <Animated.View
style={[a.w_full, a.flex_row, a.align_center, a.gap_sm]} style={[a.w_full]}
layout={isNative ? LinearTransition : undefined} layout={native(LinearTransition)}
entering={fade && isNative ? FadeIn : undefined} entering={native(FadeIn)}
exiting={fade && isNative ? FadeOut : undefined}> exiting={native(FadeOut)}>
{children} {children}
</Animated.View> </Animated.View>
) )
@@ -272,29 +242,8 @@ function Requirement({
function RequirementText({children}: {children: React.ReactNode}) { function RequirementText({children}: {children: React.ReactNode}) {
const t = useTheme() const t = useTheme()
return ( return (
<Text style={[a.text_sm, a.flex_1, t.atoms.text_contrast_medium]}> <Text style={[a.text_sm, a.flex_1, {color: t.palette.negative_500}]}>
<Trans>{children}</Trans> <Trans>{children}</Trans>
</Text> </Text>
) )
} }
function RequirementIcon({
state,
}: {
state: 'initial' | 'valid' | 'invalid' | 'loading'
}) {
const t = useTheme()
switch (state) {
case 'initial':
return <CircleIcon size="sm" style={t.atoms.text_contrast_low} />
case 'valid':
return (
<CircleCheckIcon size="sm" style={{color: t.palette.positive_700}} />
)
case 'invalid':
return <CircleXIcon size="sm" style={{color: t.palette.negative_500}} />
case 'loading':
return <Loader size="sm" style={t.atoms.text_contrast_low} />
}
}