1- import React from ' react' ;
2- import clsx from ' clsx' ;
3- import Link from ' @docusaurus/Link' ;
4- import useBaseUrl from ' @docusaurus/useBaseUrl' ;
1+ import React from " react" ;
2+ import clsx from " clsx" ;
3+ import Link from " @docusaurus/Link" ;
4+ import useBaseUrl from " @docusaurus/useBaseUrl" ;
55
6- import styles from './styles.module.css' ;
6+ import styles from "./styles.module.css" ;
7+
8+ declare global {
9+ namespace JSX {
10+ interface IntrinsicElements {
11+ "ion-icon" : React . DetailedHTMLProps <
12+ React . HTMLAttributes < HTMLElement > & { name ?: string } ,
13+ HTMLElement
14+ > ;
15+ }
16+ }
17+ }
718
819interface Props extends React . HTMLAttributes < HTMLDivElement > {
920 href ?: string ;
@@ -13,82 +24,88 @@ interface Props extends React.HTMLAttributes<HTMLDivElement> {
1324 iconset ?: string ;
1425 ionicon ?: string ;
1526 img ?: string ;
16- size ?: 'md' | 'lg' ;
27+ size ?: "md" | "lg" ;
28+ activeIndex ?: number ;
1729}
1830
1931function DocsCard ( props : Props ) : JSX . Element {
20- const isStatic = typeof props . href === 'undefined' ;
21- const isOutbound = typeof props . href !== 'undefined' ? / ^ h t t p / . test ( props . href ) : false ;
22- const header = props . header === 'undefined' ? null : < header className = "Card-header" > { props . header } </ header > ;
32+ const isStatic = typeof props . href === "undefined" ;
33+ const isOutbound =
34+ typeof props . href !== "undefined" ? / ^ h t t p / . test ( props . href ) : false ;
35+ // const header =
36+ // props.header === "undefined" ? null : (
37+ // <header>{props.header}</header>
38+ // );
2339 const hoverIcon = props . hoverIcon || props . icon ;
2440
2541 const content = (
2642 < >
27- { props . img && < img src = { useBaseUrl ( props . img ) } className = "Card-image" /> }
28- < div className = "Card-container" >
29- { ( props . icon || hoverIcon ) && (
30- < div className = "Card-icon-row" >
31- { /* {props.icon && <img src={useBaseUrl(props.icon)} className="Card-icon Card-icon-default" /> } */ }
32- { hoverIcon && < img src = { useBaseUrl ( hoverIcon ) } className = "Card-icon Card-icon-hover" /> }
33- </ div >
34- ) }
35- { props . ionicon && < ion-icon name = { props . ionicon } className = "Card-ionicon" > </ ion-icon > }
36- { props . iconset && (
37- < div className = "Card-iconset__container" >
38- { props . iconset . split ( ',' ) . map ( ( icon , index ) => (
39- < img
40- src = { useBaseUrl ( icon ) }
41- className = { `Card-icon ${ index === props . activeIndex ? 'Card-icon-active' : '' } ` }
42- data-index = { index }
43- key = { index }
44- />
45- ) ) }
46- </ div >
47- ) }
48- < h3 >
49- { props . header && header }
50- </ h3 >
51- < div className = "Card-content" >
52- < p >
53- { props . children }
54- </ p >
43+ { props . img && < img src = { useBaseUrl ( props . img ) } /> }
44+ { /* FLEX HEADER (ICON + TITLE) */ }
45+ { ( props . icon || props . ionicon || hoverIcon ) && (
46+ < div className = { styles . cardHeaderRow } >
47+ { hoverIcon && (
48+ < img
49+ src = { useBaseUrl ( hoverIcon ) }
50+ className = { styles . cardIcon }
51+ alt = ""
52+ />
53+ ) }
54+
55+ { props . ionicon && (
56+ < ion-icon
57+ name = { props . ionicon }
58+ className = { styles . cardIonicon }
59+ > </ ion-icon >
60+ ) }
61+
62+ { props . header && (
63+ < h3 className = { styles . cardHeader } > { props . header } </ h3 >
64+ ) }
5565 </ div >
66+ ) }
67+ < div >
68+ < p > { props . children } </ p >
5669 </ div >
5770 </ >
5871 ) ;
5972
6073 const className = clsx ( {
61- ' Card-with-image' : typeof props . img !== ' undefined' ,
62- ' Card-without-image' : typeof props . img === ' undefined' ,
63- ' Card-size-lg' : props . size === 'lg' ,
64- [ props . className ] : props . className ,
74+ " Card-with-image" : typeof props . img !== " undefined" ,
75+ " Card-without-image" : typeof props . img === " undefined" ,
76+ " Card-size-lg" : props . size === "lg" ,
77+ ... ( props . className ? { [ props . className ] : true } : { } ) ,
6578 } ) ;
6679
6780 if ( isStatic ) {
6881 return (
69- < docs-card class = { className } >
70- < div className = { clsx ( styles . card , ' docs-card' ) } > { content } </ div >
71- </ docs-card >
82+ < div className = { className } >
83+ < div className = { clsx ( styles . card , " docs-card" ) } > { content } </ div >
84+ </ div >
7285 ) ;
7386 }
7487
7588 if ( isOutbound ) {
7689 return (
77- < docs-card class = { className } >
78- < a className = { clsx ( styles . card , 'docs-card' ) } href = { props . href } target = "_blank" >
90+ < div className = { className } >
91+ < a
92+ className = { clsx ( styles . card , "docs-card" ) }
93+ href = { props . href }
94+ target = "_blank"
95+ >
7996 { content }
8097 </ a >
81- </ docs-card >
98+ </ div >
8299 ) ;
83100 }
84101
85102 return (
86- < docs-card class = { className } >
87- < Link to = { props . href } className = { clsx ( styles . card , ' docs-card' ) } >
103+ < div className = { className } >
104+ < Link to = { props . href } className = { clsx ( styles . card , " docs-card" ) } >
88105 { content }
89106 </ Link >
90- </ docs-card >
107+ </ div >
91108 ) ;
92109}
93110
94- export default DocsCard ;
111+ export default DocsCard ;
0 commit comments