@@ -95,57 +95,6 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
95
95
detail : { UNSAFE_className : classNames ( styles , 'spectrum-Card-detail' ) }
96
96
} ) , [ titleProps , contentProps , height , isQuiet , orientation ] ) ;
97
97
98
- // This is only for quiet grid cards
99
- let [ isCloseToSquare , setIsCloseToSquare ] = useState ( false ) ;
100
- useLayoutEffect ( ( ) => {
101
- if ( ! ( layout === 'grid' && isQuiet ) ) {
102
- return ;
103
- }
104
- // ToDo: how to handle illustrations? what if the illustration looks like an image? What about swatches/fonts https://spectrum-contributions.corp.adobe.com/page/asset-card-beta/#File-type
105
- let image = gridRef . current . querySelector ( `.${ styles [ 'spectrum-Card-image' ] } img` ) as HTMLImageElement ;
106
- if ( ! image ) {
107
- return ;
108
- }
109
- let measure = ( ) => {
110
- let height = image . naturalHeight ;
111
- let width = image . naturalWidth ;
112
- /*
113
- * ToDo: Choose between min-padding and plain ratio
114
- * Do we want to just do a ratio measurement when it's close to being a square?
115
- * or do we want to actually figure out min-padding?
116
- * Min Padding would require us to check that the padding is not less than the min in both Vertical and Horizontal
117
- * Unfortunately img contain doesn't actually create padding, which is what this math below can figure out
118
- * Vs the commented out straight ratio check
119
- * */
120
- let imgTagHeight = image . clientHeight ;
121
- let imgTagWidth = image . clientWidth ;
122
- let ratio = Math . min ( imgTagWidth / width , imgTagHeight / height ) ;
123
- let trueHeight = ratio * height ;
124
- let trueWidth = ratio * width ;
125
- let paddingVertical = imgTagHeight - trueHeight ;
126
- let paddingHorizontal = imgTagWidth - trueWidth ;
127
- if ( paddingVertical < 16 && paddingHorizontal < 16 ) { // ToDo: does this need to be different per scale?
128
- setIsCloseToSquare ( true ) ;
129
- } else {
130
- setIsCloseToSquare ( false ) ;
131
- }
132
-
133
- // let ratio = height / width;
134
- // if (ratio > 0.9 && ratio < 1.1) {
135
- // setIsCloseToSquare(true);
136
- // }
137
- } ;
138
- if ( image . complete ) {
139
- measure ( ) ;
140
- } else {
141
- image . addEventListener ( 'load' , measure ) ;
142
- return ( ) => {
143
- image . removeEventListener ( 'load' , measure ) ;
144
- } ;
145
- }
146
- // ToDo: how to re-run if image src changes?
147
- } , [ children , setIsCloseToSquare , isQuiet , layout ] ) ;
148
-
149
98
useLayoutEffect ( ( ) => {
150
99
if ( gridRef ?. current ) {
151
100
let walker = getFocusableTreeWalker ( gridRef . current ) ;
@@ -170,7 +119,6 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
170
119
'spectrum-Card--default' : ! isQuiet && orientation !== 'horizontal' ,
171
120
'spectrum-Card--isQuiet' : isQuiet && orientation !== 'horizontal' ,
172
121
'spectrum-Card--horizontal' : orientation === 'horizontal' ,
173
- 'spectrum-Card--closeToSquare' : isCloseToSquare ,
174
122
'spectrum-Card--noPreview' : ! hasPreview ,
175
123
'is-hovered' : isHovered ,
176
124
'is-focused' : isFocused ,
0 commit comments