@@ -2,7 +2,7 @@ import type { Interpolation, Theme } from "@emotion/react";
2
2
import ArrowForwardOutlined from "@mui/icons-material/ArrowForwardOutlined" ;
3
3
import Button from "@mui/material/Button" ;
4
4
import type { FC , HTMLAttributes } from "react" ;
5
- import { Link as RouterLink } from "react-router-dom" ;
5
+ import { Link as RouterLink , useNavigate } from "react-router-dom" ;
6
6
import type { Template } from "api/typesGenerated" ;
7
7
import { ExternalAvatar } from "components/Avatar/Avatar" ;
8
8
import { AvatarData } from "components/AvatarData/AvatarData" ;
@@ -16,10 +16,25 @@ export const TemplateCard: FC<TemplateCardProps> = ({
16
16
template,
17
17
...divProps
18
18
} ) => {
19
+ const navigate = useNavigate ( ) ;
20
+ const templatePageLink = `/templates/${ template . name } ` ;
19
21
const hasIcon = template . icon && template . icon !== "" ;
20
22
23
+ const handleKeyDown = ( e : React . KeyboardEvent ) => {
24
+ if ( e . key === "Enter" && e . currentTarget === e . target ) {
25
+ navigate ( templatePageLink ) ;
26
+ }
27
+ } ;
28
+
21
29
return (
22
- < div css = { styles . card } { ...divProps } >
30
+ < div
31
+ css = { styles . card }
32
+ { ...divProps }
33
+ role = "button"
34
+ tabIndex = { 0 }
35
+ onClick = { ( ) => navigate ( templatePageLink ) }
36
+ onKeyDown = { handleKeyDown }
37
+ >
23
38
< div css = { styles . header } >
24
39
< div >
25
40
< AvatarData
@@ -60,6 +75,9 @@ export const TemplateCard: FC<TemplateCardProps> = ({
60
75
startIcon = { < ArrowForwardOutlined /> }
61
76
title = { `Create a workspace using the ${ template . display_name } template` }
62
77
to = { `/templates/${ template . name } /workspace` }
78
+ onClick = { ( e ) => {
79
+ e . stopPropagation ( ) ;
80
+ } }
63
81
>
64
82
Create Workspace
65
83
</ Button >
@@ -79,6 +97,11 @@ const styles = {
79
97
color : "inherit" ,
80
98
display : "flex" ,
81
99
flexDirection : "column" ,
100
+ cursor : "pointer" ,
101
+ "&:hover" : {
102
+ color : theme . experimental . l2 . hover . text ,
103
+ borderColor : theme . experimental . l2 . hover . text ,
104
+ } ,
82
105
} ) ,
83
106
84
107
header : {
@@ -95,27 +118,6 @@ const styles = {
95
118
height : 32 ,
96
119
} ,
97
120
98
- tags : {
99
- display : "flex" ,
100
- flexWrap : "wrap" ,
101
- gap : 8 ,
102
- justifyContent : "end" ,
103
- } ,
104
-
105
- tag : ( theme ) => ( {
106
- borderColor : theme . palette . divider ,
107
- textDecoration : "none" ,
108
- cursor : "pointer" ,
109
- "&: hover" : {
110
- borderColor : theme . palette . primary . main ,
111
- } ,
112
- } ) ,
113
-
114
- activeTag : ( theme ) => ( {
115
- borderColor : theme . roles . active . outline ,
116
- backgroundColor : theme . roles . active . background ,
117
- } ) ,
118
-
119
121
description : ( theme ) => ( {
120
122
fontSize : 13 ,
121
123
color : theme . palette . text . secondary ,
0 commit comments