From 91c85698ae22d0726cbd7124e356bc1a7c8aaa9a Mon Sep 17 00:00:00 2001 From: Doug Richar Date: Mon, 30 Sep 2024 14:19:50 -0400 Subject: [PATCH] fix(ui): enhance overall accessibility and ARIA support (#289) * fix(ui): enhance overall accessibility and ARIA support - Add ARIA labels and roles to form inputs and buttons - Enhance color contrast for text elements in dark mode - Improve semantic structure of headings in card components - Update `InfoPopover` for better screen reader support - Refactor form fields in `AddValidatorForm` for accessibility - Adjust text colors in `Footer` for better visibility * fix(ui): add ARIA labels to Select components - Add aria-label attributes to `SelectTrigger` components in: - AddValidatorForm - NodeSelect - SelectAccount - UnstakeModal - EditEntryGating - StakingDetails - Update placeholder text in `UnstakeModal`'s `SelectValue` --- ui/src/components/AddPoolModal.tsx | 6 +- ui/src/components/AddStakeModal.tsx | 4 +- ui/src/components/AddValidatorForm.tsx | 138 +++++++++++------- ui/src/components/AssetLookup.tsx | 6 +- ui/src/components/Footer.tsx | 2 +- ui/src/components/InfoPopover.tsx | 18 ++- ui/src/components/NfdAvatar.tsx | 9 +- ui/src/components/NfdLookup.tsx | 3 + ui/src/components/NfdThumbnail.tsx | 2 +- ui/src/components/NodeSelect.tsx | 2 +- ui/src/components/SelectAccount.tsx | 2 +- ui/src/components/UnstakeModal.tsx | 13 +- .../components/ValidatorDetails/Details.tsx | 2 +- .../EditCommissionAccount.tsx | 3 +- .../ValidatorDetails/EditEntryGating.tsx | 57 ++++++-- .../ValidatorDetails/EditManagerAccount.tsx | 7 +- .../ValidatorDetails/EditNfdForInfo.tsx | 10 +- .../ValidatorDetails/EditRewardPerPayout.tsx | 4 +- .../ValidatorDetails/EditSunsettingInfo.tsx | 25 +++- .../ValidatorDetails/Highlights.tsx | 16 +- .../ValidatorDetails/LinkPoolToNfdModal.tsx | 4 + .../ValidatorDetails/StakingDetails.tsx | 8 +- ui/src/components/ValidatorTable.tsx | 11 +- ui/src/components/ui/badge.tsx | 2 +- ui/src/components/ui/button.tsx | 2 +- ui/src/components/ui/card.tsx | 10 +- ui/src/components/ui/select.tsx | 2 +- 27 files changed, 254 insertions(+), 114 deletions(-) diff --git a/ui/src/components/AddPoolModal.tsx b/ui/src/components/AddPoolModal.tsx index a9de8b70..43bc3b8e 100644 --- a/ui/src/components/AddPoolModal.tsx +++ b/ui/src/components/AddPoolModal.tsx @@ -484,11 +484,15 @@ export function AddPoolModal({ hidden: !showRewardTokenInfo, })} /> - + Link Pool to NFD ( - Amount to Stake + Amount to Stake
{ field.onChange(e) // Inform react-hook-form of the change diff --git a/ui/src/components/AddValidatorForm.tsx b/ui/src/components/AddValidatorForm.tsx index 022ea690..daa4f1dc 100644 --- a/ui/src/components/AddValidatorForm.tsx +++ b/ui/src/components/AddValidatorForm.tsx @@ -375,9 +375,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="owner" render={({ field }) => ( - + Owner account - + Account that controls config (cold wallet recommended) * @@ -385,14 +385,16 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
@@ -414,9 +419,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="manager" render={({ field }) => ( - + Manager account - + Account that triggers payouts and keyreg transactions (must sign transactions) @@ -425,14 +430,16 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
@@ -454,9 +464,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="validatorCommissionAddress" render={({ field }) => ( - + Commission account - + Account that receives validator commission payments * @@ -464,14 +474,16 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
@@ -498,9 +513,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="minEntryStake" render={({ field }) => ( - + Minimum entry stake - + Minimum stake required to enter a pool * @@ -508,9 +523,18 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
- +
- +
{errors.minEntryStake?.message} @@ -523,9 +547,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="epochRoundLength" render={({ field }) => ( - + Epoch length - + Frequency of rewards payouts, in blocks. If a timeframe is selected, it will be converted to blocks based on the current average block time (approx.{' '} {blockTime.secs} seconds). @@ -535,13 +559,17 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
+ {errors.percentToValidator?.message} @@ -606,7 +634,7 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { Pools per node - + Number of pools to allow per node (max of 3 is recommended) * @@ -614,7 +642,7 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { 0 ? 'pr-10' : '', )} - placeholder="" + placeholder="Enter NFD name" autoComplete="new-password" spellCheck="false" {...field} @@ -738,6 +767,7 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {

( - Amount per payout + Amount per payout - + Enter amount in whole units (not base units) {errors.rewardPerPayout?.message} @@ -775,7 +805,7 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { Gating type - + Require stakers to hold a qualified asset to enter pool (optional) @@ -804,7 +834,7 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { }} > - + @@ -831,15 +861,19 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="entryGatingAddress" render={({ field }) => ( - + Asset creator account - + Must hold asset created by this account to enter pool * - + {errors.entryGatingAddress?.message} @@ -851,12 +885,16 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
+ Asset ID - + Must hold asset with this ID to enter pool * @@ -911,9 +949,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="entryGatingNfdCreator" render={({ field }) => ( - + Asset creator NFD - + Must hold asset created by an account linked to this NFD to enter pool * @@ -921,8 +959,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
0 ? 'pr-10' : '')} - placeholder="" + placeholder="Enter NFD name" autoComplete="new-password" spellCheck="false" {...field} @@ -971,9 +1010,9 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { name="entryGatingNfdParent" render={({ field }) => ( - + Root/parent NFD - + Must hold a segment of this root/parent NFD to enter pool * @@ -982,11 +1021,12 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) {
0 ? 'pr-10' : '', )} - placeholder="" + placeholder="Enter NFD name" autoComplete="new-password" spellCheck="false" {...field} @@ -1069,14 +1109,14 @@ export function AddValidatorForm({ constraints }: AddValidatorFormProps) { - + Minimum balance - + Optional minimum required balance of the entry gating asset. - + No minimum if left blank {errors.gatingAssetMinBalance?.message} diff --git a/ui/src/components/AssetLookup.tsx b/ui/src/components/AssetLookup.tsx index 78cab672..ea10f06b 100644 --- a/ui/src/components/AssetLookup.tsx +++ b/ui/src/components/AssetLookup.tsx @@ -18,6 +18,7 @@ interface AssetLookupProps< TName extends FieldPath = FieldPath, > { form: UseFormReturn + id: string name: TName asset: Asset | null setAsset: (asset: Asset | null) => void @@ -33,6 +34,7 @@ export function AssetLookup< TName extends FieldPath = FieldPath, >({ form, + id, name, asset, setAsset, @@ -100,7 +102,7 @@ export function AssetLookup< const renderLabel = () => { if (typeof label === 'string') { - return {label} + return {label} } if (label) { @@ -121,9 +123,11 @@ export function AssetLookup<
{ field.onChange(e) // Inform react-hook-form of the change diff --git a/ui/src/components/Footer.tsx b/ui/src/components/Footer.tsx index 133cd84e..33767c2b 100644 --- a/ui/src/components/Footer.tsx +++ b/ui/src/components/Footer.tsx @@ -52,7 +52,7 @@ export function Footer() { ))}
-

+

RĂ©ti Pooling v{__APP_VERSION__} |{' '} - - + + - + {children} diff --git a/ui/src/components/NfdAvatar.tsx b/ui/src/components/NfdAvatar.tsx index b8c867f4..39e78309 100644 --- a/ui/src/components/NfdAvatar.tsx +++ b/ui/src/components/NfdAvatar.tsx @@ -6,12 +6,17 @@ import { getNfdAvatarUrl } from '@/utils/nfd' interface NfdAvatarProps { nfd: Nfd className?: string + alt?: string } -const NfdAvatar: React.FC = React.memo(function NfdAvatar({ nfd, className = '' }) { +const NfdAvatar: React.FC = React.memo(function NfdAvatar({ + nfd, + className = '', + alt, +}) { return ( - + ) }) diff --git a/ui/src/components/NfdLookup.tsx b/ui/src/components/NfdLookup.tsx index 642e2edd..60e75c9b 100644 --- a/ui/src/components/NfdLookup.tsx +++ b/ui/src/components/NfdLookup.tsx @@ -25,6 +25,7 @@ interface NfdLookupProps< TName extends FieldPath = FieldPath, > { form: UseFormReturn + id: string name: TName nfd: Nfd | null setNfd: (nfd: Nfd | null) => void @@ -42,6 +43,7 @@ export function NfdLookup< TName extends FieldPath = FieldPath, >({ form, + id, name, nfd, setNfd, @@ -143,6 +145,7 @@ export function NfdLookup<

( <>
- +
{nfd.name}
diff --git a/ui/src/components/NodeSelect.tsx b/ui/src/components/NodeSelect.tsx index a3e4c61c..0cd4d9fd 100644 --- a/ui/src/components/NodeSelect.tsx +++ b/ui/src/components/NodeSelect.tsx @@ -17,7 +17,7 @@ interface NodeSelectProps { export function NodeSelect({ nodesInfo, value, onValueChange }: NodeSelectProps) { return ( - + diff --git a/ui/src/components/UnstakeModal.tsx b/ui/src/components/UnstakeModal.tsx index 83a83dc9..522fc9d1 100644 --- a/ui/src/components/UnstakeModal.tsx +++ b/ui/src/components/UnstakeModal.tsx @@ -281,8 +281,8 @@ export function UnstakeModal({ validator, setValidator, stakesByValidator }: Uns ) : ( <> +