Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions js/src/components/account-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ const appearanceDict = {
/**
* Renders a Card component with account info and status.
*
* ## CSS Parts:
* `icon` - area with the icon fetched for respective appearence.
* `title` - area with the title fetched for respective appearence.
* `indicator` - indicator/action area
* `description` - description area
*
* @param {Object} props React props.
* @param {string} [props.className] Additional CSS class name to be appended.
* @param {APPEARANCE | {icon, title}} props.appearance Kind of account to indicate the card appearance, or a tuple with icon and title to be used.
Expand All @@ -76,12 +82,20 @@ export default function AccountCard( {
<Section.Card className={ classnames( 'gla-account-card', className ) }>
<Section.Card.Body>
<Flex gap={ 4 }>
{ ! hideIcon && <FlexItem>{ icon }</FlexItem> }
{ ! hideIcon && (
<FlexItem className="part--icon">{ icon }</FlexItem>
) }
<FlexBlock>
<Subsection.Title>{ title }</Subsection.Title>
<div>{ description }</div>
<Subsection.Title className="part--title">
{ title }
</Subsection.Title>
<div className="part--description">{ description }</div>
</FlexBlock>
{ indicator && <FlexItem>{ indicator }</FlexItem> }
{ indicator && (
<FlexItem className="part--indicator">
{ indicator }
</FlexItem>
) }
</Flex>
</Section.Card.Body>
{ children }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { __ } from '@wordpress/i18n';
import { Icon, warning as warningIcon } from '@wordpress/icons';
import { getPath, getQuery } from '@woocommerce/navigation';
import classNames from 'classnames';

/**
* Internal dependencies
Expand Down Expand Up @@ -43,15 +44,11 @@ export default function ContactInformationPreviewCard( {
eventProps={ { path: getPath(), subpath } }
/>
);
let description;
let description = content;

if ( loading ) {
description = (
<span
className="gla-contact-info-preview-card__placeholder"
aria-busy="true"
title={ __( 'Loading…', 'google-listings-and-ads' ) }
></span>
<div title={ __( 'Loading…', 'google-listings-and-ads' ) }></div>
);
} else if ( warning ) {
appearance = {
Expand All @@ -66,19 +63,16 @@ export default function ContactInformationPreviewCard( {
</>
),
};
description = (
<span className="gla-contact-info-preview-card__notice-details">
{ content }
</span>
);
} else {
description = content;
}

return (
<AccountCard
appearance={ appearance }
className="gla-contact-info-preview-card"
aria-busy={ loading }
className={ classNames( 'gla-contact-info-preview-card', {
'state--loading': loading,
'state--warning': warning,
} ) }
description={ description }
hideIcon
indicator={ editButton }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
// :host
.gla-contact-info-preview-card {
// Vertically align icon inside the title.
.wcdl-subsection-title {
// :host::part( title ) - if we use inheritance
// account-card::part( title ) - if we use composition
.part--title {
display: flex;
align-items: center;
}
&__notice-icon {

// :--warning::part( icon )
&.state--warning {
fill: $alert-red;
margin: calc(var(--main-gap) / -8) 0;
}
&__notice-details {
// :--warning>[slot="description"]
// :--warning::part( description )
&.state--warning .part--description {
color: $gray-700;
}

&__placeholder {
// :--loading>[slot="description"]
// :--loading::part( description )
&.state--loading .part--description {
@include placeholder();
display: inline-block;
width: 18em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function PhoneNumberCardPreview( { editHref, learnMore } ) {
const { loaded, data } = useGoogleMCPhoneNumber();
let content, warning;

// Mock invalid data for testing.
data.isValid = false;

if ( loaded ) {
if ( data.isValid ) {
content = data.display;
Expand Down
28 changes: 17 additions & 11 deletions js/src/components/contact-information/store-address-card.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
// :host
.gla-store-address-card {
// We could've used `StoreAddressCard'`s selectors,
// but the elements are wrapped with `<FlexItem>`,
// which does not have accessible semantic selector.
// So we have to rely on `<AccountCard>`'s internal implementation details.
.components-flex__item {

// ::part( icon )
.part--icon {
align-self: start;
}

.components-flex__item:nth-child(3) {
// ::part( indicator )
.part--indicator {
align-self: start;
svg {
margin-left: 4px;
}
}

p {
margin: 1em 0;
}
p:last-child {
margin-bottom: 0;
// ::part( description )
.part--description {
display: flex;
flex-direction: column;
gap: 1em;

// [slot="description"]
> p {
margin: 0;
}
}
}