Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/pink-apricots-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Refactored `AccountConnection` to use new layout primitives

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import React from 'react';
import type {Action} from '../../types';
import {Avatar} from '../Avatar';
import {buttonFrom} from '../Button';
import {Card} from '../Card';
import {Stack} from '../Stack';
import {TextStyle} from '../TextStyle';
import {SettingAction} from '../SettingAction';

import styles from './AccountConnection.scss';
import {AlphaCard} from '../AlphaCard';
import {Box} from '../Box';
import {Inline} from '../Inline';
import {Text} from '../Text';
import {AlphaStack} from '../AlphaStack';

export interface AccountConnectionProps {
/** Content to display as title */
Expand Down Expand Up @@ -54,39 +54,37 @@ export function AccountConnection({

let titleMarkup: React.ReactNode = null;
if (title) {
titleMarkup = <div>{title}</div>;
titleMarkup = <>{title}</>;
} else if (accountName) {
titleMarkup = <div>{accountName}</div>;
titleMarkup = <>{accountName}</>;
}

const detailsMarkup = details ? (
<div>
<TextStyle variation="subdued">{details}</TextStyle>
</div>
<Text as="span" variant="bodyMd" color="subdued">
{details}
</Text>
) : null;

const termsOfServiceMarkup = termsOfService ? (
<div className={styles.TermsOfService}>{termsOfService}</div>
<Box paddingTop="5">{termsOfService}</Box>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be using tokens, rather than hardcoded numbers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait. I see. This is a number from the set made available in the Box component props. 🤦

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it maps to our spacing tokens. But perhaps it's not very clear? I wonder if there's anything we can do to make that easier?

) : null;

const actionElement = action
? buttonFrom(action, {primary: !connected})
: null;

return (
<Card sectioned>
<AlphaCard>
<SettingAction action={actionElement}>
<Stack>
<Inline spacing="4">
{avatarMarkup}
<Stack.Item fill>
<div className={styles.Content}>
{titleMarkup}
{detailsMarkup}
</div>
</Stack.Item>
</Stack>
<AlphaStack spacing="2">
{titleMarkup}
{detailsMarkup}
</AlphaStack>
</Inline>
</SettingAction>
{termsOfServiceMarkup}
</Card>
</AlphaCard>
);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import React from 'react';
import {mountWithApp} from 'tests/utilities';
import {matchMedia} from '@shopify/jest-dom-mocks';

import {Avatar} from '../../Avatar';
import {Button} from '../../Button';
import {AccountConnection} from '../AccountConnection';

describe('<AccountConnection />', () => {
beforeEach(() => {
matchMedia.mock();
});

afterEach(() => {
matchMedia.restore();
});

describe('title', () => {
it('shows the title when one is provided', () => {
const title = 'Example app';
Expand Down