Skip to content

Commit fa8e0e5

Browse files
avelinelaurkim
authored andcommitted
Refactor AccountConnection with new layout and type components (#7345)
Fixes #7341 <!-- link to issue if one exists -->
1 parent 49ed527 commit fa8e0e5

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

.changeset/pink-apricots-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Refactored `AccountConnection` to use new layout primitives

polaris-react/src/components/AccountConnection/AccountConnection.scss

Lines changed: 0 additions & 10 deletions
This file was deleted.

polaris-react/src/components/AccountConnection/AccountConnection.tsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import React from 'react';
33
import type {Action} from '../../types';
44
import {Avatar} from '../Avatar';
55
import {buttonFrom} from '../Button';
6-
import {Card} from '../Card';
7-
import {Stack} from '../Stack';
8-
import {Text} from '../Text';
96
import {SettingAction} from '../SettingAction';
10-
11-
import styles from './AccountConnection.scss';
7+
import {AlphaCard} from '../AlphaCard';
8+
import {Box} from '../Box';
9+
import {Inline} from '../Inline';
10+
import {Text} from '../Text';
11+
import {AlphaStack} from '../AlphaStack';
1212

1313
export interface AccountConnectionProps {
1414
/** Content to display as title */
@@ -54,41 +54,37 @@ export function AccountConnection({
5454

5555
let titleMarkup: React.ReactNode = null;
5656
if (title) {
57-
titleMarkup = <div>{title}</div>;
57+
titleMarkup = <>{title}</>;
5858
} else if (accountName) {
59-
titleMarkup = <div>{accountName}</div>;
59+
titleMarkup = <>{accountName}</>;
6060
}
6161

6262
const detailsMarkup = details ? (
63-
<div>
64-
<Text variant="bodyMd" color="subdued" as="span">
65-
{details}
66-
</Text>
67-
</div>
63+
<Text as="span" variant="bodyMd" color="subdued">
64+
{details}
65+
</Text>
6866
) : null;
6967

7068
const termsOfServiceMarkup = termsOfService ? (
71-
<div className={styles.TermsOfService}>{termsOfService}</div>
69+
<Box paddingTop="5">{termsOfService}</Box>
7270
) : null;
7371

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

7876
return (
79-
<Card sectioned>
77+
<AlphaCard>
8078
<SettingAction action={actionElement}>
81-
<Stack>
79+
<Inline spacing="4">
8280
{avatarMarkup}
83-
<Stack.Item fill>
84-
<div className={styles.Content}>
85-
{titleMarkup}
86-
{detailsMarkup}
87-
</div>
88-
</Stack.Item>
89-
</Stack>
81+
<AlphaStack spacing="2">
82+
{titleMarkup}
83+
{detailsMarkup}
84+
</AlphaStack>
85+
</Inline>
9086
</SettingAction>
9187
{termsOfServiceMarkup}
92-
</Card>
88+
</AlphaCard>
9389
);
9490
}

polaris-react/src/components/AccountConnection/tests/AccountConnection.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import React from 'react';
22
import {mountWithApp} from 'tests/utilities';
3+
import {matchMedia} from '@shopify/jest-dom-mocks';
34

45
import {Avatar} from '../../Avatar';
56
import {Button} from '../../Button';
67
import {AccountConnection} from '../AccountConnection';
78

89
describe('<AccountConnection />', () => {
10+
beforeEach(() => {
11+
matchMedia.mock();
12+
});
13+
14+
afterEach(() => {
15+
matchMedia.restore();
16+
});
17+
918
describe('title', () => {
1019
it('shows the title when one is provided', () => {
1120
const title = 'Example app';

0 commit comments

Comments
 (0)