-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f0c3ee
commit d9ed16c
Showing
90 changed files
with
36,606 additions
and
35,035 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 80 additions & 72 deletions
152
polaris-react/src/components/AccountConnection/AccountConnection.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,95 @@ | ||
import React, {useCallback, useState} from 'react'; | ||
import type {ComponentMeta} from '@storybook/react'; | ||
import type {Meta} from '@storybook/react'; | ||
import {AccountConnection, Box, Link, Text, BlockStack} from '@shopify/polaris'; | ||
|
||
export default { | ||
component: AccountConnection, | ||
} as ComponentMeta<typeof AccountConnection>; | ||
} as Meta<typeof AccountConnection>; | ||
|
||
export function All() { | ||
return ( | ||
<> | ||
<BlockStack gap="400"> | ||
<Text as="h2" variant="headingXl"> | ||
Default | ||
</Text> | ||
<Default /> | ||
<Box paddingBlockEnd="300" /> | ||
</BlockStack> | ||
<BlockStack gap="400"> | ||
<Text as="h2" variant="headingXl"> | ||
With account connected | ||
</Text> | ||
<WithAccountConnected /> | ||
<Box paddingBlockEnd="300" /> | ||
</BlockStack> | ||
</> | ||
); | ||
} | ||
export const All = { | ||
render() { | ||
return ( | ||
/* eslint-disable react/jsx-pascal-case */ | ||
<> | ||
<BlockStack gap="400"> | ||
<Text as="h2" variant="headingXl"> | ||
Default | ||
</Text> | ||
<Default.render /> | ||
<Box paddingBlockEnd="300" /> | ||
</BlockStack> | ||
<BlockStack gap="400"> | ||
<Text as="h2" variant="headingXl"> | ||
With account connected | ||
</Text> | ||
<WithAccountConnected.render /> | ||
<Box paddingBlockEnd="300" /> | ||
</BlockStack> | ||
</> | ||
/* eslint-enable react/jsx-pascal-case */ | ||
); | ||
}, | ||
}; | ||
|
||
export function Default() { | ||
const [connected, setConnected] = useState(false); | ||
const accountName = connected ? 'Olive Eight' : ''; | ||
export const Default = { | ||
render() { | ||
const [connected, setConnected] = useState(false); | ||
const accountName = connected ? 'Olive Eight' : ''; | ||
|
||
const handleAction = useCallback(() => { | ||
setConnected((connected) => !connected); | ||
}, []); | ||
const handleAction = useCallback(() => { | ||
setConnected((connected) => !connected); | ||
}, []); | ||
|
||
const buttonText = connected ? 'Disconnect' : 'Connect'; | ||
const details = connected ? 'Account connected' : 'No account connected'; | ||
const buttonText = connected ? 'Disconnect' : 'Connect'; | ||
const details = connected ? 'Account connected' : 'No account connected'; | ||
|
||
const terms = connected ? null : ( | ||
<Text as="p" variant="bodyMd"> | ||
By clicking Connect, you agree to accept Sample App’s{' '} | ||
<Link url="Example App">terms and conditions</Link>. You’ll pay a | ||
commission rate of 15% on sales made through Sample App. | ||
</Text> | ||
); | ||
const terms = connected ? null : ( | ||
<Text as="p" variant="bodyMd"> | ||
By clicking Connect, you agree to accept Sample App’s{' '} | ||
<Link url="Example App">terms and conditions</Link>. You’ll pay a | ||
commission rate of 15% on sales made through Sample App. | ||
</Text> | ||
); | ||
|
||
return ( | ||
<AccountConnection | ||
accountName={accountName} | ||
connected={connected} | ||
title="Example App" | ||
action={{ | ||
content: buttonText, | ||
onAction: handleAction, | ||
}} | ||
details={details} | ||
termsOfService={terms} | ||
/> | ||
); | ||
} | ||
return ( | ||
<AccountConnection | ||
accountName={accountName} | ||
connected={connected} | ||
title="Example App" | ||
action={{ | ||
content: buttonText, | ||
onAction: handleAction, | ||
}} | ||
details={details} | ||
termsOfService={terms} | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export function WithAccountConnected() { | ||
const [connected, setConnected] = useState(true); | ||
const accountName = connected ? 'Olive Eight' : ''; | ||
export const WithAccountConnected = { | ||
render() { | ||
const [connected, setConnected] = useState(true); | ||
const accountName = connected ? 'Olive Eight' : ''; | ||
|
||
const handleAction = useCallback(() => { | ||
setConnected((connected) => !connected); | ||
}, []); | ||
const handleAction = useCallback(() => { | ||
setConnected((connected) => !connected); | ||
}, []); | ||
|
||
const buttonText = connected ? 'Disconnect' : 'Connect'; | ||
const details = connected ? 'Account connected' : 'No account connected'; | ||
const buttonText = connected ? 'Disconnect' : 'Connect'; | ||
const details = connected ? 'Account connected' : 'No account connected'; | ||
|
||
return ( | ||
<AccountConnection | ||
accountName={accountName} | ||
connected={connected} | ||
title="Example App" | ||
action={{ | ||
content: buttonText, | ||
onAction: handleAction, | ||
}} | ||
details={details} | ||
/> | ||
); | ||
} | ||
return ( | ||
<AccountConnection | ||
accountName={accountName} | ||
connected={connected} | ||
title="Example App" | ||
action={{ | ||
content: buttonText, | ||
onAction: handleAction, | ||
}} | ||
details={details} | ||
/> | ||
); | ||
}, | ||
}; |
Oops, something went wrong.