@@ -15,7 +15,7 @@ import {AvatarContext} from './Avatar';
1515import { ButtonContext , LinkButtonContext } from './Button' ;
1616import { Checkbox } from './Checkbox' ;
1717import { color , focusRing , lightDark , space , style } from '../style' with { type : 'macro' } ;
18- import { composeRenderProps , ContextValue , DEFAULT_SLOT , type GridListItem , GridListItemProps , Provider } from 'react-aria-components' ;
18+ import { composeRenderProps , ContextValue , DEFAULT_SLOT , type GridListItem , GridListItemProps , Link , Provider } from 'react-aria-components' ;
1919import { ContentContext , FooterContext , TextContext } from './Content' ;
2020import { createContext , CSSProperties , forwardRef , ReactNode , useContext } from 'react' ;
2121import { DividerContext } from './Divider' ;
@@ -95,18 +95,19 @@ let card = style({
9595 variant : {
9696 tertiary : {
9797 // Render border with box-shadow to avoid affecting layout.
98- default : `[0 0 0 1px ${ color ( 'gray-100' ) } ]` ,
99- isHovered : `[0 0 0 1px ${ color ( 'gray-200' ) } ]` ,
100- isFocusVisible : `[0 0 0 1px ${ color ( 'gray-200' ) } ]` ,
98+ default : `[0 0 0 2px ${ color ( 'gray-100' ) } ]` ,
99+ isHovered : `[0 0 0 2px ${ color ( 'gray-200' ) } ]` ,
100+ isFocusVisible : `[0 0 0 2px ${ color ( 'gray-200' ) } ]` ,
101101 isSelected : 'none' ,
102- forcedColors : '[0 0 0 1px ButtonBorder]'
102+ forcedColors : '[0 0 0 2px ButtonBorder]'
103103 } ,
104104 quiet : 'none'
105105 }
106106 } ,
107107 forcedColorAdjust : 'none' ,
108108 transition : 'default' ,
109109 fontFamily : 'sans' ,
110+ textDecoration : 'none' ,
110111 overflow : {
111112 default : 'clip' ,
112113 variant : {
@@ -424,6 +425,28 @@ export const Card = forwardRef(function Card(props: CardProps, ref: DOMRef<HTMLD
424425 </ Provider >
425426 ) ;
426427
428+ let press = pressScale ( domRef , UNSAFE_style ) ;
429+ if ( ElementType === 'div' && ! isSkeleton && props . href ) {
430+ // Standalone Card that has an href should be rendered as a Link.
431+ // NOTE: In this case, the card must not contain interactive elements.
432+ return (
433+ < Link
434+ { ...filterDOMProps ( otherProps , { isLink : true } ) }
435+ ref = { domRef as any }
436+ className = { renderProps => UNSAFE_className + card ( { ...renderProps , size, density, variant, isCardView : false , isLink : true } , styles ) }
437+ style = { renderProps =>
438+ // Only the preview in quiet cards scales down on press
439+ variant === 'quiet' ? UNSAFE_style : press ( renderProps )
440+ } >
441+ { ( renderProps ) => (
442+ < InternalCardContext . Provider value = { { size, isQuiet, isCheckboxSelection : false , isSelected : false , ...renderProps } } >
443+ { children }
444+ </ InternalCardContext . Provider >
445+ ) }
446+ </ Link >
447+ ) ;
448+ }
449+
427450 if ( ElementType === 'div' || isSkeleton ) {
428451 return (
429452 < div
@@ -441,7 +464,6 @@ export const Card = forwardRef(function Card(props: CardProps, ref: DOMRef<HTMLD
441464 ) ;
442465 }
443466
444- let press = pressScale ( domRef , UNSAFE_style ) ;
445467 return (
446468 < ElementType
447469 { ...props }
0 commit comments