Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aria attribute #1261

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions demos/client-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function App(props: AppProps) {
dappName={config.dappName}
value={account}
onChange={setAccount}
aria-label="Select account"
/>
</FormControl>
) : (
Expand All @@ -189,9 +190,10 @@ function App(props: AppProps) {
id="email"
label="Email"
type="text"
autoComplete="Email"
autoComplete="email"
autoCapitalize="none"
onChange={(e) => setEmail(e.target.value)}
aria-label="Email"
/>
</FormControl>

Expand All @@ -201,8 +203,9 @@ function App(props: AppProps) {
id="name"
label="Name"
type="text"
autoComplete="Name"
autoComplete="name"
onChange={(e) => setName(e.target.value)}
aria-label="Name"
/>
</FormControl>
)}
Expand All @@ -212,8 +215,9 @@ function App(props: AppProps) {
id="password"
label="Password"
type="password"
autoComplete="Password"
autoComplete="password"
onChange={(e) => setPassword(e.target.value)}
aria-label="Password"
/>
</FormControl>

Expand All @@ -222,9 +226,14 @@ function App(props: AppProps) {
<ProcaptchaFrictionless
config={config}
callbacks={{ onError, onHuman, onExpired }}
aria-label="Frictionless captcha"
/>
) : (
<Procaptcha config={config} callbacks={{ onError, onHuman, onExpired }} />
<Procaptcha
config={config}
callbacks={{ onError, onHuman, onExpired }}
aria-label="Captcha"
/>
)}
</FormControl>
<FormControl>
Expand All @@ -234,6 +243,7 @@ function App(props: AppProps) {
variant="contained"
onClick={onActionHandler}
disabled={!procaptchaOutput}
aria-label={isLogin ? 'Login' : 'Sign up'}
>
{isLogin ? 'Login' : 'Sign up'}
</Button>
Expand All @@ -242,7 +252,12 @@ function App(props: AppProps) {
<Typography>- or -</Typography>
</Box>
</Box>
<Button onClick={onChangeHandler}>{isLogin ? 'Signup' : 'Login'}</Button>
<Button
onClick={onChangeHandler}
aria-label={isLogin ? 'Sign up' : 'Login'}
>
{isLogin ? 'Sign up' : 'Login'}
</Button>
</Stack>
</Box>
</FormControl>
Expand Down
8 changes: 6 additions & 2 deletions packages/procaptcha-pow/src/components/Captcha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ const Procaptcha = (props: ProcaptchaProps) => {
>
<div style={{ flex: 1 }}>
{state.loading ? (
<LoadingSpinner themeColor={themeColor} />
<LoadingSpinner
themeColor={themeColor}
aria-label="Loading spinner"
/>
) : (
<Checkbox
checked={state.isHuman}
onChange={manager.start}
themeColor={themeColor}
labelText={'I am human'}
aria-label="human checkbox"
></Checkbox>
)}
</div>
Expand All @@ -107,7 +111,7 @@ const Procaptcha = (props: ProcaptchaProps) => {
<div style={{ display: 'inline-flex', flexDirection: 'column' }}>
<a href={WIDGET_URL} target="_blank" aria-label={WIDGET_URL_TEXT}>
<div style={{ flex: 1 }}>
<Logo themeColor={themeColor}></Logo>
<Logo themeColor={themeColor} aria-label="Prosopo logo"></Logo>
</div>
</a>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/procaptcha-react/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const Button: React.FC<ButtonProps> = ({ themeColor, buttonType, text, onClick }
e.preventDefault()
onClick()
}}
aria-label={text}
>
{text}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ const CaptchaComponent = ({
buttonType="cancel"
onClick={onCancel}
text={t('WIDGET.CANCEL')}
></Button>
aria-label={t('WIDGET.CANCEL')}
/>
<Button
themeColor={themeColor}
buttonType="next"
text={index < challenge.captchas.length - 1 ? t('WIDGET.NEXT') : t('WIDGET.SUBMIT')}
onClick={index < challenge.captchas.length - 1 ? onNext : onSubmit}
></Button>
aria-label={index < challenge.captchas.length - 1 ? t('WIDGET.NEXT') : t('WIDGET.SUBMIT')}
/>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
themeColor: 'light' | 'dark'
}

const getHash = (item: any) => {

Check warning on line 26 in packages/procaptcha-react/src/components/CaptchaWidget.tsx

View workflow job for this annotation

GitHub Actions / check

Unexpected any. Specify a different type
if (!item.hash) {
throw new ProsopoDatasetError('CAPTCHA.MISSING_ITEM_HASH', { context: { item } })
}
Expand Down Expand Up @@ -138,6 +138,7 @@
aria-hidden="true"
viewBox="0 0 24 24"
data-testid="CheckIcon"
aria-label="Check icon"
>
<path d="M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const ProcaptchaWidget = (props: ProcaptchaProps) => {
onChange={manager.start}
checked={state.isHuman}
labelText="I am human"
aria-label="human checkbox"
/>
</div>
<div
Expand All @@ -116,7 +117,10 @@ const ProcaptchaWidget = (props: ProcaptchaProps) => {
}}
>
<div style={{ display: 'inline-flex' }}>
<LoadingSpinner themeColor={themeColor} />
<LoadingSpinner
themeColor={themeColor}
aria-label="Loading spinner"
/>
</div>
</div>
</div>
Expand All @@ -125,7 +129,7 @@ const ProcaptchaWidget = (props: ProcaptchaProps) => {
<div style={{ display: 'inline-flex', flexDirection: 'column' }}>
<a href={WIDGET_URL} target="_blank" aria-label={WIDGET_URL_TEXT}>
<div style={{ flex: 1 }}>
<Logo themeColor={themeColor}></Logo>
<Logo themeColor={themeColor} aria-label="Prosopo logo"></Logo>
</div>
</a>
</div>
Expand Down
7 changes: 5 additions & 2 deletions packages/web-components/src/CaptchaPlaceholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ export const ProcaptchaPlaceholder = (props: PlaceholderProps) => {
}}
>
<div style={{ display: 'inline-flex' }}>
<LoadingSpinner themeColor={themeColor} />
<LoadingSpinner
themeColor={themeColor}
aria-label="Loading spinner"
/>
</div>
</div>
</div>
Expand All @@ -84,7 +87,7 @@ export const ProcaptchaPlaceholder = (props: PlaceholderProps) => {
<div style={{ display: 'inline-flex', flexDirection: 'column' }}>
<a href={WIDGET_URL} target="_blank" aria-label={WIDGET_URL_TEXT}>
<div style={{ flex: 1 }}>
<Logo themeColor={themeColor}></Logo>
<Logo themeColor={themeColor} aria-label="Prosopo logo"></Logo>
</div>
</a>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const Checkbox: React.FC<CheckboxProps> = ({ themeColor, onChange, checke
type={'checkbox'}
aria-live={'assertive'}
aria-haspopup={'true'}
aria-label={labelText}
onChange={onChange}
checked={checked}
style={checkboxStyle}
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/src/LogoWithText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const LogoWithText: React.FC<LogoWithoutTextProps> = ({ themeColor }: Log
height="35px"
width="140px"
style={{ fill }}
aria-label="Prosopo Logo With Text"
>
<title>Prosopo Logo With Text</title>
<path
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/src/LogoWithoutText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const LogoWithoutText: React.FC<LogoWithoutTextProps> = ({ themeColor }:
viewBox="0 0 260 348"
height="35px"
style={{ fill }}
aria-label="Prosopo Logo Without Text"
>
<title>Prosopo Logo Without Text</title>
<path d="M95.7053 40.2707C127.005 40.2707 157.022 52.6841 179.154 74.78C201.286 96.8759 213.719 126.844 213.719 158.093H254.056C254.056 70.7808 183.16 -4.57764e-05 95.7053 -4.57764e-05V40.2707Z" />
Expand Down
Loading