Skip to content

Commit 40485a3

Browse files
avelinelaurkim
authored andcommitted
Refactor AccountConnection with new layout and type components (#7345)
### WHY are these changes introduced? Fixes #7341 <!-- link to issue if one exists -->
1 parent a595fa3 commit 40485a3

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
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 & 21 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 {TextStyle} from '../TextStyle';
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,39 +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-
<TextStyle variation="subdued">{details}</TextStyle>
65-
</div>
63+
<Text as="span" variant="bodyMd" color="subdued">
64+
{details}
65+
</Text>
6666
) : null;
6767

6868
const termsOfServiceMarkup = termsOfService ? (
69-
<div className={styles.TermsOfService}>{termsOfService}</div>
69+
<Box paddingTop="5">{termsOfService}</Box>
7070
) : null;
7171

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

7676
return (
77-
<Card sectioned>
77+
<AlphaCard>
7878
<SettingAction action={actionElement}>
79-
<Stack>
79+
<Inline spacing="4">
8080
{avatarMarkup}
81-
<Stack.Item fill>
82-
<div className={styles.Content}>
83-
{titleMarkup}
84-
{detailsMarkup}
85-
</div>
86-
</Stack.Item>
87-
</Stack>
81+
<AlphaStack spacing="2">
82+
{titleMarkup}
83+
{detailsMarkup}
84+
</AlphaStack>
85+
</Inline>
8886
</SettingAction>
8987
{termsOfServiceMarkup}
90-
</Card>
88+
</AlphaCard>
9189
);
9290
}

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)