Skip to content

Commit 285849a

Browse files
committed
Use withComponent over as prop
1 parent c80ab20 commit 285849a

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

client/landing/gutenboarding/onboarding-block/design-selector/design-card.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import classnames from 'classnames';
99
/**
1010
* Internal dependencies
1111
*/
12-
import { Card, CardMedia } from '@wordpress/components';
12+
import { Card as CardComponent, CardMedia as CardMediaComponent } from '@wordpress/components';
13+
14+
const Card = CardComponent.withComponent( 'button' );
15+
const CardMedia = CardMediaComponent.withComponent( 'span' );
1316

1417
const gridWidth = 960;
1518
const srcSet = ( src: string, widths: number[] ) =>
@@ -18,7 +21,7 @@ const srcSet = ( src: string, widths: number[] ) =>
1821
interface Props {
1922
isSelected?: boolean;
2023
design: import('@automattic/data-stores').VerticalsTemplates.Template;
21-
onClick: MouseEventHandler< HTMLDivElement >;
24+
onClick: MouseEventHandler< HTMLButtonElement >;
2225
style?: CSSProperties;
2326
dialogId: string;
2427
}
@@ -30,15 +33,14 @@ const DesignCard: FunctionComponent< Props > = ( {
3033
style,
3134
} ) => (
3235
<Card
33-
as="button"
3436
className={ classnames( 'design-selector__design-option', { 'is-selected': isSelected } ) }
3537
isElevated
3638
onClick={ onClick }
3739
style={ style }
3840
aria-haspopup="dialog"
3941
aria-controls={ dialogId }
4042
>
41-
<CardMedia as="span">
43+
<CardMedia>
4244
<img
4345
width={ 480 }
4446
height={ 360 }

client/landing/gutenboarding/onboarding-block/design-selector/page-layout-selector.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ import classnames from 'classnames';
88
/**
99
* Internal dependencies
1010
*/
11-
import { Card, CardFooter, CardMedia, Icon } from '@wordpress/components';
11+
import {
12+
Card as CardComponent,
13+
CardFooter as CardFooterComponent,
14+
CardMedia as CardMediaComponent,
15+
Icon,
16+
} from '@wordpress/components';
1217
import { removeQueryArgs } from '@wordpress/url';
1318

19+
const Card = CardComponent.withComponent( 'button' );
20+
const CardFooter = CardFooterComponent.withComponent( 'span' );
21+
const CardMedia = CardMediaComponent.withComponent( 'span' );
22+
1423
type Template = import('@automattic/data-stores').VerticalsTemplates.Template;
1524

1625
interface Props {
@@ -36,7 +45,6 @@ const PageLayoutSelector: FunctionComponent< Props > = ( {
3645
<div className="page-layout-selector__grid">
3746
{ templates.map( template => (
3847
<Card
39-
as="button"
4048
className={ classnames( 'page-layout-selector__item', {
4149
'is-selected': selectedLayouts.has( template.slug ),
4250
} ) }
@@ -46,10 +54,10 @@ const PageLayoutSelector: FunctionComponent< Props > = ( {
4654
<span className="page-layout-selector__selected-indicator">
4755
<Icon icon="yes" size={ 24 } />
4856
</span>
49-
<CardMedia className="page-layout-selector__card-media" as="span">
57+
<CardMedia className="page-layout-selector__card-media">
5058
<img alt={ template.description } src={ removeQueryArgs( template.preview, 'w' ) } />
5159
</CardMedia>
52-
<CardFooter className="page-layout-selector__card-footer" as="span">
60+
<CardFooter className="page-layout-selector__card-footer">
5361
{ template.title }
5462
</CardFooter>
5563
</Card>

0 commit comments

Comments
 (0)