@@ -2,26 +2,27 @@ import Button from "@mui/material/Button";
2
2
import GitHubIcon from "@mui/icons-material/GitHub" ;
3
3
import KeyIcon from "@mui/icons-material/VpnKey" ;
4
4
import Box from "@mui/material/Box" ;
5
- import { type FC } from "react" ;
5
+ import { useId , type FC } from "react" ;
6
6
import { Language } from "./SignInForm" ;
7
7
import { type AuthMethods } from "api/typesGenerated" ;
8
+ import { visuallyHidden } from "@mui/utils" ;
8
9
9
10
type OAuthSignInFormProps = {
10
11
isSigningIn : boolean ;
11
12
redirectTo : string ;
12
13
authMethods ?: AuthMethods ;
13
14
} ;
14
15
16
+ const iconStyles = {
17
+ width : 16 ,
18
+ height : 16 ,
19
+ } ;
20
+
15
21
export const OAuthSignInForm : FC < OAuthSignInFormProps > = ( {
16
22
isSigningIn,
17
23
redirectTo,
18
24
authMethods,
19
25
} ) => {
20
- const iconStyles = {
21
- width : 16 ,
22
- height : 16 ,
23
- } ;
24
-
25
26
return (
26
27
< Box display = "grid" gap = "16px" >
27
28
{ authMethods ?. github . enabled && (
@@ -51,11 +52,7 @@ export const OAuthSignInForm: FC<OAuthSignInFormProps> = ({
51
52
size = "xlarge"
52
53
startIcon = {
53
54
authMethods . oidc . iconUrl ? (
54
- < img
55
- alt = "Open ID Connect icon"
56
- src = { authMethods . oidc . iconUrl }
57
- css = { iconStyles }
58
- />
55
+ < OidcIcon iconUrl = { authMethods . oidc . iconUrl } />
59
56
) : (
60
57
< KeyIcon css = { iconStyles } />
61
58
)
@@ -70,3 +67,24 @@ export const OAuthSignInForm: FC<OAuthSignInFormProps> = ({
70
67
</ Box >
71
68
) ;
72
69
} ;
70
+
71
+ type OidcIconProps = {
72
+ iconUrl : string ;
73
+ } ;
74
+
75
+ function OidcIcon ( { iconUrl } : OidcIconProps ) {
76
+ const hookId = useId ( ) ;
77
+ const oidcId = `${ hookId } -oidc` ;
78
+
79
+ // Even if the URL is defined, there is a chance that the request for the
80
+ // image fails. Have to use blank alt text to avoid button from getting ugly
81
+ // if that happens, but also still need a way to inject accessible text
82
+ return (
83
+ < >
84
+ < img alt = "" src = { iconUrl } css = { iconStyles } aria-labelledby = { oidcId } />
85
+ < div id = { oidcId } css = { { ...visuallyHidden } } >
86
+ Open ID Connect
87
+ </ div >
88
+ </ >
89
+ ) ;
90
+ }
0 commit comments