Skip to content

Commit aefc18d

Browse files
committed
FIX CONFLICTS 🥭
2 parents 6d9d5c7 + f896350 commit aefc18d

File tree

3 files changed

+55
-51
lines changed

3 files changed

+55
-51
lines changed

frontend/app/components/redesign/Typography.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type TypographyProps = {
2020
variant: TextStyleType
2121
as?: React.ElementType
2222
className?: string
23+
htmlFor?: string
2324
children: React.ReactNode
2425
} & React.HTMLAttributes<HTMLElement>
2526

frontend/app/components/redesign/components/InputField.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(
6969
)}
7070
id={fieldId}
7171
name={fieldId}
72-
required={required}
73-
aria-invalid={!!displayError}
74-
aria-describedby={ariaDescriptionId}
72+
aria-invalid={!!error}
73+
aria-describedby={displayError ? 'input-error' : ariaDescriptionId}
7574
{...props}
7675
/>
7776
{ariaDescription && !displayError && (
@@ -82,6 +81,8 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(
8281

8382
{displayError && (
8483
<span
84+
id="input-error"
85+
role="alert"
8586
className="absolute right-3 top-full
8687
-translate-y-1/2
8788
px-1 text-xs text-text-error bg-white"

frontend/app/components/redesign/components/ToolsWalletAddress.tsx

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useId, useRef, useEffect } from 'react'
1+
import React, { useState, useRef, useEffect } from 'react'
22
import { Tooltip } from './Tooltip'
33
import { InputField } from './InputField'
44
import { ToolsSecondaryButton } from './ToolsSecondaryButton'
@@ -20,11 +20,10 @@ interface ToolsWalletAddressProps {
2020
}
2121

2222
export const ToolsWalletAddress = ({ toolName }: ToolsWalletAddressProps) => {
23-
const snap = useSnapshot(toolState)
23+
const snap = useSnapshot(toolState, { sync: true })
2424
const uiActions = useUIActions()
2525
const [error, setError] = useState<ElementErrors>()
2626
const [isLoading, setIsLoading] = useState(false)
27-
const generatedId = useId()
2827
const inputRef = useRef<HTMLInputElement>(null)
2928

3029
useEffect(() => {
@@ -98,6 +97,9 @@ export const ToolsWalletAddress = ({ toolName }: ToolsWalletAddressProps) => {
9897
if (snap.walletConnectStep !== 'unfilled') {
9998
toolActions.setConnectWalletStep('unfilled')
10099
}
100+
if (error) {
101+
setError(undefined)
102+
}
101103
}
102104

103105
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
@@ -107,55 +109,50 @@ export const ToolsWalletAddress = ({ toolName }: ToolsWalletAddressProps) => {
107109
}
108110
}
109111

110-
const renderStatusMessage = () => {
112+
const getStatusMessage = (): {
113+
message: string
114+
type: 'error' | 'success' | 'info'
115+
} => {
111116
if (snap.walletConnectStep === 'error') {
112-
return (
113-
<p className="w-full text-style-small-standard !text-red-600">
114-
You have not connected your wallet address yet.
115-
</p>
116-
)
117+
return {
118+
message: 'You have not connected your wallet address yet.',
119+
type: 'error'
120+
}
117121
}
118-
119122
if (!snap.isWalletConnected) {
120-
return (
121-
<p className="w-full text-style-small-standard">
122-
If you&apos;re connecting your wallet address for the first time,
123-
you&apos;ll start with the default configuration.
124-
<br />
125-
You can then customize and save your config as needed.
126-
</p>
127-
)
123+
return {
124+
message:
125+
"If you're connecting your wallet address for the first time, you'll start with the default configuration. You can then customize and save your config as needed.",
126+
type: 'info'
127+
}
128128
}
129-
130129
if (!snap.hasRemoteConfigs) {
131-
return (
132-
<p className="w-full text-style-small-standard !text-text-success">
133-
There are no custom edits for the {toolName} correlated to this wallet
134-
address but you can start customizing when you want.
135-
</p>
136-
)
130+
return {
131+
message: `There are no custom edits for the ${toolName} correlated to this wallet address but you can start customizing when you want.`,
132+
type: 'success'
133+
}
137134
}
138135

139-
return (
140-
<p className="w-full text-style-small-standard !text-text-success">
141-
We&apos;ve loaded your configuration.
142-
<br />
143-
Feel free to keep customizing your {toolName} to fit your style.
144-
</p>
145-
)
136+
return {
137+
message: `We've loaded your configuration. Feel free to keep customizing your ${toolName} to fit your style.`,
138+
type: 'success'
139+
}
146140
}
141+
142+
const statusMessage = getStatusMessage()
147143
return (
148144
<form
149145
onSubmit={handleSubmit}
150146
className={cx(
151147
'flex flex-col xl:flex-row xl:items-start gap-2xl p-md bg-white rounded-lg',
152148
snap.walletConnectStep === 'error' && 'border border-red-600'
153149
)}
154-
aria-labelledby={generatedId}
155150
>
156-
<div className="flex flex-col items-start gap-md w-full xl:flex-1 xl:grow">
151+
<div className="items-start gap-md w-full xl:flex-1 xl:grow">
157152
<div className="inline-flex items-center gap-xs">
158-
<Heading5 id={generatedId}>Wallet address</Heading5>
153+
<Heading5 htmlFor="wallet-address-url" as="label">
154+
Wallet address
155+
</Heading5>
159156
<Tooltip>
160157
Your wallet is required in order for us to save this components
161158
configuration for you, link it to the original author, and verify
@@ -164,11 +161,7 @@ export const ToolsWalletAddress = ({ toolName }: ToolsWalletAddressProps) => {
164161
behalf.
165162
</Tooltip>
166163
</div>
167-
168-
<div
169-
id="wallet-address-input"
170-
className="flex items-start gap-3 w-full"
171-
>
164+
<div className="flex items-start gap-3 w-full pt-md">
172165
<div className="flex-1 min-w-0 h-12">
173166
<InputField
174167
ref={inputRef}
@@ -178,11 +171,11 @@ export const ToolsWalletAddress = ({ toolName }: ToolsWalletAddressProps) => {
178171
? undefined
179172
: 'https://walletprovider.com/MyWallet'
180173
}
181-
defaultValue={snap.walletAddress}
182-
onBlur={handleWalletAddressChange}
174+
value={snap.walletAddress}
175+
onChange={handleWalletAddressChange}
183176
disabled={snap.isWalletConnected}
177+
readOnly={isLoading}
184178
error={error?.fieldErrors.walletAddress}
185-
aria-labelledby={generatedId}
186179
/>
187180
</div>
188181
{snap.isWalletConnected && (
@@ -200,16 +193,25 @@ export const ToolsWalletAddress = ({ toolName }: ToolsWalletAddressProps) => {
200193
</div>
201194
</div>
202195

203-
<div
204-
id="wallet-address-message"
205-
className="flex flex-col w-full xl:max-w-[490px] items-start gap-xs xl:flex-1 xl:grow"
206-
>
207-
{renderStatusMessage()}
196+
<div className="flex flex-col w-full xl:max-w-[490px] items-start gap-xs xl:flex-1 xl:grow">
197+
<span
198+
id="wallet-status"
199+
role={statusMessage.type === 'error' ? 'alert' : 'status'}
200+
className={cx(
201+
'w-full text-style-small-standard',
202+
statusMessage.type === 'error' && '!text-red-600',
203+
statusMessage.type === 'success' && '!text-text-success'
204+
)}
205+
>
206+
{statusMessage.message}
207+
</span>
208+
208209
{!snap.isWalletConnected && (
209210
<ToolsSecondaryButton
210211
type="submit"
211212
className="xl:w-[143px]"
212213
disabled={isLoading}
214+
aria-busy={isLoading}
213215
>
214216
<div className="flex items-center justify-center gap-2">
215217
{isLoading && <SVGSpinner className="w-4 h-4" />}

0 commit comments

Comments
 (0)