diff --git a/.changeset/tough-nails-thank.md b/.changeset/tough-nails-thank.md new file mode 100644 index 00000000000..e11a4d730d5 --- /dev/null +++ b/.changeset/tough-nails-thank.md @@ -0,0 +1,5 @@ +--- +'polaris.shopify.com': patch +--- + +Move code examples to examples the app directory to avoid conflicting stylesheets on the website diff --git a/polaris.shopify.com/.vscode/settings.json b/polaris.shopify.com/.vscode/settings.json new file mode 100644 index 00000000000..d0679104bda --- /dev/null +++ b/polaris.shopify.com/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true +} \ No newline at end of file diff --git a/polaris.shopify.com/app/examples/account-connection-default/page.tsx b/polaris.shopify.com/app/examples/account-connection-default/page.tsx new file mode 100644 index 00000000000..362449b1e0f --- /dev/null +++ b/polaris.shopify.com/app/examples/account-connection-default/page.tsx @@ -0,0 +1,40 @@ +'use client'; + +import {Link, AccountConnection} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AccountConnectionExample() { + const [connected, setConnected] = useState(false); + const accountName = connected ? 'Jane Appleseed' : ''; + + const handleAction = useCallback(() => { + setConnected((connected) => !connected); + }, []); + + const buttonText = connected ? 'Disconnect' : 'Connect'; + const details = connected ? 'Account connected' : 'No account connected'; + const terms = connected ? null : ( +

+ By clicking Connect, you agree to accept Sample App’s{' '} + terms and conditions. You’ll pay a + commission rate of 15% on sales made through Sample App. +

+ ); + + return ( + + ); +} + +export default withPolarisExample(AccountConnectionExample); diff --git a/polaris.shopify.com/app/examples/action-list-in-a-popover/page.tsx b/polaris.shopify.com/app/examples/action-list-in-a-popover/page.tsx new file mode 100644 index 00000000000..76b9742cf9b --- /dev/null +++ b/polaris.shopify.com/app/examples/action-list-in-a-popover/page.tsx @@ -0,0 +1,54 @@ +'use client'; + +import {Button, Popover, ActionList} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ActionListInPopoverExample() { + const [active, setActive] = useState(true); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const handleImportedAction = useCallback( + () => console.log('Imported action'), + [], + ); + + const handleExportedAction = useCallback( + () => console.log('Exported action'), + [], + ); + + const activator = ( + + ); + + return ( +
+ + + +
+ ); +} + +export default withPolarisExample(ActionListInPopoverExample); diff --git a/polaris.shopify.com/app/examples/action-list-with-a-prefix-and-a-suffix/page.tsx b/polaris.shopify.com/app/examples/action-list-with-a-prefix-and-a-suffix/page.tsx new file mode 100644 index 00000000000..fcc543f7bd5 --- /dev/null +++ b/polaris.shopify.com/app/examples/action-list-with-a-prefix-and-a-suffix/page.tsx @@ -0,0 +1,36 @@ +'use client'; + +import {ActionList, Thumbnail, Icon, Avatar} from '@shopify/polaris'; +import {ChevronRightMinor} from '@shopify/polaris-icons'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ActionListWithPrefixSuffixExample() { + return ( +
+ + ), + suffix: , + }, + { + content: 'Or there', + prefix: , + suffix: , + }, + ]} + /> +
+ ); +} + +export default withPolarisExample(ActionListWithPrefixSuffixExample); diff --git a/polaris.shopify.com/app/examples/action-list-with-an-icon-and-a-suffix/page.tsx b/polaris.shopify.com/app/examples/action-list-with-an-icon-and-a-suffix/page.tsx new file mode 100644 index 00000000000..d2faeea13fd --- /dev/null +++ b/polaris.shopify.com/app/examples/action-list-with-an-icon-and-a-suffix/page.tsx @@ -0,0 +1,44 @@ +'use client'; + +import {Button, Popover, ActionList, Icon} from '@shopify/polaris'; +import {ImportMinor, TickSmallMinor, ExportMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ActionListWithSuffixExample() { + const [active, setActive] = useState(true); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const activator = ( + + ); + + return ( +
+ + , + }, + {content: 'Export file', icon: ExportMinor}, + ]} + /> + +
+ ); +} + +export default withPolarisExample(ActionListWithSuffixExample); diff --git a/polaris.shopify.com/app/examples/action-list-with-destructive-item/page.tsx b/polaris.shopify.com/app/examples/action-list-with-destructive-item/page.tsx new file mode 100644 index 00000000000..56dbb55837e --- /dev/null +++ b/polaris.shopify.com/app/examples/action-list-with-destructive-item/page.tsx @@ -0,0 +1,53 @@ +'use client'; + +import {Button, Popover, ActionList} from '@shopify/polaris'; +import {ImportMinor, ExportMinor, DeleteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ActionListWithDestructiveItemExample() { + const [active, setActive] = useState(true); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const activator = ( + + ); + + return ( +
+ + + +
+ ); +} + +export default withPolarisExample(ActionListWithDestructiveItemExample); diff --git a/polaris.shopify.com/app/examples/action-list-with-help-text/page.tsx b/polaris.shopify.com/app/examples/action-list-with-help-text/page.tsx new file mode 100644 index 00000000000..1cd70d4a043 --- /dev/null +++ b/polaris.shopify.com/app/examples/action-list-with-help-text/page.tsx @@ -0,0 +1,48 @@ +'use client'; + +import {Button, Popover, ActionList} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ActionListWithHelpTextExample() { + const [active, setActive] = useState(true); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const activator = ( + + ); + + return ( +
+ + + +
+ ); +} + +export default withPolarisExample(ActionListWithHelpTextExample); diff --git a/polaris.shopify.com/app/examples/action-list-with-icons-or-image/page.tsx b/polaris.shopify.com/app/examples/action-list-with-icons-or-image/page.tsx new file mode 100644 index 00000000000..66b96a90963 --- /dev/null +++ b/polaris.shopify.com/app/examples/action-list-with-icons-or-image/page.tsx @@ -0,0 +1,39 @@ +'use client'; + +import {Button, Popover, ActionList} from '@shopify/polaris'; +import {ImportMinor, ExportMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ActionListWithMediaExample() { + const [active, setActive] = useState(true); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const activator = ( + + ); + + return ( +
+ + + +
+ ); +} + +export default withPolarisExample(ActionListWithMediaExample); diff --git a/polaris.shopify.com/app/examples/action-list-with-sections/page.tsx b/polaris.shopify.com/app/examples/action-list-with-sections/page.tsx new file mode 100644 index 00000000000..7def1412651 --- /dev/null +++ b/polaris.shopify.com/app/examples/action-list-with-sections/page.tsx @@ -0,0 +1,56 @@ +'use client'; + +import {Button, Popover, ActionList} from '@shopify/polaris'; +import { + ImportMinor, + ExportMinor, + EditMinor, + DeleteMinor, +} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SectionedActionListExample() { + const [active, setActive] = useState(true); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const activator = ( + + ); + + return ( +
+ + + +
+ ); +} + +export default withPolarisExample(SectionedActionListExample); diff --git a/polaris.shopify.com/app/examples/alpha-card-default/page.tsx b/polaris.shopify.com/app/examples/alpha-card-default/page.tsx new file mode 100644 index 00000000000..fb3686e9945 --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-card-default/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {AlphaCard, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaCardExample() { + return ( + + + Content inside a card + + + ); +} + +export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/app/examples/alpha-card-with-rounded-corners/page.tsx b/polaris.shopify.com/app/examples/alpha-card-with-rounded-corners/page.tsx new file mode 100644 index 00000000000..36ca7f5c4b7 --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-card-with-rounded-corners/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {AlphaCard, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaCardExample() { + return ( + + + Content inside a card + + + ); +} + +export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/app/examples/alpha-card-with-subdued-background/page.tsx b/polaris.shopify.com/app/examples/alpha-card-with-subdued-background/page.tsx new file mode 100644 index 00000000000..8ce8925d534 --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-card-with-subdued-background/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {AlphaCard, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaCardExample() { + return ( + + + Content inside a card + + + ); +} + +export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/app/examples/alpha-card-with-varying-padding/page.tsx b/polaris.shopify.com/app/examples/alpha-card-with-varying-padding/page.tsx new file mode 100644 index 00000000000..1d6cb7a0a0d --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-card-with-varying-padding/page.tsx @@ -0,0 +1,48 @@ +'use client'; + +import {AlphaCard, Text, AlphaStack} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaCardExample() { + return ( + + + + + + + + + + + + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/app/examples/alpha-stack-default/page.tsx b/polaris.shopify.com/app/examples/alpha-stack-default/page.tsx new file mode 100644 index 00000000000..1324cc92ecb --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-stack-default/page.tsx @@ -0,0 +1,49 @@ +'use client'; + +import React from 'react'; +import {AlphaStack, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaStackExample() { + return ( + + + + + + ); +} + +const Placeholder = ({ + label = '', + height = 'auto', + width = 'auto', + childWidth = 'auto', +}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(AlphaStackExample); diff --git a/polaris.shopify.com/app/examples/alpha-stack-with-align/page.tsx b/polaris.shopify.com/app/examples/alpha-stack-with-align/page.tsx new file mode 100644 index 00000000000..b5b8258daa9 --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-stack-with-align/page.tsx @@ -0,0 +1,64 @@ +'use client'; + +import React from 'react'; +import {AlphaStack, Page, Inline, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaStackWithAlignExample() { + return ( + + + + + + + + + + + + + + + + + + + + ); +} + +const Placeholder = ({ + label = '', + height = 'auto', + width = 'auto', + childAlign, +}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(AlphaStackWithAlignExample); diff --git a/polaris.shopify.com/app/examples/alpha-stack-with-full-width-children/page.tsx b/polaris.shopify.com/app/examples/alpha-stack-with-full-width-children/page.tsx new file mode 100644 index 00000000000..94c0ff8e051 --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-stack-with-full-width-children/page.tsx @@ -0,0 +1,49 @@ +'use client'; + +import React from 'react'; +import {AlphaStack, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaStackWithFullWidthChildrenExample() { + return ( + + + + + + ); +} + +const Placeholder = ({ + label = '', + height = 'auto', + width = '100%', + childWidth = 'auto', +}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(AlphaStackWithFullWidthChildrenExample); diff --git a/polaris.shopify.com/app/examples/alpha-stack-with-gap/page.tsx b/polaris.shopify.com/app/examples/alpha-stack-with-gap/page.tsx new file mode 100644 index 00000000000..69c4f57b3cc --- /dev/null +++ b/polaris.shopify.com/app/examples/alpha-stack-with-gap/page.tsx @@ -0,0 +1,66 @@ +'use client'; + +import React from 'react'; +import {AlphaStack, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AlphaStackWithGapExample() { + return ( + + + + + + + + ); +} + +const SpacingBackground = ({children, width}) => { + return ( +
+ {children} +
+ ); +}; + +const Placeholder = ({ + label = '', + height = 'auto', + width = 'auto', + childWidth = 'auto', +}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(AlphaStackWithGapExample); diff --git a/polaris.shopify.com/app/examples/app-provider-default/page.tsx b/polaris.shopify.com/app/examples/app-provider-default/page.tsx new file mode 100644 index 00000000000..4fe7236ae0f --- /dev/null +++ b/polaris.shopify.com/app/examples/app-provider-default/page.tsx @@ -0,0 +1,72 @@ +'use client'; + +import { + AppProvider, + Page, + LegacyCard, + ResourceList, + Avatar, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AppProviderExample() { + return ( + + + + { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+
+ ); +} + +export default withPolarisExample(AppProviderExample); diff --git a/polaris.shopify.com/app/examples/app-provider-with-i18n/page.tsx b/polaris.shopify.com/app/examples/app-provider-with-i18n/page.tsx new file mode 100644 index 00000000000..d5fcd145768 --- /dev/null +++ b/polaris.shopify.com/app/examples/app-provider-with-i18n/page.tsx @@ -0,0 +1,72 @@ +'use client'; + +import { + AppProvider, + Page, + LegacyCard, + ResourceList, + Avatar, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AppProviderI18NExample() { + return ( + + + + { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+
+ ); +} + +export default withPolarisExample(AppProviderI18NExample); diff --git a/polaris.shopify.com/app/examples/app-provider-with-link-component/page.tsx b/polaris.shopify.com/app/examples/app-provider-with-link-component/page.tsx new file mode 100644 index 00000000000..b375fd4b618 --- /dev/null +++ b/polaris.shopify.com/app/examples/app-provider-with-link-component/page.tsx @@ -0,0 +1,48 @@ +'use client'; + +import {AppProvider, Page} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AppProviderLinkExample() { + const CustomLinkComponent = ({children, url, ...rest}) => { + return ( + console.log('Custom link clicked')} + {...rest} + > + {children} + + ); + }; + + return ( + + +

Page content

+
+
+ ); +} + +export default withPolarisExample(AppProviderLinkExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-default/page.tsx b/polaris.shopify.com/app/examples/autocomplete-default/page.tsx new file mode 100644 index 00000000000..8e0a1b523f7 --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-default/page.tsx @@ -0,0 +1,78 @@ +'use client'; + +import {Autocomplete, Icon} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutocompleteExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + }, + [deselectedOptions], + ); + + const updateSelection = useCallback( + (selected) => { + const selectedValue = selected.map((selectedItem) => { + const matchedOption = options.find((option) => { + return option.value.match(selectedItem); + }); + return matchedOption && matchedOption.label; + }); + + setSelectedOptions(selected); + setInputValue(selectedValue[0]); + }, + [options], + ); + + const textField = ( + } + placeholder="Search" + /> + ); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-action/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-action/page.tsx new file mode 100644 index 00000000000..72ca6b08c11 --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-action/page.tsx @@ -0,0 +1,101 @@ +'use client'; + +import {Autocomplete, Icon} from '@shopify/polaris'; +import {SearchMinor, CirclePlusMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutocompleteActionBeforeExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + const [loading, setLoading] = useState(false); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (!loading) { + setLoading(true); + } + + setTimeout(() => { + if (value === '') { + setOptions(deselectedOptions); + setLoading(false); + return; + } + const filterRegex = new RegExp(value, 'i'); + const resultOptions = options.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + setLoading(false); + }, 300); + }, + [deselectedOptions, loading, options], + ); + + const updateSelection = useCallback( + (selected) => { + const selectedText = selected.map((selectedItem) => { + const matchedOption = options.find((option) => { + return option.value.match(selectedItem); + }); + return matchedOption && matchedOption.label; + }); + setSelectedOptions(selected); + setInputValue(selectedText[0]); + }, + [options], + ); + + const textField = ( + } + placeholder="Search" + /> + ); + + return ( +
+ { + console.log('actionBefore clicked!'); + }, + }} + options={options} + selected={selectedOptions} + onSelect={updateSelection} + listTitle="Suggested tags" + loading={loading} + textField={textField} + /> +
+ ); +} + +export default withPolarisExample(AutocompleteActionBeforeExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-destructive-action/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-destructive-action/page.tsx new file mode 100644 index 00000000000..ff5021e781a --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-destructive-action/page.tsx @@ -0,0 +1,96 @@ +'use client'; + +import {Autocomplete, Icon} from '@shopify/polaris'; +import {SearchMinor, DeleteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutocompleteActionBeforeExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + const [loading, setLoading] = useState(false); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (!loading) { + setLoading(true); + } + + setTimeout(() => { + if (value === '') { + setOptions(deselectedOptions); + setLoading(false); + return; + } + const filterRegex = new RegExp(value, 'i'); + const resultOptions = options.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + setLoading(false); + }, 300); + }, + [deselectedOptions, loading, options], + ); + + const updateSelection = useCallback( + (selected) => { + const selectedText = selected.map((selectedItem) => { + const matchedOption = options.find((option) => { + return option.value.match(selectedItem); + }); + return matchedOption && matchedOption.label; + }); + setSelectedOptions(selected); + setInputValue(selectedText[0]); + }, + [options], + ); + + const textField = ( + } + placeholder="Search" + /> + ); + + return ( +
+ { + console.log('actionBefore clicked!'); + }, + }} + options={options} + selected={selectedOptions} + onSelect={updateSelection} + listTitle="Suggested tags" + loading={loading} + textField={textField} + /> +
+ ); +} + +export default withPolarisExample(AutocompleteActionBeforeExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-empty-state/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-empty-state/page.tsx new file mode 100644 index 00000000000..30401a6eaad --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-empty-state/page.tsx @@ -0,0 +1,96 @@ +'use client'; + +import {Autocomplete, Icon, TextContainer} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import React, {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutocompleteExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + const [loading, setLoading] = useState(false); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (!loading) { + setLoading(true); + } + + setTimeout(() => { + if (value === '') { + setOptions(deselectedOptions); + setLoading(false); + return; + } + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + setLoading(false); + }, 300); + }, + [deselectedOptions, loading], + ); + + const updateSelection = useCallback( + (selected) => { + const selectedText = selected.map((selectedItem) => { + const matchedOption = options.find((option) => { + return option.value.match(selectedItem); + }); + return matchedOption && matchedOption.label; + }); + setSelectedOptions(selected); + setInputValue(selectedText[0]); + }, + [options], + ); + + const textField = ( + } + placeholder="Search" + /> + ); + + const emptyState = ( + + +
+ Could not find any results +
+
+ ); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-lazy-loading/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-lazy-loading/page.tsx new file mode 100644 index 00000000000..fc96df4b7d7 --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-lazy-loading/page.tsx @@ -0,0 +1,132 @@ +'use client'; + +import {Autocomplete, Tag, LegacyStack} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutoCompleteLazyLoadExample() { + const paginationInterval = 25; + const deselectedOptions = Array.from(Array(100)).map((_, index) => ({ + value: `rustic ${index + 1}`, + label: `Rustic ${index + 1}`, + })); + + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + const [isLoading, setIsLoading] = useState(false); + const [willLoadMoreResults, setWillLoadMoreResults] = useState(true); + const [visibleOptionIndex, setVisibleOptionIndex] = + useState(paginationInterval); + + const handleLoadMoreResults = useCallback(() => { + if (willLoadMoreResults) { + setIsLoading(true); + + setTimeout(() => { + const remainingOptionCount = options.length - visibleOptionIndex; + const nextVisibleOptionIndex = + remainingOptionCount >= paginationInterval + ? visibleOptionIndex + paginationInterval + : visibleOptionIndex + remainingOptionCount; + + setIsLoading(false); + setVisibleOptionIndex(nextVisibleOptionIndex); + + if (remainingOptionCount <= paginationInterval) { + setWillLoadMoreResults(false); + } + }, 1000); + } + }, [willLoadMoreResults, visibleOptionIndex, options.length]); + + const removeTag = useCallback( + (tag) => () => { + const options = [...selectedOptions]; + options.splice(options.indexOf(tag), 1); + setSelectedOptions(options); + }, + [selectedOptions], + ); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + + let endIndex = resultOptions.length - 1; + if (resultOptions.length === 0) { + endIndex = 0; + } + setOptions(resultOptions); + setInputValue; + }, + [deselectedOptions], + ); + + const textField = ( + + ); + + const hasSelectedOptions = selectedOptions.length > 0; + + const tagsMarkup = hasSelectedOptions + ? selectedOptions.map((option) => { + let tagLabel = ''; + tagLabel = option.replace('_', ' '); + tagLabel = titleCase(tagLabel); + return ( + + {tagLabel} + + ); + }) + : null; + const optionList = options.slice(0, visibleOptionIndex); + const selectedTagMarkup = hasSelectedOptions ? ( + {tagsMarkup} + ) : null; + + return ( + + {selectedTagMarkup} + + + ); + + function titleCase(string) { + return string + .toLowerCase() + .split(' ') + .map((word) => { + return word.replace(word[0], word[0].toUpperCase()); + }) + .join(' '); + } +} + +export default withPolarisExample(AutoCompleteLazyLoadExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-loading/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-loading/page.tsx new file mode 100644 index 00000000000..83b10b35cbf --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-loading/page.tsx @@ -0,0 +1,86 @@ +'use client'; + +import {Autocomplete, Icon} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutocompleteExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + const [loading, setLoading] = useState(false); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (!loading) { + setLoading(true); + } + + setTimeout(() => { + if (value === '') { + setOptions(deselectedOptions); + setLoading(false); + return; + } + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + setLoading(false); + }, 300); + }, + [deselectedOptions, loading], + ); + + const updateSelection = useCallback( + (selected) => { + const selectedText = selected.map((selectedItem) => { + const matchedOption = options.find((option) => { + return option.value.match(selectedItem); + }); + return matchedOption && matchedOption.label; + }); + setSelectedOptions(selected); + setInputValue(selectedText[0]); + }, + [options], + ); + + const textField = ( + } + placeholder="Search" + /> + ); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-multiple-sections/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-multiple-sections/page.tsx new file mode 100644 index 00000000000..af51fec1451 --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-multiple-sections/page.tsx @@ -0,0 +1,106 @@ +'use client'; + +import {Autocomplete, Icon} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutocompleteExample() { + const deselectedOptions = useMemo( + () => [ + { + title: 'Frequently used', + options: [ + {value: 'ups', label: 'UPS'}, + {value: 'usps', label: 'USPS'}, + ], + }, + { + title: 'All carriers', + options: [ + {value: 'dhl', label: 'DHL Express'}, + {value: 'canada_post', label: 'Canada Post'}, + ], + }, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = []; + + deselectedOptions.forEach((opt) => { + const lol = opt.options.filter((option) => + option.label.match(filterRegex), + ); + + resultOptions.push({ + title: opt.title, + options: lol, + }); + }); + + setOptions(resultOptions); + }, + [deselectedOptions], + ); + + const updateSelection = useCallback( + ([selected]) => { + let selectedValue; + + options.forEach(({options: opt}) => { + if (selectedValue) { + return; + } + + const matchedOption = opt.find((option) => + option.value.match(selected), + ); + + if (matchedOption) { + selectedValue = matchedOption.label; + } + }); + + setSelectedOptions([selected]); + setInputValue(String(selectedValue) ? String(selectedValue) : ''); + }, + [options], + ); + + const textField = ( + } + placeholder="Search" + /> + ); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-multiple-tags/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-multiple-tags/page.tsx new file mode 100644 index 00000000000..3bc8eb15b8a --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-multiple-tags/page.tsx @@ -0,0 +1,101 @@ +'use client'; + +import {LegacyStack, Tag, Autocomplete} from '@shopify/polaris'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultiAutocompleteExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState(['rustic']); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + let endIndex = resultOptions.length - 1; + if (resultOptions.length === 0) { + endIndex = 0; + } + setOptions(resultOptions); + }, + [deselectedOptions], + ); + + const removeTag = useCallback( + (tag) => () => { + const options = [...selectedOptions]; + options.splice(options.indexOf(tag), 1); + setSelectedOptions(options); + }, + [selectedOptions], + ); + + const verticalContentMarkup = + selectedOptions.length > 0 ? ( + + {selectedOptions.map((option) => { + let tagLabel = ''; + tagLabel = option.replace('_', ' '); + tagLabel = titleCase(tagLabel); + return ( + + {tagLabel} + + ); + })} + + ) : null; + + const textField = ( + + ); + + return ( +
+ +
+ ); + + function titleCase(string) { + return string + .toLowerCase() + .split(' ') + .map((word) => word.replace(word[0], word[0].toUpperCase())) + .join(''); + } +} + +export default withPolarisExample(MultiAutocompleteExample); diff --git a/polaris.shopify.com/app/examples/autocomplete-with-wrapping-action/page.tsx b/polaris.shopify.com/app/examples/autocomplete-with-wrapping-action/page.tsx new file mode 100644 index 00000000000..a7c3ab48d0d --- /dev/null +++ b/polaris.shopify.com/app/examples/autocomplete-with-wrapping-action/page.tsx @@ -0,0 +1,103 @@ +'use client'; + +import {Autocomplete, Icon} from '@shopify/polaris'; +import {SearchMinor, CirclePlusMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AutocompleteActionBeforeExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + const [loading, setLoading] = useState(false); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (!loading) { + setLoading(true); + } + + setTimeout(() => { + if (value === '') { + setOptions(deselectedOptions); + setLoading(false); + return; + } + const filterRegex = new RegExp(value, 'i'); + const resultOptions = options.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + setLoading(false); + }, 300); + }, + [deselectedOptions, loading, options], + ); + + const updateSelection = useCallback( + (selected) => { + const selectedText = selected.map((selectedItem) => { + const matchedOption = options.find((option) => { + return option.value.match(selectedItem); + }); + return matchedOption && matchedOption.label; + }); + setSelectedOptions(selected); + setInputValue(selectedText[0]); + }, + [options], + ); + + const textField = ( + } + placeholder="Search" + /> + ); + + return ( +
+ { + console.log('actionBefore clicked!'); + }, + }} + options={options} + selected={selectedOptions} + onSelect={updateSelection} + listTitle="Suggested tags" + loading={loading} + textField={textField} + /> +
+ ); +} + +export default withPolarisExample(AutocompleteActionBeforeExample); diff --git a/polaris.shopify.com/app/examples/avatar-default/page.tsx b/polaris.shopify.com/app/examples/avatar-default/page.tsx new file mode 100644 index 00000000000..5442776fd00 --- /dev/null +++ b/polaris.shopify.com/app/examples/avatar-default/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Avatar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AvatarExample() { + return ; +} + +export default withPolarisExample(AvatarExample); diff --git a/polaris.shopify.com/app/examples/avatar-extra-small/page.tsx b/polaris.shopify.com/app/examples/avatar-extra-small/page.tsx new file mode 100644 index 00000000000..3dacdeac6bf --- /dev/null +++ b/polaris.shopify.com/app/examples/avatar-extra-small/page.tsx @@ -0,0 +1,38 @@ +'use client'; + +import {Button, Popover, ActionList, Avatar} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ExtraSmallAvatarExample() { + const [active, setActive] = useState(true); + const toggleActive = useCallback(() => setActive((active) => !active), []); + const activator = ( + + ); + + return ( +
+ + , + }, + { + content: 'Farrah Fawcett', + prefix: ( + + ), + }, + ]} + /> + +
+ ); +} + +export default withPolarisExample(ExtraSmallAvatarExample); diff --git a/polaris.shopify.com/app/examples/avatar-square/page.tsx b/polaris.shopify.com/app/examples/avatar-square/page.tsx new file mode 100644 index 00000000000..44d7c35198f --- /dev/null +++ b/polaris.shopify.com/app/examples/avatar-square/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Avatar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function AvatarExample() { + return ; +} + +export default withPolarisExample(AvatarExample); diff --git a/polaris.shopify.com/app/examples/badge-attention/page.tsx b/polaris.shopify.com/app/examples/badge-attention/page.tsx new file mode 100644 index 00000000000..acee1aa27a7 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-attention/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return Open; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-complete/page.tsx b/polaris.shopify.com/app/examples/badge-complete/page.tsx new file mode 100644 index 00000000000..840036f2651 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-complete/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return Fulfilled; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-critical/page.tsx b/polaris.shopify.com/app/examples/badge-critical/page.tsx new file mode 100644 index 00000000000..3bb916228d2 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-critical/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return Action required; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-default/page.tsx b/polaris.shopify.com/app/examples/badge-default/page.tsx new file mode 100644 index 00000000000..510f7e8078b --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-default/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return Fulfilled; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-incomplete/page.tsx b/polaris.shopify.com/app/examples/badge-incomplete/page.tsx new file mode 100644 index 00000000000..a944fc7d703 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-incomplete/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return ( + + Unfulfilled + + ); +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-informational/page.tsx b/polaris.shopify.com/app/examples/badge-informational/page.tsx new file mode 100644 index 00000000000..e78072b1ef5 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-informational/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return Draft; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-partially-complete/page.tsx b/polaris.shopify.com/app/examples/badge-partially-complete/page.tsx new file mode 100644 index 00000000000..0dd4c2ba7d6 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-partially-complete/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return ( + + Partially fulfilled + + ); +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-small/page.tsx b/polaris.shopify.com/app/examples/badge-small/page.tsx new file mode 100644 index 00000000000..911c3e491f4 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-small/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return Fulfilled; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-success/page.tsx b/polaris.shopify.com/app/examples/badge-success/page.tsx new file mode 100644 index 00000000000..60f8f81ee6a --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-success/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return Active; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-warning/page.tsx b/polaris.shopify.com/app/examples/badge-warning/page.tsx new file mode 100644 index 00000000000..552d841c931 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-warning/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return On hold; +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/badge-with-status-and-progress-label-override/page.tsx b/polaris.shopify.com/app/examples/badge-with-status-and-progress-label-override/page.tsx new file mode 100644 index 00000000000..e97d536dd58 --- /dev/null +++ b/polaris.shopify.com/app/examples/badge-with-status-and-progress-label-override/page.tsx @@ -0,0 +1,19 @@ +'use client'; + +import {Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BadgeExample() { + return ( + + Published + + ); +} + +export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/app/examples/banner-critical/page.tsx b/polaris.shopify.com/app/examples/banner-critical/page.tsx new file mode 100644 index 00000000000..43963c1f084 --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-critical/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {Banner, Link} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + +

+ Before fulfilling this order or capturing payment, please{' '} + review the Risk Analysis and determine if this order + is fraudulent. +

+
+ ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/banner-default/page.tsx b/polaris.shopify.com/app/examples/banner-default/page.tsx new file mode 100644 index 00000000000..622bda3d1c7 --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-default/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {Banner} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + {}}> +

This order was archived on March 7, 2017 at 3:12pm EDT.

+
+ ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/banner-dismissible/page.tsx b/polaris.shopify.com/app/examples/banner-dismissible/page.tsx new file mode 100644 index 00000000000..b1cebeb199a --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-dismissible/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {Banner, Link} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + {}}> +

+ Use your finance report to get detailed information about your business.{' '} + Let us know what you think +

+
+ ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/banner-in-a-card/page.tsx b/polaris.shopify.com/app/examples/banner-in-a-card/page.tsx new file mode 100644 index 00000000000..11963250011 --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-in-a-card/page.tsx @@ -0,0 +1,24 @@ +'use client'; + +import {LegacyCard, TextContainer, Banner, Link} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + + + {}}> +

+ Use your finance report to get detailed information about your + business. Let us know what you think +

+
+ +

View a summary of your online store’s performance.

+
+
+ ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/banner-in-a-modal/page.tsx b/polaris.shopify.com/app/examples/banner-in-a-modal/page.tsx new file mode 100644 index 00000000000..533c8a943a3 --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-in-a-modal/page.tsx @@ -0,0 +1,49 @@ +'use client'; + +import {Button, Modal, TextContainer, Banner} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerInModalExample() { + const [active, setActive] = useState(false); + + const handleChange = useCallback(() => setActive(!active), [active]); + + return ( +
+ + + + + +

+ Connect your instagram account to your shop before proceeding. +

+
+

+ Use Instagram posts to share your products with millions of + people. Let shoppers buy from your store without leaving + Instagram. +

+
+
+
+
+ ); +} + +export default withPolarisExample(BannerInModalExample); diff --git a/polaris.shopify.com/app/examples/banner-informational/page.tsx b/polaris.shopify.com/app/examples/banner-informational/page.tsx new file mode 100644 index 00000000000..5538464bd8b --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-informational/page.tsx @@ -0,0 +1,21 @@ +'use client'; + +import {Banner} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + {}} + > +

Make sure you know how these changes affect your store.

+
+ ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/banner-success/page.tsx b/polaris.shopify.com/app/examples/banner-success/page.tsx new file mode 100644 index 00000000000..f648eee1f5b --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-success/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {Banner} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + {}} + /> + ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/banner-warning/page.tsx b/polaris.shopify.com/app/examples/banner-warning/page.tsx new file mode 100644 index 00000000000..1a7d69d29e7 --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-warning/page.tsx @@ -0,0 +1,24 @@ +'use client'; + +import {Banner, List} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + + + + The name of the city you’re shipping to has characters that aren’t + allowed. City name can only include spaces and hyphens. + + + + ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/banner-with-focus/page.tsx b/polaris.shopify.com/app/examples/banner-with-focus/page.tsx new file mode 100644 index 00000000000..9e218812912 --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-with-focus/page.tsx @@ -0,0 +1,27 @@ +'use client'; + +import {Banner} from '@shopify/polaris'; +import {useEffect, useRef} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerWithFocusExample() { + const banner = useRef(); + + useEffect(() => banner.current.focus(), []); + + return ( + {}} + status="critical" + ref={banner} + > +

+ Before fulfilling this order or capturing payment, please review the + fraud analysis and determine if this order is fraudulent +

+
+ ); +} + +export default withPolarisExample(BannerWithFocusExample); diff --git a/polaris.shopify.com/app/examples/banner-with-footer-call-to-action/page.tsx b/polaris.shopify.com/app/examples/banner-with-footer-call-to-action/page.tsx new file mode 100644 index 00000000000..6b96cca9b8d --- /dev/null +++ b/polaris.shopify.com/app/examples/banner-with-footer-call-to-action/page.tsx @@ -0,0 +1,24 @@ +'use client'; + +import {Banner} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BannerExample() { + return ( + {}} + > +

+ Add weights to show accurate rates at checkout and when buying shipping + labels in Shopify. +

+
+ ); +} + +export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/app/examples/bleed-all-directions/page.tsx b/polaris.shopify.com/app/examples/bleed-all-directions/page.tsx new file mode 100644 index 00000000000..e6d9986a0c4 --- /dev/null +++ b/polaris.shopify.com/app/examples/bleed-all-directions/page.tsx @@ -0,0 +1,43 @@ +'use client'; + +import React from 'react'; +import {Bleed, Box, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BleedAllDirectionsExample() { + return ( + + + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(BleedAllDirectionsExample); diff --git a/polaris.shopify.com/app/examples/bleed-horizontal/page.tsx b/polaris.shopify.com/app/examples/bleed-horizontal/page.tsx new file mode 100644 index 00000000000..7bf5822f5b4 --- /dev/null +++ b/polaris.shopify.com/app/examples/bleed-horizontal/page.tsx @@ -0,0 +1,43 @@ +'use client'; + +import React from 'react'; +import {Bleed, Box, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BleedHorizontalExample() { + return ( + + + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(BleedHorizontalExample); diff --git a/polaris.shopify.com/app/examples/bleed-specific-direction/page.tsx b/polaris.shopify.com/app/examples/bleed-specific-direction/page.tsx new file mode 100644 index 00000000000..bba3b996aae --- /dev/null +++ b/polaris.shopify.com/app/examples/bleed-specific-direction/page.tsx @@ -0,0 +1,60 @@ +'use client'; + +import React from 'react'; +import {AlphaStack, Bleed, Box, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BleedSpecificDirectionExample() { + return ( + + + + + + + + + + + + + + + + + + + + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(BleedSpecificDirectionExample); diff --git a/polaris.shopify.com/app/examples/bleed-vertical/page.tsx b/polaris.shopify.com/app/examples/bleed-vertical/page.tsx new file mode 100644 index 00000000000..cded710fec8 --- /dev/null +++ b/polaris.shopify.com/app/examples/bleed-vertical/page.tsx @@ -0,0 +1,43 @@ +'use client'; + +import React from 'react'; +import {Bleed, Box, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BleedVerticalExample() { + return ( + + + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(BleedVerticalExample); diff --git a/polaris.shopify.com/app/examples/box-default/page.tsx b/polaris.shopify.com/app/examples/box-default/page.tsx new file mode 100644 index 00000000000..faf15b50fde --- /dev/null +++ b/polaris.shopify.com/app/examples/box-default/page.tsx @@ -0,0 +1,38 @@ +'use client'; + +import React from 'react'; +import {Box, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BoxDefaultExample() { + return ( + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(BoxDefaultExample); diff --git a/polaris.shopify.com/app/examples/box-with-border-radius/page.tsx b/polaris.shopify.com/app/examples/box-with-border-radius/page.tsx new file mode 100644 index 00000000000..eca5d453ea2 --- /dev/null +++ b/polaris.shopify.com/app/examples/box-with-border-radius/page.tsx @@ -0,0 +1,39 @@ +'use client'; + +import React from 'react'; +import {Box, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BoxWithBorderRadiusExample() { + return ( + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(BoxWithBorderRadiusExample); diff --git a/polaris.shopify.com/app/examples/box-with-border/page.tsx b/polaris.shopify.com/app/examples/box-with-border/page.tsx new file mode 100644 index 00000000000..1a899b8b0a8 --- /dev/null +++ b/polaris.shopify.com/app/examples/box-with-border/page.tsx @@ -0,0 +1,38 @@ +'use client'; + +import React from 'react'; +import {Box, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BoxWithBorderExample() { + return ( + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(BoxWithBorderExample); diff --git a/polaris.shopify.com/app/examples/box-with-color/page.tsx b/polaris.shopify.com/app/examples/box-with-color/page.tsx new file mode 100644 index 00000000000..61f08786d46 --- /dev/null +++ b/polaris.shopify.com/app/examples/box-with-color/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import React from 'react'; +import {Box, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BoxWithColorExample() { + return ( + + + Content inside a box + + + ); +} + +export default withPolarisExample(BoxWithColorExample); diff --git a/polaris.shopify.com/app/examples/box-with-padding/page.tsx b/polaris.shopify.com/app/examples/box-with-padding/page.tsx new file mode 100644 index 00000000000..4af28562538 --- /dev/null +++ b/polaris.shopify.com/app/examples/box-with-padding/page.tsx @@ -0,0 +1,73 @@ +'use client'; + +import React from 'react'; +import {AlphaStack, Box, LegacyStack, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BoxWithPaddingExample() { + return ( + +
+ + + +
+ +
+ + + +
+
+ + + +
+
+ +
+ + + +
+
+ + + +
+
+
+ ); +} + +const Placeholder = ({ + label = '', + height = 'auto', + width = 'auto', + childAlign, +}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(BoxWithPaddingExample); diff --git a/polaris.shopify.com/app/examples/box-with-shadow/page.tsx b/polaris.shopify.com/app/examples/box-with-shadow/page.tsx new file mode 100644 index 00000000000..288e06dcb4c --- /dev/null +++ b/polaris.shopify.com/app/examples/box-with-shadow/page.tsx @@ -0,0 +1,38 @@ +'use client'; + +import React from 'react'; +import {Box, Text} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function BoxWithShadowExample() { + return ( + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+
+ + {label} + +
+
+ ); +}; + +export default withPolarisExample(BoxWithShadowExample); diff --git a/polaris.shopify.com/app/examples/button-default/page.tsx b/polaris.shopify.com/app/examples/button-default/page.tsx new file mode 100644 index 00000000000..c529b08698c --- /dev/null +++ b/polaris.shopify.com/app/examples/button-default/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-destructive/page.tsx b/polaris.shopify.com/app/examples/button-destructive/page.tsx new file mode 100644 index 00000000000..7db123b2cda --- /dev/null +++ b/polaris.shopify.com/app/examples/button-destructive/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-disabled-state/page.tsx b/polaris.shopify.com/app/examples/button-disabled-state/page.tsx new file mode 100644 index 00000000000..a2cf5a4f186 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-disabled-state/page.tsx @@ -0,0 +1,35 @@ +'use client'; + +import {ButtonGroup, Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ( + + + + + + + + + + + + ); +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-full-width/page.tsx b/polaris.shopify.com/app/examples/button-full-width/page.tsx new file mode 100644 index 00000000000..74c7d7f2773 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-full-width/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-group-default/page.tsx b/polaris.shopify.com/app/examples/button-group-default/page.tsx new file mode 100644 index 00000000000..48231b3b3ae --- /dev/null +++ b/polaris.shopify.com/app/examples/button-group-default/page.tsx @@ -0,0 +1,16 @@ +'use client'; + +import {ButtonGroup, Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonGroupExample() { + return ( + + + + + ); +} + +export default withPolarisExample(ButtonGroupExample); diff --git a/polaris.shopify.com/app/examples/button-group-outline-with-segmented-buttons/page.tsx b/polaris.shopify.com/app/examples/button-group-outline-with-segmented-buttons/page.tsx new file mode 100644 index 00000000000..054c6e3a92c --- /dev/null +++ b/polaris.shopify.com/app/examples/button-group-outline-with-segmented-buttons/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {ButtonGroup, Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonGroupExample() { + return ( + + + + + + ); +} + +export default withPolarisExample(ButtonGroupExample); diff --git a/polaris.shopify.com/app/examples/button-group-with-segmented-buttons/page.tsx b/polaris.shopify.com/app/examples/button-group-with-segmented-buttons/page.tsx new file mode 100644 index 00000000000..fc5553c7db5 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-group-with-segmented-buttons/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {ButtonGroup, Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonGroupExample() { + return ( + + + + + + ); +} + +export default withPolarisExample(ButtonGroupExample); diff --git a/polaris.shopify.com/app/examples/button-large/page.tsx b/polaris.shopify.com/app/examples/button-large/page.tsx new file mode 100644 index 00000000000..01cac04b2df --- /dev/null +++ b/polaris.shopify.com/app/examples/button-large/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-loading-state/page.tsx b/polaris.shopify.com/app/examples/button-loading-state/page.tsx new file mode 100644 index 00000000000..fc69d84665d --- /dev/null +++ b/polaris.shopify.com/app/examples/button-loading-state/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-outline-monochrome/page.tsx b/polaris.shopify.com/app/examples/button-outline-monochrome/page.tsx new file mode 100644 index 00000000000..22ba54ac480 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-outline-monochrome/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ( +
+ +
+ ); +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-outline/page.tsx b/polaris.shopify.com/app/examples/button-outline/page.tsx new file mode 100644 index 00000000000..7b840543274 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-outline/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-plain-destructive/page.tsx b/polaris.shopify.com/app/examples/button-plain-destructive/page.tsx new file mode 100644 index 00000000000..1383bfa38ab --- /dev/null +++ b/polaris.shopify.com/app/examples/button-plain-destructive/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ( + + ); +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-plain-disclosure/page.tsx b/polaris.shopify.com/app/examples/button-plain-disclosure/page.tsx new file mode 100644 index 00000000000..5af5ed7be2f --- /dev/null +++ b/polaris.shopify.com/app/examples/button-plain-disclosure/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DisclosureButton() { + const [expanded, setExpanded] = useState(false); + + return ( + + ); +} + +export default withPolarisExample(DisclosureButton); diff --git a/polaris.shopify.com/app/examples/button-plain-monochrome/page.tsx b/polaris.shopify.com/app/examples/button-plain-monochrome/page.tsx new file mode 100644 index 00000000000..c51d15e3386 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-plain-monochrome/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ( +
+ Could not retrieve data.{' '} + +
+ ); +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-plain/page.tsx b/polaris.shopify.com/app/examples/button-plain/page.tsx new file mode 100644 index 00000000000..652202202a5 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-plain/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-pressed/page.tsx b/polaris.shopify.com/app/examples/button-pressed/page.tsx new file mode 100644 index 00000000000..5dc439622f5 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-pressed/page.tsx @@ -0,0 +1,32 @@ +'use client'; + +import {ButtonGroup, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function PressedButton() { + const [isFirstButtonActive, setIsFirstButtonActive] = useState(true); + + const handleFirstButtonClick = useCallback(() => { + if (isFirstButtonActive) return; + setIsFirstButtonActive(true); + }, [isFirstButtonActive]); + + const handleSecondButtonClick = useCallback(() => { + if (!isFirstButtonActive) return; + setIsFirstButtonActive(false); + }, [isFirstButtonActive]); + + return ( + + + + + ); +} + +export default withPolarisExample(PressedButton); diff --git a/polaris.shopify.com/app/examples/button-primary/page.tsx b/polaris.shopify.com/app/examples/button-primary/page.tsx new file mode 100644 index 00000000000..42e68edec1f --- /dev/null +++ b/polaris.shopify.com/app/examples/button-primary/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-right-aligned-disclosure/page.tsx b/polaris.shopify.com/app/examples/button-right-aligned-disclosure/page.tsx new file mode 100644 index 00000000000..59efb92e6e1 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-right-aligned-disclosure/page.tsx @@ -0,0 +1,24 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RightAlignedDisclosureButton() { + const [expanded, setExpanded] = useState(false); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(RightAlignedDisclosureButton); diff --git a/polaris.shopify.com/app/examples/button-select-disclosure/page.tsx b/polaris.shopify.com/app/examples/button-select-disclosure/page.tsx new file mode 100644 index 00000000000..03f80f0c704 --- /dev/null +++ b/polaris.shopify.com/app/examples/button-select-disclosure/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ( +
+ +
+ ); +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-slim/page.tsx b/polaris.shopify.com/app/examples/button-slim/page.tsx new file mode 100644 index 00000000000..e5bbb3e961a --- /dev/null +++ b/polaris.shopify.com/app/examples/button-slim/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ; +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-split/page.tsx b/polaris.shopify.com/app/examples/button-split/page.tsx new file mode 100644 index 00000000000..7c5120a093b --- /dev/null +++ b/polaris.shopify.com/app/examples/button-split/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ( +
+ +
+ ); +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/button-text-aligned/page.tsx b/polaris.shopify.com/app/examples/button-text-aligned/page.tsx new file mode 100644 index 00000000000..b268d99f97c --- /dev/null +++ b/polaris.shopify.com/app/examples/button-text-aligned/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ButtonExample() { + return ( + + ); +} + +export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/app/examples/callout-card-default/page.tsx b/polaris.shopify.com/app/examples/callout-card-default/page.tsx new file mode 100644 index 00000000000..db89ae7f974 --- /dev/null +++ b/polaris.shopify.com/app/examples/callout-card-default/page.tsx @@ -0,0 +1,22 @@ +'use client'; + +import {CalloutCard} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( + +

Upload your store’s logo, change colors and fonts, and more.

+
+ ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/callout-card-dismissable/page.tsx b/polaris.shopify.com/app/examples/callout-card-dismissable/page.tsx new file mode 100644 index 00000000000..9cd4b6f5181 --- /dev/null +++ b/polaris.shopify.com/app/examples/callout-card-dismissable/page.tsx @@ -0,0 +1,20 @@ +'use client'; + +import {CalloutCard} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( + {}} + > +

Upload your store’s logo, change colors and fonts, and more.

+
+ ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/callout-card-with-secondary-action/page.tsx b/polaris.shopify.com/app/examples/callout-card-with-secondary-action/page.tsx new file mode 100644 index 00000000000..0d4a590373f --- /dev/null +++ b/polaris.shopify.com/app/examples/callout-card-with-secondary-action/page.tsx @@ -0,0 +1,20 @@ +'use client'; + +import {CalloutCard} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( + +

Upload your store’s logo, change colors and fonts, and more.

+
+ ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/card-default/page.tsx b/polaris.shopify.com/app/examples/card-default/page.tsx new file mode 100644 index 00000000000..1463c51aecf --- /dev/null +++ b/polaris.shopify.com/app/examples/card-default/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {Card} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + +

View a summary of your online store’s performance.

+
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-a-subdued-section/page.tsx b/polaris.shopify.com/app/examples/card-with-a-subdued-section/page.tsx new file mode 100644 index 00000000000..de1f769169d --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-a-subdued-section/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {Card, List} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + + Felix Crafford + Ezequiel Manno + + + + + Felix Crafford + Ezequiel Manno + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-all-elements/page.tsx b/polaris.shopify.com/app/examples/card-with-all-elements/page.tsx new file mode 100644 index 00000000000..0ed02b8f47b --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-all-elements/page.tsx @@ -0,0 +1,98 @@ +'use client'; + +import { + Card, + Popover, + Button, + ActionList, + TextContainer, + ResourceList, + LegacyStack, + List, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + + View Sales + + } + onClose={() => {}} + > + + + + + + You can use sales reports to see information about your customers’ + orders based on criteria such as sales over time, by channel, or by + staff. + + + + { + const {sales, amount, url} = item; + return ( + + + {sales} + {amount} + + + ); + }} + /> + + + + Payouts + Total Sales By Channel + + + + + The sales reports are available only if your store is on the Shopify + plan or higher. + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-custom-footer-actions/page.tsx b/polaris.shopify.com/app/examples/card-with-custom-footer-actions/page.tsx new file mode 100644 index 00000000000..bccc9439d66 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-custom-footer-actions/page.tsx @@ -0,0 +1,29 @@ +'use client'; + +import {LegacyCard, LegacyStack, ButtonGroup, Button} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + +

+ Two-step authentication adds an extra layer of security when logging + in to your account. A special code will be required each time you + log in, ensuring only you can access your account. +

+ + + + + + +
+
+
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-custom-react-node-title/page.tsx b/polaris.shopify.com/app/examples/card-with-custom-react-node-title/page.tsx new file mode 100644 index 00000000000..e3a3c1a81a6 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-custom-react-node-title/page.tsx @@ -0,0 +1,30 @@ +'use client'; + +import {Card, LegacyStack, Icon, List, Text} from '@shopify/polaris'; +import {ProductsMajor} from '@shopify/polaris-icons'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + + + New Products + + + } + > + + Socks + Super Shoes + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-destructive-action/page.tsx b/polaris.shopify.com/app/examples/card-with-destructive-action/page.tsx new file mode 100644 index 00000000000..06cca26d28e --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-destructive-action/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {Card} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + +

John Smith

+
+ +

john.smith@example.com

+
+
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-destructive-footer-action/page.tsx b/polaris.shopify.com/app/examples/card-with-destructive-footer-action/page.tsx new file mode 100644 index 00000000000..5b416b28b42 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-destructive-footer-action/page.tsx @@ -0,0 +1,24 @@ +'use client'; + +import {Card, List} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + + 1 × Oasis Glass, 4-Pack + 1 × Anubis Cup, 2-Pack + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-flushed-sections/page.tsx b/polaris.shopify.com/app/examples/card-with-flushed-sections/page.tsx new file mode 100644 index 00000000000..598b492f855 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-flushed-sections/page.tsx @@ -0,0 +1,27 @@ +'use client'; + +import {Card, Image, TextContainer} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + a sheet with purple and orange stripes + + + + You can use sales reports to see information about your customers’ + orders based on criteria such as sales over time, by channel, or by + staff. + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-footer-actions/page.tsx b/polaris.shopify.com/app/examples/card-with-footer-actions/page.tsx new file mode 100644 index 00000000000..9f65b791fe3 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-footer-actions/page.tsx @@ -0,0 +1,24 @@ +'use client'; + +import {Card, List} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + + 1 × Oasis Glass, 4-Pack + 1 × Anubis Cup, 2-Pack + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-header-actions/page.tsx b/polaris.shopify.com/app/examples/card-with-header-actions/page.tsx new file mode 100644 index 00000000000..187e9fc92f9 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-header-actions/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {Card} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + +

+ Add variants if this product comes in multiple versions, like different + sizes or colors. +

+
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-multiple-footer-actions/page.tsx b/polaris.shopify.com/app/examples/card-with-multiple-footer-actions/page.tsx new file mode 100644 index 00000000000..2046d864c43 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-multiple-footer-actions/page.tsx @@ -0,0 +1,27 @@ +'use client'; + +import {Card, List} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + + 1 × Oasis Glass, 4-Pack + 1 × Anubis Cup, 2-Pack + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-multiple-sections/page.tsx b/polaris.shopify.com/app/examples/card-with-multiple-sections/page.tsx new file mode 100644 index 00000000000..45dfb4e9808 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-multiple-sections/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {Card} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + +

View a summary of your online store’s performance.

+
+ +

+ View a summary of your online store’s performance, including sales, + visitors, top products, and referrals. +

+
+
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-multiple-titled-sections/page.tsx b/polaris.shopify.com/app/examples/card-with-multiple-titled-sections/page.tsx new file mode 100644 index 00000000000..24c857811fd --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-multiple-titled-sections/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {Card} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + +

View a summary of your online store’s performance.

+
+ +

+ View a summary of your online store’s performance, including sales, + visitors, top products, and referrals. +

+
+
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-sections-and-actions/page.tsx b/polaris.shopify.com/app/examples/card-with-sections-and-actions/page.tsx new file mode 100644 index 00000000000..a7a8c478de8 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-sections-and-actions/page.tsx @@ -0,0 +1,20 @@ +'use client'; + +import {Card} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + +

John Smith

+
+ +

john.smith@example.com

+
+
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-separate-header/page.tsx b/polaris.shopify.com/app/examples/card-with-separate-header/page.tsx new file mode 100644 index 00000000000..de2e287b803 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-separate-header/page.tsx @@ -0,0 +1,40 @@ +'use client'; + +import {Card, Popover, Button, ActionList, List} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + + Add account + + } + onClose={() => {}} + > + + + + + + Felix Crafford + Ezequiel Manno + + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-subdued-for-secondary-content/page.tsx b/polaris.shopify.com/app/examples/card-with-subdued-for-secondary-content/page.tsx new file mode 100644 index 00000000000..53668469e33 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-subdued-for-secondary-content/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {Card, List} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + + Felix Crafford + Ezequiel Manno + + + ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/card-with-subsection/page.tsx b/polaris.shopify.com/app/examples/card-with-subsection/page.tsx new file mode 100644 index 00000000000..0852a8245d5 --- /dev/null +++ b/polaris.shopify.com/app/examples/card-with-subsection/page.tsx @@ -0,0 +1,38 @@ +'use client'; + +import {Card} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CardExample() { + return ( + + +

John Smith

+
+ + + 123 First St +
+ Somewhere +
+ The Universe +
+ + 123 Second St +
+ Somewhere +
+ The Universe +
+
+ + + A single subsection without a sibling has no visual appearance + + +
+ ); +} + +export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/app/examples/checkbox-default/page.tsx b/polaris.shopify.com/app/examples/checkbox-default/page.tsx new file mode 100644 index 00000000000..bb1f7bb5c9c --- /dev/null +++ b/polaris.shopify.com/app/examples/checkbox-default/page.tsx @@ -0,0 +1,20 @@ +'use client'; + +import {Checkbox} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CheckboxExample() { + const [checked, setChecked] = useState(false); + const handleChange = useCallback((newChecked) => setChecked(newChecked), []); + + return ( + + ); +} + +export default withPolarisExample(CheckboxExample); diff --git a/polaris.shopify.com/app/examples/choice-list-default/page.tsx b/polaris.shopify.com/app/examples/choice-list-default/page.tsx new file mode 100644 index 00000000000..0a2e69600d3 --- /dev/null +++ b/polaris.shopify.com/app/examples/choice-list-default/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {ChoiceList} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SingleChoiceListExample() { + const [selected, setSelected] = useState(['hidden']); + + const handleChange = useCallback((value) => setSelected(value), []); + + return ( + + ); +} + +export default withPolarisExample(SingleChoiceListExample); diff --git a/polaris.shopify.com/app/examples/choice-list-with-children-content/page.tsx b/polaris.shopify.com/app/examples/choice-list-with-children-content/page.tsx new file mode 100644 index 00000000000..abb37ca3a51 --- /dev/null +++ b/polaris.shopify.com/app/examples/choice-list-with-children-content/page.tsx @@ -0,0 +1,51 @@ +'use client'; + +import {TextField, ChoiceList} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SingleOrMultiChoiceListWithChildrenContextExample() { + const [selected, setSelected] = useState(['none']); + const [textFieldValue, setTextFieldValue] = useState(''); + + const handleChoiceListChange = useCallback((value) => setSelected(value), []); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + const renderChildren = useCallback( + () => ( + + ), + [handleTextFieldChange, textFieldValue], + ); + + return ( + + ); +} + +export default withPolarisExample( + SingleOrMultiChoiceListWithChildrenContextExample, +); diff --git a/polaris.shopify.com/app/examples/choice-list-with-dynamic-children-content/page.tsx b/polaris.shopify.com/app/examples/choice-list-with-dynamic-children-content/page.tsx new file mode 100644 index 00000000000..0225459df87 --- /dev/null +++ b/polaris.shopify.com/app/examples/choice-list-with-dynamic-children-content/page.tsx @@ -0,0 +1,54 @@ +'use client'; + +import {TextField, ChoiceList} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SingleOrMultuChoiceListWithChildrenContextWhenSelectedExample() { + const [selected, setSelected] = useState(['none']); + const [textFieldValue, setTextFieldValue] = useState(''); + + const handleChoiceListChange = useCallback((value) => setSelected(value), []); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + const renderChildren = useCallback( + (isSelected) => + isSelected && ( + + ), + [handleTextFieldChange, textFieldValue], + ); + + return ( +
+ +
+ ); +} + +export default withPolarisExample( + SingleOrMultuChoiceListWithChildrenContextWhenSelectedExample, +); diff --git a/polaris.shopify.com/app/examples/choice-list-with-error/page.tsx b/polaris.shopify.com/app/examples/choice-list-with-error/page.tsx new file mode 100644 index 00000000000..59c8d4ff616 --- /dev/null +++ b/polaris.shopify.com/app/examples/choice-list-with-error/page.tsx @@ -0,0 +1,27 @@ +'use client'; + +import {ChoiceList} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ChoiceListWithErrorExample() { + const [selected, setSelected] = useState('hidden'); + + const handleChange = useCallback((value) => setSelected(value), []); + + return ( + + ); +} + +export default withPolarisExample(ChoiceListWithErrorExample); diff --git a/polaris.shopify.com/app/examples/choice-list-with-multi-choice/page.tsx b/polaris.shopify.com/app/examples/choice-list-with-multi-choice/page.tsx new file mode 100644 index 00000000000..0892b640c74 --- /dev/null +++ b/polaris.shopify.com/app/examples/choice-list-with-multi-choice/page.tsx @@ -0,0 +1,36 @@ +'use client'; + +import {ChoiceList} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultiChoiceListExample() { + const [selected, setSelected] = useState(['hidden']); + + const handleChange = useCallback((value) => setSelected(value), []); + + return ( + + ); +} + +export default withPolarisExample(MultiChoiceListExample); diff --git a/polaris.shopify.com/app/examples/collapsible-default/page.tsx b/polaris.shopify.com/app/examples/collapsible-default/page.tsx new file mode 100644 index 00000000000..ac55b4ac1ac --- /dev/null +++ b/polaris.shopify.com/app/examples/collapsible-default/page.tsx @@ -0,0 +1,51 @@ +'use client'; + +import { + LegacyCard, + LegacyStack, + Button, + Collapsible, + TextContainer, + Link, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function CollapsibleExample() { + const [open, setOpen] = useState(true); + + const handleToggle = useCallback(() => setOpen((open) => !open), []); + + return ( +
+ + + + + +

+ Your mailing list lets you contact customers or visitors who + have shown an interest in your store. Reach out to them with + exclusive offers or updates about your products. +

+ Test link +
+
+
+
+
+ ); +} + +export default withPolarisExample(CollapsibleExample); diff --git a/polaris.shopify.com/app/examples/color-picker-default/page.tsx b/polaris.shopify.com/app/examples/color-picker-default/page.tsx new file mode 100644 index 00000000000..cb6149434f5 --- /dev/null +++ b/polaris.shopify.com/app/examples/color-picker-default/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {ColorPicker} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ColorPickerExample() { + const [color, setColor] = useState({ + hue: 120, + brightness: 1, + saturation: 1, + }); + + return ; +} + +export default withPolarisExample(ColorPickerExample); diff --git a/polaris.shopify.com/app/examples/color-picker-with-transparent-value-full-width/page.tsx b/polaris.shopify.com/app/examples/color-picker-with-transparent-value-full-width/page.tsx new file mode 100644 index 00000000000..a1999c5d7cf --- /dev/null +++ b/polaris.shopify.com/app/examples/color-picker-with-transparent-value-full-width/page.tsx @@ -0,0 +1,22 @@ +'use client'; + +import {ColorPicker} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ColorPickerWithTransparentValueExample() { + const [color, setColor] = useState({ + hue: 300, + brightness: 1, + saturation: 0.7, + alpha: 0.7, + }); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(ColorPickerWithTransparentValueExample); diff --git a/polaris.shopify.com/app/examples/color-picker-with-transparent-value/page.tsx b/polaris.shopify.com/app/examples/color-picker-with-transparent-value/page.tsx new file mode 100644 index 00000000000..1c46a3bc09d --- /dev/null +++ b/polaris.shopify.com/app/examples/color-picker-with-transparent-value/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {ColorPicker} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ColorPickerWithTransparentValueExample() { + const [color, setColor] = useState({ + hue: 300, + brightness: 1, + saturation: 0.7, + alpha: 0.7, + }); + + return ; +} + +export default withPolarisExample(ColorPickerWithTransparentValueExample); diff --git a/polaris.shopify.com/app/examples/columns-default/page.tsx b/polaris.shopify.com/app/examples/columns-default/page.tsx new file mode 100644 index 00000000000..cd2a554ff72 --- /dev/null +++ b/polaris.shopify.com/app/examples/columns-default/page.tsx @@ -0,0 +1,47 @@ +'use client'; + +import React from 'react'; +import {Columns, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ColumnsExample() { + return ( + + + + + + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(ColumnsExample); diff --git a/polaris.shopify.com/app/examples/columns-with-fixed-widths/page.tsx b/polaris.shopify.com/app/examples/columns-with-fixed-widths/page.tsx new file mode 100644 index 00000000000..a5c5d0aed2d --- /dev/null +++ b/polaris.shopify.com/app/examples/columns-with-fixed-widths/page.tsx @@ -0,0 +1,47 @@ +'use client'; + +import React from 'react'; +import {Columns, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ColumnsWithFreeAndFixedWidthsExample() { + return ( + + + + + + + + + ); +} + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(ColumnsWithFreeAndFixedWidthsExample); diff --git a/polaris.shopify.com/app/examples/columns-with-set-number/page.tsx b/polaris.shopify.com/app/examples/columns-with-set-number/page.tsx new file mode 100644 index 00000000000..9341e2b6b96 --- /dev/null +++ b/polaris.shopify.com/app/examples/columns-with-set-number/page.tsx @@ -0,0 +1,69 @@ +'use client'; + +import React from 'react'; +import {Columns, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ColumnsWithSetNumberExample() { + return ( + + + + + + + ); +} + +const SpacingBackground = ({children, width = '100%'}) => { + return ( +
+ {children} +
+ ); +}; + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(ColumnsWithSetNumberExample); diff --git a/polaris.shopify.com/app/examples/columns-with-varying-gap/page.tsx b/polaris.shopify.com/app/examples/columns-with-varying-gap/page.tsx new file mode 100644 index 00000000000..e88ce666eef --- /dev/null +++ b/polaris.shopify.com/app/examples/columns-with-varying-gap/page.tsx @@ -0,0 +1,64 @@ +'use client'; + +import React from 'react'; +import {Columns, Text, Inline} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ColumnsWithVaryingGapExample() { + return ( + + + + + + + + + + + ); +} + +const SpacingBackground = ({children, width = '100%'}) => { + return ( +
+ {children} +
+ ); +}; + +const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { + return ( +
+ +
+ + {label} + +
+
+
+ ); +}; + +export default withPolarisExample(ColumnsWithVaryingGapExample); diff --git a/polaris.shopify.com/app/examples/combobox-default/page.tsx b/polaris.shopify.com/app/examples/combobox-default/page.tsx new file mode 100644 index 00000000000..4524792769c --- /dev/null +++ b/polaris.shopify.com/app/examples/combobox-default/page.tsx @@ -0,0 +1,94 @@ +'use client'; + +import {Listbox, Combobox, Icon} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ComboboxExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + + const [selectedOption, setSelectedOption] = useState(); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + }, + [deselectedOptions], + ); + + const updateSelection = useCallback( + (selected) => { + const matchedOption = options.find((option) => { + return option.value.match(selected); + }); + + setSelectedOption(selected); + setInputValue((matchedOption && matchedOption.label) || ''); + }, + [options], + ); + + const optionsMarkup = + options.length > 0 + ? options.map((option) => { + const {label, value} = option; + + return ( + + {label} + + ); + }) + : null; + + return ( +
+ } + onChange={updateText} + label="Search tags" + labelHidden + value={inputValue} + placeholder="Search tags" + /> + } + > + {options.length > 0 ? ( + {optionsMarkup} + ) : null} + +
+ ); +} + +export default withPolarisExample(ComboboxExample); diff --git a/polaris.shopify.com/app/examples/combobox-with-loading/page.tsx b/polaris.shopify.com/app/examples/combobox-with-loading/page.tsx new file mode 100644 index 00000000000..ef0a8addef4 --- /dev/null +++ b/polaris.shopify.com/app/examples/combobox-with-loading/page.tsx @@ -0,0 +1,110 @@ +'use client'; + +import {Listbox, Combobox, Icon} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function LoadingAutocompleteExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + + const [selectedOption, setSelectedOption] = useState(); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + const [loading, setLoading] = useState(false); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (!loading) { + setLoading(true); + } + + setTimeout(() => { + if (value === '') { + setOptions(deselectedOptions); + setLoading(false); + return; + } + const filterRegex = new RegExp(value, 'i'); + const resultOptions = options.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + setLoading(false); + }, 300); + }, + [deselectedOptions, loading, options], + ); + + const updateSelection = useCallback( + (selected) => { + const matchedOption = options.find((option) => { + return option.value.match(selected); + }); + + setSelectedOption(selected); + setInputValue((matchedOption && matchedOption.label) || ''); + }, + [options], + ); + + const optionsMarkup = + options.length > 0 + ? options.map((option) => { + const {label, value} = option; + + return ( + + {label} + + ); + }) + : null; + + const loadingMarkup = loading ? : null; + + const listboxMarkup = + optionsMarkup || loadingMarkup ? ( + + {optionsMarkup && !loading ? optionsMarkup : null} + {loadingMarkup} + + ) : null; + + return ( +
+ } + onChange={updateText} + label="Search tags" + labelHidden + value={inputValue} + placeholder="Search tags" + /> + } + > + {listboxMarkup} + +
+ ); +} + +export default withPolarisExample(LoadingAutocompleteExample); diff --git a/polaris.shopify.com/app/examples/combobox-with-manual-selection/page.tsx b/polaris.shopify.com/app/examples/combobox-with-manual-selection/page.tsx new file mode 100644 index 00000000000..64a9367402b --- /dev/null +++ b/polaris.shopify.com/app/examples/combobox-with-manual-selection/page.tsx @@ -0,0 +1,130 @@ +'use client'; + +import { + Tag, + Listbox, + Combobox, + Icon, + TextContainer, + LegacyStack, + AutoSelection, +} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultiComboboxExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + }, + [deselectedOptions], + ); + + const updateSelection = useCallback( + (selected) => { + if (selectedOptions.includes(selected)) { + setSelectedOptions( + selectedOptions.filter((option) => option !== selected), + ); + } else { + setSelectedOptions([...selectedOptions, selected]); + } + + const matchedOption = options.find((option) => { + return option.value.match(selected); + }); + + updateText(''); + }, + [options, selectedOptions, updateText], + ); + + const removeTag = useCallback( + (tag) => () => { + const options = [...selectedOptions]; + options.splice(options.indexOf(tag), 1); + setSelectedOptions(options); + }, + [selectedOptions], + ); + + const tagsMarkup = selectedOptions.map((option) => ( + + {option} + + )); + + const optionsMarkup = + options.length > 0 + ? options.map((option) => { + const {label, value} = option; + + return ( + + {label} + + ); + }) + : null; + + return ( +
+ } + onChange={updateText} + label="Search tags" + labelHidden + value={inputValue} + placeholder="Search tags" + /> + } + > + {optionsMarkup ? ( + + {optionsMarkup} + + ) : null} + + + {tagsMarkup} + +
+ ); +} + +export default withPolarisExample(MultiComboboxExample); diff --git a/polaris.shopify.com/app/examples/combobox-with-multi-select-and-manual-selection/page.tsx b/polaris.shopify.com/app/examples/combobox-with-multi-select-and-manual-selection/page.tsx new file mode 100644 index 00000000000..29f4ba761cb --- /dev/null +++ b/polaris.shopify.com/app/examples/combobox-with-multi-select-and-manual-selection/page.tsx @@ -0,0 +1,129 @@ +'use client'; + +import { + Tag, + Listbox, + Combobox, + Icon, + TextContainer, + LegacyStack, +} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultiManualComboboxExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + }, + [deselectedOptions], + ); + + const updateSelection = useCallback( + (selected) => { + if (selectedOptions.includes(selected)) { + setSelectedOptions( + selectedOptions.filter((option) => option !== selected), + ); + } else { + setSelectedOptions([...selectedOptions, selected]); + } + + const matchedOption = options.find((option) => { + return option.value.match(selected); + }); + + updateText(''); + }, + [options, selectedOptions, updateText], + ); + + const removeTag = useCallback( + (tag) => () => { + const options = [...selectedOptions]; + options.splice(options.indexOf(tag), 1); + setSelectedOptions(options); + }, + [selectedOptions], + ); + + const tagsMarkup = selectedOptions.map((option) => ( + + {option} + + )); + + const optionsMarkup = + options.length > 0 + ? options.map((option) => { + const {label, value} = option; + + return ( + + {label} + + ); + }) + : null; + + return ( +
+ } + onChange={updateText} + label="Search tags" + labelHidden + value={inputValue} + placeholder="Search tags" + /> + } + > + {optionsMarkup ? ( + + {optionsMarkup} + + ) : null} + + + {tagsMarkup} + +
+ ); +} + +export default withPolarisExample(MultiManualComboboxExample); diff --git a/polaris.shopify.com/app/examples/combobox-with-multi-select-and-vertical-content/page.tsx b/polaris.shopify.com/app/examples/combobox-with-multi-select-and-vertical-content/page.tsx new file mode 100644 index 00000000000..9dfd65ef14c --- /dev/null +++ b/polaris.shopify.com/app/examples/combobox-with-multi-select-and-vertical-content/page.tsx @@ -0,0 +1,174 @@ +'use client'; + +import { + LegacyStack, + Tag, + Listbox, + EmptySearchResult, + Combobox, + Text, +} from '@shopify/polaris'; +import {useState, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultiselectTagComboboxExample() { + const [selectedTags, setSelectedTags] = useState(['Rustic']); + const [value, setValue] = useState(''); + const [suggestion, setSuggestion] = useState(''); + + const handleActiveOptionChange = useCallback( + (activeOption) => { + const activeOptionIsAction = activeOption === value; + + if (!activeOptionIsAction && !selectedTags.includes(activeOption)) { + setSuggestion(activeOption); + } else { + setSuggestion(''); + } + }, + [value, selectedTags], + ); + const updateSelection = useCallback( + (selected) => { + const nextSelectedTags = new Set([...selectedTags]); + + if (nextSelectedTags.has(selected)) { + nextSelectedTags.delete(selected); + } else { + nextSelectedTags.add(selected); + } + setSelectedTags([...nextSelectedTags]); + setValue(''); + setSuggestion(''); + }, + [selectedTags], + ); + + const removeTag = useCallback( + (tag) => () => { + updateSelection(tag); + }, + [updateSelection], + ); + + const getAllTags = useCallback(() => { + const savedTags = ['Rustic', 'Antique', 'Vinyl', 'Vintage', 'Refurbished']; + return [...new Set([...savedTags, ...selectedTags].sort())]; + }, [selectedTags]); + + const formatOptionText = useCallback( + (option) => { + const trimValue = value.trim().toLocaleLowerCase(); + const matchIndex = option.toLocaleLowerCase().indexOf(trimValue); + + if (!value || matchIndex === -1) return option; + + const start = option.slice(0, matchIndex); + const highlight = option.slice(matchIndex, matchIndex + trimValue.length); + const end = option.slice(matchIndex + trimValue.length, option.length); + + return ( +

+ {start} + + {highlight} + + {end} +

+ ); + }, + [value], + ); + + const options = useMemo(() => { + let list; + const allTags = getAllTags(); + const filterRegex = new RegExp(value, 'i'); + + if (value) { + list = allTags.filter((tag) => tag.match(filterRegex)); + } else { + list = allTags; + } + + return [...list]; + }, [value, getAllTags]); + + const verticalContentMarkup = + selectedTags.length > 0 ? ( + + {selectedTags.map((tag) => ( + + {tag} + + ))} + + ) : null; + + const optionMarkup = + options.length > 0 + ? options.map((option) => { + return ( + + + {formatOptionText(option)} + + + ); + }) + : null; + + const noResults = value && !getAllTags().includes(value); + + const actionMarkup = noResults ? ( + {`Add "${value}"`} + ) : null; + + const emptyStateMarkup = optionMarkup ? null : ( + + ); + + const listboxMarkup = + optionMarkup || actionMarkup || emptyStateMarkup ? ( + + {actionMarkup} + {optionMarkup} + + ) : null; + + return ( +
+ + } + > + {listboxMarkup} + +
+ ); +} + +export default withPolarisExample(MultiselectTagComboboxExample); diff --git a/polaris.shopify.com/app/examples/combobox-with-multi-select/page.tsx b/polaris.shopify.com/app/examples/combobox-with-multi-select/page.tsx new file mode 100644 index 00000000000..5e69b905f70 --- /dev/null +++ b/polaris.shopify.com/app/examples/combobox-with-multi-select/page.tsx @@ -0,0 +1,130 @@ +'use client'; + +import { + LegacyStack, + Tag, + Listbox, + Combobox, + Icon, + TextContainer, +} from '@shopify/polaris'; + +import {SearchMinor} from '@shopify/polaris-icons'; + +import {useState, useCallback, useMemo} from 'react'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultiAutoComboboxExample() { + const deselectedOptions = useMemo( + () => [ + {value: 'rustic', label: 'Rustic'}, + {value: 'antique', label: 'Antique'}, + {value: 'vinyl', label: 'Vinyl'}, + {value: 'vintage', label: 'Vintage'}, + {value: 'refurbished', label: 'Refurbished'}, + ], + [], + ); + + const [selectedOptions, setSelectedOptions] = useState([]); + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState(deselectedOptions); + + const updateText = useCallback( + (value) => { + setInputValue(value); + + if (value === '') { + setOptions(deselectedOptions); + return; + } + + const filterRegex = new RegExp(value, 'i'); + const resultOptions = deselectedOptions.filter((option) => + option.label.match(filterRegex), + ); + setOptions(resultOptions); + }, + [deselectedOptions], + ); + + const updateSelection = useCallback( + (selected) => { + if (selectedOptions.includes(selected)) { + setSelectedOptions( + selectedOptions.filter((option) => option !== selected), + ); + } else { + setSelectedOptions([...selectedOptions, selected]); + } + + const matchedOption = options.find((option) => { + return option.value.match(selected); + }); + + updateText(''); + }, + [options, selectedOptions, updateText], + ); + + const removeTag = useCallback( + (tag) => () => { + const options = [...selectedOptions]; + options.splice(options.indexOf(tag), 1); + setSelectedOptions(options); + }, + [selectedOptions], + ); + + const tagsMarkup = selectedOptions.map((option) => ( + + {option} + + )); + + const optionsMarkup = + options.length > 0 + ? options.map((option) => { + const {label, value} = option; + + return ( + + {label} + + ); + }) + : null; + + return ( +
+ } + onChange={updateText} + label="Search tags" + labelHidden + value={inputValue} + placeholder="Search tags" + /> + } + > + {optionsMarkup ? ( + {optionsMarkup} + ) : null} + + + {tagsMarkup} + +
+ ); +} + +export default withPolarisExample(MultiAutoComboboxExample); diff --git a/polaris.shopify.com/app/examples/contextual-save-bar-default/page.tsx b/polaris.shopify.com/app/examples/contextual-save-bar-default/page.tsx new file mode 100644 index 00000000000..24191e28754 --- /dev/null +++ b/polaris.shopify.com/app/examples/contextual-save-bar-default/page.tsx @@ -0,0 +1,33 @@ +'use client'; + +import {Frame, ContextualSaveBar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( +
+ + console.log('add form submit logic'), + loading: false, + disabled: false, + }} + discardAction={{ + onAction: () => console.log('add clear form logic'), + }} + /> + +
+ ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/contextual-save-bar-with-flush-contents/page.tsx b/polaris.shopify.com/app/examples/contextual-save-bar-with-flush-contents/page.tsx new file mode 100644 index 00000000000..5004a81b161 --- /dev/null +++ b/polaris.shopify.com/app/examples/contextual-save-bar-with-flush-contents/page.tsx @@ -0,0 +1,32 @@ +'use client'; + +import {Frame, ContextualSaveBar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( +
+ + console.log('add form submit logic'), + }} + discardAction={{ + onAction: () => console.log('add clear form logic'), + }} + /> + +
+ ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/contextual-save-bar-with-full-width/page.tsx b/polaris.shopify.com/app/examples/contextual-save-bar-with-full-width/page.tsx new file mode 100644 index 00000000000..86ff88d55ff --- /dev/null +++ b/polaris.shopify.com/app/examples/contextual-save-bar-with-full-width/page.tsx @@ -0,0 +1,34 @@ +'use client'; + +import {Frame, ContextualSaveBar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( +
+ + console.log('add form submit logic'), + loading: false, + disabled: false, + }} + discardAction={{ + onAction: () => console.log('add clear form logic'), + }} + /> + +
+ ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/data-table-default/page.tsx b/polaris.shopify.com/app/examples/data-table-default/page.tsx new file mode 100644 index 00000000000..7b0b4b76976 --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-default/page.tsx @@ -0,0 +1,46 @@ +'use client'; + +import {Page, LegacyCard, DataTable} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DataTableExample() { + const rows = [ + ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], + ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], + [ + 'Navy Merino Wool Blazer with khaki chinos and yellow belt', + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + return ( + + + + + + ); +} + +export default withPolarisExample(DataTableExample); diff --git a/polaris.shopify.com/app/examples/data-table-sortable/page.tsx b/polaris.shopify.com/app/examples/data-table-sortable/page.tsx new file mode 100644 index 00000000000..0a2a4bcfdbb --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-sortable/page.tsx @@ -0,0 +1,67 @@ +'use client'; + +import {Page, LegacyCard, DataTable} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SortableDataTableExample() { + const [sortedRows, setSortedRows] = useState(null); + + const initiallySortedRows = [ + ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], + ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], + [ + 'Navy Merino Wool Blazer with khaki chinos and yellow belt', + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + const rows = sortedRows ? sortedRows : initiallySortedRows; + + const handleSort = useCallback( + (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), + [rows], + ); + + return ( + + + + + + ); + + function sortCurrency(rows, index, direction) { + return [...rows].sort((rowA, rowB) => { + const amountA = parseFloat(rowA[index].substring(1)); + const amountB = parseFloat(rowB[index].substring(1)); + + return direction === 'descending' ? amountB - amountA : amountA - amountB; + }); + } +} + +export default withPolarisExample(SortableDataTableExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-all-of-its-elements/page.tsx b/polaris.shopify.com/app/examples/data-table-with-all-of-its-elements/page.tsx new file mode 100644 index 00000000000..c98a04ce4c6 --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-all-of-its-elements/page.tsx @@ -0,0 +1,98 @@ +'use client'; + +import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FullDataTableExample() { + const [sortedRows, setSortedRows] = useState(null); + + const initiallySortedRows = [ + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + const rows = sortedRows ? sortedRows : initiallySortedRows; + const handleSort = useCallback( + (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), + [rows], + ); + + return ( + + + + + + ); + + function sortCurrency(rows, index, direction) { + return [...rows].sort((rowA, rowB) => { + const amountA = parseFloat(rowA[index].substring(1)); + const amountB = parseFloat(rowB[index].substring(1)); + + return direction === 'descending' ? amountB - amountA : amountA - amountB; + }); + } +} + +export default withPolarisExample(FullDataTableExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-custom-totals-heading/page.tsx b/polaris.shopify.com/app/examples/data-table-with-custom-totals-heading/page.tsx new file mode 100644 index 00000000000..9cb461418d8 --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-custom-totals-heading/page.tsx @@ -0,0 +1,51 @@ +'use client'; + +import {Page, LegacyCard, DataTable} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DataTableExample() { + const rows = [ + ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], + ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], + [ + 'Navy Merino Wool Blazer with khaki chinos and yellow belt', + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + return ( + + + + + + ); +} + +export default withPolarisExample(DataTableExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-fixed-first-columns/page.tsx b/polaris.shopify.com/app/examples/data-table-with-fixed-first-columns/page.tsx new file mode 100644 index 00000000000..038868220cf --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-fixed-first-columns/page.tsx @@ -0,0 +1,340 @@ +'use client'; + +import {Link, Page, LegacyCard, DataTable, useBreakpoints} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DataTableWithFixedFirstColumnsExample() { + const rows = [ + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + '$14,250.00', + '$12,240.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + '$12,240.00', + '$11,270.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + '$10,241.00', + '$10,201.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + '$14,240.00', + '$14,200.10', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + '$14,300.30', + '$17,200.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + '$18,770.07', + '$15,545.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + '$14,240.00', + '$14,240.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + '$19,290.00', + '$12,997.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + '$11,211.20', + '$11,343.50', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + '$12,430.00', + '$17,420.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + '$14,790.00', + '$12,370.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + '$16,241.00', + '$18,211.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + '$15,111.00', + '$11,221.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + '$17,880.00', + '$11,280.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + '$11,111.00', + '$17,211.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + '$14,240.00', + '$17,840.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + '$13,238.00', + '$14,288.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + '$14,988.00', + '$14,902.10', + ], + ]; + const [sortedRows, setSortedRows] = useState(rows); + const {lgDown} = useBreakpoints(); + const fixedFirstColumns = lgDown ? 2 : 0; + + return ( + + + { + setSortedRows( + [...rows].sort((rowA, rowB) => { + const amountA = rowA[index]?.props?.children + ? rowA[index]?.props?.children + : parseFloat(rowA[index].substring(1)); + const amountB = rowB[index]?.props?.children + ? rowB[index]?.props?.children + : parseFloat(rowB[index].substring(1)); + + return ( + direction === 'descending' + ? amountA > amountB + : amountB > amountA + ) + ? 1 + : -1; + }), + ); + }} + footerContent={`Showing ${sortedRows.length} of ${sortedRows.length} results`} + stickyHeader + fixedFirstColumns={fixedFirstColumns} + /> + + + ); +} + +export default withPolarisExample(DataTableWithFixedFirstColumnsExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-footer/page.tsx b/polaris.shopify.com/app/examples/data-table-with-footer/page.tsx new file mode 100644 index 00000000000..25e31b8bb66 --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-footer/page.tsx @@ -0,0 +1,47 @@ +'use client'; + +import {Page, LegacyCard, DataTable} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DataTableFooterExample() { + const rows = [ + ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], + ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], + [ + 'Navy Merino Wool Blazer with khaki chinos and yellow belt', + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + return ( + + + + + + ); +} + +export default withPolarisExample(DataTableFooterExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-increased-density-and-zebra-striping/page.tsx b/polaris.shopify.com/app/examples/data-table-with-increased-density-and-zebra-striping/page.tsx new file mode 100644 index 00000000000..145fa027f65 --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-increased-density-and-zebra-striping/page.tsx @@ -0,0 +1,100 @@ +'use client'; + +import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FullDataTableExample() { + const [sortedRows, setSortedRows] = useState(null); + + const initiallySortedRows = [ + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + const rows = sortedRows ? sortedRows : initiallySortedRows; + const handleSort = useCallback( + (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), + [rows], + ); + + return ( + + + + + + ); + + function sortCurrency(rows, index, direction) { + return [...rows].sort((rowA, rowB) => { + const amountA = parseFloat(rowA[index].substring(1)); + const amountB = parseFloat(rowB[index].substring(1)); + + return direction === 'descending' ? amountB - amountA : amountA - amountB; + }); + } +} + +export default withPolarisExample(FullDataTableExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-row-heading-links/page.tsx b/polaris.shopify.com/app/examples/data-table-with-row-heading-links/page.tsx new file mode 100644 index 00000000000..fc058cd82a3 --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-row-heading-links/page.tsx @@ -0,0 +1,70 @@ +'use client'; + +import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DataTableLinkExample() { + const rows = [ + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$122,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + return ( + + + + + + ); +} + +export default withPolarisExample(DataTableLinkExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-sticky-header-enabled/page.tsx b/polaris.shopify.com/app/examples/data-table-with-sticky-header-enabled/page.tsx new file mode 100644 index 00000000000..8acaa7f5a8a --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-sticky-header-enabled/page.tsx @@ -0,0 +1,296 @@ +'use client'; + +import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FullDataTableExample() { + const [sortedRows, setSortedRows] = useState(null); + + const initiallySortedRows = [ + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + [ + + Emerald Silk Gown + , + '$875.00', + 124689, + 140, + '$121,500.00', + ], + [ + + Mauve Cashmere Scarf + , + '$230.00', + 124533, + 83, + '$19,090.00', + ], + [ + + Navy Merino Wool Blazer with khaki chinos and yellow belt + , + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + const rows = sortedRows ? sortedRows : initiallySortedRows; + const handleSort = useCallback( + (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), + [rows], + ); + + return ( + + + + + + ); + + function sortCurrency(rows, index, direction) { + return [...rows].sort((rowA, rowB) => { + const amountA = parseFloat(rowA[index].substring(1)); + const amountB = parseFloat(rowB[index].substring(1)); + + return direction === 'descending' ? amountB - amountA : amountA - amountB; + }); + } +} + +export default withPolarisExample(FullDataTableExample); diff --git a/polaris.shopify.com/app/examples/data-table-with-totals-in-footer/page.tsx b/polaris.shopify.com/app/examples/data-table-with-totals-in-footer/page.tsx new file mode 100644 index 00000000000..8a7eb10ad24 --- /dev/null +++ b/polaris.shopify.com/app/examples/data-table-with-totals-in-footer/page.tsx @@ -0,0 +1,47 @@ +'use client'; + +import {Page, LegacyCard, DataTable} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DataTableExample() { + const rows = [ + ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], + ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], + [ + 'Navy Merino Wool Blazer with khaki chinos and yellow belt', + '$445.00', + 124518, + 32, + '$14,240.00', + ], + ]; + + return ( + + + + + + ); +} + +export default withPolarisExample(DataTableExample); diff --git a/polaris.shopify.com/app/examples/date-picker-default/page.tsx b/polaris.shopify.com/app/examples/date-picker-default/page.tsx new file mode 100644 index 00000000000..d0e854d5f0f --- /dev/null +++ b/polaris.shopify.com/app/examples/date-picker-default/page.tsx @@ -0,0 +1,30 @@ +'use client'; + +import {DatePicker} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DatePickerExample() { + const [{month, year}, setDate] = useState({month: 1, year: 2018}); + const [selectedDates, setSelectedDates] = useState({ + start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), + end: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), + }); + + const handleMonthChange = useCallback( + (month, year) => setDate({month, year}), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/app/examples/date-picker-multi-month-ranged/page.tsx b/polaris.shopify.com/app/examples/date-picker-multi-month-ranged/page.tsx new file mode 100644 index 00000000000..8e19873f413 --- /dev/null +++ b/polaris.shopify.com/app/examples/date-picker-multi-month-ranged/page.tsx @@ -0,0 +1,32 @@ +'use client'; + +import {DatePicker} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DatePickerExample() { + const [{month, year}, setDate] = useState({month: 1, year: 2018}); + const [selectedDates, setSelectedDates] = useState({ + start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), + end: new Date('Mon Mar 12 2018 00:00:00 GMT-0500 (EST)'), + }); + + const handleMonthChange = useCallback( + (month, year) => setDate({month, year}), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/app/examples/date-picker-ranged/page.tsx b/polaris.shopify.com/app/examples/date-picker-ranged/page.tsx new file mode 100644 index 00000000000..ca6b9b21038 --- /dev/null +++ b/polaris.shopify.com/app/examples/date-picker-ranged/page.tsx @@ -0,0 +1,31 @@ +'use client'; + +import {DatePicker} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DatePickerExample() { + const [{month, year}, setDate] = useState({month: 1, year: 2018}); + const [selectedDates, setSelectedDates] = useState({ + start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), + end: new Date('Sat Feb 10 2018 00:00:00 GMT-0500 (EST)'), + }); + + const handleMonthChange = useCallback( + (month, year) => setDate({month, year}), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/app/examples/date-picker-with-disabled-date-ranges/page.tsx b/polaris.shopify.com/app/examples/date-picker-with-disabled-date-ranges/page.tsx new file mode 100644 index 00000000000..e8c48f1659e --- /dev/null +++ b/polaris.shopify.com/app/examples/date-picker-with-disabled-date-ranges/page.tsx @@ -0,0 +1,33 @@ +'use client'; + +import {DatePicker} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DatePickerExample() { + const [{month, year}, setDate] = useState({month: 1, year: 2018}); + const [selectedDates, setSelectedDates] = useState({ + start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), + end: new Date('Sat Feb 10 2018 00:00:00 GMT-0500 (EST)'), + }); + + const handleMonthChange = useCallback( + (month, year) => setDate({month, year}), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/app/examples/date-picker-with-specific-disabled-dates/page.tsx b/polaris.shopify.com/app/examples/date-picker-with-specific-disabled-dates/page.tsx new file mode 100644 index 00000000000..67b27dfe798 --- /dev/null +++ b/polaris.shopify.com/app/examples/date-picker-with-specific-disabled-dates/page.tsx @@ -0,0 +1,40 @@ +'use client'; + +import {DatePicker} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DatePickerExample() { + const [{month, year}, setDate] = useState({month: 1, year: 2018}); + const [selectedDates, setSelectedDates] = useState( + new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), + ); + + const handleMonthChange = useCallback( + (month, year) => setDate({month, year}), + [], + ); + + const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + + const disableSpecificDates = [ + new Date('Mon Feb 12 2018 00:00:00 GMT-0500 (EST)'), + new Date('Sat Feb 10 2018 00:00:00 GMT-0500 (EST)'), + new Date('Wed Feb 21 2018 00:00:00 GMT-0500 (EST)'), + ]; + + return ( + + ); +} + +export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/app/examples/description-list-default/page.tsx b/polaris.shopify.com/app/examples/description-list-default/page.tsx new file mode 100644 index 00000000000..e48729113ea --- /dev/null +++ b/polaris.shopify.com/app/examples/description-list-default/page.tsx @@ -0,0 +1,31 @@ +'use client'; + +import {DescriptionList} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( + + ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/divider-with-border-styles/page.tsx b/polaris.shopify.com/app/examples/divider-with-border-styles/page.tsx new file mode 100644 index 00000000000..ae90b7c9dd6 --- /dev/null +++ b/polaris.shopify.com/app/examples/divider-with-border-styles/page.tsx @@ -0,0 +1,35 @@ +'use client'; + +import React from 'react'; +import {Divider, Text, AlphaStack} from '@shopify/polaris'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DividerWithBorderStylesExample() { + return ( + + + Base + + + + Dark + + + + Divider + + + + Divider on dark + + + + Transparent + + + + ); +} + +export default withPolarisExample(DividerWithBorderStylesExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-accepts-only-svg-files/page.tsx b/polaris.shopify.com/app/examples/drop-zone-accepts-only-svg-files/page.tsx new file mode 100644 index 00000000000..9af069e321d --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-accepts-only-svg-files/page.tsx @@ -0,0 +1,77 @@ +'use client'; + +import { + LegacyStack, + Thumbnail, + Banner, + List, + DropZone, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneAcceptingSVGFilesExample() { + const [files, setFiles] = useState([]); + const [rejectedFiles, setRejectedFiles] = useState([]); + const hasError = rejectedFiles.length > 0; + + const handleDropZoneDrop = useCallback( + (_dropFiles, acceptedFiles, rejectedFiles) => { + setFiles((files) => [...files, ...acceptedFiles]); + setRejectedFiles(rejectedFiles); + }, + [], + ); + + const uploadedFiles = files.length > 0 && ( + + {files.map((file, index) => ( + + +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ))} +
+ ); + + const errorMessage = hasError && ( + + + {rejectedFiles.map((file, index) => ( + + {`"${file.name}" is not supported. File type must be .svg.`} + + ))} + + + ); + + return ( + + {errorMessage} + + {uploadedFiles} + + + ); +} + +export default withPolarisExample(DropZoneAcceptingSVGFilesExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-default/page.tsx b/polaris.shopify.com/app/examples/drop-zone-default/page.tsx new file mode 100644 index 00000000000..a8c69c2580c --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-default/page.tsx @@ -0,0 +1,54 @@ +'use client'; + +import {DropZone, LegacyStack, Thumbnail, Text} from '@shopify/polaris'; +import {NoteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneExample() { + const [files, setFiles] = useState([]); + + const handleDropZoneDrop = useCallback( + (_dropFiles, acceptedFiles, _rejectedFiles) => + setFiles((files) => [...files, ...acceptedFiles]), + [], + ); + + const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; + + const fileUpload = !files.length && ; + const uploadedFiles = files.length > 0 && ( +
+ + {files.map((file, index) => ( + + +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ))} +
+
+ ); + + return ( + + {uploadedFiles} + {fileUpload} + + ); +} + +export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-medium-sized/page.tsx b/polaris.shopify.com/app/examples/drop-zone-medium-sized/page.tsx new file mode 100644 index 00000000000..ba02f5deadc --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-medium-sized/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {DropZone} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneExample() { + return ( +
+ + + +
+ ); +} + +export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-nested/page.tsx b/polaris.shopify.com/app/examples/drop-zone-nested/page.tsx new file mode 100644 index 00000000000..9e60f2475f2 --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-nested/page.tsx @@ -0,0 +1,62 @@ +'use client'; + +import { + DropZone, + LegacyStack, + Thumbnail, + LegacyCard, + Text, +} from '@shopify/polaris'; +import {NoteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function NestedDropZoneExample() { + const [files, setFiles] = useState([]); + + const handleDrop = useCallback((dropFiles) => { + setFiles((files) => [...files, dropFiles]); + }, []); + + const handleDropZoneClick = useCallback(() => {}, []); + + const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; + + const fileUpload = !files.length && ; + const uploadedFiles = files.length > 0 && ( + + {files.map((file, index) => ( + + +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ))} +
+ ); + + return ( + + + + {uploadedFiles} + {fileUpload} + + + + ); +} + +export default withPolarisExample(NestedDropZoneExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-small-sized/page.tsx b/polaris.shopify.com/app/examples/drop-zone-small-sized/page.tsx new file mode 100644 index 00000000000..25e2ab11550 --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-small-sized/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {DropZone} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneExample() { + return ( +
+ + + +
+ ); +} + +export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-with-a-label/page.tsx b/polaris.shopify.com/app/examples/drop-zone-with-a-label/page.tsx new file mode 100644 index 00000000000..88f90bb5c14 --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-with-a-label/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {DropZone} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneExample() { + return ( + + + + ); +} + +export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-with-custom-file-dialog-trigger/page.tsx b/polaris.shopify.com/app/examples/drop-zone-with-custom-file-dialog-trigger/page.tsx new file mode 100644 index 00000000000..35ed6dd3c6e --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-with-custom-file-dialog-trigger/page.tsx @@ -0,0 +1,76 @@ +'use client'; + +import { + LegacyStack, + Thumbnail, + LegacyCard, + DropZone, + Text, +} from '@shopify/polaris'; +import {NoteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneWithCustomFileDialogExample() { + const [files, setFiles] = useState([]); + const [openFileDialog, setOpenFileDialog] = useState(false); + + const handleDropZoneDrop = useCallback( + (dropFiles, _acceptedFiles, _rejectedFiles) => + setFiles((files) => [...files, ...dropFiles]), + [], + ); + const toggleOpenFileDialog = useCallback( + () => setOpenFileDialog((openFileDialog) => !openFileDialog), + [], + ); + + const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; + + const uploadedFiles = files.length > 0 && ( + + {files.map((file, index) => ( + + -1 + ? window.URL.createObjectURL(file) + : NoteMinor + } + /> +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ))} +
+ ); + + return ( + + + {uploadedFiles} + + + ); +} + +export default withPolarisExample(DropZoneWithCustomFileDialogExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-with-custom-file-upload-text/page.tsx b/polaris.shopify.com/app/examples/drop-zone-with-custom-file-upload-text/page.tsx new file mode 100644 index 00000000000..73809521afb --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-with-custom-file-upload-text/page.tsx @@ -0,0 +1,55 @@ +'use client'; + +import {DropZone, LegacyStack, Thumbnail, Text} from '@shopify/polaris'; +import {NoteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneExample() { + const [files, setFiles] = useState([]); + + const handleDropZoneDrop = useCallback( + (_dropFiles, acceptedFiles, _rejectedFiles) => + setFiles((files) => [...files, ...acceptedFiles]), + [], + ); + + const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; + + const fileUpload = !files.length && ( + + ); + + const uploadedFiles = files.length > 0 && ( + + {files.map((file, index) => ( + + +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ))} +
+ ); + + return ( + + {uploadedFiles} + {fileUpload} + + ); +} + +export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-with-drop-on-page/page.tsx b/polaris.shopify.com/app/examples/drop-zone-with-drop-on-page/page.tsx new file mode 100644 index 00000000000..01912072bb0 --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-with-drop-on-page/page.tsx @@ -0,0 +1,67 @@ +'use client'; + +import {LegacyStack, Thumbnail, DropZone, Page, Text} from '@shopify/polaris'; +import {NoteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneWithDropOnPageExample() { + const [files, setFiles] = useState([]); + + const handleDropZoneDrop = useCallback( + (dropFiles, _acceptedFiles, _rejectedFiles) => + setFiles((files) => [...files, ...dropFiles]), + [], + ); + + const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; + + const uploadedFiles = files.length > 0 && ( + + {files.map((file, index) => ( + + +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ))} +
+ ); + + const uploadMessage = !uploadedFiles && ; + + return ( + + + {uploadedFiles} + {uploadMessage} + + + ); +} + +export default withPolarisExample(DropZoneWithDropOnPageExample); diff --git a/polaris.shopify.com/app/examples/drop-zone-with-image-file-upload/page.tsx b/polaris.shopify.com/app/examples/drop-zone-with-image-file-upload/page.tsx new file mode 100644 index 00000000000..82c337d419b --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-with-image-file-upload/page.tsx @@ -0,0 +1,74 @@ +'use client'; + +import { + DropZone, + LegacyStack, + Thumbnail, + Banner, + List, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneWithImageFileUpload() { + const [files, setFiles] = useState([]); + const [rejectedFiles, setRejectedFiles] = useState([]); + const hasError = rejectedFiles.length > 0; + + const handleDrop = useCallback( + (_droppedFiles, acceptedFiles, rejectedFiles) => { + setFiles((files) => [...files, ...acceptedFiles]); + setRejectedFiles(rejectedFiles); + }, + [], + ); + + const fileUpload = !files.length && ; + const uploadedFiles = files.length > 0 && ( + + {files.map((file, index) => ( + + +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ))} +
+ ); + + const errorMessage = hasError && ( + + + {rejectedFiles.map((file, index) => ( + + {`"${file.name}" is not supported. File type must be .gif, .jpg, .png or .svg.`} + + ))} + + + ); + + return ( + + {errorMessage} + + {uploadedFiles} + {fileUpload} + + + ); +} + +export default withPolarisExample(DropZoneWithImageFileUpload); diff --git a/polaris.shopify.com/app/examples/drop-zone-with-single-file-upload/page.tsx b/polaris.shopify.com/app/examples/drop-zone-with-single-file-upload/page.tsx new file mode 100644 index 00000000000..4c3ba820b6c --- /dev/null +++ b/polaris.shopify.com/app/examples/drop-zone-with-single-file-upload/page.tsx @@ -0,0 +1,48 @@ +'use client'; + +import {DropZone, LegacyStack, Thumbnail, Text} from '@shopify/polaris'; +import {NoteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DropZoneExample() { + const [file, setFile] = useState(); + + const handleDropZoneDrop = useCallback( + (_dropFiles, acceptedFiles, _rejectedFiles) => + setFile((file) => acceptedFiles[0]), + [], + ); + + const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; + + const fileUpload = !file && ; + const uploadedFile = file && ( + + +
+ {file.name}{' '} + + {file.size} bytes + +
+
+ ); + + return ( + + {uploadedFile} + {fileUpload} + + ); +} + +export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/app/examples/empty-state-default/page.tsx b/polaris.shopify.com/app/examples/empty-state-default/page.tsx new file mode 100644 index 00000000000..d71d7bf51e2 --- /dev/null +++ b/polaris.shopify.com/app/examples/empty-state-default/page.tsx @@ -0,0 +1,25 @@ +'use client'; + +import {LegacyCard, EmptyState} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function EmptyStateExample() { + return ( + + +

Track and receive your incoming inventory from suppliers.

+
+
+ ); +} + +export default withPolarisExample(EmptyStateExample); diff --git a/polaris.shopify.com/app/examples/empty-state-with-full-width-layout/page.tsx b/polaris.shopify.com/app/examples/empty-state-with-full-width-layout/page.tsx new file mode 100644 index 00000000000..a82ef285b82 --- /dev/null +++ b/polaris.shopify.com/app/examples/empty-state-with-full-width-layout/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {LegacyCard, EmptyState} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function EmptyStateExample() { + return ( + + +

+ You can use the Files section to upload images, videos, and other + documents. This example shows the content with a centered layout and + full width. +

+
+
+ ); +} + +export default withPolarisExample(EmptyStateExample); diff --git a/polaris.shopify.com/app/examples/empty-state-with-subdued-footer-context/page.tsx b/polaris.shopify.com/app/examples/empty-state-with-subdued-footer-context/page.tsx new file mode 100644 index 00000000000..20b0d0cf295 --- /dev/null +++ b/polaris.shopify.com/app/examples/empty-state-with-subdued-footer-context/page.tsx @@ -0,0 +1,35 @@ +'use client'; + +import {LegacyCard, EmptyState, Link} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function EmptyStateExample() { + return ( + + + If you don’t want to add a transfer, you can import your inventory + from{' '} + + settings + + . +

+ } + image="https://cdn.shopify.com/s/files/1/0262/4071/2726/files/emptystate-files.png" + > +

Track and receive your incoming inventory from suppliers.

+
+
+ ); +} + +export default withPolarisExample(EmptyStateExample); diff --git a/polaris.shopify.com/app/examples/exception-list-default/page.tsx b/polaris.shopify.com/app/examples/exception-list-default/page.tsx new file mode 100644 index 00000000000..43d97d5df41 --- /dev/null +++ b/polaris.shopify.com/app/examples/exception-list-default/page.tsx @@ -0,0 +1,22 @@ +'use client'; + +import {ExceptionList} from '@shopify/polaris'; +import {NoteMinor} from '@shopify/polaris-icons'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ExceptionListExample() { + return ( + + ); +} + +export default withPolarisExample(ExceptionListExample); diff --git a/polaris.shopify.com/app/examples/filters-disabled/page.tsx b/polaris.shopify.com/app/examples/filters-disabled/page.tsx new file mode 100644 index 00000000000..67a1f45a1c7 --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-disabled/page.tsx @@ -0,0 +1,142 @@ +'use client'; + +import { + TextField, + LegacyCard, + ResourceList, + Filters, + Button, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DisableAllFiltersExample() { + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleQueryValueChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + + const filters = [ + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith', + label: disambiguateLabel('taggedWith', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + return ( +
+ + +
+ +
+ + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(DisableAllFiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-some-disabled/page.tsx b/polaris.shopify.com/app/examples/filters-some-disabled/page.tsx new file mode 100644 index 00000000000..27934e71418 --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-some-disabled/page.tsx @@ -0,0 +1,161 @@ +'use client'; + +import { + TextField, + LegacyCard, + ResourceList, + Filters, + Button, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DisableSomeFiltersExample() { + const [taggedWith, setTaggedWith] = useState(null); + const [vendor, setVendor] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleQueryValueChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleVendorChange = useCallback((value) => setVendor(value), []); + + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleVendorRemove = useCallback(() => setVendor(null), []); + + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + handleVendorRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove, handleVendorRemove]); + + const filters = [ + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + { + key: 'vendor', + label: 'Vendor', + filter: ( + + ), + shortcut: true, + disabled: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith', + label: disambiguateLabel('taggedWith', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + return ( +
+ + +
+ +
+ + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(DisableSomeFiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-with-a-data-table/page.tsx b/polaris.shopify.com/app/examples/filters-with-a-data-table/page.tsx new file mode 100644 index 00000000000..8fd329ca468 --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-with-a-data-table/page.tsx @@ -0,0 +1,197 @@ +'use client'; + +import { + ChoiceList, + TextField, + LegacyCard, + Filters, + DataTable, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DataTableFiltersExample() { + const [availability, setAvailability] = useState(null); + const [productType, setProductType] = useState(null); + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleAvailabilityChange = useCallback( + (value) => setAvailability(value), + [], + ); + const handleProductTypeChange = useCallback( + (value) => setProductType(value), + [], + ); + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleFiltersQueryChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleAvailabilityRemove = useCallback(() => setAvailability(null), []); + const handleProductTypeRemove = useCallback(() => setProductType(null), []); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleFiltersClearAll = useCallback(() => { + handleAvailabilityRemove(); + handleProductTypeRemove(); + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [ + handleAvailabilityRemove, + handleQueryValueRemove, + handleProductTypeRemove, + handleTaggedWithRemove, + ]); + + const filters = [ + { + key: 'availability', + label: 'Availability', + filter: ( + + ), + shortcut: true, + }, + { + key: 'productType', + label: 'Product type', + filter: ( + + ), + }, + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + }, + ]; + + const appliedFilters = []; + if (!isEmpty(availability)) { + const key = 'availability'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, availability), + onRemove: handleAvailabilityRemove, + }); + } + if (!isEmpty(productType)) { + const key = 'productType'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, productType), + onRemove: handleProductTypeRemove, + }); + } + if (!isEmpty(taggedWith)) { + const key = 'taggedWith'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, taggedWith), + onRemove: handleTaggedWithRemove, + }); + } + + return ( +
+ + + + + + +
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith': + return `Tagged with ${value}`; + case 'availability': + return value.map((val) => `Available on ${val}`).join(', '); + case 'productType': + return value.join(', '); + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(DataTableFiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-with-a-resource-list/page.tsx b/polaris.shopify.com/app/examples/filters-with-a-resource-list/page.tsx new file mode 100644 index 00000000000..61b2045d555 --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-with-a-resource-list/page.tsx @@ -0,0 +1,211 @@ +'use client'; + +import { + ChoiceList, + TextField, + RangeSlider, + LegacyCard, + ResourceList, + Filters, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListFiltersExample() { + const [accountStatus, setAccountStatus] = useState(null); + const [moneySpent, setMoneySpent] = useState(null); + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleAccountStatusChange = useCallback( + (value) => setAccountStatus(value), + [], + ); + const handleMoneySpentChange = useCallback( + (value) => setMoneySpent(value), + [], + ); + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleFiltersQueryChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleAccountStatusRemove = useCallback( + () => setAccountStatus(null), + [], + ); + const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleFiltersClearAll = useCallback(() => { + handleAccountStatusRemove(); + handleMoneySpentRemove(); + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [ + handleAccountStatusRemove, + handleMoneySpentRemove, + handleQueryValueRemove, + handleTaggedWithRemove, + ]); + + const filters = [ + { + key: 'accountStatus', + label: 'Account status', + filter: ( + + ), + shortcut: true, + }, + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + { + key: 'moneySpent', + label: 'Money spent', + filter: ( + + ), + }, + ]; + + const appliedFilters = []; + if (!isEmpty(accountStatus)) { + const key = 'accountStatus'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, accountStatus), + onRemove: handleAccountStatusRemove, + }); + } + if (!isEmpty(moneySpent)) { + const key = 'moneySpent'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, moneySpent), + onRemove: handleMoneySpentRemove, + }); + } + if (!isEmpty(taggedWith)) { + const key = 'taggedWith'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, taggedWith), + onRemove: handleTaggedWithRemove, + }); + } + + return ( +
+ + + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'moneySpent': + return `Money spent is between $${value[0]} and $${value[1]}`; + case 'taggedWith': + return `Tagged with ${value}`; + case 'accountStatus': + return value.map((val) => `Customer ${val}`).join(', '); + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-with-children-content/page.tsx b/polaris.shopify.com/app/examples/filters-with-children-content/page.tsx new file mode 100644 index 00000000000..645bb284383 --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-with-children-content/page.tsx @@ -0,0 +1,138 @@ +'use client'; + +import { + TextField, + LegacyCard, + ResourceList, + Filters, + Button, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FiltersExample() { + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleQueryValueChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + + const filters = [ + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith', + label: disambiguateLabel('taggedWith', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + return ( +
+ + +
+ +
+ + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(FiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-with-help-text/page.tsx b/polaris.shopify.com/app/examples/filters-with-help-text/page.tsx new file mode 100644 index 00000000000..1c02e99bc16 --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-with-help-text/page.tsx @@ -0,0 +1,213 @@ +'use client'; + +import { + ChoiceList, + TextField, + RangeSlider, + LegacyCard, + ResourceList, + Filters, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListFiltersExample() { + const [accountStatus, setAccountStatus] = useState(null); + const [moneySpent, setMoneySpent] = useState(null); + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleAccountStatusChange = useCallback( + (value) => setAccountStatus(value), + [], + ); + const handleMoneySpentChange = useCallback( + (value) => setMoneySpent(value), + [], + ); + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleFiltersQueryChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleAccountStatusRemove = useCallback( + () => setAccountStatus(null), + [], + ); + const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleFiltersClearAll = useCallback(() => { + handleAccountStatusRemove(); + handleMoneySpentRemove(); + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [ + handleAccountStatusRemove, + handleMoneySpentRemove, + handleQueryValueRemove, + handleTaggedWithRemove, + ]); + + const filters = [ + { + key: 'accountStatus', + label: 'Account status', + filter: ( + + ), + shortcut: true, + }, + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + { + key: 'moneySpent', + label: 'Money spent', + filter: ( + + ), + }, + ]; + + const appliedFilters = []; + if (!isEmpty(accountStatus)) { + const key = 'accountStatus'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, accountStatus), + onRemove: handleAccountStatusRemove, + }); + } + if (!isEmpty(moneySpent)) { + const key = 'moneySpent'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, moneySpent), + onRemove: handleMoneySpentRemove, + }); + } + if (!isEmpty(taggedWith)) { + const key = 'taggedWith'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, taggedWith), + onRemove: handleTaggedWithRemove, + }); + } + + return ( +
+ + + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'moneySpent': + return `Money spent is between $${value[0]} and $${value[1]}`; + case 'taggedWith': + return `Tagged with ${value}`; + case 'accountStatus': + return value.map((val) => `Customer ${val}`).join(', '); + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-with-query-field-disabled/page.tsx b/polaris.shopify.com/app/examples/filters-with-query-field-disabled/page.tsx new file mode 100644 index 00000000000..49a02238fcd --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-with-query-field-disabled/page.tsx @@ -0,0 +1,212 @@ +'use client'; + +import { + ChoiceList, + TextField, + RangeSlider, + LegacyCard, + ResourceList, + Filters, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListFiltersExample() { + const [accountStatus, setAccountStatus] = useState(null); + const [moneySpent, setMoneySpent] = useState(null); + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleAccountStatusChange = useCallback( + (value) => setAccountStatus(value), + [], + ); + const handleMoneySpentChange = useCallback( + (value) => setMoneySpent(value), + [], + ); + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleFiltersQueryChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleAccountStatusRemove = useCallback( + () => setAccountStatus(null), + [], + ); + const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleFiltersClearAll = useCallback(() => { + handleAccountStatusRemove(); + handleMoneySpentRemove(); + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [ + handleAccountStatusRemove, + handleMoneySpentRemove, + handleQueryValueRemove, + handleTaggedWithRemove, + ]); + + const filters = [ + { + key: 'accountStatus', + label: 'Account status', + filter: ( + + ), + shortcut: true, + }, + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + { + key: 'moneySpent', + label: 'Money spent', + filter: ( + + ), + }, + ]; + + const appliedFilters = []; + if (!isEmpty(accountStatus)) { + const key = 'accountStatus'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, accountStatus), + onRemove: handleAccountStatusRemove, + }); + } + if (!isEmpty(moneySpent)) { + const key = 'moneySpent'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, moneySpent), + onRemove: handleMoneySpentRemove, + }); + } + if (!isEmpty(taggedWith)) { + const key = 'taggedWith'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, taggedWith), + onRemove: handleTaggedWithRemove, + }); + } + + return ( +
+ + + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'moneySpent': + return `Money spent is between $${value[0]} and $${value[1]}`; + case 'taggedWith': + return `Tagged with ${value}`; + case 'accountStatus': + return value.map((val) => `Customer ${val}`).join(', '); + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-with-query-field-hidden/page.tsx b/polaris.shopify.com/app/examples/filters-with-query-field-hidden/page.tsx new file mode 100644 index 00000000000..308ddc968c7 --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-with-query-field-hidden/page.tsx @@ -0,0 +1,212 @@ +'use client'; + +import { + ChoiceList, + TextField, + RangeSlider, + LegacyCard, + ResourceList, + Filters, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListFiltersExample() { + const [accountStatus, setAccountStatus] = useState(null); + const [moneySpent, setMoneySpent] = useState(null); + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleAccountStatusChange = useCallback( + (value) => setAccountStatus(value), + [], + ); + const handleMoneySpentChange = useCallback( + (value) => setMoneySpent(value), + [], + ); + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleFiltersQueryChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleAccountStatusRemove = useCallback( + () => setAccountStatus(null), + [], + ); + const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleFiltersClearAll = useCallback(() => { + handleAccountStatusRemove(); + handleMoneySpentRemove(); + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [ + handleAccountStatusRemove, + handleMoneySpentRemove, + handleQueryValueRemove, + handleTaggedWithRemove, + ]); + + const filters = [ + { + key: 'accountStatus', + label: 'Account status', + filter: ( + + ), + shortcut: true, + }, + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + { + key: 'moneySpent', + label: 'Money spent', + filter: ( + + ), + }, + ]; + + const appliedFilters = []; + if (!isEmpty(accountStatus)) { + const key = 'accountStatus'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, accountStatus), + onRemove: handleAccountStatusRemove, + }); + } + if (!isEmpty(moneySpent)) { + const key = 'moneySpent'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, moneySpent), + onRemove: handleMoneySpentRemove, + }); + } + if (!isEmpty(taggedWith)) { + const key = 'taggedWith'; + appliedFilters.push({ + key, + label: disambiguateLabel(key, taggedWith), + onRemove: handleTaggedWithRemove, + }); + } + + return ( +
+ + + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'moneySpent': + return `Money spent is between $${value[0]} and $${value[1]}`; + case 'taggedWith': + return `Tagged with ${value}`; + case 'accountStatus': + return value.map((val) => `Customer ${val}`).join(', '); + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/app/examples/filters-without-clear-button/page.tsx b/polaris.shopify.com/app/examples/filters-without-clear-button/page.tsx new file mode 100644 index 00000000000..3f4ffe3793a --- /dev/null +++ b/polaris.shopify.com/app/examples/filters-without-clear-button/page.tsx @@ -0,0 +1,143 @@ +'use client'; + +import { + TextField, + LegacyCard, + ResourceList, + Filters, + Button, + Avatar, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Playground() { + const [taggedWith, setTaggedWith] = useState(null); + const [queryValue, setQueryValue] = useState(null); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleQueryValueChange = useCallback( + (value) => setQueryValue(value), + [], + ); + + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + + const filters = [ + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + hideClearButton: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith', + label: disambiguateLabel('taggedWith', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + return ( +
+ + +
+ +
+ + } + items={[ + { + id: 341, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 256, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]} + renderItem={(item) => { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(Playground); diff --git a/polaris.shopify.com/app/examples/footer-help-default/page.tsx b/polaris.shopify.com/app/examples/footer-help-default/page.tsx new file mode 100644 index 00000000000..0479b9ec81d --- /dev/null +++ b/polaris.shopify.com/app/examples/footer-help-default/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {FooterHelp, Link} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FooterHelpExample() { + return ( + + Learn more about{' '} + + fulfilling orders + + + ); +} + +export default withPolarisExample(FooterHelpExample); diff --git a/polaris.shopify.com/app/examples/form-custom-on-submit/page.tsx b/polaris.shopify.com/app/examples/form-custom-on-submit/page.tsx new file mode 100644 index 00000000000..edb3e5821ea --- /dev/null +++ b/polaris.shopify.com/app/examples/form-custom-on-submit/page.tsx @@ -0,0 +1,52 @@ +'use client'; + +import {Form, FormLayout, Checkbox, TextField, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FormOnSubmitExample() { + const [newsletter, setNewsletter] = useState(false); + const [email, setEmail] = useState(''); + + const handleSubmit = useCallback((_event) => { + setEmail(''); + setNewsletter(false); + }, []); + + const handleNewsLetterChange = useCallback( + (value) => setNewsletter(value), + [], + ); + + const handleEmailChange = useCallback((value) => setEmail(value), []); + + return ( +
+ + + + + We’ll use this email address to inform you on future changes to + Polaris. + + } + /> + + + +
+ ); +} + +export default withPolarisExample(FormOnSubmitExample); diff --git a/polaris.shopify.com/app/examples/form-layout-condensed-field-group/page.tsx b/polaris.shopify.com/app/examples/form-layout-condensed-field-group/page.tsx new file mode 100644 index 00000000000..eaf9b034e86 --- /dev/null +++ b/polaris.shopify.com/app/examples/form-layout-condensed-field-group/page.tsx @@ -0,0 +1,20 @@ +'use client'; + +import {FormLayout, TextField} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( + + + {}} autoComplete="off" /> + {}} autoComplete="off" /> + {}} autoComplete="off" /> + {}} autoComplete="off" /> + + + ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/form-layout-default/page.tsx b/polaris.shopify.com/app/examples/form-layout-default/page.tsx new file mode 100644 index 00000000000..6f544dde4e5 --- /dev/null +++ b/polaris.shopify.com/app/examples/form-layout-default/page.tsx @@ -0,0 +1,21 @@ +'use client'; + +import {FormLayout, TextField} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( + + {}} autoComplete="off" /> + {}} + autoComplete="email" + /> + + ); +} + +export default withPolarisExample(() => ); diff --git a/polaris.shopify.com/app/examples/form-layout-field-group/page.tsx b/polaris.shopify.com/app/examples/form-layout-field-group/page.tsx new file mode 100644 index 00000000000..338be67b881 --- /dev/null +++ b/polaris.shopify.com/app/examples/form-layout-field-group/page.tsx @@ -0,0 +1,28 @@ +'use client'; + +import {FormLayout, TextField} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function Example() { + return ( + + + {}} + autoComplete="off" + /> + {}} + autoComplete="off" + /> + + + ); +} + +export default withPolarisExample(Example); diff --git a/polaris.shopify.com/app/examples/form-without-native-validation/page.tsx b/polaris.shopify.com/app/examples/form-without-native-validation/page.tsx new file mode 100644 index 00000000000..ccf16136f85 --- /dev/null +++ b/polaris.shopify.com/app/examples/form-without-native-validation/page.tsx @@ -0,0 +1,31 @@ +'use client'; + +import {Form, FormLayout, TextField, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FormWithoutNativeValidationExample() { + const [url, setUrl] = useState(''); + + const handleSubmit = useCallback((_event) => setUrl(''), []); + + const handleUrlChange = useCallback((value) => setUrl(value), []); + + return ( +
+ + + + + +
+ ); +} + +export default withPolarisExample(FormWithoutNativeValidationExample); diff --git a/polaris.shopify.com/app/examples/frame-in-an-application/page.tsx b/polaris.shopify.com/app/examples/frame-in-an-application/page.tsx new file mode 100644 index 00000000000..3e034724225 --- /dev/null +++ b/polaris.shopify.com/app/examples/frame-in-an-application/page.tsx @@ -0,0 +1,362 @@ +'use client'; + +import { + ActionList, + AppProvider, + LegacyCard, + ContextualSaveBar, + FormLayout, + Frame, + Layout, + Loading, + Modal, + Navigation, + Page, + SkeletonBodyText, + SkeletonDisplayText, + SkeletonPage, + TextContainer, + TextField, + Toast, + TopBar, +} from '@shopify/polaris'; +import { + ArrowLeftMinor, + HomeMajor, + OrdersMajor, + ConversationMinor, +} from '@shopify/polaris-icons'; +import {useState, useCallback, useRef} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FrameExample() { + const defaultState = useRef({ + emailFieldValue: 'dharma@jadedpixel.com', + nameFieldValue: 'Jaded Pixel', + }); + const skipToContentRef = useRef(null); + + const [toastActive, setToastActive] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [isDirty, setIsDirty] = useState(false); + const [searchActive, setSearchActive] = useState(false); + const [searchValue, setSearchValue] = useState(''); + const [userMenuActive, setUserMenuActive] = useState(false); + const [mobileNavigationActive, setMobileNavigationActive] = useState(false); + const [modalActive, setModalActive] = useState(false); + const [nameFieldValue, setNameFieldValue] = useState( + defaultState.current.nameFieldValue, + ); + const [emailFieldValue, setEmailFieldValue] = useState( + defaultState.current.emailFieldValue, + ); + const [storeName, setStoreName] = useState( + defaultState.current.nameFieldValue, + ); + const [supportSubject, setSupportSubject] = useState(''); + const [supportMessage, setSupportMessage] = useState(''); + + const handleSubjectChange = useCallback( + (value) => setSupportSubject(value), + [], + ); + const handleMessageChange = useCallback( + (value) => setSupportMessage(value), + [], + ); + const handleDiscard = useCallback(() => { + setEmailFieldValue(defaultState.current.emailFieldValue); + setNameFieldValue(defaultState.current.nameFieldValue); + setIsDirty(false); + }, []); + const handleSave = useCallback(() => { + defaultState.current.nameFieldValue = nameFieldValue; + defaultState.current.emailFieldValue = emailFieldValue; + + setIsDirty(false); + setToastActive(true); + setStoreName(defaultState.current.nameFieldValue); + }, [emailFieldValue, nameFieldValue]); + const handleNameFieldChange = useCallback((value) => { + setNameFieldValue(value); + value && setIsDirty(true); + }, []); + const handleEmailFieldChange = useCallback((value) => { + setEmailFieldValue(value); + value && setIsDirty(true); + }, []); + const handleSearchResultsDismiss = useCallback(() => { + setSearchActive(false); + setSearchValue(''); + }, []); + const handleSearchFieldChange = useCallback((value) => { + setSearchValue(value); + setSearchActive(value.length > 0); + }, []); + const toggleToastActive = useCallback( + () => setToastActive((toastActive) => !toastActive), + [], + ); + const toggleUserMenuActive = useCallback( + () => setUserMenuActive((userMenuActive) => !userMenuActive), + [], + ); + const toggleMobileNavigationActive = useCallback( + () => + setMobileNavigationActive( + (mobileNavigationActive) => !mobileNavigationActive, + ), + [], + ); + const toggleIsLoading = useCallback( + () => setIsLoading((isLoading) => !isLoading), + [], + ); + const toggleModalActive = useCallback( + () => setModalActive((modalActive) => !modalActive), + [], + ); + + const toastMarkup = toastActive ? ( + + ) : null; + + const userMenuActions = [ + { + items: [{content: 'Community forums'}], + }, + ]; + + const contextualSaveBarMarkup = isDirty ? ( + + ) : null; + + const userMenuMarkup = ( + + ); + + const searchResultsMarkup = ( + + ); + + const searchFieldMarkup = ( + + ); + + const topBarMarkup = ( + + ); + + const navigationMarkup = ( + + + + + ); + + const loadingMarkup = isLoading ? : null; + + const skipToContentTarget = ( + + ); + + const actualPageMarkup = ( + + + {skipToContentTarget} + + + + + + + + + + + ); + + const loadingPageMarkup = ( + + + + + + + + + + + + + ); + + const pageMarkup = isLoading ? loadingPageMarkup : actualPageMarkup; + + const modalMarkup = ( + + + + + + + + + ); + + const logo = { + width: 124, + topBarSource: + 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999', + contextualSaveBarSource: + 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-gray.svg?6215648040070010999', + url: '#', + accessibilityLabel: 'Jaded Pixel', + }; + + return ( +
+ + + {contextualSaveBarMarkup} + {loadingMarkup} + {pageMarkup} + {toastMarkup} + {modalMarkup} + + +
+ ); +} + +export default withPolarisExample(FrameExample); diff --git a/polaris.shopify.com/app/examples/frame-with-an-offset/page.tsx b/polaris.shopify.com/app/examples/frame-with-an-offset/page.tsx new file mode 100644 index 00000000000..d3f84a31853 --- /dev/null +++ b/polaris.shopify.com/app/examples/frame-with-an-offset/page.tsx @@ -0,0 +1,368 @@ +'use client'; + +import { + ActionList, + AppProvider, + LegacyCard, + ContextualSaveBar, + FormLayout, + Frame, + Layout, + Loading, + Modal, + Navigation, + Page, + SkeletonBodyText, + SkeletonDisplayText, + SkeletonPage, + TextContainer, + TextField, + Toast, + TopBar, +} from '@shopify/polaris'; +import { + ArrowLeftMinor, + HomeMajor, + OrdersMajor, + ConversationMinor, +} from '@shopify/polaris-icons'; +import {useState, useCallback, useRef} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FrameExample() { + const defaultState = useRef({ + emailFieldValue: 'dharma@jadedpixel.com', + nameFieldValue: 'Jaded Pixel', + }); + const skipToContentRef = useRef(null); + + const [toastActive, setToastActive] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [isDirty, setIsDirty] = useState(false); + const [searchActive, setSearchActive] = useState(false); + const [searchValue, setSearchValue] = useState(''); + const [userMenuActive, setUserMenuActive] = useState(false); + const [mobileNavigationActive, setMobileNavigationActive] = useState(false); + const [modalActive, setModalActive] = useState(false); + const [nameFieldValue, setNameFieldValue] = useState( + defaultState.current.nameFieldValue, + ); + const [emailFieldValue, setEmailFieldValue] = useState( + defaultState.current.emailFieldValue, + ); + const [storeName, setStoreName] = useState( + defaultState.current.nameFieldValue, + ); + const [supportSubject, setSupportSubject] = useState(''); + const [supportMessage, setSupportMessage] = useState(''); + + const handleSubjectChange = useCallback( + (value) => setSupportSubject(value), + [], + ); + const handleMessageChange = useCallback( + (value) => setSupportMessage(value), + [], + ); + const handleDiscard = useCallback(() => { + setEmailFieldValue(defaultState.current.emailFieldValue); + setNameFieldValue(defaultState.current.nameFieldValue); + setIsDirty(false); + }, []); + const handleSave = useCallback(() => { + defaultState.current.nameFieldValue = nameFieldValue; + defaultState.current.emailFieldValue = emailFieldValue; + + setIsDirty(false); + setToastActive(true); + setStoreName(defaultState.current.nameFieldValue); + }, [emailFieldValue, nameFieldValue]); + const handleNameFieldChange = useCallback((value) => { + setNameFieldValue(value); + value && setIsDirty(true); + }, []); + const handleEmailFieldChange = useCallback((value) => { + setEmailFieldValue(value); + value && setIsDirty(true); + }, []); + const handleSearchResultsDismiss = useCallback(() => { + setSearchActive(false); + setSearchValue(''); + }, []); + const handleSearchFieldChange = useCallback((value) => { + setSearchValue(value); + setSearchActive(value.length > 0); + }, []); + const toggleToastActive = useCallback( + () => setToastActive((toastActive) => !toastActive), + [], + ); + const toggleUserMenuActive = useCallback( + () => setUserMenuActive((userMenuActive) => !userMenuActive), + [], + ); + const toggleMobileNavigationActive = useCallback( + () => + setMobileNavigationActive( + (mobileNavigationActive) => !mobileNavigationActive, + ), + [], + ); + const toggleIsLoading = useCallback( + () => setIsLoading((isLoading) => !isLoading), + [], + ); + const toggleModalActive = useCallback( + () => setModalActive((modalActive) => !modalActive), + [], + ); + + const toastMarkup = toastActive ? ( + + ) : null; + + const userMenuActions = [ + { + items: [{content: 'Community forums'}], + }, + ]; + + const contextualSaveBarMarkup = isDirty ? ( + + ) : null; + + const userMenuMarkup = ( + + ); + + const searchResultsMarkup = ( + + ); + + const searchFieldMarkup = ( + + ); + + const topBarMarkup = ( + + ); + + const navigationMarkup = ( + + + + + ); + + const loadingMarkup = isLoading ? : null; + + const skipToContentTarget = ( +
+ ); + + const actualPageMarkup = ( + + + {skipToContentTarget} + + + + + + + + + + + ); + + const loadingPageMarkup = ( + + + + + + + + + + + + + ); + + const pageMarkup = isLoading ? loadingPageMarkup : actualPageMarkup; + + const modalMarkup = ( + + + + + + + + + ); + + const logo = { + width: 124, + topBarSource: + 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999', + contextualSaveBarSource: + 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-gray.svg?6215648040070010999', + url: '#', + accessibilityLabel: 'Jaded Pixel', + }; + + return ( +
+ + + Global ribbon +
+ } + topBar={topBarMarkup} + navigation={navigationMarkup} + showMobileNavigation={mobileNavigationActive} + onNavigationDismiss={toggleMobileNavigationActive} + skipToContentTarget={skipToContentRef.current} + > + {contextualSaveBarMarkup} + {loadingMarkup} + {pageMarkup} + {toastMarkup} + {modalMarkup} + + + + ); +} + +export default withPolarisExample(FrameExample); diff --git a/polaris.shopify.com/app/examples/fullscreen-bar-no-children/page.tsx b/polaris.shopify.com/app/examples/fullscreen-bar-no-children/page.tsx new file mode 100644 index 00000000000..cfa1f43c310 --- /dev/null +++ b/polaris.shopify.com/app/examples/fullscreen-bar-no-children/page.tsx @@ -0,0 +1,31 @@ +'use client'; + +import {FullscreenBar, Button, Text} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FullscreenBarExample() { + const [isFullscreen, setFullscreen] = useState(true); + + const handleActionClick = useCallback(() => { + setFullscreen(false); + }, []); + + const fullscreenBarMarkup = ; + + return ( +
+ {isFullscreen && fullscreenBarMarkup} +
+ {!isFullscreen && ( + + )} + + Page content + +
+
+ ); +} + +export default withPolarisExample(FullscreenBarExample); diff --git a/polaris.shopify.com/app/examples/fullscreen-bar-with-children/page.tsx b/polaris.shopify.com/app/examples/fullscreen-bar-with-children/page.tsx new file mode 100644 index 00000000000..c53354a2aac --- /dev/null +++ b/polaris.shopify.com/app/examples/fullscreen-bar-with-children/page.tsx @@ -0,0 +1,63 @@ +'use client'; + +import { + Badge, + ButtonGroup, + FullscreenBar, + Button, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FullscreenBarExample() { + const [isFullscreen, setFullscreen] = useState(true); + + const handleActionClick = useCallback(() => { + setFullscreen(false); + }, []); + + const fullscreenBarMarkup = ( + +
+ Draft +
+ + Page title + +
+ + + + +
+
+ ); + + return ( +
+ {isFullscreen && fullscreenBarMarkup} +
+ {!isFullscreen && ( + + )} + + Page content + +
+
+ ); +} + +export default withPolarisExample(FullscreenBarExample); diff --git a/polaris.shopify.com/app/examples/grid-custom-layout/page.tsx b/polaris.shopify.com/app/examples/grid-custom-layout/page.tsx new file mode 100644 index 00000000000..425ef4f24a1 --- /dev/null +++ b/polaris.shopify.com/app/examples/grid-custom-layout/page.tsx @@ -0,0 +1,54 @@ +'use client'; + +import {Page, Grid, LegacyCard} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function GridExample() { + return ( + + + + +
+ + +
+ + +
+ + + + + ); +} + +export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/app/examples/grid-three-one-third-column/page.tsx b/polaris.shopify.com/app/examples/grid-three-one-third-column/page.tsx new file mode 100644 index 00000000000..eae81fe6cdf --- /dev/null +++ b/polaris.shopify.com/app/examples/grid-three-one-third-column/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {Page, Grid, LegacyCard} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function GridExample() { + return ( + + + + +

View a summary of your online store’s sales.

+
+
+ + +

View a summary of your online store’s orders.

+
+
+
+
+ ); +} + +export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/app/examples/grid-two-column/page.tsx b/polaris.shopify.com/app/examples/grid-two-column/page.tsx new file mode 100644 index 00000000000..223b47d9c55 --- /dev/null +++ b/polaris.shopify.com/app/examples/grid-two-column/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {Page, Grid, LegacyCard} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function GridExample() { + return ( + + + + +

View a summary of your online store’s sales.

+
+
+ + +

View a summary of your online store’s orders.

+
+
+
+
+ ); +} + +export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/app/examples/grid-two-thirds-and-one-third-column/page.tsx b/polaris.shopify.com/app/examples/grid-two-thirds-and-one-third-column/page.tsx new file mode 100644 index 00000000000..eae81fe6cdf --- /dev/null +++ b/polaris.shopify.com/app/examples/grid-two-thirds-and-one-third-column/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {Page, Grid, LegacyCard} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function GridExample() { + return ( + + + + +

View a summary of your online store’s sales.

+
+
+ + +

View a summary of your online store’s orders.

+
+
+
+
+ ); +} + +export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/app/examples/icon-colored/page.tsx b/polaris.shopify.com/app/examples/icon-colored/page.tsx new file mode 100644 index 00000000000..a8f11de0bcf --- /dev/null +++ b/polaris.shopify.com/app/examples/icon-colored/page.tsx @@ -0,0 +1,22 @@ +'use client'; + +import {Icon} from '@shopify/polaris'; +import {CirclePlusMinor} from '@shopify/polaris-icons'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IconExample() { + return ( +
+ + + + + + + +
+ ); +} + +export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/app/examples/icon-default/page.tsx b/polaris.shopify.com/app/examples/icon-default/page.tsx new file mode 100644 index 00000000000..48d19b568c4 --- /dev/null +++ b/polaris.shopify.com/app/examples/icon-default/page.tsx @@ -0,0 +1,12 @@ +'use client'; + +import {Icon} from '@shopify/polaris'; +import {CirclePlusMinor} from '@shopify/polaris-icons'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IconExample() { + return ; +} + +export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/app/examples/icon-with-backdrop/page.tsx b/polaris.shopify.com/app/examples/icon-with-backdrop/page.tsx new file mode 100644 index 00000000000..c9f7bffc2f3 --- /dev/null +++ b/polaris.shopify.com/app/examples/icon-with-backdrop/page.tsx @@ -0,0 +1,20 @@ +'use client'; + +import {Icon} from '@shopify/polaris'; +import {CirclePlusMinor} from '@shopify/polaris-icons'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IconExample() { + return ( +
+ + + + + +
+ ); +} + +export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/app/examples/icon-with-custom-svg-and-color/page.tsx b/polaris.shopify.com/app/examples/icon-with-custom-svg-and-color/page.tsx new file mode 100644 index 00000000000..2240a9d029b --- /dev/null +++ b/polaris.shopify.com/app/examples/icon-with-custom-svg-and-color/page.tsx @@ -0,0 +1,21 @@ +'use client'; + +import {Icon} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IconWithReactChild() { + const iconContent = () => { + return ( + + + + + + ); + }; + + return ; +} + +export default withPolarisExample(IconWithReactChild); diff --git a/polaris.shopify.com/app/examples/icon-with-custom-svg/page.tsx b/polaris.shopify.com/app/examples/icon-with-custom-svg/page.tsx new file mode 100644 index 00000000000..475131b9e9b --- /dev/null +++ b/polaris.shopify.com/app/examples/icon-with-custom-svg/page.tsx @@ -0,0 +1,13 @@ +'use client'; + +import {Icon} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IconExample() { + return ( + + ); +} + +export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/app/examples/index-table-default/page.tsx b/polaris.shopify.com/app/examples/index-table-default/page.tsx new file mode 100644 index 00000000000..70e25d6baca --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-default/page.tsx @@ -0,0 +1,114 @@ +'use client'; + +import { + IndexTable, + LegacyCard, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SimpleIndexTableExample() { + const customers = [ + { + id: '3411', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '2561', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent}, index) => ( + + + + {name} + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + + + Order count + + ), + }, + { + id: 'amount-spent', + title: ( + + Amount spent + + ), + }, + , + ]} + > + {rowMarkup} + + + ); +} + +export default withPolarisExample(SimpleIndexTableExample); diff --git a/polaris.shopify.com/app/examples/index-table-flush/page.tsx b/polaris.shopify.com/app/examples/index-table-flush/page.tsx new file mode 100644 index 00000000000..68c80be9a4f --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-flush/page.tsx @@ -0,0 +1,115 @@ +'use client'; + +import { + IndexTable, + LegacyCard, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SimpleFlushIndexTableExample() { + const customers = [ + { + id: '3411', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '2561', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent}, index) => ( + + + + {name} + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + + + Order count + + ), + }, + { + id: 'amount-spent', + flush: true, + title: ( + + Amount spent + + ), + }, + ]} + > + {rowMarkup} + + + ); +} + +export default withPolarisExample(SimpleFlushIndexTableExample); diff --git a/polaris.shopify.com/app/examples/index-table-small-screen-with-all-of-its-elements/page.tsx b/polaris.shopify.com/app/examples/index-table-small-screen-with-all-of-its-elements/page.tsx new file mode 100644 index 00000000000..14003aea6ad --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-small-screen-with-all-of-its-elements/page.tsx @@ -0,0 +1,226 @@ +'use client'; + +import { + TextField, + IndexTable, + LegacyCard, + Filters, + Select, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SmallScreenIndexTableWithAllElementsExample() { + const customers = [ + { + id: '3418', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '2568', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + const [taggedWith, setTaggedWith] = useState('VIP'); + const [queryValue, setQueryValue] = useState(null); + const [sortValue, setSortValue] = useState('today'); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + const handleSortChange = useCallback((value) => setSortValue(value), []); + + const promotedBulkActions = [ + { + content: 'Edit customers', + onAction: () => console.log('Todo: implement bulk edit'), + }, + ]; + const bulkActions = [ + { + content: 'Add tags', + onAction: () => console.log('Todo: implement bulk add tags'), + }, + { + content: 'Remove tags', + onAction: () => console.log('Todo: implement bulk remove tags'), + }, + { + content: 'Delete customers', + onAction: () => console.log('Todo: implement bulk delete'), + }, + ]; + + const filters = [ + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith', + label: disambiguateLabel('taggedWith', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + const sortOptions = [ + {label: 'Today', value: 'today'}, + {label: 'Yesterday', value: 'yesterday'}, + {label: 'Last 7 days', value: 'lastWeek'}, + ]; + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent}, index) => ( + +
+ + {name} + +

{location}

+ + {orders} + + + {amountSpent} + +
+
+ ), + ); + + return ( +
+ +
+
+ +
+
+ +
+
+ + Order count + + ), + }, + { + id: 'amount-spent', + hidden: false, + title: ( + + Amount spent + + ), + }, + ]} + > + {rowMarkup} + +
+ ); + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(IndexTableWithAllElementsExample); diff --git a/polaris.shopify.com/app/examples/index-table-with-bulk-actions-and-selection-across-pages/page.tsx b/polaris.shopify.com/app/examples/index-table-with-bulk-actions-and-selection-across-pages/page.tsx new file mode 100644 index 00000000000..dca054913ba --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-with-bulk-actions-and-selection-across-pages/page.tsx @@ -0,0 +1,140 @@ +'use client'; + +import { + IndexTable, + LegacyCard, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IndexTableWithBulkActionsAndSelectionAcrossPagesExample() { + const customers = [ + { + id: '3414', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '2564', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + + const promotedBulkActions = [ + { + content: 'Edit customers', + onAction: () => console.log('Todo: implement bulk edit'), + }, + ]; + const bulkActions = [ + { + content: 'Add tags', + onAction: () => console.log('Todo: implement bulk add tags'), + }, + { + content: 'Remove tags', + onAction: () => console.log('Todo: implement bulk remove tags'), + }, + { + content: 'Delete customers', + onAction: () => console.log('Todo: implement bulk delete'), + }, + ]; + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent}, index) => ( + + + + {name} + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + + + Order count + + ), + }, + { + id: 'amount-spent', + title: ( + + Amount spent + + ), + }, + , + ]} + > + {rowMarkup} + + + ); +} + +export default withPolarisExample( + IndexTableWithBulkActionsAndSelectionAcrossPagesExample, +); diff --git a/polaris.shopify.com/app/examples/index-table-with-bulk-actions/page.tsx b/polaris.shopify.com/app/examples/index-table-with-bulk-actions/page.tsx new file mode 100644 index 00000000000..824ae4828ab --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-with-bulk-actions/page.tsx @@ -0,0 +1,137 @@ +'use client'; + +import { + IndexTable, + LegacyCard, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IndexTableWithBulkActionsExample() { + const customers = [ + { + id: '3413', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '2563', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + + const promotedBulkActions = [ + { + content: 'Edit customers', + onAction: () => console.log('Todo: implement bulk edit'), + }, + ]; + const bulkActions = [ + { + content: 'Add tags', + onAction: () => console.log('Todo: implement bulk add tags'), + }, + { + content: 'Remove tags', + onAction: () => console.log('Todo: implement bulk remove tags'), + }, + { + content: 'Delete customers', + onAction: () => console.log('Todo: implement bulk delete'), + }, + ]; + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent}, index) => ( + + + + {name} + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + + + Order count + + ), + }, + { + id: 'amount-spent', + title: ( + + Amount spent + + ), + }, + , + ]} + > + {rowMarkup} + + + ); +} + +export default withPolarisExample(IndexTableWithBulkActionsExample); diff --git a/polaris.shopify.com/app/examples/index-table-with-clickable-button-column/page.tsx b/polaris.shopify.com/app/examples/index-table-with-clickable-button-column/page.tsx new file mode 100644 index 00000000000..c472cfccf4d --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-with-clickable-button-column/page.tsx @@ -0,0 +1,121 @@ +'use client'; + +import { + IndexTable, + LegacyCard, + Button, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ClickThroughButtonIndexTableExample() { + const customers = [ + { + id: '3411', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '2561', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + + const rowMarkup = customers.map( + ({id, url, name, location, orders, amountSpent}, index) => ( + + + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + + + Order count + + ), + }, + { + id: 'amount-spent', + hidden: false, + title: ( + + Amount spent + + ), + }, + ]} + > + {rowMarkup} + + + ); +} + +export default withPolarisExample(ClickThroughButtonIndexTableExample); diff --git a/polaris.shopify.com/app/examples/index-table-with-empty-state/page.tsx b/polaris.shopify.com/app/examples/index-table-with-empty-state/page.tsx new file mode 100644 index 00000000000..44a43fc1b81 --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-with-empty-state/page.tsx @@ -0,0 +1,107 @@ +'use client'; + +import { + EmptySearchResult, + IndexTable, + LegacyCard, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IndexTableWithCustomEmptyStateExample() { + const customers = []; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + + const emptyStateMarkup = ( + + ); + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent}, index) => ( + + + + {name} + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + + + Order count + + ), + }, + { + id: 'amount-spent', + title: ( + + Amount spent + + ), + }, + , + ]} + > + {rowMarkup} + + + ); +} + +export default withPolarisExample(IndexTableWithCustomEmptyStateExample); diff --git a/polaris.shopify.com/app/examples/index-table-with-filtering/page.tsx b/polaris.shopify.com/app/examples/index-table-with-filtering/page.tsx new file mode 100644 index 00000000000..d2282e1ca4c --- /dev/null +++ b/polaris.shopify.com/app/examples/index-table-with-filtering/page.tsx @@ -0,0 +1,203 @@ +'use client'; + +import { + TextField, + IndexTable, + LegacyCard, + Filters, + Select, + useIndexResourceState, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function IndexTableWithFilteringExample() { + const customers = [ + { + id: '3416', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '2566', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const {selectedResources, allResourcesSelected, handleSelectionChange} = + useIndexResourceState(customers); + const [taggedWith, setTaggedWith] = useState('VIP'); + const [queryValue, setQueryValue] = useState(null); + const [sortValue, setSortValue] = useState('today'); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + const handleSortChange = useCallback((value) => setSortValue(value), []); + + const filters = [ + { + key: 'taggedWith', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith', + label: disambiguateLabel('taggedWith', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + const sortOptions = [ + {label: 'Today', value: 'today'}, + {label: 'Yesterday', value: 'yesterday'}, + {label: 'Last 7 days', value: 'lastWeek'}, + ]; + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent}, index) => ( + + + + {name} + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + +
+
+ +
+
+ + + + + +
+ ); +} + +export default withPolarisExample(PopoverFormExample); diff --git a/polaris.shopify.com/app/examples/popover-with-lazy-loaded-list/page.tsx b/polaris.shopify.com/app/examples/popover-with-lazy-loaded-list/page.tsx new file mode 100644 index 00000000000..617efdc870e --- /dev/null +++ b/polaris.shopify.com/app/examples/popover-with-lazy-loaded-list/page.tsx @@ -0,0 +1,99 @@ +'use client'; + +import {Button, LegacyCard, Popover, ResourceList, Avatar} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function PopoverLazyLoadExample() { + const [popoverActive, setPopoverActive] = useState(true); + const [visibleStaffIndex, setVisibleStaffIndex] = useState(5); + const staff = [ + 'Abbey Mayert', + 'Abbi Senger', + 'Abdul Goodwin', + 'Abdullah Borer', + 'Abe Nader', + 'Abigayle Smith', + 'Abner Torphy', + 'Abraham Towne', + 'Abraham Vik', + 'Ada Fisher', + 'Adah Pouros', + 'Adam Waelchi', + 'Adan Zemlak', + 'Addie Wehner', + 'Addison Wexler', + 'Alex Hernandez', + ]; + + const togglePopoverActive = useCallback( + () => setPopoverActive((popoverActive) => !popoverActive), + [], + ); + + const handleScrolledToBottom = useCallback(() => { + const totalIndexes = staff.length; + const interval = + visibleStaffIndex + 3 < totalIndexes + ? 3 + : totalIndexes - visibleStaffIndex; + + if (interval > 0) { + setVisibleStaffIndex(visibleStaffIndex + interval); + } + }, [staff.length, visibleStaffIndex]); + + const handleResourceListItemClick = useCallback(() => {}, []); + + const activator = ( + + ); + + const staffList = staff.slice(0, visibleStaffIndex).map((name) => ({ + name, + initials: getInitials(name), + })); + + return ( + +
+ + + + + +
+
+ ); + + function renderItem({name, initials}) { + return ( + } + onClick={handleResourceListItemClick} + > + {name} + + ); + } + + function getInitials(name) { + return name + .split(' ') + .map((surnameOrFamilyName) => { + return surnameOrFamilyName.slice(0, 1); + }) + .join(''); + } +} + +export default withPolarisExample(PopoverLazyLoadExample); diff --git a/polaris.shopify.com/app/examples/popover-with-searchable-listbox/page.tsx b/polaris.shopify.com/app/examples/popover-with-searchable-listbox/page.tsx new file mode 100644 index 00000000000..827bb2f298b --- /dev/null +++ b/polaris.shopify.com/app/examples/popover-with-searchable-listbox/page.tsx @@ -0,0 +1,333 @@ +'use client'; + +import React, {useState} from 'react'; +import { + Listbox, + TextField, + Icon, + Link, + Popover, + AutoSelection, + Scrollable, + EmptySearchResult, + Text, +} from '@shopify/polaris'; +import {SearchMinor} from '@shopify/polaris-icons'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +const actionValue = '__ACTION__'; + +const segments = [ + { + label: 'All customers', + id: 'gid://shopify/CustomerSegment/1', + value: '0', + }, + { + label: 'VIP customers', + id: 'gid://shopify/CustomerSegment/2', + value: '1', + }, + { + label: 'New customers', + id: 'gid://shopify/CustomerSegment/3', + value: '2', + }, + { + label: 'Abandoned carts - last 30 days', + id: 'gid://shopify/CustomerSegment/4', + value: '3', + }, + { + label: 'Wholesale customers', + id: 'gid://shopify/CustomerSegment/5', + value: '4', + }, + { + label: 'Email subscribers', + id: 'gid://shopify/CustomerSegment/6', + value: '5', + }, + { + label: 'From New York', + id: 'gid://shopify/CustomerSegment/7', + value: '6', + }, + { + label: 'Repeat buyers', + id: 'gid://shopify/CustomerSegment/8', + value: '7', + }, + { + label: 'First time buyers', + id: 'gid://shopify/CustomerSegment/9', + value: '8', + }, + { + label: 'From Canada', + id: 'gid://shopify/CustomerSegment/10', + value: '9', + }, + { + label: 'Bought in last 60 days', + id: 'gid://shopify/CustomerSegment/11', + value: '10', + }, + { + label: 'Bought last BFCM', + id: 'gid://shopify/CustomerSegment/12', + value: '11', + }, +]; + +const lazyLoadSegments = Array.from(Array(100)).map((_, index) => ({ + label: `Other customers ${index + 13}`, + id: `gid://shopify/CustomerSegment/${index + 13}`, + value: `${index + 12}`, +})); + +segments.push(...lazyLoadSegments); + +const interval = 25; + +function PopoverWithSearchableListboxExample() { + const [pickerOpen, setPickerOpen] = useState(false); + const [showFooterAction, setShowFooterAction] = useState(true); + const [query, setQuery] = useState(''); + const [lazyLoading, setLazyLoading] = useState(false); + const [willLoadMoreResults, setWillLoadMoreResults] = useState(true); + const [visibleOptionIndex, setVisibleOptionIndex] = useState(6); + const [activeOptionId, setActiveOptionId] = useState(segments[0].id); + const [selectedSegmentIndex, setSelectedSegmentIndex] = useState(0); + const [filteredSegments, setFilteredSegments] = useState([]); + + const handleClickShowAll = () => { + setShowFooterAction(false); + setVisibleOptionIndex(interval); + }; + + const handleFilterSegments = (query: string) => { + const nextFilteredSegments = segments.filter((segment) => { + return segment.label + .toLocaleLowerCase() + .includes(query.toLocaleLowerCase().trim()); + }); + + setFilteredSegments(nextFilteredSegments); + }; + + const handleQueryChange = (query: string) => { + setQuery(query); + + if (query.length >= 2) handleFilterSegments(query); + }; + + const handleQueryClear = () => { + handleQueryChange(''); + }; + + const handleOpenPicker = () => { + setPickerOpen(true); + }; + + const handleClosePicker = () => { + setPickerOpen(false); + handleQueryChange(''); + }; + + const handleSegmentSelect = (segmentIndex: string) => { + if (segmentIndex === actionValue) { + return handleClickShowAll(); + } + + setSelectedSegmentIndex(Number(segmentIndex)); + handleClosePicker(); + }; + + const handleActiveOptionChange = (_: string, domId: string) => { + setActiveOptionId(domId); + }; + + /* This is just to illustrate lazy loading state vs loading state. This is an example, so we aren't fetching from GraphQL. You'd use `pageInfo.hasNextPage` from your GraphQL query data instead of this fake "willLoadMoreResults" state along with setting `first` your GraphQL query's variables to your app's default max edges limit (e.g., 250). */ + + const handleLazyLoadSegments = () => { + if (willLoadMoreResults && !showFooterAction) { + setLazyLoading(true); + + const options = query ? filteredSegments : segments; + + setTimeout(() => { + const remainingOptionCount = options.length - visibleOptionIndex; + const nextVisibleOptionIndex = + remainingOptionCount >= interval + ? visibleOptionIndex + interval + : visibleOptionIndex + remainingOptionCount; + + setLazyLoading(false); + setVisibleOptionIndex(nextVisibleOptionIndex); + + if (remainingOptionCount <= interval) { + setWillLoadMoreResults(false); + } + }, 1000); + } + }; + + const listboxId = 'SearchableListboxInPopover'; + + /* Your app's feature/context specific activator here */ + const activator = ( +
+ + + {segments[selectedSegmentIndex].label} + + +
+ ); + + const textFieldMarkup = ( +
+ + } + ariaActiveDescendant={activeOptionId} + ariaControls={listboxId} + onChange={handleQueryChange} + onClearButtonClick={handleQueryClear} + /> + +
+ ); + + const segmentOptions = query ? filteredSegments : segments; + + const segmentList = + segmentOptions.length > 0 + ? segmentOptions + .slice(0, visibleOptionIndex) + .map(({label, id, value}) => { + const selected = segments[selectedSegmentIndex].id === id; + + return ( + + + {label} + + + ); + }) + : null; + + const showAllMarkup = showFooterAction ? ( + + Show all 111 segments + + ) : null; + + const lazyLoadingMarkup = lazyLoading ? ( + + ) : null; + + const noResultsMarkup = + segmentOptions.length === 0 ? ( + + ) : null; + + const listboxMarkup = ( + + {segmentList} + {showAllMarkup} + {noResultsMarkup} + {lazyLoadingMarkup} + + ); + + return ( +
+ + +
+ {textFieldMarkup} + + + {listboxMarkup} + +
+
+
+
+ ); +} + +const StopPropagation = ({children}: React.PropsWithChildren) => { + const stopEventPropagation = (event: React.MouseEvent | React.TouchEvent) => { + event.stopPropagation(); + }; + + return ( +
+ {children} +
+ ); +}; + +export default withPolarisExample(PopoverWithSearchableListboxExample); diff --git a/polaris.shopify.com/app/examples/progress-bar-colored/page.tsx b/polaris.shopify.com/app/examples/progress-bar-colored/page.tsx new file mode 100644 index 00000000000..4eed5411e0a --- /dev/null +++ b/polaris.shopify.com/app/examples/progress-bar-colored/page.tsx @@ -0,0 +1,17 @@ +'use client'; + +import {ProgressBar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ProgressBarExample() { + return ( +
+ +
+ +
+ ); +} + +export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/app/examples/progress-bar-default/page.tsx b/polaris.shopify.com/app/examples/progress-bar-default/page.tsx new file mode 100644 index 00000000000..65ff9099d05 --- /dev/null +++ b/polaris.shopify.com/app/examples/progress-bar-default/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {ProgressBar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ProgressBarExample() { + return ( +
+ +
+ ); +} + +export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/app/examples/progress-bar-non-animated/page.tsx b/polaris.shopify.com/app/examples/progress-bar-non-animated/page.tsx new file mode 100644 index 00000000000..281c3640196 --- /dev/null +++ b/polaris.shopify.com/app/examples/progress-bar-non-animated/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {ProgressBar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ProgressBarExample() { + return ( +
+ +
+ ); +} + +export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/app/examples/progress-bar-small/page.tsx b/polaris.shopify.com/app/examples/progress-bar-small/page.tsx new file mode 100644 index 00000000000..953b5525606 --- /dev/null +++ b/polaris.shopify.com/app/examples/progress-bar-small/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {ProgressBar} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ProgressBarExample() { + return ( +
+ +
+ ); +} + +export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/app/examples/radio-button-default/page.tsx b/polaris.shopify.com/app/examples/radio-button-default/page.tsx new file mode 100644 index 00000000000..0e8ebf66e6c --- /dev/null +++ b/polaris.shopify.com/app/examples/radio-button-default/page.tsx @@ -0,0 +1,37 @@ +'use client'; + +import {LegacyStack, RadioButton} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RadioButtonExample() { + const [value, setValue] = useState('disabled'); + + const handleChange = useCallback( + (_checked, newValue) => setValue(newValue), + [], + ); + + return ( + + + + + ); +} + +export default withPolarisExample(RadioButtonExample); diff --git a/polaris.shopify.com/app/examples/range-slider-default/page.tsx b/polaris.shopify.com/app/examples/range-slider-default/page.tsx new file mode 100644 index 00000000000..68ecf332500 --- /dev/null +++ b/polaris.shopify.com/app/examples/range-slider-default/page.tsx @@ -0,0 +1,27 @@ +'use client'; + +import {LegacyCard, RangeSlider} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RangeSliderExample() { + const [rangeValue, setRangeValue] = useState(32); + + const handleRangeSliderChange = useCallback( + (value) => setRangeValue(value), + [], + ); + + return ( + + + + ); +} + +export default withPolarisExample(RangeSliderExample); diff --git a/polaris.shopify.com/app/examples/range-slider-with-dual-thumb/page.tsx b/polaris.shopify.com/app/examples/range-slider-with-dual-thumb/page.tsx new file mode 100644 index 00000000000..3c87ba6dc4e --- /dev/null +++ b/polaris.shopify.com/app/examples/range-slider-with-dual-thumb/page.tsx @@ -0,0 +1,124 @@ +'use client'; + +import { + LegacyCard, + RangeSlider, + LegacyStack, + TextField, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function DualThumbRangeSliderExample() { + const initialValue = [900, 1000]; + const prefix = '$'; + const min = 0; + const max = 2000; + const step = 10; + + const [intermediateTextFieldValue, setIntermediateTextFieldValue] = + useState(initialValue); + const [rangeValue, setRangeValue] = useState(initialValue); + + const handleRangeSliderChange = useCallback((value) => { + setRangeValue(value); + setIntermediateTextFieldValue(value); + }, []); + + const handleLowerTextFieldChange = useCallback( + (value) => { + const upperValue = rangeValue[1]; + setIntermediateTextFieldValue([parseInt(value, 10), upperValue]); + }, + [rangeValue], + ); + + const handleUpperTextFieldChange = useCallback( + (value) => { + const lowerValue = rangeValue[0]; + setIntermediateTextFieldValue([lowerValue, parseInt(value, 10)]); + }, + [rangeValue], + ); + + const handleLowerTextFieldBlur = useCallback(() => { + const upperValue = rangeValue[1]; + const value = intermediateTextFieldValue[0]; + + setRangeValue([parseInt(value, 10), upperValue]); + }, [intermediateTextFieldValue, rangeValue]); + + const handleUpperTextFieldBlur = useCallback(() => { + const lowerValue = rangeValue[0]; + const value = intermediateTextFieldValue[1]; + + setRangeValue([lowerValue, parseInt(value, 10)]); + }, [intermediateTextFieldValue, rangeValue]); + + const handleEnterKeyPress = useCallback( + (event) => { + const newValue = intermediateTextFieldValue; + const oldValue = rangeValue; + + if (event.keyCode === Key.Enter && newValue !== oldValue) { + setRangeValue(newValue); + } + }, + [intermediateTextFieldValue, rangeValue], + ); + + const lowerTextFieldValue = + intermediateTextFieldValue[0] === rangeValue[0] + ? rangeValue[0] + : intermediateTextFieldValue[0]; + + const upperTextFieldValue = + intermediateTextFieldValue[1] === rangeValue[1] + ? rangeValue[1] + : intermediateTextFieldValue[1]; + + return ( + +
+ + + + + +
+
+ ); +} + +export default withPolarisExample(DualThumbRangeSliderExample); diff --git a/polaris.shopify.com/app/examples/range-slider-with-min-and-max/page.tsx b/polaris.shopify.com/app/examples/range-slider-with-min-and-max/page.tsx new file mode 100644 index 00000000000..7399d16460e --- /dev/null +++ b/polaris.shopify.com/app/examples/range-slider-with-min-and-max/page.tsx @@ -0,0 +1,29 @@ +'use client'; + +import {LegacyCard, RangeSlider} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RangeSliderWithPreciseRangeControlExample() { + const [rangeValue, setRangeValue] = useState(0); + + const handleRangeSliderChange = useCallback( + (value) => setRangeValue(value), + [], + ); + + return ( + + + + ); +} + +export default withPolarisExample(RangeSliderWithPreciseRangeControlExample); diff --git a/polaris.shopify.com/app/examples/range-slider-with-prefix-and-suffix/page.tsx b/polaris.shopify.com/app/examples/range-slider-with-prefix-and-suffix/page.tsx new file mode 100644 index 00000000000..6335d2ef534 --- /dev/null +++ b/polaris.shopify.com/app/examples/range-slider-with-prefix-and-suffix/page.tsx @@ -0,0 +1,36 @@ +'use client'; + +import {LegacyCard, RangeSlider} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RangeSliderWithPrefixAndSuffixExample() { + const [rangeValue, setRangeValue] = useState(100); + + const handleRangeSliderChange = useCallback( + (value) => setRangeValue(value), + [], + ); + + const suffixStyles = { + minWidth: '24px', + textAlign: 'right', + }; + + return ( + + Hue

} + suffix={

{rangeValue}

} + /> +
+ ); +} + +export default withPolarisExample(RangeSliderWithPrefixAndSuffixExample); diff --git a/polaris.shopify.com/app/examples/range-slider-with-steps/page.tsx b/polaris.shopify.com/app/examples/range-slider-with-steps/page.tsx new file mode 100644 index 00000000000..bc2b81c0e33 --- /dev/null +++ b/polaris.shopify.com/app/examples/range-slider-with-steps/page.tsx @@ -0,0 +1,30 @@ +'use client'; + +import {LegacyCard, RangeSlider} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RangeSliderWithPreciseRangeControlExample() { + const [rangeValue, setRangeValue] = useState(4); + + const handleRangeSliderChange = useCallback( + (value) => setRangeValue(value), + [], + ); + + return ( + + + + ); +} + +export default withPolarisExample(RangeSliderWithPreciseRangeControlExample); diff --git a/polaris.shopify.com/app/examples/resource-item-default/page.tsx b/polaris.shopify.com/app/examples/resource-item-default/page.tsx new file mode 100644 index 00000000000..7c18d0101bc --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-item-default/page.tsx @@ -0,0 +1,47 @@ +'use client'; + +import {LegacyCard, ResourceList, ResourceItem, Text} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceItemExample() { + const [selectedItems, setSelectedItems] = useState([]); + + return ( + + { + const {id, url, title, author} = item; + const authorMarkup = author ?
by {author}
: null; + return ( + + + {title} + + {authorMarkup} + + ); + }} + /> +
+ ); +} + +export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/app/examples/resource-item-with-media/page.tsx b/polaris.shopify.com/app/examples/resource-item-with-media/page.tsx new file mode 100644 index 00000000000..ddbe8874fd1 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-item-with-media/page.tsx @@ -0,0 +1,52 @@ +'use client'; + +import {LegacyCard, ResourceList, ResourceItem, Avatar, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceItemExample() { + return ( + + { + const {id, url, avatarSource, name, location} = item; + + return ( + + } + accessibilityLabel={`View details for ${name}`} + name={name} + > + + {name} + +
{location}
+
+ ); + }} + /> +
+ ); +} + +export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/app/examples/resource-item-with-shortcut-actions/page.tsx b/polaris.shopify.com/app/examples/resource-item-with-shortcut-actions/page.tsx new file mode 100644 index 00000000000..f6e9eff4881 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-item-with-shortcut-actions/page.tsx @@ -0,0 +1,57 @@ +'use client'; + +import {LegacyCard, ResourceList, ResourceItem, Avatar, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceItemExample() { + return ( + + { + const {id, url, avatarSource, name, location, latestOrderUrl} = item; + const shortcutActions = latestOrderUrl + ? [{content: 'View latest order', url: latestOrderUrl}] + : null; + + return ( + + } + shortcutActions={shortcutActions} + accessibilityLabel={`View details for ${name}`} + name={name} + > + + {name} + +
{location}
+
+ ); + }} + /> +
+ ); +} + +export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/app/examples/resource-item-with-vertical-alignment/page.tsx b/polaris.shopify.com/app/examples/resource-item-with-vertical-alignment/page.tsx new file mode 100644 index 00000000000..5072cdcd5d0 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-item-with-vertical-alignment/page.tsx @@ -0,0 +1,54 @@ +'use client'; + +import {LegacyCard, ResourceList, ResourceItem, Avatar, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceItemExample() { + return ( + + { + const {id, url, avatarSource, name, location, lastOrder} = item; + return ( + + } + accessibilityLabel={`View details for ${name}`} + name={name} + > + + {name} + +
{location}
+
{lastOrder}
+
+ ); + }} + /> +
+ ); +} + +export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/app/examples/resource-list-default/page.tsx b/polaris.shopify.com/app/examples/resource-list-default/page.tsx new file mode 100644 index 00000000000..33aca5fc56a --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-default/page.tsx @@ -0,0 +1,49 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListExample() { + return ( + + { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+ ); +} + +export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-a-custom-empty-search-result-state/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-a-custom-empty-search-result-state/page.tsx new file mode 100644 index 00000000000..92954052099 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-a-custom-empty-search-result-state/page.tsx @@ -0,0 +1,127 @@ +'use client'; + +import { + TextField, + Filters, + Button, + LegacyCard, + ResourceList, + Avatar, + ResourceItem, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithFilteringExample() { + const [taggedWith, setTaggedWith] = useState('VIP'); + const [queryValue, setQueryValue] = useState(null); + const [items, setItems] = useState([]); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleQueryValueChange = useCallback((value) => { + setQueryValue(value); + setItems([]); + }, []); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const filters = [ + { + key: 'taggedWith2', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith2', + label: disambiguateLabel('taggedWith2', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + const filterControl = ( + +
+ +
+
+ ); + + return ( + + This is a custom empty state
} + /> +
+ ); + + function renderItem(item) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith2': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(ResourceListWithFilteringExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-all-of-its-elements/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-all-of-its-elements/page.tsx new file mode 100644 index 00000000000..e51225656a8 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-all-of-its-elements/page.tsx @@ -0,0 +1,188 @@ +'use client'; + +import { + TextField, + Filters, + Button, + LegacyCard, + ResourceList, + Avatar, + ResourceItem, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListExample() { + const [selectedItems, setSelectedItems] = useState([]); + const [sortValue, setSortValue] = useState('DATE_MODIFIED_DESC'); + const [taggedWith, setTaggedWith] = useState('VIP'); + const [queryValue, setQueryValue] = useState(null); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleQueryValueChange = useCallback( + (value) => setQueryValue(value), + [], + ); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const items = [ + { + id: 112, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + latestOrderUrl: 'orders/1456', + }, + { + id: 212, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + latestOrderUrl: 'orders/1457', + }, + ]; + + const promotedBulkActions = [ + { + content: 'Edit customers', + onAction: () => console.log('Todo: implement bulk edit'), + }, + ]; + + const bulkActions = [ + { + content: 'Add tags', + onAction: () => console.log('Todo: implement bulk add tags'), + }, + { + content: 'Remove tags', + onAction: () => console.log('Todo: implement bulk remove tags'), + }, + { + content: 'Delete customers', + onAction: () => console.log('Todo: implement bulk delete'), + }, + ]; + + const filters = [ + { + key: 'taggedWith3', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith3', + label: disambiguateLabel('taggedWith3', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + const filterControl = ( + +
+ +
+
+ ); + + return ( + + { + setSortValue(selected); + console.log(`Sort option changed to ${selected}.`); + }} + filterControl={filterControl} + /> + + ); + + function renderItem(item) { + const {id, url, name, location, latestOrderUrl} = item; + const media = ; + const shortcutActions = latestOrderUrl + ? [{content: 'View latest order', url: latestOrderUrl}] + : null; + return ( + + + {name} + +
{location}
+
+ ); + } + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith3': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-alternate-tool/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-alternate-tool/page.tsx new file mode 100644 index 00000000000..c67d959cad8 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-alternate-tool/page.tsx @@ -0,0 +1,66 @@ +'use client'; + +import { + LegacyCard, + ResourceList, + Button, + Avatar, + ResourceItem, + Text, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithAlternateToolExample() { + const resourceName = { + singular: 'Customer', + plural: 'Customers', + }; + + const items = [ + { + id: 107, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 207, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]; + + return ( + + Email customers} + /> + + ); + + function renderItem(item) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } +} + +export default withPolarisExample(ResourceListWithAlternateToolExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-bulk-actions/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-bulk-actions/page.tsx new file mode 100644 index 00000000000..26d5e5ffb5d --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-bulk-actions/page.tsx @@ -0,0 +1,86 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithBulkActionsExample() { + const [selectedItems, setSelectedItems] = useState([]); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const items = [ + { + id: 103, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 203, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]; + + const promotedBulkActions = [ + { + content: 'Edit customers', + onAction: () => console.log('Todo: implement bulk edit'), + }, + ]; + + const bulkActions = [ + { + content: 'Add tags', + onAction: () => console.log('Todo: implement bulk add tags'), + }, + { + content: 'Remove tags', + onAction: () => console.log('Todo: implement bulk remove tags'), + }, + { + content: 'Delete customers', + onAction: () => console.log('Todo: implement bulk delete'), + }, + ]; + + return ( + + + + ); + + function renderItem(item) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } +} + +export default withPolarisExample(ResourceListWithBulkActionsExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-empty-state/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-empty-state/page.tsx new file mode 100644 index 00000000000..aa811f8b76e --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-empty-state/page.tsx @@ -0,0 +1,61 @@ +'use client'; + +import { + Filters, + EmptyState, + Page, + Layout, + LegacyCard, + ResourceList, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithEmptyStateExample() { + const items = []; + const appliedFilters = []; + const filters = []; + + const filterControl = ( + + ); + + const emptyStateMarkup = + !appliedFilters.length && !items.length ? ( + +

+ You can use the Files section to upload images, videos, and other + documents +

+
+ ) : undefined; + + return ( + + + + + {}} + filterControl={filterControl} + resourceName={{singular: 'file', plural: 'files'}} + /> + + + + + ); +} + +export default withPolarisExample(ResourceListWithEmptyStateExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-filtering/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-filtering/page.tsx new file mode 100644 index 00000000000..265df89adf7 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-filtering/page.tsx @@ -0,0 +1,136 @@ +'use client'; + +import { + TextField, + Filters, + Button, + LegacyCard, + ResourceList, + Avatar, + ResourceItem, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithFilteringExample() { + const [taggedWith, setTaggedWith] = useState('VIP'); + const [queryValue, setQueryValue] = useState(null); + + const handleTaggedWithChange = useCallback( + (value) => setTaggedWith(value), + [], + ); + const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); + const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); + const handleClearAll = useCallback(() => { + handleTaggedWithRemove(); + handleQueryValueRemove(); + }, [handleQueryValueRemove, handleTaggedWithRemove]); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const items = [ + { + id: 108, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 208, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]; + + const filters = [ + { + key: 'taggedWith1', + label: 'Tagged with', + filter: ( + + ), + shortcut: true, + }, + ]; + + const appliedFilters = !isEmpty(taggedWith) + ? [ + { + key: 'taggedWith1', + label: disambiguateLabel('taggedWith1', taggedWith), + onRemove: handleTaggedWithRemove, + }, + ] + : []; + + const filterControl = ( + +
+ +
+
+ ); + + return ( + + + + ); + + function renderItem(item) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } + + function disambiguateLabel(key, value) { + switch (key) { + case 'taggedWith1': + return `Tagged with ${value}`; + default: + return value; + } + } + + function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else { + return value === '' || value == null; + } + } +} + +export default withPolarisExample(ResourceListWithFilteringExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-item-shortcut-actions/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-item-shortcut-actions/page.tsx new file mode 100644 index 00000000000..9f07bc54373 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-item-shortcut-actions/page.tsx @@ -0,0 +1,61 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListExample() { + return ( + + { + const {id, url, name, location, latestOrderUrl} = item; + const media = ; + const shortcutActions = latestOrderUrl + ? [ + { + content: 'View latest order', + accessibilityLabel: `View ${name}’s latest order`, + url: latestOrderUrl, + }, + ] + : null; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+ ); +} + +export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-loading-state/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-loading-state/page.tsx new file mode 100644 index 00000000000..7b8fe4ae186 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-loading-state/page.tsx @@ -0,0 +1,87 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithLoadingExample() { + const [selectedItems, setSelectedItems] = useState([]); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const items = [ + { + id: 104, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 204, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]; + + const promotedBulkActions = [ + { + content: 'Edit customers', + onAction: () => console.log('Todo: implement bulk edit'), + }, + ]; + + const bulkActions = [ + { + content: 'Add tags', + onAction: () => console.log('Todo: implement bulk add tags'), + }, + { + content: 'Remove tags', + onAction: () => console.log('Todo: implement bulk remove tags'), + }, + { + content: 'Delete customers', + onAction: () => console.log('Todo: implement bulk delete'), + }, + ]; + + return ( + + + + ); + + function renderItem(item) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } +} + +export default withPolarisExample(ResourceListWithLoadingExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-multiselect/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-multiselect/page.tsx new file mode 100644 index 00000000000..59eb3ff27b8 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-multiselect/page.tsx @@ -0,0 +1,116 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListExample() { + const [selectedItems, setSelectedItems] = useState([]); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const items = [ + { + id: 111, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 211, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + { + id: 311, + url: '#', + name: 'Joe Smith', + location: 'Arizona, USA', + }, + { + id: 411, + url: '#', + name: 'Haden Jerado', + location: 'Decatur, USA', + }, + { + id: 511, + url: '#', + name: 'Tom Thommas', + location: 'Florida, USA', + }, + { + id: 611, + url: '#', + name: 'Emily Amrak', + location: 'Texas, USA', + }, + ]; + + const promotedBulkActions = [ + { + content: 'Edit customers', + onAction: () => console.log('Todo: implement bulk edit'), + }, + ]; + + const bulkActions = [ + { + content: 'Add tags', + onAction: () => console.log('Todo: implement bulk add tags'), + }, + { + content: 'Remove tags', + onAction: () => console.log('Todo: implement bulk remove tags'), + }, + { + content: 'Delete customers', + onAction: () => console.log('Todo: implement bulk delete'), + }, + ]; + + return ( + + + + ); + + function renderItem(item, _, index) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } + + function resolveItemIds({id}) { + return id; + } +} + +export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-persistent-item-shortcut-actions/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-persistent-item-shortcut-actions/page.tsx new file mode 100644 index 00000000000..4d4d50632f7 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-persistent-item-shortcut-actions/page.tsx @@ -0,0 +1,62 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListExample() { + return ( + + { + const {id, url, name, location, latestOrderUrl} = item; + const media = ; + const shortcutActions = latestOrderUrl + ? [ + { + content: 'View latest order', + accessibilityLabel: `View ${name}’s latest order`, + url: latestOrderUrl, + }, + ] + : null; + + return ( + + + {name} + +
{location}
+
+ ); + }} + /> +
+ ); +} + +export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-selection-and-no-bulk-actions/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-selection-and-no-bulk-actions/page.tsx new file mode 100644 index 00000000000..5c14a040673 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-selection-and-no-bulk-actions/page.tsx @@ -0,0 +1,63 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithSelectionExample() { + const [selectedItems, setSelectedItems] = useState([]); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const items = [ + { + id: 101, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 201, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]; + + return ( + + + + ); + + function renderItem(item) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } +} + +export default withPolarisExample(ResourceListWithSelectionExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-sorting/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-sorting/page.tsx new file mode 100644 index 00000000000..e83341a8921 --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-sorting/page.tsx @@ -0,0 +1,69 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import {useState} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithSortingExample() { + const [sortValue, setSortValue] = useState('DATE_MODIFIED_DESC'); + + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const items = [ + { + id: 106, + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + }, + { + id: 206, + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + }, + ]; + + return ( + + { + setSortValue(selected); + console.log(`Sort option changed to ${selected}.`); + }} + /> + + ); + + function renderItem(item) { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + } +} + +export default withPolarisExample(ResourceListWithSortingExample); diff --git a/polaris.shopify.com/app/examples/resource-list-with-total-count/page.tsx b/polaris.shopify.com/app/examples/resource-list-with-total-count/page.tsx new file mode 100644 index 00000000000..eeadef3304a --- /dev/null +++ b/polaris.shopify.com/app/examples/resource-list-with-total-count/page.tsx @@ -0,0 +1,51 @@ +'use client'; + +import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ResourceListWithTotalItemsCount() { + return ( + + { + const {id, url, name, location} = item; + const media = ; + + return ( + + + {name} + +
{location}
+
+ ); + }} + showHeader + totalItemsCount={50} + /> +
+ ); +} + +export default withPolarisExample(ResourceListWithTotalItemsCount); diff --git a/polaris.shopify.com/app/examples/scrollable-default/page.tsx b/polaris.shopify.com/app/examples/scrollable-default/page.tsx new file mode 100644 index 00000000000..0d72cfe995e --- /dev/null +++ b/polaris.shopify.com/app/examples/scrollable-default/page.tsx @@ -0,0 +1,31 @@ +'use client'; + +import {LegacyCard, Scrollable} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ScrollableExample() { + return ( + + +

+ By signing up for the Shopify service (“Service”) or any of the + services of Shopify Inc. (“Shopify”) you are agreeing to be bound by + the following terms and conditions (“Terms of Service”). The Services + offered by Shopify under the Terms of Service include various products + and services to help you create and manage a retail store, whether an + online store (“Online Services”), a physical retail store (“POS + Services”), or both. Any new features or tools which are added to the + current Service shall be also subject to the Terms of Service. You can + review the current version of the Terms of Service at any time at + https://www.shopify.com/legal/terms. Shopify reserves the right to + update and change the Terms of Service by posting updates and changes + to the Shopify website. You are advised to check the Terms of Service + from time to time for any updates or changes that may impact you. +

+
+
+ ); +} + +export default withPolarisExample(ScrollableExample); diff --git a/polaris.shopify.com/app/examples/scrollable-to-child-component/page.tsx b/polaris.shopify.com/app/examples/scrollable-to-child-component/page.tsx new file mode 100644 index 00000000000..f3aa7ea1755 --- /dev/null +++ b/polaris.shopify.com/app/examples/scrollable-to-child-component/page.tsx @@ -0,0 +1,299 @@ +'use client'; + +import {LegacyCard, Scrollable} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ScrollableExample() { + return ( + + +
    +
  1. Account Terms
  2. +
+

+ You must be 18 years or older or at least the age of majority in the + jurisdiction where you reside or from which you use this Service. +

+

+ To access and use the Services, you must register for a Shopify + account (“Account”) by providing your full legal name, current + address, phone number, a valid email address, and any other + information indicated as required. Shopify may reject your application + for an Account, or cancel an existing Account, for any reason, in our + sole discretion. +

+

+ You acknowledge that Shopify will use the email address you provide as + the primary method for communication. +

+

+ You are responsible for keeping your password secure. Shopify cannot + and will not be liable for any loss or damage from your failure to + maintain the security of your Account and password. +

+

+ You are responsible for all activity and content such as photos, + images, videos, graphics, written content, audio files, code, + information, or data uploaded, collected, generated, stored, + displayed, distributed, transmitted or exhibited on or in connection + with your Account (“Materials”). +

+

+ A breach or violation of any term in the Terms of Service, including + the AUP, as determined in the sole discretion of Shopify will result + in an immediate termination of your services. +

+

Which means

+

+ You are responsible for your Account and any Materials you upload to + the Shopify Service. Remember that with any violation of these terms + we will cancel your service. +

+ +

If we need to reach you, we will send you an email.

+ +
    +
  1. Account Activation
  2. +
+ +

2.1 Shopify Account

+
+ +

+ Subject to section 2.1.2, the person signing up for the Service will + be the contracting party (“Account Owner”) for the purposes of our + Terms of Service and will be the person who is authorized to use any + corresponding account we may provide to the Account Owner in + connection with the Service. +

+

+ If you are signing up for the Service on behalf of your employer, your + employer shall be the Account Owner. If you are signing up for the + Service on behalf of your employer, then you represent and warrant + that you have the authority to bind your employer to our Terms of + Service. +

+

2.2 PayPal Express Checkout and Shopify Payments Accounts

+ +

+ Upon completion of sign up for the Service, Shopify will create a + PayPal Express Checkout account on your behalf, using your email + address. Depending on your location, Shopify may also create a Shopify + Payments account on your behalf. +

+

+ You acknowledge that PayPal Express Checkout and/or Shopify Payments + will be your default payments gateway(s) and that it is your sole + responsibility as the Account Owner to activate and maintain these + accounts. If you do not wish to keep either of the payment accounts + active, it is your responsibility to deactivate them. For the + avoidance of doubt, PayPal Express Checkout is a Third Party Service, + as defined in Section 15 of these Terms of Service. +

+

2.3 Apple Pay for Safari Account

+ +

+ Upon completion of sign up for the Service, Shopify will create an + Apple Pay for Safari (“Apple Pay”) account on your behalf, using the + URL(s) and business name associated with your Account. Depending on + your location, Shopify may activate your Apple Pay account on your + behalf, otherwise you will be required to activate your Apple Pay + account within your Account admin. If you do not wish to keep your + Apple Pay account active, it is your responsibility to deactivate it. + For the avoidance of doubt, Apple Pay is a Third Party Service, as + defined in Section 15 of these Terms of Service. +

+

+ If you use an Apple Pay supported payment gateway and your customers + have enabled Apple Pay on their device, customers may purchase goods + and services from your store using Apple Pay. +

+

+ By using Apple Pay on your store, you are agreeing to be bound by the + Apple Pay Platform Web Merchant Terms and Conditions, as they may be + amended by Apple from time to time. If Apple amends the Apple Pay + Platform Web Merchant Terms and Conditions, the amended and restated + version will be posted here:{' '} + + https://www.shopify.com/legal/apple-pay + + . Such amendments to the Apple Pay Platform Web Merchant Terms are + effective as of the date of posting. Your continued use of Apple Pay + on your store after the amended Apple Pay Platform Web Merchant Terms + are posted constitutes your agreement to, and acceptance of, the + amended Apple Pay Platform Web Merchant Terms. If you do not agree to + any changes to the Apple Pay Platform Web Merchant Terms, de-activate + your Apple Pay account and do not continue to use Apple Pay on your + store. +

+

2.4 Google Payment

+ +

+ Upon completion of sign up for the Service, if you have been enrolled + in Shopify Payments, Shopify will also create a Google Payment account + on your behalf. If you do not wish to keep your Google Payment account + active, it is your responsibility to deactivate it. For the avoidance + of doubt, Google Payment is a Third Party Service, as defined in + Section 15 of these Terms of Service. +

+ +

+ If you use a Google Payment supported payment gateway and your + customers have enabled Google Payment, customers may purchase goods + and services from your store using Google Payment. +

+ +

+ By using Google Payment on your store, you are agreeing to be bound by + the Google Payment API Terms of Service, as they may be amended by + Google from time to time. If Google amends the Google Payment API + Terms of Service, the amended and restated version will be posted + here:{' '} + + https://payments.developers.google.com/terms/sellertos + + . Such amendments to the Google Payment API Terms of Service are + effective as of the date of posting. Your continued use of Google + Payment on your store after the amended Google Payment API Terms of + Service are posted constitutes your agreement to, and acceptance of, + the amended Google Payment API Terms of Service. If you do not agree + to any changes to the Google Payment API Terms of Service, de-activate + your Google Payment account and do not continue to use Google Payment + on your store. +

+ +

2.5 Domain Names

+ +

+ Upon purchasing a domain name through Shopify, domain registration + will be preset to automatically renew each year so long as your + Shopify Account remains active. You acknowledge that it is your sole + responsibility to deactivate the auto-renewal function should you + choose to do so. +

+

Which means

+

+ The person signing up for the Shopify Service is responsible for the + account and is bound by these Terms of Service. If you signup on + behalf of your employer, your employer owns the account and is also + bound by our Terms of Service. +

+ +

+ We automatically create accounts for you to accept payments. You are + responsible for activating and deactivating these accounts. +

+ +

+ Any domain you purchase through us will automatically renew unless you + opt out. +

+ +
    +
  1. General Conditions
  2. +
+

+ You must read, agree with and accept all of the terms and conditions + contained in these Terms of Service, including the AUP and the Privacy + Policy before you may become a member of Shopify. +

+ +

+ Technical support is only provided to paying Account holders and is + only available via email. +

+

+ The Terms of Service shall be governed by and interpreted in + accordance with the laws of the Province of Ontario and the laws of + Canada applicable therein, without regard to principles of conflicts + of laws. The parties irrevocably and unconditionally submit to the + exclusive jurisdiction of the courts of the Province of Ontario with + respect to any dispute or claim arising out of or in connection with + the Terms of Service. The United Nations Convention on Contracts for + the International Sale of Goods will not apply to these Terms of + Service and is hereby expressly excluded. +

+

+ You acknowledge and agree that Shopify may amend these Terms of + Service at any time by posting the relevant amended and restated Terms + of Service on Shopify’s website, available at{' '} + + https://www.shopify.com/legal/terms + {' '} + and such amendments to the Terms of Service are effective as of the + date of posting. Your continued use of the Services after the amended + Terms of Service are posted to Shopify’s website constitutes your + agreement to, and acceptance of, the amended Terms of Service. If you + do not agree to any changes to the Terms of Service, do not continue + to use the Service. +

+

+ You may not use the Shopify service for any illegal or unauthorized + purpose nor may you, in the use of the Service, violate any laws in + your jurisdiction (including but not limited to copyright laws), the + laws applicable to you in your customer’s jurisdiction, or the laws of + Canada and the Province of Ontario. You will comply with all + applicable laws, rules and regulations in your use of the Service. +

+

+ You agree not to reproduce, duplicate, copy, sell, resell or exploit + any portion of the Service, use of the Service, or access to the + Service without the express written permission by Shopify. +

+

+ You shall not purchase search engine or other pay per click keywords + (such as Google AdWords), or domain names that use Shopify or Shopify + trademarks and/or variations and misspellings thereof. +

+

+ Questions about the Terms of Service should be sent to{' '} + support@shopify.com. +

+

+ You understand that your Materials (not including credit card + information), may be transferred unencrypted and involve (a) + transmissions over various networks; and (b) changes to conform and + adapt to technical requirements of connecting networks or devices. + Credit Card information is always encrypted during transfer over + networks. +

+

+ You acknowledge and agree that your use of the Service, including + information transmitted to or stored by Shopify, is governed by its + privacy policy at{' '} + + https://www.shopify.com/legal/privacy + +

+

+ The Terms of Service may be available in languages other than English. + To the extent of any inconsistencies or conflicts between these + English Terms of Service and Shopify’s Terms of Service available in + another language, the most current English version of the Terms of + Service at{' '} + + https://www.shopify.com/legal/terms + {' '} + will prevail. +

+

Which means

+

+ The Shopify service belongs to us. You are not allowed to rip it off + or use it for any illegal or sketchy purpose. +

+ +

+ If a dispute arises the issue will be dealt with in the Province of + Ontario. +

+ +

+ Your Materials may be transferred unencrypted and may be altered, but + credit card information is always encrypted. +

+ + + ); +} +export default withPolarisExample(ScrollableExample); diff --git a/polaris.shopify.com/app/examples/select-default/page.tsx b/polaris.shopify.com/app/examples/select-default/page.tsx new file mode 100644 index 00000000000..7902e447d0e --- /dev/null +++ b/polaris.shopify.com/app/examples/select-default/page.tsx @@ -0,0 +1,28 @@ +'use client'; + +import {Select} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SelectExample() { + const [selected, setSelected] = useState('today'); + + const handleSelectChange = useCallback((value) => setSelected(value), []); + + const options = [ + {label: 'Today', value: 'today'}, + {label: 'Yesterday', value: 'yesterday'}, + {label: 'Last 7 days', value: 'lastWeek'}, + ]; + + return ( + + ); +} + +export default withPolarisExample(SelectExample); diff --git a/polaris.shopify.com/app/examples/select-with-inline-label/page.tsx b/polaris.shopify.com/app/examples/select-with-inline-label/page.tsx new file mode 100644 index 00000000000..2d4612e458f --- /dev/null +++ b/polaris.shopify.com/app/examples/select-with-inline-label/page.tsx @@ -0,0 +1,32 @@ +'use client'; + +import {Select} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function InlineLabelExample() { + const [selected, setSelected] = useState('newestUpdate'); + + const handleSelectChange = useCallback((value) => setSelected(value), []); + + const options = [ + {label: 'Newest update', value: 'newestUpdate'}, + {label: 'Oldest update', value: 'oldestUpdate'}, + {label: 'Most spent', value: 'mostSpent'}, + {label: 'Most orders', value: 'mostOrders'}, + {label: 'Last name A–Z', value: 'lastNameAlpha'}, + {label: 'Last name Z–A', value: 'lastNameReverseAlpha'}, + ]; + + return ( + + ); +} + +export default withPolarisExample(PrefixExample); diff --git a/polaris.shopify.com/app/examples/select-with-separate-validation-error/page.tsx b/polaris.shopify.com/app/examples/select-with-separate-validation-error/page.tsx new file mode 100644 index 00000000000..a067b22e426 --- /dev/null +++ b/polaris.shopify.com/app/examples/select-with-separate-validation-error/page.tsx @@ -0,0 +1,77 @@ +'use client'; + +import { + LegacyStack, + FormLayout, + TextField, + Select, + InlineError, + LegacyCard, + Link, + Text, +} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SeparateValidationErrorExample() { + const [weight, setWeight] = useState('12'); + const [unit, setUnit] = useState(''); + + const handleWeightChange = useCallback((value) => setWeight(value), []); + const handleUnitChange = useCallback((value) => setUnit(value), []); + + const unitSelectID = 'unit'; + const errorMessage = generateErrorMessage(); + const formGroupMarkup = ( + + + + + + ); +} + +export default withPolarisExample(ValidationErrorExample); diff --git a/polaris.shopify.com/app/examples/setting-toggle-default/page.tsx b/polaris.shopify.com/app/examples/setting-toggle-default/page.tsx new file mode 100644 index 00000000000..0f1bdd2d6a9 --- /dev/null +++ b/polaris.shopify.com/app/examples/setting-toggle-default/page.tsx @@ -0,0 +1,32 @@ +'use client'; + +import {SettingToggle, Text} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SettingToggleExample() { + const [active, setActive] = useState(false); + + const handleToggle = useCallback(() => setActive((active) => !active), []); + + const contentStatus = active ? 'Deactivate' : 'Activate'; + const textStatus = active ? 'activated' : 'deactivated'; + + return ( + + This setting is{' '} + + {textStatus} + + . + + ); +} + +export default withPolarisExample(SettingToggleExample); diff --git a/polaris.shopify.com/app/examples/sheet-default/page.tsx b/polaris.shopify.com/app/examples/sheet-default/page.tsx new file mode 100644 index 00000000000..4b9cc180758 --- /dev/null +++ b/polaris.shopify.com/app/examples/sheet-default/page.tsx @@ -0,0 +1,152 @@ +'use client'; + +import { + List, + Button, + Page, + LegacyCard, + Sheet, + Scrollable, + ChoiceList, + Text, +} from '@shopify/polaris'; +import {MobileCancelMajor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SheetExample() { + const [sheetActive, setSheetActive] = useState(true); + const [title, setTitle] = useState('Big yellow socks'); + const [description, setDescription] = useState( + "They’re big, yellow socks. What more could you possibly want from socks? These socks will change your life.\n\nThey’re made from light, hand-loomed cotton that’s so soft, you'll feel like you are walking on a cloud.", + ); + const [salesChannels, setSalesChannels] = useState([ + {value: 'onlineStore', label: 'Online Store'}, + {value: 'facebook', label: 'Facebook'}, + {value: 'googleShopping', label: 'Google shopping'}, + {value: 'facebookMarketing', label: 'Facebook Marketing'}, + ]); + const [selected, setSelected] = useState([]); + + const toggleSheetActive = useCallback( + () => setSheetActive((sheetActive) => !sheetActive), + [], + ); + const handleSelectedChange = useCallback((value) => setSelected(value), []); + const handleTitleChange = useCallback((value) => setTitle(value), []); + const handleDescriptionChange = useCallback( + (value) => setDescription(value), + [], + ); + + const selectedSalesChannels = selected.map((key) => { + return salesChannels.reduce((accumulator, current) => { + accumulator[current.value] = current.label; + return accumulator; + }, {})[key]; + }); + const hasSelectedSalesChannels = selectedSalesChannels.length > 0; + + const salesChannelsCardMarkup = hasSelectedSalesChannels ? ( + + {selectedSalesChannels.map((channel, index) => ( + {channel} + ))} + + ) : ( +
+

No sales channels selected

+ +
+ ); + + const salesChannelAction = hasSelectedSalesChannels + ? [ + { + onAction: toggleSheetActive, + content: 'Manage sales channels', + }, + ] + : null; + + return ( + + + {salesChannelsCardMarkup} + + +
+
+ + Manage sales channels + +
+ + + +
+ + +
+
+
+
+ ); +} + +export default withPolarisExample(SheetExample); diff --git a/polaris.shopify.com/app/examples/sheet-with-searchable-listbox/page.tsx b/polaris.shopify.com/app/examples/sheet-with-searchable-listbox/page.tsx new file mode 100644 index 00000000000..2200df62556 --- /dev/null +++ b/polaris.shopify.com/app/examples/sheet-with-searchable-listbox/page.tsx @@ -0,0 +1,387 @@ +'use client'; + +import React, {useState, useCallback} from 'react'; +import { + TextField, + LegacyStack, + Listbox, + Page, + Sheet, + Scrollable, + AutoSelection, + Icon, + Button, + EmptySearchResult, + TextContainer, + Text, +} from '@shopify/polaris'; +import {MobileCancelMajor, SearchMinor} from '@shopify/polaris-icons'; + +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +const actionValue = '__ACTION__'; + +const segments = [ + { + label: 'All customers', + id: 'gid://shopify/CustomerSegment/1', + value: '0', + }, + { + label: 'VIP customers', + id: 'gid://shopify/CustomerSegment/2', + value: '1', + }, + { + label: 'New customers', + id: 'gid://shopify/CustomerSegment/3', + value: '2', + }, + { + label: 'Abandoned carts - last 30 days', + id: 'gid://shopify/CustomerSegment/4', + value: '3', + }, + { + label: 'Wholesale customers', + id: 'gid://shopify/CustomerSegment/5', + value: '4', + }, + { + label: 'Email subscribers', + id: 'gid://shopify/CustomerSegment/6', + value: '5', + }, + { + label: 'From New York', + id: 'gid://shopify/CustomerSegment/7', + value: '6', + }, + { + label: 'Repeat buyers', + id: 'gid://shopify/CustomerSegment/8', + value: '7', + }, + { + label: 'First time buyers', + id: 'gid://shopify/CustomerSegment/9', + value: '8', + }, + { + label: 'From Canada', + id: 'gid://shopify/CustomerSegment/10', + value: '9', + }, + { + label: 'Bought in last 60 days', + id: 'gid://shopify/CustomerSegment/11', + value: '10', + }, + { + label: 'Bought last BFCM', + id: 'gid://shopify/CustomerSegment/12', + value: '11', + }, +]; + +const lazyLoadSegments = Array.from(Array(100)).map((_, index) => ({ + label: `Other customers ${index + 13}`, + id: `gid://shopify/CustomerSegment/${index + 13}`, + value: `${index + 12}`, +})); + +segments.push(...lazyLoadSegments); + +const interval = 25; + +function SheetWithSearchableListboxExample() { + const [sheetOpen, setSheetOpen] = useState(true); + const [showFooterAction, setShowFooterAction] = useState(true); + const [query, setQuery] = useState(''); + const [lazyLoading, setLazyLoading] = useState(false); + const [willLoadMoreResults, setWillLoadMoreResults] = useState(true); + const [visibleOptionIndex, setVisibleOptionIndex] = useState(6); + const [activeOptionId, setActiveOptionId] = useState(segments[0].id); + const [selectedSegmentIndex, setSelectedSegmentIndex] = useState(0); + const [filteredSegments, setFilteredSegments] = useState([]); + + const handleClickShowAll = () => { + setShowFooterAction(false); + setVisibleOptionIndex(segments.length); + }; + + const handleFilterSegments = (query: string) => { + const nextFilteredSegments = segments.filter((segment) => { + return segment.label + .toLocaleLowerCase() + .includes(query.toLocaleLowerCase().trim()); + }); + + setFilteredSegments(nextFilteredSegments); + }; + + const handleQueryChange = (query: string) => { + setQuery(query); + + if (query.length >= 2) handleFilterSegments(query); + }; + + const handleQueryClear = () => { + handleQueryChange(''); + }; + + const handleResetVisibleOptionIndex = () => { + setVisibleOptionIndex(interval); + }; + + const handleOpenSheet = () => { + setSheetOpen(true); + }; + + const handleCloseSheet = () => { + setSheetOpen(false); + handleQueryChange(''); + handleResetVisibleOptionIndex(); + }; + + const handleSegmentSelect = (segmentIndex: string) => { + if (segmentIndex === actionValue) { + return handleClickShowAll(); + } + + setSelectedSegmentIndex(Number(segmentIndex)); + handleCloseSheet(); + }; + + const handleActiveOptionChange = (_: string, domId: string) => { + setActiveOptionId(domId); + }; + + /* This is just to illustrate lazy loading state vs loading state. This is an example, so we aren't fetching from GraphQL. You'd use `pageInfo.hasNextPage` from your GraphQL query data instead of this fake "willLoadMoreResults" state along with setting `first` your GraphQL query's variables to your app's default max edges limit (e.g., 250). */ + + const handleLazyLoadSegments = () => { + if (willLoadMoreResults && !showFooterAction) { + setLazyLoading(true); + + const options = query ? filteredSegments : segments; + + setTimeout(() => { + const remainingOptionCount = options.length - visibleOptionIndex; + const nextVisibleOptionIndex = + remainingOptionCount >= interval + ? visibleOptionIndex + interval + : visibleOptionIndex + remainingOptionCount; + + setLazyLoading(false); + setVisibleOptionIndex(nextVisibleOptionIndex); + + if (remainingOptionCount <= interval) { + setWillLoadMoreResults(false); + } + }, 1000); + } + }; + + const listboxId = 'SearchableListboxInSheet'; + + /* Your app's feature/context specific activator here */ + const activator = ( + + ); + + const textFieldMarkup = ( +
+ + } + ariaActiveDescendant={activeOptionId} + ariaControls={listboxId} + onChange={handleQueryChange} + onClearButtonClick={handleQueryClear} + /> + +
+ ); + + const segmentOptions = query ? filteredSegments : segments; + + const segmentList = + segmentOptions.length > 0 + ? segmentOptions + .slice(0, visibleOptionIndex) + .map(({label, id, value}) => { + const selected = segments[selectedSegmentIndex].id === id; + + return ( + + + {label} + + + ); + }) + : null; + + const showAllMarkup = showFooterAction ? ( + + Show all 111 segments + + ) : null; + + const lazyLoadingMarkup = lazyLoading ? ( + + ) : null; + + const noResultsMarkup = + segmentOptions.length === 0 ? ( + + ) : null; + + const listboxMarkup = ( +
+ + {segmentList} + {showAllMarkup} + {noResultsMarkup} + {lazyLoadingMarkup} + +
+ ); + + return ( +
+ {activator} + +
+
+
+ + Action + +
+ + + Look up customer segmentation membership + + + Look up whether a customer is included in a segment. + + +
+
+ {textFieldMarkup} + + + {listboxMarkup} + +
+
+
+
+ ); +} + +const StopPropagation = ({children}: React.PropsWithChildren) => { + const stopEventPropagation = (event: React.MouseEvent | React.TouchEvent) => { + event.stopPropagation(); + }; + + return ( +
+ {children} +
+ ); +}; + +export default withPolarisExample(SheetWithSearchableListboxExample); diff --git a/polaris.shopify.com/app/examples/skeleton-body-text-default/page.tsx b/polaris.shopify.com/app/examples/skeleton-body-text-default/page.tsx new file mode 100644 index 00000000000..9d4cfa24198 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-body-text-default/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonBodyText} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-body-text-single-line-content/page.tsx b/polaris.shopify.com/app/examples/skeleton-body-text-single-line-content/page.tsx new file mode 100644 index 00000000000..ecfa04f19c6 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-body-text-single-line-content/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonBodyText} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-display-text-extra-large/page.tsx b/polaris.shopify.com/app/examples/skeleton-display-text-extra-large/page.tsx new file mode 100644 index 00000000000..45ef37c7715 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-display-text-extra-large/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonDisplayText} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-display-text-medium-and-large/page.tsx b/polaris.shopify.com/app/examples/skeleton-display-text-medium-and-large/page.tsx new file mode 100644 index 00000000000..53af90f2932 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-display-text-medium-and-large/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonDisplayText} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-display-text-small/page.tsx b/polaris.shopify.com/app/examples/skeleton-display-text-small/page.tsx new file mode 100644 index 00000000000..cdf57716881 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-display-text-small/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonDisplayText} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-page-with-dynamic-content/page.tsx b/polaris.shopify.com/app/examples/skeleton-page-with-dynamic-content/page.tsx new file mode 100644 index 00000000000..f114c4aa6a2 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-page-with-dynamic-content/page.tsx @@ -0,0 +1,64 @@ +'use client'; + +import { + SkeletonPage, + Layout, + LegacyCard, + SkeletonBodyText, + TextContainer, + SkeletonDisplayText, +} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-page-with-static-content/page.tsx b/polaris.shopify.com/app/examples/skeleton-page-with-static-content/page.tsx new file mode 100644 index 00000000000..cde2077fee8 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-page-with-static-content/page.tsx @@ -0,0 +1,45 @@ +'use client'; + +import {SkeletonPage, Layout, LegacyCard, SkeletonBodyText} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-tabs-default/page.tsx b/polaris.shopify.com/app/examples/skeleton-tabs-default/page.tsx new file mode 100644 index 00000000000..08c7257701b --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-tabs-default/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {LegacyCard, SkeletonTabs} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ( + + + + ); +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-tabs-with-a-custom-count/page.tsx b/polaris.shopify.com/app/examples/skeleton-tabs-with-a-custom-count/page.tsx new file mode 100644 index 00000000000..f7cd00a79e1 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-tabs-with-a-custom-count/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import {LegacyCard, SkeletonTabs} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ( + + + + ); +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-thumbnail-extra-small/page.tsx b/polaris.shopify.com/app/examples/skeleton-thumbnail-extra-small/page.tsx new file mode 100644 index 00000000000..48ae65d43be --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-thumbnail-extra-small/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonThumbnail} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-thumbnail-large/page.tsx b/polaris.shopify.com/app/examples/skeleton-thumbnail-large/page.tsx new file mode 100644 index 00000000000..80829932576 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-thumbnail-large/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonThumbnail} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-thumbnail-medium/page.tsx b/polaris.shopify.com/app/examples/skeleton-thumbnail-medium/page.tsx new file mode 100644 index 00000000000..ff485be834f --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-thumbnail-medium/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonThumbnail} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/skeleton-thumbnail-small/page.tsx b/polaris.shopify.com/app/examples/skeleton-thumbnail-small/page.tsx new file mode 100644 index 00000000000..70ddb9c7ee7 --- /dev/null +++ b/polaris.shopify.com/app/examples/skeleton-thumbnail-small/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {SkeletonThumbnail} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SkeletonExample() { + return ; +} + +export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/app/examples/spinner-default/page.tsx b/polaris.shopify.com/app/examples/spinner-default/page.tsx new file mode 100644 index 00000000000..87688081e1f --- /dev/null +++ b/polaris.shopify.com/app/examples/spinner-default/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Spinner} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SpinnerExample() { + return ; +} + +export default withPolarisExample(SpinnerExample); diff --git a/polaris.shopify.com/app/examples/spinner-small/page.tsx b/polaris.shopify.com/app/examples/spinner-small/page.tsx new file mode 100644 index 00000000000..31a98412ca1 --- /dev/null +++ b/polaris.shopify.com/app/examples/spinner-small/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Spinner} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SpinnerExample() { + return ; +} + +export default withPolarisExample(SpinnerExample); diff --git a/polaris.shopify.com/app/examples/spinner-with-focus-management/page.tsx b/polaris.shopify.com/app/examples/spinner-with-focus-management/page.tsx new file mode 100644 index 00000000000..bbbc98090a6 --- /dev/null +++ b/polaris.shopify.com/app/examples/spinner-with-focus-management/page.tsx @@ -0,0 +1,84 @@ +'use client'; + +import { + Spinner, + Form, + FormLayout, + TextField, + Button, + LegacyCard, + Tabs, +} from '@shopify/polaris'; +import {useState, useEffect, useCallback, useRef} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SpinnerWithFocusManagement() { + const tabs = useRef([ + { + id: 'all-customers', + content: 'All', + accessibilityLabel: 'All customers', + panelID: 'all-customers-content', + }, + { + id: 'accepts-marketing', + content: 'Accepts marketing', + panelID: 'accepts-marketing-content', + }, + ]); + + const [selected, setSelected] = useState(0); + const [loading, setLoading] = useState(false); + const [value, setValue] = useState(''); + const [textFieldFocused, setTextFieldFocused] = useState(false); + + useEffect(() => { + setTextFieldFocused(!loading); + }, [loading]); + + const handleTabChange = useCallback((selectedTab) => { + setLoading(true); + setSelected(selectedTab); + setTimeout(() => { + setValue(''); + return setLoading(false); + }, 1500); + }, []); + + const handleUrlChange = useCallback((value) => setValue(value), []); + + const handleSubmit = useCallback((_event) => setValue(''), []); + + const label = selected ? 'Marketing' : 'Customers'; + const sectionMarkup = loading ? ( + + ) : ( +
+ + + + +
+ ); + + return ( + + + + {sectionMarkup} + + + + ); +} + +export default withPolarisExample(SpinnerWithFocusManagement); diff --git a/polaris.shopify.com/app/examples/stack-default/page.tsx b/polaris.shopify.com/app/examples/stack-default/page.tsx new file mode 100644 index 00000000000..ec84ff83f1a --- /dev/null +++ b/polaris.shopify.com/app/examples/stack-default/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {Stack, Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function StackExample() { + return ( + + Paid + Processing + Fulfilled + Completed + + ); +} + +export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/app/examples/stack-fill-available-space-proportionally/page.tsx b/polaris.shopify.com/app/examples/stack-fill-available-space-proportionally/page.tsx new file mode 100644 index 00000000000..2e71c361a86 --- /dev/null +++ b/polaris.shopify.com/app/examples/stack-fill-available-space-proportionally/page.tsx @@ -0,0 +1,19 @@ +'use client'; + +import {Stack, Badge, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function StackExample() { + return ( + + + Order #1136 + + Paid + Fulfilled + + ); +} + +export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/app/examples/stack-non-wrapping/page.tsx b/polaris.shopify.com/app/examples/stack-non-wrapping/page.tsx new file mode 100644 index 00000000000..dc40cee8f29 --- /dev/null +++ b/polaris.shopify.com/app/examples/stack-non-wrapping/page.tsx @@ -0,0 +1,18 @@ +'use client'; + +import {Stack, Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function StackExample() { + return ( + + Paid + Processing + Fulfilled + Completed + + ); +} + +export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/app/examples/stack-spacing/page.tsx b/polaris.shopify.com/app/examples/stack-spacing/page.tsx new file mode 100644 index 00000000000..c61dc36af96 --- /dev/null +++ b/polaris.shopify.com/app/examples/stack-spacing/page.tsx @@ -0,0 +1,16 @@ +'use client'; + +import {Stack, Badge} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function StackExample() { + return ( + + Paid + Fulfilled + + ); +} + +export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/app/examples/stack-vertical-centering/page.tsx b/polaris.shopify.com/app/examples/stack-vertical-centering/page.tsx new file mode 100644 index 00000000000..4572feb86c8 --- /dev/null +++ b/polaris.shopify.com/app/examples/stack-vertical-centering/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {Stack, Badge, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function StackExample() { + return ( + + + Order +
+ #1136 +
+ was paid +
+ Paid + Fulfilled +
+ ); +} + +export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/app/examples/stack-where-a-single-item-fills-the-remaining-space/page.tsx b/polaris.shopify.com/app/examples/stack-where-a-single-item-fills-the-remaining-space/page.tsx new file mode 100644 index 00000000000..e3b0b55d41e --- /dev/null +++ b/polaris.shopify.com/app/examples/stack-where-a-single-item-fills-the-remaining-space/page.tsx @@ -0,0 +1,25 @@ +'use client'; + +import {Stack, Badge, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function StackExample() { + return ( + + + + Order #1136 + + + + Paid + + + Fulfilled + + + ); +} + +export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/app/examples/stack-where-items-fill-space-evenly/page.tsx b/polaris.shopify.com/app/examples/stack-where-items-fill-space-evenly/page.tsx new file mode 100644 index 00000000000..d757d7f9586 --- /dev/null +++ b/polaris.shopify.com/app/examples/stack-where-items-fill-space-evenly/page.tsx @@ -0,0 +1,19 @@ +'use client'; + +import {Stack, Badge, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function StackExample() { + return ( + + + Order #1136 + + Paid + Fulfilled + + ); +} + +export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/app/examples/tabs-default/page.tsx b/polaris.shopify.com/app/examples/tabs-default/page.tsx new file mode 100644 index 00000000000..05726dbbaaa --- /dev/null +++ b/polaris.shopify.com/app/examples/tabs-default/page.tsx @@ -0,0 +1,50 @@ +'use client'; + +import {LegacyCard, Tabs} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TabsExample() { + const [selected, setSelected] = useState(0); + + const handleTabChange = useCallback( + (selectedTabIndex) => setSelected(selectedTabIndex), + [], + ); + + const tabs = [ + { + id: 'all-customers-1', + content: 'All', + accessibilityLabel: 'All customers', + panelID: 'all-customers-content-1', + }, + { + id: 'accepts-marketing-1', + content: 'Accepts marketing', + panelID: 'accepts-marketing-content-1', + }, + { + id: 'repeat-customers-1', + content: 'Repeat customers', + panelID: 'repeat-customers-content-1', + }, + { + id: 'prospects-1', + content: 'Prospects', + panelID: 'prospects-content-1', + }, + ]; + + return ( + + + +

Tab {selected} selected

+
+
+
+ ); +} + +export default withPolarisExample(TabsExample); diff --git a/polaris.shopify.com/app/examples/tabs-fitted/page.tsx b/polaris.shopify.com/app/examples/tabs-fitted/page.tsx new file mode 100644 index 00000000000..61971467589 --- /dev/null +++ b/polaris.shopify.com/app/examples/tabs-fitted/page.tsx @@ -0,0 +1,40 @@ +'use client'; + +import {LegacyCard, Tabs} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function FittedTabsExample() { + const [selected, setSelected] = useState(0); + + const handleTabChange = useCallback( + (selectedTabIndex) => setSelected(selectedTabIndex), + [], + ); + + const tabs = [ + { + id: 'all-customers-fitted-2', + content: 'All', + accessibilityLabel: 'All customers', + panelID: 'all-customers-fitted-content-2', + }, + { + id: 'accepts-marketing-fitted-2', + content: 'Accepts marketing', + panelID: 'accepts-marketing-fitted-Ccontent-2', + }, + ]; + + return ( + + + +

Tab {selected} selected

+
+
+
+ ); +} + +export default withPolarisExample(FittedTabsExample); diff --git a/polaris.shopify.com/app/examples/tabs-with-badge-content/page.tsx b/polaris.shopify.com/app/examples/tabs-with-badge-content/page.tsx new file mode 100644 index 00000000000..550afa7441d --- /dev/null +++ b/polaris.shopify.com/app/examples/tabs-with-badge-content/page.tsx @@ -0,0 +1,48 @@ +'use client'; + +import {Badge, LegacyCard, Tabs} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TabsWithBadgeExample() { + const [selected, setSelected] = useState(0); + + const handleTabChange = useCallback( + (selectedTabIndex) => setSelected(selectedTabIndex), + [], + ); + + const tabs = [ + { + id: 'all-customers-fitted-3', + content: ( + + All 10+ + + ), + accessibilityLabel: 'All customers', + panelID: 'all-customers-fitted-content-3', + }, + { + id: 'accepts-marketing-fitted-3', + content: ( + + Accepts marketing 4 + + ), + panelID: 'accepts-marketing-fitted-content-3', + }, + ]; + + return ( + + + +

Tab {selected} selected

+
+
+
+ ); +} + +export default withPolarisExample(TabsWithBadgeExample); diff --git a/polaris.shopify.com/app/examples/tabs-with-custom-disclosure/page.tsx b/polaris.shopify.com/app/examples/tabs-with-custom-disclosure/page.tsx new file mode 100644 index 00000000000..0a7aac5bf18 --- /dev/null +++ b/polaris.shopify.com/app/examples/tabs-with-custom-disclosure/page.tsx @@ -0,0 +1,55 @@ +'use client'; + +import {LegacyCard, Tabs} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TabsWithCustomDisclosureExample() { + const [selected, setSelected] = useState(0); + + const handleTabChange = useCallback( + (selectedTabIndex) => setSelected(selectedTabIndex), + [], + ); + + const tabs = [ + { + id: 'all-customers-4', + content: 'All', + accessibilityLabel: 'All customers', + panelID: 'all-customers-content-4', + }, + { + id: 'accepts-marketing-4', + content: 'Accepts marketing', + panelID: 'accepts-marketing-content-4', + }, + { + id: 'repeat-customers-4', + content: 'Repeat customers', + panelID: 'repeat-customers-content-4', + }, + { + id: 'prospects-4', + content: 'Prospects', + panelID: 'prospects-content-4', + }, + ]; + + return ( + + + +

Tab {selected} selected

+
+
+
+ ); +} + +export default withPolarisExample(TabsWithCustomDisclosureExample); diff --git a/polaris.shopify.com/app/examples/tag-clickable/page.tsx b/polaris.shopify.com/app/examples/tag-clickable/page.tsx new file mode 100644 index 00000000000..7a43a18107f --- /dev/null +++ b/polaris.shopify.com/app/examples/tag-clickable/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Tag} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TagExample() { + return console.log('Clicked')}>Wholesale; +} + +export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/app/examples/tag-default/page.tsx b/polaris.shopify.com/app/examples/tag-default/page.tsx new file mode 100644 index 00000000000..8e88373715f --- /dev/null +++ b/polaris.shopify.com/app/examples/tag-default/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Tag} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TagExample() { + return Wholesale; +} + +export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/app/examples/tag-removable-with-link/page.tsx b/polaris.shopify.com/app/examples/tag-removable-with-link/page.tsx new file mode 100644 index 00000000000..fd4221e5f5d --- /dev/null +++ b/polaris.shopify.com/app/examples/tag-removable-with-link/page.tsx @@ -0,0 +1,33 @@ +'use client'; + +import {Tag, LegacyStack} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RemovableTagWithLinkExample() { + const [selectedTags, setSelectedTags] = useState([ + 'Rustic', + 'Antique', + 'Vinyl', + 'Refurbished', + ]); + + const removeTag = useCallback( + (tag) => () => { + setSelectedTags((previousTags) => + previousTags.filter((previousTag) => previousTag !== tag), + ); + }, + [], + ); + + const tagMarkup = selectedTags.map((option) => ( + + {option} + + )); + + return {tagMarkup}; +} + +export default withPolarisExample(RemovableTagWithLinkExample); diff --git a/polaris.shopify.com/app/examples/tag-removable/page.tsx b/polaris.shopify.com/app/examples/tag-removable/page.tsx new file mode 100644 index 00000000000..ad0e5e0dc56 --- /dev/null +++ b/polaris.shopify.com/app/examples/tag-removable/page.tsx @@ -0,0 +1,34 @@ +'use client'; + +import {Tag, LegacyStack} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RemovableTagExample() { + const [selectedTags, setSelectedTags] = useState([ + 'Rustic', + 'Antique', + 'Vinyl', + 'Refurbished', + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ipsum quam. Aliquam fermentum bibendum vestibulum. Vestibulum condimentum luctus metus, sed sagittis magna pellentesque eget. Duis dapibus pretium nisi, et venenatis tortor dignissim ut. Quisque eget lacus ac ex eleifend ultrices. Phasellus facilisis ex sit amet leo elementum condimentum. Ut vel maximus felis. Etiam eget diam eu eros blandit interdum. Sed eu metus sed justo aliquam iaculis ac sit amet ex. Curabitur justo magna, porttitor non pulvinar eu, malesuada at leo. Cras mollis consectetur eros, quis maximus lorem dignissim at. Proin in rhoncus massa. Vivamus lectus nunc, fringilla euismod risus commodo, mattis blandit nulla.', + ]); + + const removeTag = useCallback( + (tag) => () => { + setSelectedTags((previousTags) => + previousTags.filter((previousTag) => previousTag !== tag), + ); + }, + [], + ); + + const tagMarkup = selectedTags.map((option) => ( + + {option} + + )); + + return {tagMarkup}; +} + +export default withPolarisExample(RemovableTagExample); diff --git a/polaris.shopify.com/app/examples/tag-with-custom-content/page.tsx b/polaris.shopify.com/app/examples/tag-with-custom-content/page.tsx new file mode 100644 index 00000000000..cc36b322b9e --- /dev/null +++ b/polaris.shopify.com/app/examples/tag-with-custom-content/page.tsx @@ -0,0 +1,19 @@ +'use client'; + +import {Tag, LegacyStack, Icon} from '@shopify/polaris'; +import {WandMinor} from '@shopify/polaris-icons'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TagExample() { + return ( + + + + Wholesale + + + ); +} + +export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/app/examples/tag-with-link/page.tsx b/polaris.shopify.com/app/examples/tag-with-link/page.tsx new file mode 100644 index 00000000000..cab80f313e6 --- /dev/null +++ b/polaris.shopify.com/app/examples/tag-with-link/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {Tag} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TagExample() { + return Wholesale; +} + +export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/app/examples/text-align/page.tsx b/polaris.shopify.com/app/examples/text-align/page.tsx new file mode 100644 index 00000000000..79e3666c638 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-align/page.tsx @@ -0,0 +1,30 @@ +'use client'; + +import {Text, LegacyStack} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextExample() { + return ( + + + Manage your Shopify store on-the-go with real-time notifications, access + to your dashboard, and order management, all from your smartphone. + + + Manage your Shopify store on-the-go with real-time notifications, access + to your dashboard, and order management, all from your smartphone. + + + Manage your Shopify store on-the-go with real-time notifications, access + to your dashboard, and order management, all from your smartphone. + + + Manage your Shopify store on-the-go with real-time notifications, access + to your dashboard, and order management, all from your smartphone. + + + ); +} + +export default withPolarisExample(TextExample); diff --git a/polaris.shopify.com/app/examples/text-body/page.tsx b/polaris.shopify.com/app/examples/text-body/page.tsx new file mode 100644 index 00000000000..c60af4b6aac --- /dev/null +++ b/polaris.shopify.com/app/examples/text-body/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {Text, LegacyStack} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextExample() { + return ( + + + Shopify POS is the easiest way to sell your products in person. + Available for iPad, iPhone, and Android. + + + Shopify POS is the easiest way to sell your products in person. + Available for iPad, iPhone, and Android. + + + Shopify POS is the easiest way to sell your products in person. + Available for iPad, iPhone, and Android. + + + ); +} + +export default withPolarisExample(TextExample); diff --git a/polaris.shopify.com/app/examples/text-color/page.tsx b/polaris.shopify.com/app/examples/text-color/page.tsx new file mode 100644 index 00000000000..da7646ce327 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-color/page.tsx @@ -0,0 +1,32 @@ +'use client'; + +import {Text, LegacyStack} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextExample() { + return ( + + + Use to de-emphasize a piece of text that is less important to merchants + than other nearby text. May also be used to indicate when normal content + is absent, for example, “No supplier listed”. Don’t use only for + aesthetic effect. + + + Use in combination with a symbol showing an increasing value to indicate + an upward trend. + + + Use to denote something that needs attention, or that merchants need to + take action on. + + + Use in combination with a symbol showing a decreasing value to indicate + a downward trend. + + + ); +} + +export default withPolarisExample(TextExample); diff --git a/polaris.shopify.com/app/examples/text-container-default/page.tsx b/polaris.shopify.com/app/examples/text-container-default/page.tsx new file mode 100644 index 00000000000..e210ec0c56b --- /dev/null +++ b/polaris.shopify.com/app/examples/text-container-default/page.tsx @@ -0,0 +1,21 @@ +'use client'; + +import {TextContainer, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextContainerExample() { + return ( + + + Install the Shopify POS App + +

+ Shopify POS is the easiest way to sell your products in person. + Available for iPad, iPhone, and Android. +

+
+ ); +} + +export default withPolarisExample(TextContainerExample); diff --git a/polaris.shopify.com/app/examples/text-container-loose/page.tsx b/polaris.shopify.com/app/examples/text-container-loose/page.tsx new file mode 100644 index 00000000000..51d72c14f0f --- /dev/null +++ b/polaris.shopify.com/app/examples/text-container-loose/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {TextContainer} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextContainerExample() { + return ( + +

+ Manage your Shopify store on-the-go with real-time notifications, access + to your dashboard, and order management, all from your smartphone. +

+

+ Shopify POS is the fastest and easiest way to start accepting Visa, + Mastercard, American Express, and Discover right from your smartphone or + tablet. +

+
+ ); +} + +export default withPolarisExample(TextContainerExample); diff --git a/polaris.shopify.com/app/examples/text-container-tight/page.tsx b/polaris.shopify.com/app/examples/text-container-tight/page.tsx new file mode 100644 index 00000000000..ad79a80cc0d --- /dev/null +++ b/polaris.shopify.com/app/examples/text-container-tight/page.tsx @@ -0,0 +1,21 @@ +'use client'; + +import {TextContainer, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextContainerExample() { + return ( + + + Install the Shopify POS App + +

+ Shopify POS is the easiest way to sell your products in person. + Available for iPad, iPhone, and Android. +

+
+ ); +} + +export default withPolarisExample(TextContainerExample); diff --git a/polaris.shopify.com/app/examples/text-field-default/page.tsx b/polaris.shopify.com/app/examples/text-field-default/page.tsx new file mode 100644 index 00000000000..ccc8d4413ad --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-default/page.tsx @@ -0,0 +1,22 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextFieldExample() { + const [value, setValue] = useState('Jaded Pixel'); + + const handleChange = useCallback((newValue) => setValue(newValue), []); + + return ( + + ); +} + +export default withPolarisExample(TextFieldExample); diff --git a/polaris.shopify.com/app/examples/text-field-disabled/page.tsx b/polaris.shopify.com/app/examples/text-field-disabled/page.tsx new file mode 100644 index 00000000000..9b737ee6dbd --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-disabled/page.tsx @@ -0,0 +1,11 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextFieldExample() { + return ; +} + +export default withPolarisExample(TextFieldExample); diff --git a/polaris.shopify.com/app/examples/text-field-email/page.tsx b/polaris.shopify.com/app/examples/text-field-email/page.tsx new file mode 100644 index 00000000000..9c94f24126f --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-email/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function EmailFieldExample() { + const [value, setValue] = useState('bernadette.lapresse@jadedpixel.com'); + + const handleChange = useCallback((newValue) => setValue(newValue), []); + + return ( + + ); +} + +export default withPolarisExample(EmailFieldExample); diff --git a/polaris.shopify.com/app/examples/text-field-multiline/page.tsx b/polaris.shopify.com/app/examples/text-field-multiline/page.tsx new file mode 100644 index 00000000000..8ad9276d5db --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-multiline/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultilineFieldExample() { + const [value, setValue] = useState('1776 Barnes Street\nOrlando, FL 32801'); + + const handleChange = useCallback((newValue) => setValue(newValue), []); + + return ( + + ); +} + +export default withPolarisExample(MultilineFieldExample); diff --git a/polaris.shopify.com/app/examples/text-field-number/page.tsx b/polaris.shopify.com/app/examples/text-field-number/page.tsx new file mode 100644 index 00000000000..1674b6da073 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-number/page.tsx @@ -0,0 +1,23 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function NumberFieldExample() { + const [value, setValue] = useState('1'); + + const handleChange = useCallback((newValue) => setValue(newValue), []); + + return ( + + ); +} + +export default withPolarisExample(NumberFieldExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-character-count/page.tsx b/polaris.shopify.com/app/examples/text-field-with-character-count/page.tsx new file mode 100644 index 00000000000..c97dcea0f95 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-character-count/page.tsx @@ -0,0 +1,27 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextFieldWithCharacterCountExample() { + const [textFieldValue, setTextFieldValue] = useState('Jaded Pixel'); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(TextFieldWithCharacterCountExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-clear-button/page.tsx b/polaris.shopify.com/app/examples/text-field-with-clear-button/page.tsx new file mode 100644 index 00000000000..83fe61e7514 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-clear-button/page.tsx @@ -0,0 +1,29 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextFieldWithClearButtonExample() { + const [textFieldValue, setTextFieldValue] = useState('Jaded Pixel'); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + const handleClearButtonClick = useCallback(() => setTextFieldValue(''), []); + + return ( + + ); +} + +export default withPolarisExample(TextFieldWithClearButtonExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-connected-fields/page.tsx b/polaris.shopify.com/app/examples/text-field-with-connected-fields/page.tsx new file mode 100644 index 00000000000..de17faacfc0 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-connected-fields/page.tsx @@ -0,0 +1,39 @@ +'use client'; + +import {TextField, Select, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ConnectedFieldsExample() { + const [textFieldValue, setTextFieldValue] = useState('10.6'); + const [selectValue, setSelectValue] = useState('kg'); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + const handleSelectChange = useCallback((value) => setSelectValue(value), []); + + return ( + + } + connectedRight={} + /> + ); +} + +export default withPolarisExample(ConnectedFieldsExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-help-text/page.tsx b/polaris.shopify.com/app/examples/text-field-with-help-text/page.tsx new file mode 100644 index 00000000000..518466c0513 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-help-text/page.tsx @@ -0,0 +1,29 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function HelpTextExample() { + const [textFieldValue, setTextFieldValue] = useState( + 'bernadette.lapresse@jadedpixel.com', + ); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(HelpTextExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-hidden-label/page.tsx b/polaris.shopify.com/app/examples/text-field-with-hidden-label/page.tsx new file mode 100644 index 00000000000..9781245d5f7 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-hidden-label/page.tsx @@ -0,0 +1,49 @@ +'use client'; + +import {FormLayout, ChoiceList, TextField, Select} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function HiddenLabelExample() { + const [value, setValue] = useState('12'); + const [selected, setSelected] = useState('yes'); + + const handleTextChange = useCallback((newValue) => setValue(newValue), []); + + const handleChoiceChange = useCallback( + (selections) => setSelected(selections[0]), + [], + ); + + return ( + + + + } + /> + + ); +} + +export default withPolarisExample(HiddenLabelExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-inline-suggestion/page.tsx b/polaris.shopify.com/app/examples/text-field-with-inline-suggestion/page.tsx new file mode 100644 index 00000000000..6bfc594f114 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-inline-suggestion/page.tsx @@ -0,0 +1,116 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useEffect, useCallback, useMemo} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextFieldWithSuggestionExample() { + const suggestions = useMemo( + () => [ + 'Alabama', + 'Alaska', + 'American Samoa', + 'Arizona', + 'Arkansas', + 'California', + 'Colorado', + 'Connecticut', + 'Delaware', + 'District of Columbia', + 'Florida', + 'Georgia', + 'Guam', + 'Hawaii', + 'Idaho', + 'Illinois', + 'Indiana', + 'Iowa', + 'Kansas', + 'Kentucky', + 'Louisiana', + 'Maine', + 'Maryland', + 'Massachusetts', + 'Michigan', + 'Minnesota', + 'Minor Outlying Islands', + 'Mississippi', + 'Missouri', + 'Montana', + 'Nebraska', + 'Nevada', + 'New Hampshire', + 'New Jersey', + 'New Mexico', + 'New York', + 'North Carolina', + 'North Dakota', + 'Northern Mariana Islands', + 'Ohio', + 'Oklahoma', + 'Oregon', + 'Pennsylvania', + 'Puerto Rico', + 'Rhode Island', + 'South Carolina', + 'South Dakota', + 'Tennessee', + 'Texas', + 'U.S. Virgin Islands', + 'Utah', + 'Vermont', + 'Virginia', + 'Washington', + 'West Virginia', + 'Wisconsin', + 'Wyoming', + ], + [], + ); + + const [value, setValue] = useState(''); + const [suggestion, setSuggestion] = useState(''); + + const handleSuggestion = useCallback( + (nextValue) => { + const nextSuggestion = suggestions.find((suggestion) => + suggestion.toLowerCase().startsWith(nextValue.toLowerCase()), + ); + + if (nextSuggestion) setSuggestion(nextSuggestion); + }, + [suggestions], + ); + + useEffect(() => { + if (value !== suggestion) handleSuggestion(value); + }, [handleSuggestion, suggestion, value]); + + const handleChange = useCallback((value) => { + setValue(value); + setSuggestion(''); + }, []); + + const handleKeyDown = useCallback( + (event) => { + if (event.key === 'Enter') { + handleChange(suggestion); + } + }, + [suggestion, handleChange], + ); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(TextFieldWithSuggestionExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-label-action/page.tsx b/polaris.shopify.com/app/examples/text-field-with-label-action/page.tsx new file mode 100644 index 00000000000..c43e1d6e09b --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-label-action/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function LabelActionExample() { + const [textFieldValue, setTextFieldValue] = useState('6201.11.0000'); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(LabelActionExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-monospaced-font/page.tsx b/polaris.shopify.com/app/examples/text-field-with-monospaced-font/page.tsx new file mode 100644 index 00000000000..b99915a5893 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-monospaced-font/page.tsx @@ -0,0 +1,25 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TextFieldWithMonospacedFontExample() { + const [textFieldValue, setTextFieldValue] = useState('Jaded Pixel'); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(TextFieldWithMonospacedFontExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-placeholder-text/page.tsx b/polaris.shopify.com/app/examples/text-field-with-placeholder-text/page.tsx new file mode 100644 index 00000000000..f84295f43fb --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-placeholder-text/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function PlaceholderExample() { + const [textFieldValue, setTextFieldValue] = useState(''); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(PlaceholderExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-prefix-or-suffix/page.tsx b/polaris.shopify.com/app/examples/text-field-with-prefix-or-suffix/page.tsx new file mode 100644 index 00000000000..42e44b6ad2f --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-prefix-or-suffix/page.tsx @@ -0,0 +1,27 @@ +'use client'; + +import {TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function PrefixExample() { + const [textFieldValue, setTextFieldValue] = useState('2.00'); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + return ( + + ); +} + +export default withPolarisExample(PrefixExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-right-aligned-text/page.tsx b/polaris.shopify.com/app/examples/text-field-with-right-aligned-text/page.tsx new file mode 100644 index 00000000000..d3abfb5c77d --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-right-aligned-text/page.tsx @@ -0,0 +1,30 @@ +'use client'; + +import {LegacyStack, TextField} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function RightAlignExample() { + const [textFieldValue, setTextFieldValue] = useState('1'); + + const handleTextFieldChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + return ( + + Price + + + ); +} + +export default withPolarisExample(RightAlignExample); diff --git a/polaris.shopify.com/app/examples/text-field-with-separate-validation-error/page.tsx b/polaris.shopify.com/app/examples/text-field-with-separate-validation-error/page.tsx new file mode 100644 index 00000000000..e035d3166b7 --- /dev/null +++ b/polaris.shopify.com/app/examples/text-field-with-separate-validation-error/page.tsx @@ -0,0 +1,96 @@ +'use client'; + +import { + LegacyStack, + FormLayout, + Select, + TextField, + InlineError, + Button, + LegacyCard, +} from '@shopify/polaris'; +import {DeleteMinor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function SeparateValidationErrorExample() { + const [textFieldValue, setTextFieldValue] = useState(''); + const [selectTypeValue, setSelectTypeValue] = useState('Product type'); + const [selectConditionValue, setSelectConditionValue] = + useState('is equal to'); + + const handleTextFieldValueChange = useCallback( + (value) => setTextFieldValue(value), + [], + ); + + const handleSelectTypeChange = useCallback( + (value) => setSelectTypeValue(value), + [], + ); + + const handleSelectConditionChange = useCallback( + (value) => setSelectConditionValue(value), + [], + ); + + const textFieldID = 'ruleContent'; + const isInvalid = isValueInvalid(textFieldValue); + const errorMessage = isInvalid + ? 'Enter 3 or more characters for product type is equal to' + : ''; + + const formGroupMarkup = ( + + + + + + + + +
+ +
+
+ + {toastMarkup} + + +
+ ); +} + +export default withPolarisExample(ToastExample); diff --git a/polaris.shopify.com/app/examples/toast-error/page.tsx b/polaris.shopify.com/app/examples/toast-error/page.tsx new file mode 100644 index 00000000000..5c91952acfc --- /dev/null +++ b/polaris.shopify.com/app/examples/toast-error/page.tsx @@ -0,0 +1,28 @@ +'use client'; + +import {Toast, Frame, Page, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ErrorToastExample() { + const [active, setActive] = useState(false); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const toastMarkup = active ? ( + + ) : null; + + return ( +
+ + + + {toastMarkup} + + +
+ ); +} + +export default withPolarisExample(ErrorToastExample); diff --git a/polaris.shopify.com/app/examples/toast-multiple-messages/page.tsx b/polaris.shopify.com/app/examples/toast-multiple-messages/page.tsx new file mode 100644 index 00000000000..198ab6e925c --- /dev/null +++ b/polaris.shopify.com/app/examples/toast-multiple-messages/page.tsx @@ -0,0 +1,45 @@ +'use client'; + +import {Toast, Frame, Page, ButtonGroup, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function MultipleToastExample() { + const [activeOne, setActiveOne] = useState(false); + const [activeTwo, setActiveTwo] = useState(false); + + const toggleActiveOne = useCallback( + () => setActiveOne((activeOne) => !activeOne), + [], + ); + + const toggleActiveTwo = useCallback( + () => setActiveTwo((activeTwo) => !activeTwo), + [], + ); + + const toastMarkup1 = activeOne ? ( + + ) : null; + + const toastMarkup2 = activeTwo ? ( + + ) : null; + + return ( +
+ + + + + + + {toastMarkup1} + {toastMarkup2} + + +
+ ); +} + +export default withPolarisExample(MultipleToastExample); diff --git a/polaris.shopify.com/app/examples/toast-with-action/page.tsx b/polaris.shopify.com/app/examples/toast-with-action/page.tsx new file mode 100644 index 00000000000..104a347d1cb --- /dev/null +++ b/polaris.shopify.com/app/examples/toast-with-action/page.tsx @@ -0,0 +1,36 @@ +'use client'; + +import {Toast, Frame, Page, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ToastWithActionExample() { + const [active, setActive] = useState(false); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const toastMarkup = active ? ( + {}, + }} + duration={10000} + onDismiss={toggleActive} + /> + ) : null; + + return ( +
+ + + + {toastMarkup} + + +
+ ); +} + +export default withPolarisExample(ToastWithActionExample); diff --git a/polaris.shopify.com/app/examples/toast-with-custom-duration/page.tsx b/polaris.shopify.com/app/examples/toast-with-custom-duration/page.tsx new file mode 100644 index 00000000000..fa36709a3c4 --- /dev/null +++ b/polaris.shopify.com/app/examples/toast-with-custom-duration/page.tsx @@ -0,0 +1,28 @@ +'use client'; + +import {Toast, Frame, Page, Button} from '@shopify/polaris'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function ToastWithCustomDurationExample() { + const [active, setActive] = useState(false); + + const toggleActive = useCallback(() => setActive((active) => !active), []); + + const toastMarkup = active ? ( + + ) : null; + + return ( +
+ + + + {toastMarkup} + + +
+ ); +} + +export default withPolarisExample(ToastWithCustomDurationExample); diff --git a/polaris.shopify.com/app/examples/tooltip-default/page.tsx b/polaris.shopify.com/app/examples/tooltip-default/page.tsx new file mode 100644 index 00000000000..312681353ee --- /dev/null +++ b/polaris.shopify.com/app/examples/tooltip-default/page.tsx @@ -0,0 +1,19 @@ +'use client'; + +import {Tooltip, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TooltipExample() { + return ( +
+ + + Order #1001 + + +
+ ); +} + +export default withPolarisExample(TooltipExample); diff --git a/polaris.shopify.com/app/examples/tooltip-visible-only-with-child-interaction/page.tsx b/polaris.shopify.com/app/examples/tooltip-visible-only-with-child-interaction/page.tsx new file mode 100644 index 00000000000..3130f4c6f5b --- /dev/null +++ b/polaris.shopify.com/app/examples/tooltip-visible-only-with-child-interaction/page.tsx @@ -0,0 +1,34 @@ +'use client'; + +import {ButtonGroup, Tooltip, Button, TextField} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TooltipExample() { + return ( +
+ + + + + + + + + + + + + + + +
+ ); +} + +export default withPolarisExample(TooltipExample); diff --git a/polaris.shopify.com/app/examples/tooltip-with-suffix/page.tsx b/polaris.shopify.com/app/examples/tooltip-with-suffix/page.tsx new file mode 100644 index 00000000000..391d466d2df --- /dev/null +++ b/polaris.shopify.com/app/examples/tooltip-with-suffix/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {Tooltip, Button, Inline, Text} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TooltipExample() { + return ( +
+ + Bold + + ⌘B + + + } + > + + +
+ ); +} + +export default withPolarisExample(TooltipExample); diff --git a/polaris.shopify.com/app/examples/top-bar-default/page.tsx b/polaris.shopify.com/app/examples/top-bar-default/page.tsx new file mode 100644 index 00000000000..ea0ed222aad --- /dev/null +++ b/polaris.shopify.com/app/examples/top-bar-default/page.tsx @@ -0,0 +1,120 @@ +'use client'; + +import {TopBar, ActionList, Icon, Frame, Text} from '@shopify/polaris'; +import {ArrowLeftMinor, QuestionMarkMajor} from '@shopify/polaris-icons'; +import {useState, useCallback} from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function TopBarExample() { + const [isUserMenuOpen, setIsUserMenuOpen] = useState(false); + const [isSecondaryMenuOpen, setIsSecondaryMenuOpen] = useState(false); + const [isSearchActive, setIsSearchActive] = useState(false); + const [searchValue, setSearchValue] = useState(''); + + const toggleIsUserMenuOpen = useCallback( + () => setIsUserMenuOpen((isUserMenuOpen) => !isUserMenuOpen), + [], + ); + + const toggleIsSecondaryMenuOpen = useCallback( + () => setIsSecondaryMenuOpen((isSecondaryMenuOpen) => !isSecondaryMenuOpen), + [], + ); + + const handleSearchResultsDismiss = useCallback(() => { + setIsSearchActive(false); + setSearchValue(''); + }, []); + + const handleSearchChange = useCallback((value) => { + setSearchValue(value); + setIsSearchActive(value.length > 0); + }, []); + + const handleNavigationToggle = useCallback(() => { + console.log('toggle navigation visibility'); + }, []); + + const logo = { + width: 124, + topBarSource: + 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999', + url: '#', + accessibilityLabel: 'Jaded Pixel', + }; + + const userMenuMarkup = ( + + ); + + const searchResultsMarkup = ( + + ); + + const searchFieldMarkup = ( + + ); + + const secondaryMenuMarkup = ( + + + + Secondary menu + + + } + open={isSecondaryMenuOpen} + onOpen={toggleIsSecondaryMenuOpen} + onClose={toggleIsSecondaryMenuOpen} + actions={[ + { + items: [{content: 'Community forums'}], + }, + ]} + /> + ); + + const topBarMarkup = ( + + ); + + return ( +
+ +
+ ); +} + +export default withPolarisExample(TopBarExample); diff --git a/polaris.shopify.com/app/examples/video-thumbnail-default/page.tsx b/polaris.shopify.com/app/examples/video-thumbnail-default/page.tsx new file mode 100644 index 00000000000..678b3b95dce --- /dev/null +++ b/polaris.shopify.com/app/examples/video-thumbnail-default/page.tsx @@ -0,0 +1,26 @@ +'use client'; + +import {MediaCard, VideoThumbnail} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function VideoThumbnailExample() { + return ( + {}, + }} + description={`In this course, you’ll learn how the Kular family turned their mom’s recipe book into a global business.`} + popoverActions={[{content: 'Dismiss', onAction: () => {}}]} + > + + + ); +} + +export default withPolarisExample(() => ); diff --git a/polaris.shopify.com/app/examples/video-thumbnail-with-progress/page.tsx b/polaris.shopify.com/app/examples/video-thumbnail-with-progress/page.tsx new file mode 100644 index 00000000000..77db503c128 --- /dev/null +++ b/polaris.shopify.com/app/examples/video-thumbnail-with-progress/page.tsx @@ -0,0 +1,28 @@ +'use client'; + +import {MediaCard, VideoThumbnail} from '@shopify/polaris'; +import React from 'react'; +import {withPolarisExample} from '../../../src/components/PolarisExampleWrapper'; + +function VideoThumbnailExample() { + return ( + {}, + }} + description={`In this course, you’ll learn how the Kular family turned their mom’s recipe book into a global business.`} + popoverActions={[{content: 'Dismiss', onAction: () => {}}]} + > + + + ); +} + +export default withPolarisExample(VideoThumbnailExample); diff --git a/polaris.shopify.com/app/layout.tsx b/polaris.shopify.com/app/layout.tsx new file mode 100644 index 00000000000..afe6b77331f --- /dev/null +++ b/polaris.shopify.com/app/layout.tsx @@ -0,0 +1,9 @@ +'use client'; + +export default function RootLayout({children}: {children: React.ReactNode}) { + return ( + + {children} + + ); +} diff --git a/polaris.shopify.com/next-env.d.ts b/polaris.shopify.com/next-env.d.ts index 4f11a03dc6c..fd36f9494e2 100644 --- a/polaris.shopify.com/next-env.d.ts +++ b/polaris.shopify.com/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/polaris.shopify.com/next.config.js b/polaris.shopify.com/next.config.js index ad5dd4c667e..420b44ba455 100644 --- a/polaris.shopify.com/next.config.js +++ b/polaris.shopify.com/next.config.js @@ -13,6 +13,7 @@ const nextConfig = { scrollRestoration: true, // this includes files from the monorepo base one directory up outputFileTracingRoot: path.join(__dirname, '../'), + appDir: true, }, async rewrites() { return [ diff --git a/polaris.shopify.com/package.json b/polaris.shopify.com/package.json index e717e609a67..347a1172e63 100644 --- a/polaris.shopify.com/package.json +++ b/polaris.shopify.com/package.json @@ -33,7 +33,7 @@ "gray-matter": "^4.0.3", "lodash.get": "^4.4.2", "lodash.throttle": "^4.1.1", - "next": "^13.0.6", + "next": "^13.2.3", "prismjs": "^1.27.0", "sharp": "^0.31.2", "react": "^18.2.0", diff --git a/polaris.shopify.com/pages/_app.tsx b/polaris.shopify.com/pages/_app.tsx index b3e34be9754..481d191fbf2 100644 --- a/polaris.shopify.com/pages/_app.tsx +++ b/polaris.shopify.com/pages/_app.tsx @@ -4,7 +4,6 @@ import Script from 'next/script'; import {useEffect} from 'react'; import {useRouter} from 'next/router'; import useDarkMode from 'use-dark-mode'; -import '@shopify/polaris/build/esm/styles.css'; import {className} from '../src/utils/various'; import Frame from '../src/components/Frame'; diff --git a/polaris.shopify.com/pages/components/[group]/[component]/index.tsx b/polaris.shopify.com/pages/components/[group]/[component]/index.tsx index 441904eca3f..42e7d992603 100644 --- a/polaris.shopify.com/pages/components/[group]/[component]/index.tsx +++ b/polaris.shopify.com/pages/components/[group]/[component]/index.tsx @@ -105,7 +105,7 @@ export const getStaticProps: GetStaticProps< (example: ComponentExample) => { const examplePath = path.resolve( process.cwd(), - `pages/examples/${example.fileName}`, + `app/examples/${example.fileName.replace('.tsx', '')}/page.tsx`, ); let code = ''; @@ -117,6 +117,8 @@ export const getStaticProps: GetStaticProps< .join('\n'); } + code = code.replace("'use client';\n\n", ''); + return {...example, code}; }, ); diff --git a/polaris.shopify.com/pages/components/[group]/index.tsx b/polaris.shopify.com/pages/components/[group]/index.tsx index 86c39b443b6..883ee795933 100644 --- a/polaris.shopify.com/pages/components/[group]/index.tsx +++ b/polaris.shopify.com/pages/components/[group]/index.tsx @@ -110,7 +110,7 @@ export default function GroupPage({ {relatedResources.map((resource) => (
  • {resource}
  • diff --git a/polaris.shopify.com/pages/examples/account-connection-default.tsx b/polaris.shopify.com/pages/examples/account-connection-default.tsx deleted file mode 100644 index 36a0a2a8083..00000000000 --- a/polaris.shopify.com/pages/examples/account-connection-default.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import {Link, AccountConnection} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AccountConnectionExample() { - const [connected, setConnected] = useState(false); - const accountName = connected ? 'Jane Appleseed' : ''; - - const handleAction = useCallback(() => { - setConnected((connected) => !connected); - }, []); - - const buttonText = connected ? 'Disconnect' : 'Connect'; - const details = connected ? 'Account connected' : 'No account connected'; - const terms = connected ? null : ( -

    - By clicking Connect, you agree to accept Sample App’s{' '} - terms and conditions. You’ll pay a - commission rate of 15% on sales made through Sample App. -

    - ); - - return ( - - ); -} - -export default withPolarisExample(AccountConnectionExample); diff --git a/polaris.shopify.com/pages/examples/action-list-in-a-popover.tsx b/polaris.shopify.com/pages/examples/action-list-in-a-popover.tsx deleted file mode 100644 index e21c44a35c6..00000000000 --- a/polaris.shopify.com/pages/examples/action-list-in-a-popover.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import {Button, Popover, ActionList} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ActionListInPopoverExample() { - const [active, setActive] = useState(true); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const handleImportedAction = useCallback( - () => console.log('Imported action'), - [], - ); - - const handleExportedAction = useCallback( - () => console.log('Exported action'), - [], - ); - - const activator = ( - - ); - - return ( -
    - - - -
    - ); -} - -export default withPolarisExample(ActionListInPopoverExample); diff --git a/polaris.shopify.com/pages/examples/action-list-with-a-prefix-and-a-suffix.tsx b/polaris.shopify.com/pages/examples/action-list-with-a-prefix-and-a-suffix.tsx deleted file mode 100644 index f2b9cc97ac8..00000000000 --- a/polaris.shopify.com/pages/examples/action-list-with-a-prefix-and-a-suffix.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import {ActionList, Thumbnail, Icon, Avatar} from '@shopify/polaris'; -import {ChevronRightMinor} from '@shopify/polaris-icons'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ActionListWithPrefixSuffixExample() { - return ( -
    - - ), - suffix: , - }, - { - content: 'Or there', - prefix: , - suffix: , - }, - ]} - /> -
    - ); -} - -export default withPolarisExample(ActionListWithPrefixSuffixExample); diff --git a/polaris.shopify.com/pages/examples/action-list-with-an-icon-and-a-suffix.tsx b/polaris.shopify.com/pages/examples/action-list-with-an-icon-and-a-suffix.tsx deleted file mode 100644 index 432e39b826d..00000000000 --- a/polaris.shopify.com/pages/examples/action-list-with-an-icon-and-a-suffix.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import {Button, Popover, ActionList, Icon} from '@shopify/polaris'; -import {ImportMinor, TickSmallMinor, ExportMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ActionListWithSuffixExample() { - const [active, setActive] = useState(true); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const activator = ( - - ); - - return ( -
    - - , - }, - {content: 'Export file', icon: ExportMinor}, - ]} - /> - -
    - ); -} - -export default withPolarisExample(ActionListWithSuffixExample); diff --git a/polaris.shopify.com/pages/examples/action-list-with-destructive-item.tsx b/polaris.shopify.com/pages/examples/action-list-with-destructive-item.tsx deleted file mode 100644 index ae86412a889..00000000000 --- a/polaris.shopify.com/pages/examples/action-list-with-destructive-item.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import {Button, Popover, ActionList} from '@shopify/polaris'; -import {ImportMinor, ExportMinor, DeleteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ActionListWithDestructiveItemExample() { - const [active, setActive] = useState(true); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const activator = ( - - ); - - return ( -
    - - - -
    - ); -} - -export default withPolarisExample(ActionListWithDestructiveItemExample); diff --git a/polaris.shopify.com/pages/examples/action-list-with-help-text.tsx b/polaris.shopify.com/pages/examples/action-list-with-help-text.tsx deleted file mode 100644 index 69ef7d08cf8..00000000000 --- a/polaris.shopify.com/pages/examples/action-list-with-help-text.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import {Button, Popover, ActionList} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ActionListWithHelpTextExample() { - const [active, setActive] = useState(true); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const activator = ( - - ); - - return ( -
    - - - -
    - ); -} - -export default withPolarisExample(ActionListWithHelpTextExample); diff --git a/polaris.shopify.com/pages/examples/action-list-with-icons-or-image.tsx b/polaris.shopify.com/pages/examples/action-list-with-icons-or-image.tsx deleted file mode 100644 index cfb48c247b5..00000000000 --- a/polaris.shopify.com/pages/examples/action-list-with-icons-or-image.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import {Button, Popover, ActionList} from '@shopify/polaris'; -import {ImportMinor, ExportMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ActionListWithMediaExample() { - const [active, setActive] = useState(true); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const activator = ( - - ); - - return ( -
    - - - -
    - ); -} - -export default withPolarisExample(ActionListWithMediaExample); diff --git a/polaris.shopify.com/pages/examples/action-list-with-sections.tsx b/polaris.shopify.com/pages/examples/action-list-with-sections.tsx deleted file mode 100644 index e14df7574a8..00000000000 --- a/polaris.shopify.com/pages/examples/action-list-with-sections.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import {Button, Popover, ActionList} from '@shopify/polaris'; -import { - ImportMinor, - ExportMinor, - EditMinor, - DeleteMinor, -} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SectionedActionListExample() { - const [active, setActive] = useState(true); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const activator = ( - - ); - - return ( -
    - - - -
    - ); -} - -export default withPolarisExample(SectionedActionListExample); diff --git a/polaris.shopify.com/pages/examples/alpha-card-default.tsx b/polaris.shopify.com/pages/examples/alpha-card-default.tsx deleted file mode 100644 index 50986b57f56..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-card-default.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {AlphaCard, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaCardExample() { - return ( - - - Content inside a card - - - ); -} - -export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/pages/examples/alpha-card-with-rounded-corners.tsx b/polaris.shopify.com/pages/examples/alpha-card-with-rounded-corners.tsx deleted file mode 100644 index dade684c47f..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-card-with-rounded-corners.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {AlphaCard, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaCardExample() { - return ( - - - Content inside a card - - - ); -} - -export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/pages/examples/alpha-card-with-subdued-background.tsx b/polaris.shopify.com/pages/examples/alpha-card-with-subdued-background.tsx deleted file mode 100644 index c2cf0838a10..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-card-with-subdued-background.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {AlphaCard, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaCardExample() { - return ( - - - Content inside a card - - - ); -} - -export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/pages/examples/alpha-card-with-varying-padding.tsx b/polaris.shopify.com/pages/examples/alpha-card-with-varying-padding.tsx deleted file mode 100644 index b40d25aebe0..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-card-with-varying-padding.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import {AlphaCard, Text, AlphaStack} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaCardExample() { - return ( - - - - - - - - - - - - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(AlphaCardExample); diff --git a/polaris.shopify.com/pages/examples/alpha-stack-default.tsx b/polaris.shopify.com/pages/examples/alpha-stack-default.tsx deleted file mode 100644 index b95e2b3f011..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-stack-default.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react'; -import {AlphaStack, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaStackExample() { - return ( - - - - - - ); -} - -const Placeholder = ({ - label = '', - height = 'auto', - width = 'auto', - childWidth = 'auto', -}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(AlphaStackExample); diff --git a/polaris.shopify.com/pages/examples/alpha-stack-with-align.tsx b/polaris.shopify.com/pages/examples/alpha-stack-with-align.tsx deleted file mode 100644 index 9e706e5613c..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-stack-with-align.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React from 'react'; -import {AlphaStack, Page, Inline, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaStackWithAlignExample() { - return ( - - - - - - - - - - - - - - - - - - - - ); -} - -const Placeholder = ({ - label = '', - height = 'auto', - width = 'auto', - childAlign, -}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(AlphaStackWithAlignExample); diff --git a/polaris.shopify.com/pages/examples/alpha-stack-with-full-width-children.tsx b/polaris.shopify.com/pages/examples/alpha-stack-with-full-width-children.tsx deleted file mode 100644 index 5e6a2744cb1..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-stack-with-full-width-children.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react'; -import {AlphaStack, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaStackWithFullWidthChildrenExample() { - return ( - - - - - - ); -} - -const Placeholder = ({ - label = '', - height = 'auto', - width = '100%', - childWidth = 'auto', -}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(AlphaStackWithFullWidthChildrenExample); diff --git a/polaris.shopify.com/pages/examples/alpha-stack-with-gap.tsx b/polaris.shopify.com/pages/examples/alpha-stack-with-gap.tsx deleted file mode 100644 index 739ba85c012..00000000000 --- a/polaris.shopify.com/pages/examples/alpha-stack-with-gap.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react'; -import {AlphaStack, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AlphaStackWithGapExample() { - return ( - - - - - - - - ); -} - -const SpacingBackground = ({children, width}) => { - return ( -
    - {children} -
    - ); -}; - -const Placeholder = ({ - label = '', - height = 'auto', - width = 'auto', - childWidth = 'auto', -}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(AlphaStackWithGapExample); diff --git a/polaris.shopify.com/pages/examples/app-provider-default.tsx b/polaris.shopify.com/pages/examples/app-provider-default.tsx deleted file mode 100644 index a7c7fdecf48..00000000000 --- a/polaris.shopify.com/pages/examples/app-provider-default.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { - AppProvider, - Page, - LegacyCard, - ResourceList, - Avatar, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AppProviderExample() { - return ( - - - - { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    -
    - ); -} - -export default withPolarisExample(AppProviderExample); diff --git a/polaris.shopify.com/pages/examples/app-provider-with-i18n.tsx b/polaris.shopify.com/pages/examples/app-provider-with-i18n.tsx deleted file mode 100644 index f4a9f9cecd5..00000000000 --- a/polaris.shopify.com/pages/examples/app-provider-with-i18n.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { - AppProvider, - Page, - LegacyCard, - ResourceList, - Avatar, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AppProviderI18NExample() { - return ( - - - - { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    -
    - ); -} - -export default withPolarisExample(AppProviderI18NExample); diff --git a/polaris.shopify.com/pages/examples/app-provider-with-link-component.tsx b/polaris.shopify.com/pages/examples/app-provider-with-link-component.tsx deleted file mode 100644 index 7373957f327..00000000000 --- a/polaris.shopify.com/pages/examples/app-provider-with-link-component.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import {AppProvider, Page} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AppProviderLinkExample() { - const CustomLinkComponent = ({children, url, ...rest}) => { - return ( - console.log('Custom link clicked')} - {...rest} - > - {children} - - ); - }; - - return ( - - -

    Page content

    -
    -
    - ); -} - -export default withPolarisExample(AppProviderLinkExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-default.tsx b/polaris.shopify.com/pages/examples/autocomplete-default.tsx deleted file mode 100644 index 51bc4d5b002..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-default.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import {Autocomplete, Icon} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutocompleteExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - }, - [deselectedOptions], - ); - - const updateSelection = useCallback( - (selected) => { - const selectedValue = selected.map((selectedItem) => { - const matchedOption = options.find((option) => { - return option.value.match(selectedItem); - }); - return matchedOption && matchedOption.label; - }); - - setSelectedOptions(selected); - setInputValue(selectedValue[0]); - }, - [options], - ); - - const textField = ( - } - placeholder="Search" - /> - ); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-action.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-action.tsx deleted file mode 100644 index 0403a1f0373..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-action.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import {Autocomplete, Icon} from '@shopify/polaris'; -import {SearchMinor, CirclePlusMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutocompleteActionBeforeExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - const [loading, setLoading] = useState(false); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (!loading) { - setLoading(true); - } - - setTimeout(() => { - if (value === '') { - setOptions(deselectedOptions); - setLoading(false); - return; - } - const filterRegex = new RegExp(value, 'i'); - const resultOptions = options.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - setLoading(false); - }, 300); - }, - [deselectedOptions, loading, options], - ); - - const updateSelection = useCallback( - (selected) => { - const selectedText = selected.map((selectedItem) => { - const matchedOption = options.find((option) => { - return option.value.match(selectedItem); - }); - return matchedOption && matchedOption.label; - }); - setSelectedOptions(selected); - setInputValue(selectedText[0]); - }, - [options], - ); - - const textField = ( - } - placeholder="Search" - /> - ); - - return ( -
    - { - console.log('actionBefore clicked!'); - }, - }} - options={options} - selected={selectedOptions} - onSelect={updateSelection} - listTitle="Suggested tags" - loading={loading} - textField={textField} - /> -
    - ); -} - -export default withPolarisExample(AutocompleteActionBeforeExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-destructive-action.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-destructive-action.tsx deleted file mode 100644 index aca60e1f50c..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-destructive-action.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import {Autocomplete, Icon} from '@shopify/polaris'; -import {SearchMinor, DeleteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutocompleteActionBeforeExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - const [loading, setLoading] = useState(false); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (!loading) { - setLoading(true); - } - - setTimeout(() => { - if (value === '') { - setOptions(deselectedOptions); - setLoading(false); - return; - } - const filterRegex = new RegExp(value, 'i'); - const resultOptions = options.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - setLoading(false); - }, 300); - }, - [deselectedOptions, loading, options], - ); - - const updateSelection = useCallback( - (selected) => { - const selectedText = selected.map((selectedItem) => { - const matchedOption = options.find((option) => { - return option.value.match(selectedItem); - }); - return matchedOption && matchedOption.label; - }); - setSelectedOptions(selected); - setInputValue(selectedText[0]); - }, - [options], - ); - - const textField = ( - } - placeholder="Search" - /> - ); - - return ( -
    - { - console.log('actionBefore clicked!'); - }, - }} - options={options} - selected={selectedOptions} - onSelect={updateSelection} - listTitle="Suggested tags" - loading={loading} - textField={textField} - /> -
    - ); -} - -export default withPolarisExample(AutocompleteActionBeforeExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-empty-state.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-empty-state.tsx deleted file mode 100644 index 2b9f304c3c2..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-empty-state.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import {Autocomplete, Icon, TextContainer} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import React, {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutocompleteExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - const [loading, setLoading] = useState(false); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (!loading) { - setLoading(true); - } - - setTimeout(() => { - if (value === '') { - setOptions(deselectedOptions); - setLoading(false); - return; - } - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - setLoading(false); - }, 300); - }, - [deselectedOptions, loading], - ); - - const updateSelection = useCallback( - (selected) => { - const selectedText = selected.map((selectedItem) => { - const matchedOption = options.find((option) => { - return option.value.match(selectedItem); - }); - return matchedOption && matchedOption.label; - }); - setSelectedOptions(selected); - setInputValue(selectedText[0]); - }, - [options], - ); - - const textField = ( - } - placeholder="Search" - /> - ); - - const emptyState = ( - - -
    - Could not find any results -
    -
    - ); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-lazy-loading.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-lazy-loading.tsx deleted file mode 100644 index 0e3c193e069..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-lazy-loading.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import {Autocomplete, Tag, LegacyStack} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutoCompleteLazyLoadExample() { - const paginationInterval = 25; - const deselectedOptions = Array.from(Array(100)).map((_, index) => ({ - value: `rustic ${index + 1}`, - label: `Rustic ${index + 1}`, - })); - - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - const [isLoading, setIsLoading] = useState(false); - const [willLoadMoreResults, setWillLoadMoreResults] = useState(true); - const [visibleOptionIndex, setVisibleOptionIndex] = - useState(paginationInterval); - - const handleLoadMoreResults = useCallback(() => { - if (willLoadMoreResults) { - setIsLoading(true); - - setTimeout(() => { - const remainingOptionCount = options.length - visibleOptionIndex; - const nextVisibleOptionIndex = - remainingOptionCount >= paginationInterval - ? visibleOptionIndex + paginationInterval - : visibleOptionIndex + remainingOptionCount; - - setIsLoading(false); - setVisibleOptionIndex(nextVisibleOptionIndex); - - if (remainingOptionCount <= paginationInterval) { - setWillLoadMoreResults(false); - } - }, 1000); - } - }, [willLoadMoreResults, visibleOptionIndex, options.length]); - - const removeTag = useCallback( - (tag) => () => { - const options = [...selectedOptions]; - options.splice(options.indexOf(tag), 1); - setSelectedOptions(options); - }, - [selectedOptions], - ); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - - let endIndex = resultOptions.length - 1; - if (resultOptions.length === 0) { - endIndex = 0; - } - setOptions(resultOptions); - setInputValue; - }, - [deselectedOptions], - ); - - const textField = ( - - ); - - const hasSelectedOptions = selectedOptions.length > 0; - - const tagsMarkup = hasSelectedOptions - ? selectedOptions.map((option) => { - let tagLabel = ''; - tagLabel = option.replace('_', ' '); - tagLabel = titleCase(tagLabel); - return ( - - {tagLabel} - - ); - }) - : null; - const optionList = options.slice(0, visibleOptionIndex); - const selectedTagMarkup = hasSelectedOptions ? ( - {tagsMarkup} - ) : null; - - return ( - - {selectedTagMarkup} - - - ); - - function titleCase(string) { - return string - .toLowerCase() - .split(' ') - .map((word) => { - return word.replace(word[0], word[0].toUpperCase()); - }) - .join(' '); - } -} - -export default withPolarisExample(AutoCompleteLazyLoadExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-loading.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-loading.tsx deleted file mode 100644 index fefd902e0a9..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-loading.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import {Autocomplete, Icon} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutocompleteExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - const [loading, setLoading] = useState(false); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (!loading) { - setLoading(true); - } - - setTimeout(() => { - if (value === '') { - setOptions(deselectedOptions); - setLoading(false); - return; - } - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - setLoading(false); - }, 300); - }, - [deselectedOptions, loading], - ); - - const updateSelection = useCallback( - (selected) => { - const selectedText = selected.map((selectedItem) => { - const matchedOption = options.find((option) => { - return option.value.match(selectedItem); - }); - return matchedOption && matchedOption.label; - }); - setSelectedOptions(selected); - setInputValue(selectedText[0]); - }, - [options], - ); - - const textField = ( - } - placeholder="Search" - /> - ); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-multiple-sections.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-multiple-sections.tsx deleted file mode 100644 index d29dcf5af72..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-multiple-sections.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import {Autocomplete, Icon} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutocompleteExample() { - const deselectedOptions = useMemo( - () => [ - { - title: 'Frequently used', - options: [ - {value: 'ups', label: 'UPS'}, - {value: 'usps', label: 'USPS'}, - ], - }, - { - title: 'All carriers', - options: [ - {value: 'dhl', label: 'DHL Express'}, - {value: 'canada_post', label: 'Canada Post'}, - ], - }, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = []; - - deselectedOptions.forEach((opt) => { - const lol = opt.options.filter((option) => - option.label.match(filterRegex), - ); - - resultOptions.push({ - title: opt.title, - options: lol, - }); - }); - - setOptions(resultOptions); - }, - [deselectedOptions], - ); - - const updateSelection = useCallback( - ([selected]) => { - let selectedValue; - - options.forEach(({options: opt}) => { - if (selectedValue) { - return; - } - - const matchedOption = opt.find((option) => - option.value.match(selected), - ); - - if (matchedOption) { - selectedValue = matchedOption.label; - } - }); - - setSelectedOptions([selected]); - setInputValue(String(selectedValue) ? String(selectedValue) : ''); - }, - [options], - ); - - const textField = ( - } - placeholder="Search" - /> - ); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(AutocompleteExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-multiple-tags.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-multiple-tags.tsx deleted file mode 100644 index b2904fd9554..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-multiple-tags.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import {LegacyStack, Tag, Autocomplete} from '@shopify/polaris'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultiAutocompleteExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState(['rustic']); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - let endIndex = resultOptions.length - 1; - if (resultOptions.length === 0) { - endIndex = 0; - } - setOptions(resultOptions); - }, - [deselectedOptions], - ); - - const removeTag = useCallback( - (tag) => () => { - const options = [...selectedOptions]; - options.splice(options.indexOf(tag), 1); - setSelectedOptions(options); - }, - [selectedOptions], - ); - - const verticalContentMarkup = - selectedOptions.length > 0 ? ( - - {selectedOptions.map((option) => { - let tagLabel = ''; - tagLabel = option.replace('_', ' '); - tagLabel = titleCase(tagLabel); - return ( - - {tagLabel} - - ); - })} - - ) : null; - - const textField = ( - - ); - - return ( -
    - -
    - ); - - function titleCase(string) { - return string - .toLowerCase() - .split(' ') - .map((word) => word.replace(word[0], word[0].toUpperCase())) - .join(''); - } -} - -export default withPolarisExample(MultiAutocompleteExample); diff --git a/polaris.shopify.com/pages/examples/autocomplete-with-wrapping-action.tsx b/polaris.shopify.com/pages/examples/autocomplete-with-wrapping-action.tsx deleted file mode 100644 index 98bfdc0aa71..00000000000 --- a/polaris.shopify.com/pages/examples/autocomplete-with-wrapping-action.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import {Autocomplete, Icon} from '@shopify/polaris'; -import {SearchMinor, CirclePlusMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AutocompleteActionBeforeExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - const [loading, setLoading] = useState(false); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (!loading) { - setLoading(true); - } - - setTimeout(() => { - if (value === '') { - setOptions(deselectedOptions); - setLoading(false); - return; - } - const filterRegex = new RegExp(value, 'i'); - const resultOptions = options.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - setLoading(false); - }, 300); - }, - [deselectedOptions, loading, options], - ); - - const updateSelection = useCallback( - (selected) => { - const selectedText = selected.map((selectedItem) => { - const matchedOption = options.find((option) => { - return option.value.match(selectedItem); - }); - return matchedOption && matchedOption.label; - }); - setSelectedOptions(selected); - setInputValue(selectedText[0]); - }, - [options], - ); - - const textField = ( - } - placeholder="Search" - /> - ); - - return ( -
    - { - console.log('actionBefore clicked!'); - }, - }} - options={options} - selected={selectedOptions} - onSelect={updateSelection} - listTitle="Suggested tags" - loading={loading} - textField={textField} - /> -
    - ); -} - -export default withPolarisExample(AutocompleteActionBeforeExample); diff --git a/polaris.shopify.com/pages/examples/avatar-default.tsx b/polaris.shopify.com/pages/examples/avatar-default.tsx deleted file mode 100644 index 97eff02e80a..00000000000 --- a/polaris.shopify.com/pages/examples/avatar-default.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Avatar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AvatarExample() { - return ; -} - -export default withPolarisExample(AvatarExample); diff --git a/polaris.shopify.com/pages/examples/avatar-extra-small.tsx b/polaris.shopify.com/pages/examples/avatar-extra-small.tsx deleted file mode 100644 index 83a9faa5eb1..00000000000 --- a/polaris.shopify.com/pages/examples/avatar-extra-small.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import {Button, Popover, ActionList, Avatar} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ExtraSmallAvatarExample() { - const [active, setActive] = useState(true); - const toggleActive = useCallback(() => setActive((active) => !active), []); - const activator = ( - - ); - - return ( -
    - - , - }, - { - content: 'Farrah Fawcett', - prefix: ( - - ), - }, - ]} - /> - -
    - ); -} - -export default withPolarisExample(ExtraSmallAvatarExample); diff --git a/polaris.shopify.com/pages/examples/avatar-square.tsx b/polaris.shopify.com/pages/examples/avatar-square.tsx deleted file mode 100644 index a08b37a7ad7..00000000000 --- a/polaris.shopify.com/pages/examples/avatar-square.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Avatar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function AvatarExample() { - return ; -} - -export default withPolarisExample(AvatarExample); diff --git a/polaris.shopify.com/pages/examples/badge-attention.tsx b/polaris.shopify.com/pages/examples/badge-attention.tsx deleted file mode 100644 index a0ae22c50c4..00000000000 --- a/polaris.shopify.com/pages/examples/badge-attention.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return Open; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-complete.tsx b/polaris.shopify.com/pages/examples/badge-complete.tsx deleted file mode 100644 index 0862b11d46d..00000000000 --- a/polaris.shopify.com/pages/examples/badge-complete.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return Fulfilled; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-critical.tsx b/polaris.shopify.com/pages/examples/badge-critical.tsx deleted file mode 100644 index 494d469d2f0..00000000000 --- a/polaris.shopify.com/pages/examples/badge-critical.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return Action required; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-default.tsx b/polaris.shopify.com/pages/examples/badge-default.tsx deleted file mode 100644 index a76f02a19d8..00000000000 --- a/polaris.shopify.com/pages/examples/badge-default.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return Fulfilled; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-incomplete.tsx b/polaris.shopify.com/pages/examples/badge-incomplete.tsx deleted file mode 100644 index 46a615701c7..00000000000 --- a/polaris.shopify.com/pages/examples/badge-incomplete.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return ( - - Unfulfilled - - ); -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-informational.tsx b/polaris.shopify.com/pages/examples/badge-informational.tsx deleted file mode 100644 index f5823fc4294..00000000000 --- a/polaris.shopify.com/pages/examples/badge-informational.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return Draft; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-partially-complete.tsx b/polaris.shopify.com/pages/examples/badge-partially-complete.tsx deleted file mode 100644 index 7516df35bb9..00000000000 --- a/polaris.shopify.com/pages/examples/badge-partially-complete.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return ( - - Partially fulfilled - - ); -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-small.tsx b/polaris.shopify.com/pages/examples/badge-small.tsx deleted file mode 100644 index 53be196ffe3..00000000000 --- a/polaris.shopify.com/pages/examples/badge-small.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return Fulfilled; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-success.tsx b/polaris.shopify.com/pages/examples/badge-success.tsx deleted file mode 100644 index 3eda9e067d0..00000000000 --- a/polaris.shopify.com/pages/examples/badge-success.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return Active; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-warning.tsx b/polaris.shopify.com/pages/examples/badge-warning.tsx deleted file mode 100644 index 2520caaa444..00000000000 --- a/polaris.shopify.com/pages/examples/badge-warning.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return On hold; -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/badge-with-status-and-progress-label-override.tsx b/polaris.shopify.com/pages/examples/badge-with-status-and-progress-label-override.tsx deleted file mode 100644 index 20ac58a5ca1..00000000000 --- a/polaris.shopify.com/pages/examples/badge-with-status-and-progress-label-override.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import {Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BadgeExample() { - return ( - - Published - - ); -} - -export default withPolarisExample(BadgeExample); diff --git a/polaris.shopify.com/pages/examples/banner-critical.tsx b/polaris.shopify.com/pages/examples/banner-critical.tsx deleted file mode 100644 index b9528607fd0..00000000000 --- a/polaris.shopify.com/pages/examples/banner-critical.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Banner, Link} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - -

    - Before fulfilling this order or capturing payment, please{' '} - review the Risk Analysis and determine if this order - is fraudulent. -

    -
    - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/banner-default.tsx b/polaris.shopify.com/pages/examples/banner-default.tsx deleted file mode 100644 index 95fd88af1d8..00000000000 --- a/polaris.shopify.com/pages/examples/banner-default.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {Banner} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - {}}> -

    This order was archived on March 7, 2017 at 3:12pm EDT.

    -
    - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/banner-dismissible.tsx b/polaris.shopify.com/pages/examples/banner-dismissible.tsx deleted file mode 100644 index ca889889782..00000000000 --- a/polaris.shopify.com/pages/examples/banner-dismissible.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {Banner, Link} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - {}}> -

    - Use your finance report to get detailed information about your business.{' '} - Let us know what you think -

    -
    - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/banner-in-a-card.tsx b/polaris.shopify.com/pages/examples/banner-in-a-card.tsx deleted file mode 100644 index 5a9e07a3673..00000000000 --- a/polaris.shopify.com/pages/examples/banner-in-a-card.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {LegacyCard, TextContainer, Banner, Link} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - - - {}}> -

    - Use your finance report to get detailed information about your - business. Let us know what you think -

    -
    - -

    View a summary of your online store’s performance.

    -
    -
    - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/banner-in-a-modal.tsx b/polaris.shopify.com/pages/examples/banner-in-a-modal.tsx deleted file mode 100644 index 2aab09ce6b7..00000000000 --- a/polaris.shopify.com/pages/examples/banner-in-a-modal.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import {Button, Modal, TextContainer, Banner} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerInModalExample() { - const [active, setActive] = useState(false); - - const handleChange = useCallback(() => setActive(!active), [active]); - - return ( -
    - - - - - -

    - Connect your instagram account to your shop before proceeding. -

    -
    -

    - Use Instagram posts to share your products with millions of - people. Let shoppers buy from your store without leaving - Instagram. -

    -
    -
    -
    -
    - ); -} - -export default withPolarisExample(BannerInModalExample); diff --git a/polaris.shopify.com/pages/examples/banner-informational.tsx b/polaris.shopify.com/pages/examples/banner-informational.tsx deleted file mode 100644 index 7aec36301bd..00000000000 --- a/polaris.shopify.com/pages/examples/banner-informational.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import {Banner} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - {}} - > -

    Make sure you know how these changes affect your store.

    -
    - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/banner-success.tsx b/polaris.shopify.com/pages/examples/banner-success.tsx deleted file mode 100644 index f53a274d0b8..00000000000 --- a/polaris.shopify.com/pages/examples/banner-success.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {Banner} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - {}} - /> - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/banner-warning.tsx b/polaris.shopify.com/pages/examples/banner-warning.tsx deleted file mode 100644 index 4e9accf3df4..00000000000 --- a/polaris.shopify.com/pages/examples/banner-warning.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {Banner, List} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - - - - The name of the city you’re shipping to has characters that aren’t - allowed. City name can only include spaces and hyphens. - - - - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/banner-with-focus.tsx b/polaris.shopify.com/pages/examples/banner-with-focus.tsx deleted file mode 100644 index 1af958f97a6..00000000000 --- a/polaris.shopify.com/pages/examples/banner-with-focus.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {Banner} from '@shopify/polaris'; -import {useEffect, useRef} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerWithFocusExample() { - const banner = useRef(); - - useEffect(() => banner.current.focus(), []); - - return ( - {}} - status="critical" - ref={banner} - > -

    - Before fulfilling this order or capturing payment, please review the - fraud analysis and determine if this order is fraudulent -

    -
    - ); -} - -export default withPolarisExample(BannerWithFocusExample); diff --git a/polaris.shopify.com/pages/examples/banner-with-footer-call-to-action.tsx b/polaris.shopify.com/pages/examples/banner-with-footer-call-to-action.tsx deleted file mode 100644 index e114e46ed59..00000000000 --- a/polaris.shopify.com/pages/examples/banner-with-footer-call-to-action.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {Banner} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BannerExample() { - return ( - {}} - > -

    - Add weights to show accurate rates at checkout and when buying shipping - labels in Shopify. -

    -
    - ); -} - -export default withPolarisExample(BannerExample); diff --git a/polaris.shopify.com/pages/examples/bleed-all-directions.tsx b/polaris.shopify.com/pages/examples/bleed-all-directions.tsx deleted file mode 100644 index 6c96d716127..00000000000 --- a/polaris.shopify.com/pages/examples/bleed-all-directions.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react'; -import {Bleed, Box, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BleedAllDirectionsExample() { - return ( - - - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(BleedAllDirectionsExample); diff --git a/polaris.shopify.com/pages/examples/bleed-horizontal.tsx b/polaris.shopify.com/pages/examples/bleed-horizontal.tsx deleted file mode 100644 index acb7ab88420..00000000000 --- a/polaris.shopify.com/pages/examples/bleed-horizontal.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react'; -import {Bleed, Box, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BleedHorizontalExample() { - return ( - - - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(BleedHorizontalExample); diff --git a/polaris.shopify.com/pages/examples/bleed-specific-direction.tsx b/polaris.shopify.com/pages/examples/bleed-specific-direction.tsx deleted file mode 100644 index 297205058fd..00000000000 --- a/polaris.shopify.com/pages/examples/bleed-specific-direction.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react'; -import {AlphaStack, Bleed, Box, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BleedSpecificDirectionExample() { - return ( - - - - - - - - - - - - - - - - - - - - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(BleedSpecificDirectionExample); diff --git a/polaris.shopify.com/pages/examples/bleed-vertical.tsx b/polaris.shopify.com/pages/examples/bleed-vertical.tsx deleted file mode 100644 index 695a06e4a4d..00000000000 --- a/polaris.shopify.com/pages/examples/bleed-vertical.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react'; -import {Bleed, Box, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BleedVerticalExample() { - return ( - - - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(BleedVerticalExample); diff --git a/polaris.shopify.com/pages/examples/box-default.tsx b/polaris.shopify.com/pages/examples/box-default.tsx deleted file mode 100644 index 2f2254e5065..00000000000 --- a/polaris.shopify.com/pages/examples/box-default.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -import {Box, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BoxDefaultExample() { - return ( - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(BoxDefaultExample); diff --git a/polaris.shopify.com/pages/examples/box-with-border-radius.tsx b/polaris.shopify.com/pages/examples/box-with-border-radius.tsx deleted file mode 100644 index 208560e8193..00000000000 --- a/polaris.shopify.com/pages/examples/box-with-border-radius.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import {Box, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BoxWithBorderRadiusExample() { - return ( - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(BoxWithBorderRadiusExample); diff --git a/polaris.shopify.com/pages/examples/box-with-border.tsx b/polaris.shopify.com/pages/examples/box-with-border.tsx deleted file mode 100644 index 70463ac0f04..00000000000 --- a/polaris.shopify.com/pages/examples/box-with-border.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -import {Box, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BoxWithBorderExample() { - return ( - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(BoxWithBorderExample); diff --git a/polaris.shopify.com/pages/examples/box-with-color.tsx b/polaris.shopify.com/pages/examples/box-with-color.tsx deleted file mode 100644 index 8789b92cb0f..00000000000 --- a/polaris.shopify.com/pages/examples/box-with-color.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import {Box, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BoxWithColorExample() { - return ( - - - Content inside a box - - - ); -} - -export default withPolarisExample(BoxWithColorExample); diff --git a/polaris.shopify.com/pages/examples/box-with-padding.tsx b/polaris.shopify.com/pages/examples/box-with-padding.tsx deleted file mode 100644 index 5e8faabe37c..00000000000 --- a/polaris.shopify.com/pages/examples/box-with-padding.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -import {AlphaStack, Box, LegacyStack, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BoxWithPaddingExample() { - return ( - -
    - - - -
    - -
    - - - -
    -
    - - - -
    -
    - -
    - - - -
    -
    - - - -
    -
    -
    - ); -} - -const Placeholder = ({ - label = '', - height = 'auto', - width = 'auto', - childAlign, -}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(BoxWithPaddingExample); diff --git a/polaris.shopify.com/pages/examples/box-with-shadow.tsx b/polaris.shopify.com/pages/examples/box-with-shadow.tsx deleted file mode 100644 index 7405c9fc7e2..00000000000 --- a/polaris.shopify.com/pages/examples/box-with-shadow.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -import {Box, Text} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function BoxWithShadowExample() { - return ( - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    -
    - - {label} - -
    -
    - ); -}; - -export default withPolarisExample(BoxWithShadowExample); diff --git a/polaris.shopify.com/pages/examples/button-default.tsx b/polaris.shopify.com/pages/examples/button-default.tsx deleted file mode 100644 index 3ba730b232a..00000000000 --- a/polaris.shopify.com/pages/examples/button-default.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-destructive.tsx b/polaris.shopify.com/pages/examples/button-destructive.tsx deleted file mode 100644 index 8ac32c70bd2..00000000000 --- a/polaris.shopify.com/pages/examples/button-destructive.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-disabled-state.tsx b/polaris.shopify.com/pages/examples/button-disabled-state.tsx deleted file mode 100644 index d55927c7f9d..00000000000 --- a/polaris.shopify.com/pages/examples/button-disabled-state.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import {ButtonGroup, Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ( - - - - - - - - - - - - ); -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-full-width.tsx b/polaris.shopify.com/pages/examples/button-full-width.tsx deleted file mode 100644 index 13d5b186934..00000000000 --- a/polaris.shopify.com/pages/examples/button-full-width.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-group-default.tsx b/polaris.shopify.com/pages/examples/button-group-default.tsx deleted file mode 100644 index e8ba4162632..00000000000 --- a/polaris.shopify.com/pages/examples/button-group-default.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import {ButtonGroup, Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonGroupExample() { - return ( - - - - - ); -} - -export default withPolarisExample(ButtonGroupExample); diff --git a/polaris.shopify.com/pages/examples/button-group-outline-with-segmented-buttons.tsx b/polaris.shopify.com/pages/examples/button-group-outline-with-segmented-buttons.tsx deleted file mode 100644 index dc38bafbb03..00000000000 --- a/polaris.shopify.com/pages/examples/button-group-outline-with-segmented-buttons.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {ButtonGroup, Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonGroupExample() { - return ( - - - - - - ); -} - -export default withPolarisExample(ButtonGroupExample); diff --git a/polaris.shopify.com/pages/examples/button-group-with-segmented-buttons.tsx b/polaris.shopify.com/pages/examples/button-group-with-segmented-buttons.tsx deleted file mode 100644 index 595242c32d1..00000000000 --- a/polaris.shopify.com/pages/examples/button-group-with-segmented-buttons.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {ButtonGroup, Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonGroupExample() { - return ( - - - - - - ); -} - -export default withPolarisExample(ButtonGroupExample); diff --git a/polaris.shopify.com/pages/examples/button-large.tsx b/polaris.shopify.com/pages/examples/button-large.tsx deleted file mode 100644 index 2e47891c246..00000000000 --- a/polaris.shopify.com/pages/examples/button-large.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-loading-state.tsx b/polaris.shopify.com/pages/examples/button-loading-state.tsx deleted file mode 100644 index 8940ab715ae..00000000000 --- a/polaris.shopify.com/pages/examples/button-loading-state.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-outline-monochrome.tsx b/polaris.shopify.com/pages/examples/button-outline-monochrome.tsx deleted file mode 100644 index 2545223c12f..00000000000 --- a/polaris.shopify.com/pages/examples/button-outline-monochrome.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ( -
    - -
    - ); -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-outline.tsx b/polaris.shopify.com/pages/examples/button-outline.tsx deleted file mode 100644 index 0f31768401a..00000000000 --- a/polaris.shopify.com/pages/examples/button-outline.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-plain-destructive.tsx b/polaris.shopify.com/pages/examples/button-plain-destructive.tsx deleted file mode 100644 index 744e3b63362..00000000000 --- a/polaris.shopify.com/pages/examples/button-plain-destructive.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ( - - ); -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-plain-disclosure.tsx b/polaris.shopify.com/pages/examples/button-plain-disclosure.tsx deleted file mode 100644 index f160cd219d7..00000000000 --- a/polaris.shopify.com/pages/examples/button-plain-disclosure.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Button} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DisclosureButton() { - const [expanded, setExpanded] = useState(false); - - return ( - - ); -} - -export default withPolarisExample(DisclosureButton); diff --git a/polaris.shopify.com/pages/examples/button-plain-monochrome.tsx b/polaris.shopify.com/pages/examples/button-plain-monochrome.tsx deleted file mode 100644 index 8160eaa542d..00000000000 --- a/polaris.shopify.com/pages/examples/button-plain-monochrome.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ( -
    - Could not retrieve data.{' '} - -
    - ); -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-plain.tsx b/polaris.shopify.com/pages/examples/button-plain.tsx deleted file mode 100644 index 85859fad096..00000000000 --- a/polaris.shopify.com/pages/examples/button-plain.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-pressed.tsx b/polaris.shopify.com/pages/examples/button-pressed.tsx deleted file mode 100644 index 4ed7dd95975..00000000000 --- a/polaris.shopify.com/pages/examples/button-pressed.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import {ButtonGroup, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function PressedButton() { - const [isFirstButtonActive, setIsFirstButtonActive] = useState(true); - - const handleFirstButtonClick = useCallback(() => { - if (isFirstButtonActive) return; - setIsFirstButtonActive(true); - }, [isFirstButtonActive]); - - const handleSecondButtonClick = useCallback(() => { - if (!isFirstButtonActive) return; - setIsFirstButtonActive(false); - }, [isFirstButtonActive]); - - return ( - - - - - ); -} - -export default withPolarisExample(PressedButton); diff --git a/polaris.shopify.com/pages/examples/button-primary.tsx b/polaris.shopify.com/pages/examples/button-primary.tsx deleted file mode 100644 index c89d055051e..00000000000 --- a/polaris.shopify.com/pages/examples/button-primary.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-right-aligned-disclosure.tsx b/polaris.shopify.com/pages/examples/button-right-aligned-disclosure.tsx deleted file mode 100644 index cdc7c6169b9..00000000000 --- a/polaris.shopify.com/pages/examples/button-right-aligned-disclosure.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {Button} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RightAlignedDisclosureButton() { - const [expanded, setExpanded] = useState(false); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(RightAlignedDisclosureButton); diff --git a/polaris.shopify.com/pages/examples/button-select-disclosure.tsx b/polaris.shopify.com/pages/examples/button-select-disclosure.tsx deleted file mode 100644 index 73c5e1ecf06..00000000000 --- a/polaris.shopify.com/pages/examples/button-select-disclosure.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ( -
    - -
    - ); -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-slim.tsx b/polaris.shopify.com/pages/examples/button-slim.tsx deleted file mode 100644 index 2d072b1bcc2..00000000000 --- a/polaris.shopify.com/pages/examples/button-slim.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ; -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-split.tsx b/polaris.shopify.com/pages/examples/button-split.tsx deleted file mode 100644 index 6f2f800677f..00000000000 --- a/polaris.shopify.com/pages/examples/button-split.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ( -
    - -
    - ); -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/button-text-aligned.tsx b/polaris.shopify.com/pages/examples/button-text-aligned.tsx deleted file mode 100644 index b98cc2a3d83..00000000000 --- a/polaris.shopify.com/pages/examples/button-text-aligned.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ButtonExample() { - return ( - - ); -} - -export default withPolarisExample(ButtonExample); diff --git a/polaris.shopify.com/pages/examples/callout-card-default.tsx b/polaris.shopify.com/pages/examples/callout-card-default.tsx deleted file mode 100644 index 37659536183..00000000000 --- a/polaris.shopify.com/pages/examples/callout-card-default.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {CalloutCard} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( - -

    Upload your store’s logo, change colors and fonts, and more.

    -
    - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/callout-card-dismissable.tsx b/polaris.shopify.com/pages/examples/callout-card-dismissable.tsx deleted file mode 100644 index edf7faeb505..00000000000 --- a/polaris.shopify.com/pages/examples/callout-card-dismissable.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import {CalloutCard} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( - {}} - > -

    Upload your store’s logo, change colors and fonts, and more.

    -
    - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/callout-card-with-secondary-action.tsx b/polaris.shopify.com/pages/examples/callout-card-with-secondary-action.tsx deleted file mode 100644 index 2ad2aa532b4..00000000000 --- a/polaris.shopify.com/pages/examples/callout-card-with-secondary-action.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import {CalloutCard} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( - -

    Upload your store’s logo, change colors and fonts, and more.

    -
    - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/card-default.tsx b/polaris.shopify.com/pages/examples/card-default.tsx deleted file mode 100644 index d6d4d282497..00000000000 --- a/polaris.shopify.com/pages/examples/card-default.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {Card} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - -

    View a summary of your online store’s performance.

    -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-a-subdued-section.tsx b/polaris.shopify.com/pages/examples/card-with-a-subdued-section.tsx deleted file mode 100644 index 8688b8dd5a9..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-a-subdued-section.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Card, List} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - - Felix Crafford - Ezequiel Manno - - - - - Felix Crafford - Ezequiel Manno - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-all-elements.tsx b/polaris.shopify.com/pages/examples/card-with-all-elements.tsx deleted file mode 100644 index 73d0e53db74..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-all-elements.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { - Card, - Popover, - Button, - ActionList, - TextContainer, - ResourceList, - LegacyStack, - List, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - - View Sales - - } - onClose={() => {}} - > - - - - - - You can use sales reports to see information about your customers’ - orders based on criteria such as sales over time, by channel, or by - staff. - - - - { - const {sales, amount, url} = item; - return ( - - - {sales} - {amount} - - - ); - }} - /> - - - - Payouts - Total Sales By Channel - - - - - The sales reports are available only if your store is on the Shopify - plan or higher. - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-custom-footer-actions.tsx b/polaris.shopify.com/pages/examples/card-with-custom-footer-actions.tsx deleted file mode 100644 index 3639d8d0aaa..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-custom-footer-actions.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import {LegacyCard, LegacyStack, ButtonGroup, Button} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - -

    - Two-step authentication adds an extra layer of security when logging - in to your account. A special code will be required each time you - log in, ensuring only you can access your account. -

    - - - - - - -
    -
    -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-custom-react-node-title.tsx b/polaris.shopify.com/pages/examples/card-with-custom-react-node-title.tsx deleted file mode 100644 index 1eb354ddfa1..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-custom-react-node-title.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import {Card, LegacyStack, Icon, List, Text} from '@shopify/polaris'; -import {ProductsMajor} from '@shopify/polaris-icons'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - - - New Products - - - } - > - - Socks - Super Shoes - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-destructive-action.tsx b/polaris.shopify.com/pages/examples/card-with-destructive-action.tsx deleted file mode 100644 index 8adbe3e272e..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-destructive-action.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Card} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - -

    John Smith

    -
    - -

    john.smith@example.com

    -
    -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-destructive-footer-action.tsx b/polaris.shopify.com/pages/examples/card-with-destructive-footer-action.tsx deleted file mode 100644 index 7b5ed2be756..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-destructive-footer-action.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {Card, List} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - - 1 × Oasis Glass, 4-Pack - 1 × Anubis Cup, 2-Pack - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-flushed-sections.tsx b/polaris.shopify.com/pages/examples/card-with-flushed-sections.tsx deleted file mode 100644 index d92188de877..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-flushed-sections.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {Card, Image, TextContainer} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - a sheet with purple and orange stripes - - - - You can use sales reports to see information about your customers’ - orders based on criteria such as sales over time, by channel, or by - staff. - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-footer-actions.tsx b/polaris.shopify.com/pages/examples/card-with-footer-actions.tsx deleted file mode 100644 index 762d8abe773..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-footer-actions.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import {Card, List} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - - 1 × Oasis Glass, 4-Pack - 1 × Anubis Cup, 2-Pack - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-header-actions.tsx b/polaris.shopify.com/pages/examples/card-with-header-actions.tsx deleted file mode 100644 index bedf0ccec79..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-header-actions.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {Card} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - -

    - Add variants if this product comes in multiple versions, like different - sizes or colors. -

    -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-multiple-footer-actions.tsx b/polaris.shopify.com/pages/examples/card-with-multiple-footer-actions.tsx deleted file mode 100644 index 5c5b383f34b..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-multiple-footer-actions.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {Card, List} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - - 1 × Oasis Glass, 4-Pack - 1 × Anubis Cup, 2-Pack - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-multiple-sections.tsx b/polaris.shopify.com/pages/examples/card-with-multiple-sections.tsx deleted file mode 100644 index c45601246a6..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-multiple-sections.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Card} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - -

    View a summary of your online store’s performance.

    -
    - -

    - View a summary of your online store’s performance, including sales, - visitors, top products, and referrals. -

    -
    -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-multiple-titled-sections.tsx b/polaris.shopify.com/pages/examples/card-with-multiple-titled-sections.tsx deleted file mode 100644 index 88e470bd1cd..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-multiple-titled-sections.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Card} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - -

    View a summary of your online store’s performance.

    -
    - -

    - View a summary of your online store’s performance, including sales, - visitors, top products, and referrals. -

    -
    -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-sections-and-actions.tsx b/polaris.shopify.com/pages/examples/card-with-sections-and-actions.tsx deleted file mode 100644 index 1db87cb7304..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-sections-and-actions.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import {Card} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - -

    John Smith

    -
    - -

    john.smith@example.com

    -
    -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-separate-header.tsx b/polaris.shopify.com/pages/examples/card-with-separate-header.tsx deleted file mode 100644 index c764f6a6488..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-separate-header.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import {Card, Popover, Button, ActionList, List} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - - Add account - - } - onClose={() => {}} - > - - - - - - Felix Crafford - Ezequiel Manno - - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-subdued-for-secondary-content.tsx b/polaris.shopify.com/pages/examples/card-with-subdued-for-secondary-content.tsx deleted file mode 100644 index cbe2dcb9815..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-subdued-for-secondary-content.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {Card, List} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - - Felix Crafford - Ezequiel Manno - - - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/card-with-subsection.tsx b/polaris.shopify.com/pages/examples/card-with-subsection.tsx deleted file mode 100644 index ed71c4e4295..00000000000 --- a/polaris.shopify.com/pages/examples/card-with-subsection.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import {Card} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CardExample() { - return ( - - -

    John Smith

    -
    - - - 123 First St -
    - Somewhere -
    - The Universe -
    - - 123 Second St -
    - Somewhere -
    - The Universe -
    -
    - - - A single subsection without a sibling has no visual appearance - - -
    - ); -} - -export default withPolarisExample(CardExample); diff --git a/polaris.shopify.com/pages/examples/checkbox-default.tsx b/polaris.shopify.com/pages/examples/checkbox-default.tsx deleted file mode 100644 index 21273c69926..00000000000 --- a/polaris.shopify.com/pages/examples/checkbox-default.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import {Checkbox} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CheckboxExample() { - const [checked, setChecked] = useState(false); - const handleChange = useCallback((newChecked) => setChecked(newChecked), []); - - return ( - - ); -} - -export default withPolarisExample(CheckboxExample); diff --git a/polaris.shopify.com/pages/examples/choice-list-default.tsx b/polaris.shopify.com/pages/examples/choice-list-default.tsx deleted file mode 100644 index a7497309d72..00000000000 --- a/polaris.shopify.com/pages/examples/choice-list-default.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {ChoiceList} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SingleChoiceListExample() { - const [selected, setSelected] = useState(['hidden']); - - const handleChange = useCallback((value) => setSelected(value), []); - - return ( - - ); -} - -export default withPolarisExample(SingleChoiceListExample); diff --git a/polaris.shopify.com/pages/examples/choice-list-with-children-content.tsx b/polaris.shopify.com/pages/examples/choice-list-with-children-content.tsx deleted file mode 100644 index 7a4601e5fbf..00000000000 --- a/polaris.shopify.com/pages/examples/choice-list-with-children-content.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import {TextField, ChoiceList} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SingleOrMultiChoiceListWithChildrenContextExample() { - const [selected, setSelected] = useState(['none']); - const [textFieldValue, setTextFieldValue] = useState(''); - - const handleChoiceListChange = useCallback((value) => setSelected(value), []); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - const renderChildren = useCallback( - () => ( - - ), - [handleTextFieldChange, textFieldValue], - ); - - return ( - - ); -} - -export default withPolarisExample( - SingleOrMultiChoiceListWithChildrenContextExample, -); diff --git a/polaris.shopify.com/pages/examples/choice-list-with-dynamic-children-content.tsx b/polaris.shopify.com/pages/examples/choice-list-with-dynamic-children-content.tsx deleted file mode 100644 index 2c0b8cbcecc..00000000000 --- a/polaris.shopify.com/pages/examples/choice-list-with-dynamic-children-content.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import {TextField, ChoiceList} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SingleOrMultuChoiceListWithChildrenContextWhenSelectedExample() { - const [selected, setSelected] = useState(['none']); - const [textFieldValue, setTextFieldValue] = useState(''); - - const handleChoiceListChange = useCallback((value) => setSelected(value), []); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - const renderChildren = useCallback( - (isSelected) => - isSelected && ( - - ), - [handleTextFieldChange, textFieldValue], - ); - - return ( -
    - -
    - ); -} - -export default withPolarisExample( - SingleOrMultuChoiceListWithChildrenContextWhenSelectedExample, -); diff --git a/polaris.shopify.com/pages/examples/choice-list-with-error.tsx b/polaris.shopify.com/pages/examples/choice-list-with-error.tsx deleted file mode 100644 index 1ac420ee047..00000000000 --- a/polaris.shopify.com/pages/examples/choice-list-with-error.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {ChoiceList} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ChoiceListWithErrorExample() { - const [selected, setSelected] = useState('hidden'); - - const handleChange = useCallback((value) => setSelected(value), []); - - return ( - - ); -} - -export default withPolarisExample(ChoiceListWithErrorExample); diff --git a/polaris.shopify.com/pages/examples/choice-list-with-multi-choice.tsx b/polaris.shopify.com/pages/examples/choice-list-with-multi-choice.tsx deleted file mode 100644 index 3f308615482..00000000000 --- a/polaris.shopify.com/pages/examples/choice-list-with-multi-choice.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import {ChoiceList} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultiChoiceListExample() { - const [selected, setSelected] = useState(['hidden']); - - const handleChange = useCallback((value) => setSelected(value), []); - - return ( - - ); -} - -export default withPolarisExample(MultiChoiceListExample); diff --git a/polaris.shopify.com/pages/examples/collapsible-default.tsx b/polaris.shopify.com/pages/examples/collapsible-default.tsx deleted file mode 100644 index 331c1ec4794..00000000000 --- a/polaris.shopify.com/pages/examples/collapsible-default.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { - LegacyCard, - LegacyStack, - Button, - Collapsible, - TextContainer, - Link, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function CollapsibleExample() { - const [open, setOpen] = useState(true); - - const handleToggle = useCallback(() => setOpen((open) => !open), []); - - return ( -
    - - - - - -

    - Your mailing list lets you contact customers or visitors who - have shown an interest in your store. Reach out to them with - exclusive offers or updates about your products. -

    - Test link -
    -
    -
    -
    -
    - ); -} - -export default withPolarisExample(CollapsibleExample); diff --git a/polaris.shopify.com/pages/examples/color-picker-default.tsx b/polaris.shopify.com/pages/examples/color-picker-default.tsx deleted file mode 100644 index 3275cc017e9..00000000000 --- a/polaris.shopify.com/pages/examples/color-picker-default.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {ColorPicker} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ColorPickerExample() { - const [color, setColor] = useState({ - hue: 120, - brightness: 1, - saturation: 1, - }); - - return ; -} - -export default withPolarisExample(ColorPickerExample); diff --git a/polaris.shopify.com/pages/examples/color-picker-with-transparent-value-full-width.tsx b/polaris.shopify.com/pages/examples/color-picker-with-transparent-value-full-width.tsx deleted file mode 100644 index c7aea3f29ae..00000000000 --- a/polaris.shopify.com/pages/examples/color-picker-with-transparent-value-full-width.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {ColorPicker} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ColorPickerWithTransparentValueExample() { - const [color, setColor] = useState({ - hue: 300, - brightness: 1, - saturation: 0.7, - alpha: 0.7, - }); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(ColorPickerWithTransparentValueExample); diff --git a/polaris.shopify.com/pages/examples/color-picker-with-transparent-value.tsx b/polaris.shopify.com/pages/examples/color-picker-with-transparent-value.tsx deleted file mode 100644 index 08577f0b530..00000000000 --- a/polaris.shopify.com/pages/examples/color-picker-with-transparent-value.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {ColorPicker} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ColorPickerWithTransparentValueExample() { - const [color, setColor] = useState({ - hue: 300, - brightness: 1, - saturation: 0.7, - alpha: 0.7, - }); - - return ; -} - -export default withPolarisExample(ColorPickerWithTransparentValueExample); diff --git a/polaris.shopify.com/pages/examples/columns-default.tsx b/polaris.shopify.com/pages/examples/columns-default.tsx deleted file mode 100644 index 35ed8f63226..00000000000 --- a/polaris.shopify.com/pages/examples/columns-default.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import {Columns, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ColumnsExample() { - return ( - - - - - - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(ColumnsExample); diff --git a/polaris.shopify.com/pages/examples/columns-with-fixed-widths.tsx b/polaris.shopify.com/pages/examples/columns-with-fixed-widths.tsx deleted file mode 100644 index b07660680cd..00000000000 --- a/polaris.shopify.com/pages/examples/columns-with-fixed-widths.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import {Columns, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ColumnsWithFreeAndFixedWidthsExample() { - return ( - - - - - - - - - ); -} - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(ColumnsWithFreeAndFixedWidthsExample); diff --git a/polaris.shopify.com/pages/examples/columns-with-set-number.tsx b/polaris.shopify.com/pages/examples/columns-with-set-number.tsx deleted file mode 100644 index 533a1282858..00000000000 --- a/polaris.shopify.com/pages/examples/columns-with-set-number.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react'; -import {Columns, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ColumnsWithSetNumberExample() { - return ( - - - - - - - ); -} - -const SpacingBackground = ({children, width = '100%'}) => { - return ( -
    - {children} -
    - ); -}; - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(ColumnsWithSetNumberExample); diff --git a/polaris.shopify.com/pages/examples/columns-with-varying-gap.tsx b/polaris.shopify.com/pages/examples/columns-with-varying-gap.tsx deleted file mode 100644 index 09ce580cf50..00000000000 --- a/polaris.shopify.com/pages/examples/columns-with-varying-gap.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React from 'react'; -import {Columns, Text, Inline} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ColumnsWithVaryingGapExample() { - return ( - - - - - - - - - - - ); -} - -const SpacingBackground = ({children, width = '100%'}) => { - return ( -
    - {children} -
    - ); -}; - -const Placeholder = ({label = '', height = 'auto', width = 'auto'}) => { - return ( -
    - -
    - - {label} - -
    -
    -
    - ); -}; - -export default withPolarisExample(ColumnsWithVaryingGapExample); diff --git a/polaris.shopify.com/pages/examples/combobox-default.tsx b/polaris.shopify.com/pages/examples/combobox-default.tsx deleted file mode 100644 index 4825d442247..00000000000 --- a/polaris.shopify.com/pages/examples/combobox-default.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import {Listbox, Combobox, Icon} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ComboboxExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - - const [selectedOption, setSelectedOption] = useState(); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - }, - [deselectedOptions], - ); - - const updateSelection = useCallback( - (selected) => { - const matchedOption = options.find((option) => { - return option.value.match(selected); - }); - - setSelectedOption(selected); - setInputValue((matchedOption && matchedOption.label) || ''); - }, - [options], - ); - - const optionsMarkup = - options.length > 0 - ? options.map((option) => { - const {label, value} = option; - - return ( - - {label} - - ); - }) - : null; - - return ( -
    - } - onChange={updateText} - label="Search tags" - labelHidden - value={inputValue} - placeholder="Search tags" - /> - } - > - {options.length > 0 ? ( - {optionsMarkup} - ) : null} - -
    - ); -} - -export default withPolarisExample(ComboboxExample); diff --git a/polaris.shopify.com/pages/examples/combobox-with-loading.tsx b/polaris.shopify.com/pages/examples/combobox-with-loading.tsx deleted file mode 100644 index 6b00925aae1..00000000000 --- a/polaris.shopify.com/pages/examples/combobox-with-loading.tsx +++ /dev/null @@ -1,108 +0,0 @@ -import {Listbox, Combobox, Icon} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function LoadingAutocompleteExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - - const [selectedOption, setSelectedOption] = useState(); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - const [loading, setLoading] = useState(false); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (!loading) { - setLoading(true); - } - - setTimeout(() => { - if (value === '') { - setOptions(deselectedOptions); - setLoading(false); - return; - } - const filterRegex = new RegExp(value, 'i'); - const resultOptions = options.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - setLoading(false); - }, 300); - }, - [deselectedOptions, loading, options], - ); - - const updateSelection = useCallback( - (selected) => { - const matchedOption = options.find((option) => { - return option.value.match(selected); - }); - - setSelectedOption(selected); - setInputValue((matchedOption && matchedOption.label) || ''); - }, - [options], - ); - - const optionsMarkup = - options.length > 0 - ? options.map((option) => { - const {label, value} = option; - - return ( - - {label} - - ); - }) - : null; - - const loadingMarkup = loading ? : null; - - const listboxMarkup = - optionsMarkup || loadingMarkup ? ( - - {optionsMarkup && !loading ? optionsMarkup : null} - {loadingMarkup} - - ) : null; - - return ( -
    - } - onChange={updateText} - label="Search tags" - labelHidden - value={inputValue} - placeholder="Search tags" - /> - } - > - {listboxMarkup} - -
    - ); -} - -export default withPolarisExample(LoadingAutocompleteExample); diff --git a/polaris.shopify.com/pages/examples/combobox-with-manual-selection.tsx b/polaris.shopify.com/pages/examples/combobox-with-manual-selection.tsx deleted file mode 100644 index b3eb60a0747..00000000000 --- a/polaris.shopify.com/pages/examples/combobox-with-manual-selection.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { - Tag, - Listbox, - Combobox, - Icon, - TextContainer, - LegacyStack, - AutoSelection, -} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultiComboboxExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - }, - [deselectedOptions], - ); - - const updateSelection = useCallback( - (selected) => { - if (selectedOptions.includes(selected)) { - setSelectedOptions( - selectedOptions.filter((option) => option !== selected), - ); - } else { - setSelectedOptions([...selectedOptions, selected]); - } - - const matchedOption = options.find((option) => { - return option.value.match(selected); - }); - - updateText(''); - }, - [options, selectedOptions, updateText], - ); - - const removeTag = useCallback( - (tag) => () => { - const options = [...selectedOptions]; - options.splice(options.indexOf(tag), 1); - setSelectedOptions(options); - }, - [selectedOptions], - ); - - const tagsMarkup = selectedOptions.map((option) => ( - - {option} - - )); - - const optionsMarkup = - options.length > 0 - ? options.map((option) => { - const {label, value} = option; - - return ( - - {label} - - ); - }) - : null; - - return ( -
    - } - onChange={updateText} - label="Search tags" - labelHidden - value={inputValue} - placeholder="Search tags" - /> - } - > - {optionsMarkup ? ( - - {optionsMarkup} - - ) : null} - - - {tagsMarkup} - -
    - ); -} - -export default withPolarisExample(MultiComboboxExample); diff --git a/polaris.shopify.com/pages/examples/combobox-with-multi-select-and-manual-selection.tsx b/polaris.shopify.com/pages/examples/combobox-with-multi-select-and-manual-selection.tsx deleted file mode 100644 index 46c66efd6ef..00000000000 --- a/polaris.shopify.com/pages/examples/combobox-with-multi-select-and-manual-selection.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import { - Tag, - Listbox, - Combobox, - Icon, - TextContainer, - LegacyStack, -} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultiManualComboboxExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - }, - [deselectedOptions], - ); - - const updateSelection = useCallback( - (selected) => { - if (selectedOptions.includes(selected)) { - setSelectedOptions( - selectedOptions.filter((option) => option !== selected), - ); - } else { - setSelectedOptions([...selectedOptions, selected]); - } - - const matchedOption = options.find((option) => { - return option.value.match(selected); - }); - - updateText(''); - }, - [options, selectedOptions, updateText], - ); - - const removeTag = useCallback( - (tag) => () => { - const options = [...selectedOptions]; - options.splice(options.indexOf(tag), 1); - setSelectedOptions(options); - }, - [selectedOptions], - ); - - const tagsMarkup = selectedOptions.map((option) => ( - - {option} - - )); - - const optionsMarkup = - options.length > 0 - ? options.map((option) => { - const {label, value} = option; - - return ( - - {label} - - ); - }) - : null; - - return ( -
    - } - onChange={updateText} - label="Search tags" - labelHidden - value={inputValue} - placeholder="Search tags" - /> - } - > - {optionsMarkup ? ( - - {optionsMarkup} - - ) : null} - - - {tagsMarkup} - -
    - ); -} - -export default withPolarisExample(MultiManualComboboxExample); diff --git a/polaris.shopify.com/pages/examples/combobox-with-multi-select-and-vertical-content.tsx b/polaris.shopify.com/pages/examples/combobox-with-multi-select-and-vertical-content.tsx deleted file mode 100644 index 87ea3f969f1..00000000000 --- a/polaris.shopify.com/pages/examples/combobox-with-multi-select-and-vertical-content.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import { - LegacyStack, - Tag, - Listbox, - EmptySearchResult, - Combobox, - Text, -} from '@shopify/polaris'; -import {useState, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultiselectTagComboboxExample() { - const [selectedTags, setSelectedTags] = useState(['Rustic']); - const [value, setValue] = useState(''); - const [suggestion, setSuggestion] = useState(''); - - const handleActiveOptionChange = useCallback( - (activeOption) => { - const activeOptionIsAction = activeOption === value; - - if (!activeOptionIsAction && !selectedTags.includes(activeOption)) { - setSuggestion(activeOption); - } else { - setSuggestion(''); - } - }, - [value, selectedTags], - ); - const updateSelection = useCallback( - (selected) => { - const nextSelectedTags = new Set([...selectedTags]); - - if (nextSelectedTags.has(selected)) { - nextSelectedTags.delete(selected); - } else { - nextSelectedTags.add(selected); - } - setSelectedTags([...nextSelectedTags]); - setValue(''); - setSuggestion(''); - }, - [selectedTags], - ); - - const removeTag = useCallback( - (tag) => () => { - updateSelection(tag); - }, - [updateSelection], - ); - - const getAllTags = useCallback(() => { - const savedTags = ['Rustic', 'Antique', 'Vinyl', 'Vintage', 'Refurbished']; - return [...new Set([...savedTags, ...selectedTags].sort())]; - }, [selectedTags]); - - const formatOptionText = useCallback( - (option) => { - const trimValue = value.trim().toLocaleLowerCase(); - const matchIndex = option.toLocaleLowerCase().indexOf(trimValue); - - if (!value || matchIndex === -1) return option; - - const start = option.slice(0, matchIndex); - const highlight = option.slice(matchIndex, matchIndex + trimValue.length); - const end = option.slice(matchIndex + trimValue.length, option.length); - - return ( -

    - {start} - - {highlight} - - {end} -

    - ); - }, - [value], - ); - - const options = useMemo(() => { - let list; - const allTags = getAllTags(); - const filterRegex = new RegExp(value, 'i'); - - if (value) { - list = allTags.filter((tag) => tag.match(filterRegex)); - } else { - list = allTags; - } - - return [...list]; - }, [value, getAllTags]); - - const verticalContentMarkup = - selectedTags.length > 0 ? ( - - {selectedTags.map((tag) => ( - - {tag} - - ))} - - ) : null; - - const optionMarkup = - options.length > 0 - ? options.map((option) => { - return ( - - - {formatOptionText(option)} - - - ); - }) - : null; - - const noResults = value && !getAllTags().includes(value); - - const actionMarkup = noResults ? ( - {`Add "${value}"`} - ) : null; - - const emptyStateMarkup = optionMarkup ? null : ( - - ); - - const listboxMarkup = - optionMarkup || actionMarkup || emptyStateMarkup ? ( - - {actionMarkup} - {optionMarkup} - - ) : null; - - return ( -
    - - } - > - {listboxMarkup} - -
    - ); -} - -export default withPolarisExample(MultiselectTagComboboxExample); diff --git a/polaris.shopify.com/pages/examples/combobox-with-multi-select.tsx b/polaris.shopify.com/pages/examples/combobox-with-multi-select.tsx deleted file mode 100644 index 96c45f2ffee..00000000000 --- a/polaris.shopify.com/pages/examples/combobox-with-multi-select.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { - LegacyStack, - Tag, - Listbox, - Combobox, - Icon, - TextContainer, -} from '@shopify/polaris'; - -import {SearchMinor} from '@shopify/polaris-icons'; - -import {useState, useCallback, useMemo} from 'react'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultiAutoComboboxExample() { - const deselectedOptions = useMemo( - () => [ - {value: 'rustic', label: 'Rustic'}, - {value: 'antique', label: 'Antique'}, - {value: 'vinyl', label: 'Vinyl'}, - {value: 'vintage', label: 'Vintage'}, - {value: 'refurbished', label: 'Refurbished'}, - ], - [], - ); - - const [selectedOptions, setSelectedOptions] = useState([]); - const [inputValue, setInputValue] = useState(''); - const [options, setOptions] = useState(deselectedOptions); - - const updateText = useCallback( - (value) => { - setInputValue(value); - - if (value === '') { - setOptions(deselectedOptions); - return; - } - - const filterRegex = new RegExp(value, 'i'); - const resultOptions = deselectedOptions.filter((option) => - option.label.match(filterRegex), - ); - setOptions(resultOptions); - }, - [deselectedOptions], - ); - - const updateSelection = useCallback( - (selected) => { - if (selectedOptions.includes(selected)) { - setSelectedOptions( - selectedOptions.filter((option) => option !== selected), - ); - } else { - setSelectedOptions([...selectedOptions, selected]); - } - - const matchedOption = options.find((option) => { - return option.value.match(selected); - }); - - updateText(''); - }, - [options, selectedOptions, updateText], - ); - - const removeTag = useCallback( - (tag) => () => { - const options = [...selectedOptions]; - options.splice(options.indexOf(tag), 1); - setSelectedOptions(options); - }, - [selectedOptions], - ); - - const tagsMarkup = selectedOptions.map((option) => ( - - {option} - - )); - - const optionsMarkup = - options.length > 0 - ? options.map((option) => { - const {label, value} = option; - - return ( - - {label} - - ); - }) - : null; - - return ( -
    - } - onChange={updateText} - label="Search tags" - labelHidden - value={inputValue} - placeholder="Search tags" - /> - } - > - {optionsMarkup ? ( - {optionsMarkup} - ) : null} - - - {tagsMarkup} - -
    - ); -} - -export default withPolarisExample(MultiAutoComboboxExample); diff --git a/polaris.shopify.com/pages/examples/contextual-save-bar-default.tsx b/polaris.shopify.com/pages/examples/contextual-save-bar-default.tsx deleted file mode 100644 index 9ed55c25986..00000000000 --- a/polaris.shopify.com/pages/examples/contextual-save-bar-default.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import {Frame, ContextualSaveBar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( -
    - - console.log('add form submit logic'), - loading: false, - disabled: false, - }} - discardAction={{ - onAction: () => console.log('add clear form logic'), - }} - /> - -
    - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/contextual-save-bar-with-flush-contents.tsx b/polaris.shopify.com/pages/examples/contextual-save-bar-with-flush-contents.tsx deleted file mode 100644 index 617d134b278..00000000000 --- a/polaris.shopify.com/pages/examples/contextual-save-bar-with-flush-contents.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import {Frame, ContextualSaveBar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( -
    - - console.log('add form submit logic'), - }} - discardAction={{ - onAction: () => console.log('add clear form logic'), - }} - /> - -
    - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/contextual-save-bar-with-full-width.tsx b/polaris.shopify.com/pages/examples/contextual-save-bar-with-full-width.tsx deleted file mode 100644 index 48a5112f661..00000000000 --- a/polaris.shopify.com/pages/examples/contextual-save-bar-with-full-width.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import {Frame, ContextualSaveBar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( -
    - - console.log('add form submit logic'), - loading: false, - disabled: false, - }} - discardAction={{ - onAction: () => console.log('add clear form logic'), - }} - /> - -
    - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/data-table-default.tsx b/polaris.shopify.com/pages/examples/data-table-default.tsx deleted file mode 100644 index da4484f6f61..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-default.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import {Page, LegacyCard, DataTable} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DataTableExample() { - const rows = [ - ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], - ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], - [ - 'Navy Merino Wool Blazer with khaki chinos and yellow belt', - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - return ( - - - - - - ); -} - -export default withPolarisExample(DataTableExample); diff --git a/polaris.shopify.com/pages/examples/data-table-sortable.tsx b/polaris.shopify.com/pages/examples/data-table-sortable.tsx deleted file mode 100644 index 8a659e25d67..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-sortable.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import {Page, LegacyCard, DataTable} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SortableDataTableExample() { - const [sortedRows, setSortedRows] = useState(null); - - const initiallySortedRows = [ - ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], - ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], - [ - 'Navy Merino Wool Blazer with khaki chinos and yellow belt', - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - const rows = sortedRows ? sortedRows : initiallySortedRows; - - const handleSort = useCallback( - (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), - [rows], - ); - - return ( - - - - - - ); - - function sortCurrency(rows, index, direction) { - return [...rows].sort((rowA, rowB) => { - const amountA = parseFloat(rowA[index].substring(1)); - const amountB = parseFloat(rowB[index].substring(1)); - - return direction === 'descending' ? amountB - amountA : amountA - amountB; - }); - } -} - -export default withPolarisExample(SortableDataTableExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-all-of-its-elements.tsx b/polaris.shopify.com/pages/examples/data-table-with-all-of-its-elements.tsx deleted file mode 100644 index f282d3ae53c..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-all-of-its-elements.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FullDataTableExample() { - const [sortedRows, setSortedRows] = useState(null); - - const initiallySortedRows = [ - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - const rows = sortedRows ? sortedRows : initiallySortedRows; - const handleSort = useCallback( - (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), - [rows], - ); - - return ( - - - - - - ); - - function sortCurrency(rows, index, direction) { - return [...rows].sort((rowA, rowB) => { - const amountA = parseFloat(rowA[index].substring(1)); - const amountB = parseFloat(rowB[index].substring(1)); - - return direction === 'descending' ? amountB - amountA : amountA - amountB; - }); - } -} - -export default withPolarisExample(FullDataTableExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-custom-totals-heading.tsx b/polaris.shopify.com/pages/examples/data-table-with-custom-totals-heading.tsx deleted file mode 100644 index 542832f8a3a..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-custom-totals-heading.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import {Page, LegacyCard, DataTable} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DataTableExample() { - const rows = [ - ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], - ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], - [ - 'Navy Merino Wool Blazer with khaki chinos and yellow belt', - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - return ( - - - - - - ); -} - -export default withPolarisExample(DataTableExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-fixed-first-columns.tsx b/polaris.shopify.com/pages/examples/data-table-with-fixed-first-columns.tsx deleted file mode 100644 index 95441cb83bf..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-fixed-first-columns.tsx +++ /dev/null @@ -1,338 +0,0 @@ -import {Link, Page, LegacyCard, DataTable, useBreakpoints} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DataTableWithFixedFirstColumnsExample() { - const rows = [ - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - '$14,250.00', - '$12,240.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - '$12,240.00', - '$11,270.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - '$10,241.00', - '$10,201.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - '$14,240.00', - '$14,200.10', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - '$14,300.30', - '$17,200.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - '$18,770.07', - '$15,545.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - '$14,240.00', - '$14,240.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - '$19,290.00', - '$12,997.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - '$11,211.20', - '$11,343.50', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - '$12,430.00', - '$17,420.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - '$14,790.00', - '$12,370.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - '$16,241.00', - '$18,211.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - '$15,111.00', - '$11,221.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - '$17,880.00', - '$11,280.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - '$11,111.00', - '$17,211.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - '$14,240.00', - '$17,840.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - '$13,238.00', - '$14,288.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - '$14,988.00', - '$14,902.10', - ], - ]; - const [sortedRows, setSortedRows] = useState(rows); - const {lgDown} = useBreakpoints(); - const fixedFirstColumns = lgDown ? 2 : 0; - - return ( - - - { - setSortedRows( - [...rows].sort((rowA, rowB) => { - const amountA = rowA[index]?.props?.children - ? rowA[index]?.props?.children - : parseFloat(rowA[index].substring(1)); - const amountB = rowB[index]?.props?.children - ? rowB[index]?.props?.children - : parseFloat(rowB[index].substring(1)); - - return ( - direction === 'descending' - ? amountA > amountB - : amountB > amountA - ) - ? 1 - : -1; - }), - ); - }} - footerContent={`Showing ${sortedRows.length} of ${sortedRows.length} results`} - stickyHeader - fixedFirstColumns={fixedFirstColumns} - /> - - - ); -} - -export default withPolarisExample(DataTableWithFixedFirstColumnsExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-footer.tsx b/polaris.shopify.com/pages/examples/data-table-with-footer.tsx deleted file mode 100644 index 2d23338b5f2..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-footer.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import {Page, LegacyCard, DataTable} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DataTableFooterExample() { - const rows = [ - ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], - ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], - [ - 'Navy Merino Wool Blazer with khaki chinos and yellow belt', - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - return ( - - - - - - ); -} - -export default withPolarisExample(DataTableFooterExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-increased-density-and-zebra-striping.tsx b/polaris.shopify.com/pages/examples/data-table-with-increased-density-and-zebra-striping.tsx deleted file mode 100644 index 9448453f1fe..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-increased-density-and-zebra-striping.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FullDataTableExample() { - const [sortedRows, setSortedRows] = useState(null); - - const initiallySortedRows = [ - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - const rows = sortedRows ? sortedRows : initiallySortedRows; - const handleSort = useCallback( - (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), - [rows], - ); - - return ( - - - - - - ); - - function sortCurrency(rows, index, direction) { - return [...rows].sort((rowA, rowB) => { - const amountA = parseFloat(rowA[index].substring(1)); - const amountB = parseFloat(rowB[index].substring(1)); - - return direction === 'descending' ? amountB - amountA : amountA - amountB; - }); - } -} - -export default withPolarisExample(FullDataTableExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-row-heading-links.tsx b/polaris.shopify.com/pages/examples/data-table-with-row-heading-links.tsx deleted file mode 100644 index e03e2932903..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-row-heading-links.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DataTableLinkExample() { - const rows = [ - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$122,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - return ( - - - - - - ); -} - -export default withPolarisExample(DataTableLinkExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-sticky-header-enabled.tsx b/polaris.shopify.com/pages/examples/data-table-with-sticky-header-enabled.tsx deleted file mode 100644 index ce45af6c44e..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-sticky-header-enabled.tsx +++ /dev/null @@ -1,294 +0,0 @@ -import {Link, Page, LegacyCard, DataTable} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FullDataTableExample() { - const [sortedRows, setSortedRows] = useState(null); - - const initiallySortedRows = [ - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - [ - - Emerald Silk Gown - , - '$875.00', - 124689, - 140, - '$121,500.00', - ], - [ - - Mauve Cashmere Scarf - , - '$230.00', - 124533, - 83, - '$19,090.00', - ], - [ - - Navy Merino Wool Blazer with khaki chinos and yellow belt - , - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - const rows = sortedRows ? sortedRows : initiallySortedRows; - const handleSort = useCallback( - (index, direction) => setSortedRows(sortCurrency(rows, index, direction)), - [rows], - ); - - return ( - - - - - - ); - - function sortCurrency(rows, index, direction) { - return [...rows].sort((rowA, rowB) => { - const amountA = parseFloat(rowA[index].substring(1)); - const amountB = parseFloat(rowB[index].substring(1)); - - return direction === 'descending' ? amountB - amountA : amountA - amountB; - }); - } -} - -export default withPolarisExample(FullDataTableExample); diff --git a/polaris.shopify.com/pages/examples/data-table-with-totals-in-footer.tsx b/polaris.shopify.com/pages/examples/data-table-with-totals-in-footer.tsx deleted file mode 100644 index 9a2fc2f7ffb..00000000000 --- a/polaris.shopify.com/pages/examples/data-table-with-totals-in-footer.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import {Page, LegacyCard, DataTable} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DataTableExample() { - const rows = [ - ['Emerald Silk Gown', '$875.00', 124689, 140, '$122,500.00'], - ['Mauve Cashmere Scarf', '$230.00', 124533, 83, '$19,090.00'], - [ - 'Navy Merino Wool Blazer with khaki chinos and yellow belt', - '$445.00', - 124518, - 32, - '$14,240.00', - ], - ]; - - return ( - - - - - - ); -} - -export default withPolarisExample(DataTableExample); diff --git a/polaris.shopify.com/pages/examples/date-picker-default.tsx b/polaris.shopify.com/pages/examples/date-picker-default.tsx deleted file mode 100644 index 083ecee005d..00000000000 --- a/polaris.shopify.com/pages/examples/date-picker-default.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import {DatePicker} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DatePickerExample() { - const [{month, year}, setDate] = useState({month: 1, year: 2018}); - const [selectedDates, setSelectedDates] = useState({ - start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), - end: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), - }); - - const handleMonthChange = useCallback( - (month, year) => setDate({month, year}), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/pages/examples/date-picker-multi-month-ranged.tsx b/polaris.shopify.com/pages/examples/date-picker-multi-month-ranged.tsx deleted file mode 100644 index 03f62458044..00000000000 --- a/polaris.shopify.com/pages/examples/date-picker-multi-month-ranged.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import {DatePicker} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DatePickerExample() { - const [{month, year}, setDate] = useState({month: 1, year: 2018}); - const [selectedDates, setSelectedDates] = useState({ - start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), - end: new Date('Mon Mar 12 2018 00:00:00 GMT-0500 (EST)'), - }); - - const handleMonthChange = useCallback( - (month, year) => setDate({month, year}), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/pages/examples/date-picker-ranged.tsx b/polaris.shopify.com/pages/examples/date-picker-ranged.tsx deleted file mode 100644 index 03c82d95e32..00000000000 --- a/polaris.shopify.com/pages/examples/date-picker-ranged.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import {DatePicker} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DatePickerExample() { - const [{month, year}, setDate] = useState({month: 1, year: 2018}); - const [selectedDates, setSelectedDates] = useState({ - start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), - end: new Date('Sat Feb 10 2018 00:00:00 GMT-0500 (EST)'), - }); - - const handleMonthChange = useCallback( - (month, year) => setDate({month, year}), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/pages/examples/date-picker-with-disabled-date-ranges.tsx b/polaris.shopify.com/pages/examples/date-picker-with-disabled-date-ranges.tsx deleted file mode 100644 index c3ec5bfae9b..00000000000 --- a/polaris.shopify.com/pages/examples/date-picker-with-disabled-date-ranges.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import {DatePicker} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DatePickerExample() { - const [{month, year}, setDate] = useState({month: 1, year: 2018}); - const [selectedDates, setSelectedDates] = useState({ - start: new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), - end: new Date('Sat Feb 10 2018 00:00:00 GMT-0500 (EST)'), - }); - - const handleMonthChange = useCallback( - (month, year) => setDate({month, year}), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/pages/examples/date-picker-with-specific-disabled-dates.tsx b/polaris.shopify.com/pages/examples/date-picker-with-specific-disabled-dates.tsx deleted file mode 100644 index 32afb97f8d4..00000000000 --- a/polaris.shopify.com/pages/examples/date-picker-with-specific-disabled-dates.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import {DatePicker} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DatePickerExample() { - const [{month, year}, setDate] = useState({month: 1, year: 2018}); - const [selectedDates, setSelectedDates] = useState( - new Date('Wed Feb 07 2018 00:00:00 GMT-0500 (EST)'), - ); - - const handleMonthChange = useCallback( - (month, year) => setDate({month, year}), - [], - ); - - const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; - - const disableSpecificDates = [ - new Date('Mon Feb 12 2018 00:00:00 GMT-0500 (EST)'), - new Date('Sat Feb 10 2018 00:00:00 GMT-0500 (EST)'), - new Date('Wed Feb 21 2018 00:00:00 GMT-0500 (EST)'), - ]; - - return ( - - ); -} - -export default withPolarisExample(DatePickerExample); diff --git a/polaris.shopify.com/pages/examples/description-list-default.tsx b/polaris.shopify.com/pages/examples/description-list-default.tsx deleted file mode 100644 index 9280b65a031..00000000000 --- a/polaris.shopify.com/pages/examples/description-list-default.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import {DescriptionList} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( - - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/divider-with-border-styles.tsx b/polaris.shopify.com/pages/examples/divider-with-border-styles.tsx deleted file mode 100644 index cd8f052524a..00000000000 --- a/polaris.shopify.com/pages/examples/divider-with-border-styles.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import {Divider, Text, AlphaStack} from '@shopify/polaris'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DividerWithBorderStylesExample() { - return ( - - - Base - - - - Dark - - - - Divider - - - - Divider on dark - - - - Transparent - - - - ); -} - -export default withPolarisExample(DividerWithBorderStylesExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-accepts-only-svg-files.tsx b/polaris.shopify.com/pages/examples/drop-zone-accepts-only-svg-files.tsx deleted file mode 100644 index b72a9f59f08..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-accepts-only-svg-files.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { - LegacyStack, - Thumbnail, - Banner, - List, - DropZone, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneAcceptingSVGFilesExample() { - const [files, setFiles] = useState([]); - const [rejectedFiles, setRejectedFiles] = useState([]); - const hasError = rejectedFiles.length > 0; - - const handleDropZoneDrop = useCallback( - (_dropFiles, acceptedFiles, rejectedFiles) => { - setFiles((files) => [...files, ...acceptedFiles]); - setRejectedFiles(rejectedFiles); - }, - [], - ); - - const uploadedFiles = files.length > 0 && ( - - {files.map((file, index) => ( - - -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ))} -
    - ); - - const errorMessage = hasError && ( - - - {rejectedFiles.map((file, index) => ( - - {`"${file.name}" is not supported. File type must be .svg.`} - - ))} - - - ); - - return ( - - {errorMessage} - - {uploadedFiles} - - - ); -} - -export default withPolarisExample(DropZoneAcceptingSVGFilesExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-default.tsx b/polaris.shopify.com/pages/examples/drop-zone-default.tsx deleted file mode 100644 index 9e9bf8067bb..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-default.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import {DropZone, LegacyStack, Thumbnail, Text} from '@shopify/polaris'; -import {NoteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneExample() { - const [files, setFiles] = useState([]); - - const handleDropZoneDrop = useCallback( - (_dropFiles, acceptedFiles, _rejectedFiles) => - setFiles((files) => [...files, ...acceptedFiles]), - [], - ); - - const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; - - const fileUpload = !files.length && ; - const uploadedFiles = files.length > 0 && ( -
    - - {files.map((file, index) => ( - - -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ))} -
    -
    - ); - - return ( - - {uploadedFiles} - {fileUpload} - - ); -} - -export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-medium-sized.tsx b/polaris.shopify.com/pages/examples/drop-zone-medium-sized.tsx deleted file mode 100644 index f42992c7a9c..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-medium-sized.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {DropZone} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneExample() { - return ( -
    - - - -
    - ); -} - -export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-nested.tsx b/polaris.shopify.com/pages/examples/drop-zone-nested.tsx deleted file mode 100644 index b7bde6eb554..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-nested.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { - DropZone, - LegacyStack, - Thumbnail, - LegacyCard, - Text, -} from '@shopify/polaris'; -import {NoteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function NestedDropZoneExample() { - const [files, setFiles] = useState([]); - - const handleDrop = useCallback((dropFiles) => { - setFiles((files) => [...files, dropFiles]); - }, []); - - const handleDropZoneClick = useCallback(() => {}, []); - - const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; - - const fileUpload = !files.length && ; - const uploadedFiles = files.length > 0 && ( - - {files.map((file, index) => ( - - -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ))} -
    - ); - - return ( - - - - {uploadedFiles} - {fileUpload} - - - - ); -} - -export default withPolarisExample(NestedDropZoneExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-small-sized.tsx b/polaris.shopify.com/pages/examples/drop-zone-small-sized.tsx deleted file mode 100644 index bd3620e5204..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-small-sized.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {DropZone} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneExample() { - return ( -
    - - - -
    - ); -} - -export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-with-a-label.tsx b/polaris.shopify.com/pages/examples/drop-zone-with-a-label.tsx deleted file mode 100644 index 189dbb8f4ab..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-with-a-label.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {DropZone} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneExample() { - return ( - - - - ); -} - -export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-with-custom-file-dialog-trigger.tsx b/polaris.shopify.com/pages/examples/drop-zone-with-custom-file-dialog-trigger.tsx deleted file mode 100644 index 8694be77bd8..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-with-custom-file-dialog-trigger.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { - LegacyStack, - Thumbnail, - LegacyCard, - DropZone, - Text, -} from '@shopify/polaris'; -import {NoteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneWithCustomFileDialogExample() { - const [files, setFiles] = useState([]); - const [openFileDialog, setOpenFileDialog] = useState(false); - - const handleDropZoneDrop = useCallback( - (dropFiles, _acceptedFiles, _rejectedFiles) => - setFiles((files) => [...files, ...dropFiles]), - [], - ); - const toggleOpenFileDialog = useCallback( - () => setOpenFileDialog((openFileDialog) => !openFileDialog), - [], - ); - - const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; - - const uploadedFiles = files.length > 0 && ( - - {files.map((file, index) => ( - - -1 - ? window.URL.createObjectURL(file) - : NoteMinor - } - /> -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ))} -
    - ); - - return ( - - - {uploadedFiles} - - - ); -} - -export default withPolarisExample(DropZoneWithCustomFileDialogExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-with-custom-file-upload-text.tsx b/polaris.shopify.com/pages/examples/drop-zone-with-custom-file-upload-text.tsx deleted file mode 100644 index b5f0e4b251c..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-with-custom-file-upload-text.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import {DropZone, LegacyStack, Thumbnail, Text} from '@shopify/polaris'; -import {NoteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneExample() { - const [files, setFiles] = useState([]); - - const handleDropZoneDrop = useCallback( - (_dropFiles, acceptedFiles, _rejectedFiles) => - setFiles((files) => [...files, ...acceptedFiles]), - [], - ); - - const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; - - const fileUpload = !files.length && ( - - ); - - const uploadedFiles = files.length > 0 && ( - - {files.map((file, index) => ( - - -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ))} -
    - ); - - return ( - - {uploadedFiles} - {fileUpload} - - ); -} - -export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-with-drop-on-page.tsx b/polaris.shopify.com/pages/examples/drop-zone-with-drop-on-page.tsx deleted file mode 100644 index 747d15b2d16..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-with-drop-on-page.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import {LegacyStack, Thumbnail, DropZone, Page, Text} from '@shopify/polaris'; -import {NoteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneWithDropOnPageExample() { - const [files, setFiles] = useState([]); - - const handleDropZoneDrop = useCallback( - (dropFiles, _acceptedFiles, _rejectedFiles) => - setFiles((files) => [...files, ...dropFiles]), - [], - ); - - const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; - - const uploadedFiles = files.length > 0 && ( - - {files.map((file, index) => ( - - -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ))} -
    - ); - - const uploadMessage = !uploadedFiles && ; - - return ( - - - {uploadedFiles} - {uploadMessage} - - - ); -} - -export default withPolarisExample(DropZoneWithDropOnPageExample); diff --git a/polaris.shopify.com/pages/examples/drop-zone-with-image-file-upload.tsx b/polaris.shopify.com/pages/examples/drop-zone-with-image-file-upload.tsx deleted file mode 100644 index a19e2a3cab0..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-with-image-file-upload.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { - DropZone, - LegacyStack, - Thumbnail, - Banner, - List, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneWithImageFileUpload() { - const [files, setFiles] = useState([]); - const [rejectedFiles, setRejectedFiles] = useState([]); - const hasError = rejectedFiles.length > 0; - - const handleDrop = useCallback( - (_droppedFiles, acceptedFiles, rejectedFiles) => { - setFiles((files) => [...files, ...acceptedFiles]); - setRejectedFiles(rejectedFiles); - }, - [], - ); - - const fileUpload = !files.length && ; - const uploadedFiles = files.length > 0 && ( - - {files.map((file, index) => ( - - -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ))} -
    - ); - - const errorMessage = hasError && ( - - - {rejectedFiles.map((file, index) => ( - - {`"${file.name}" is not supported. File type must be .gif, .jpg, .png or .svg.`} - - ))} - - - ); - - return ( - - {errorMessage} - - {uploadedFiles} - {fileUpload} - - - ); -} - -export default withPolarisExample(DropZoneWithImageFileUpload); diff --git a/polaris.shopify.com/pages/examples/drop-zone-with-single-file-upload.tsx b/polaris.shopify.com/pages/examples/drop-zone-with-single-file-upload.tsx deleted file mode 100644 index 1d1ff0217c7..00000000000 --- a/polaris.shopify.com/pages/examples/drop-zone-with-single-file-upload.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import {DropZone, LegacyStack, Thumbnail, Text} from '@shopify/polaris'; -import {NoteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DropZoneExample() { - const [file, setFile] = useState(); - - const handleDropZoneDrop = useCallback( - (_dropFiles, acceptedFiles, _rejectedFiles) => - setFile((file) => acceptedFiles[0]), - [], - ); - - const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']; - - const fileUpload = !file && ; - const uploadedFile = file && ( - - -
    - {file.name}{' '} - - {file.size} bytes - -
    -
    - ); - - return ( - - {uploadedFile} - {fileUpload} - - ); -} - -export default withPolarisExample(DropZoneExample); diff --git a/polaris.shopify.com/pages/examples/empty-state-default.tsx b/polaris.shopify.com/pages/examples/empty-state-default.tsx deleted file mode 100644 index ed3f43d14a1..00000000000 --- a/polaris.shopify.com/pages/examples/empty-state-default.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import {LegacyCard, EmptyState} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function EmptyStateExample() { - return ( - - -

    Track and receive your incoming inventory from suppliers.

    -
    -
    - ); -} - -export default withPolarisExample(EmptyStateExample); diff --git a/polaris.shopify.com/pages/examples/empty-state-with-full-width-layout.tsx b/polaris.shopify.com/pages/examples/empty-state-with-full-width-layout.tsx deleted file mode 100644 index 49ef1461c6d..00000000000 --- a/polaris.shopify.com/pages/examples/empty-state-with-full-width-layout.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {LegacyCard, EmptyState} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function EmptyStateExample() { - return ( - - -

    - You can use the Files section to upload images, videos, and other - documents. This example shows the content with a centered layout and - full width. -

    -
    -
    - ); -} - -export default withPolarisExample(EmptyStateExample); diff --git a/polaris.shopify.com/pages/examples/empty-state-with-subdued-footer-context.tsx b/polaris.shopify.com/pages/examples/empty-state-with-subdued-footer-context.tsx deleted file mode 100644 index f7b7e7fcab3..00000000000 --- a/polaris.shopify.com/pages/examples/empty-state-with-subdued-footer-context.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import {LegacyCard, EmptyState, Link} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function EmptyStateExample() { - return ( - - - If you don’t want to add a transfer, you can import your inventory - from{' '} - - settings - - . -

    - } - image="https://cdn.shopify.com/s/files/1/0262/4071/2726/files/emptystate-files.png" - > -

    Track and receive your incoming inventory from suppliers.

    -
    -
    - ); -} - -export default withPolarisExample(EmptyStateExample); diff --git a/polaris.shopify.com/pages/examples/exception-list-default.tsx b/polaris.shopify.com/pages/examples/exception-list-default.tsx deleted file mode 100644 index f4f131f250a..00000000000 --- a/polaris.shopify.com/pages/examples/exception-list-default.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {ExceptionList} from '@shopify/polaris'; -import {NoteMinor} from '@shopify/polaris-icons'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ExceptionListExample() { - return ( - - ); -} - -export default withPolarisExample(ExceptionListExample); diff --git a/polaris.shopify.com/pages/examples/filters-disabled.tsx b/polaris.shopify.com/pages/examples/filters-disabled.tsx deleted file mode 100644 index 744072b8d74..00000000000 --- a/polaris.shopify.com/pages/examples/filters-disabled.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { - TextField, - LegacyCard, - ResourceList, - Filters, - Button, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DisableAllFiltersExample() { - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleQueryValueChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - - const filters = [ - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith', - label: disambiguateLabel('taggedWith', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - return ( -
    - - -
    - -
    - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(DisableAllFiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-some-disabled.tsx b/polaris.shopify.com/pages/examples/filters-some-disabled.tsx deleted file mode 100644 index 508f219d9f8..00000000000 --- a/polaris.shopify.com/pages/examples/filters-some-disabled.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { - TextField, - LegacyCard, - ResourceList, - Filters, - Button, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DisableSomeFiltersExample() { - const [taggedWith, setTaggedWith] = useState(null); - const [vendor, setVendor] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleQueryValueChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleVendorChange = useCallback((value) => setVendor(value), []); - - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleVendorRemove = useCallback(() => setVendor(null), []); - - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - handleVendorRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove, handleVendorRemove]); - - const filters = [ - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - { - key: 'vendor', - label: 'Vendor', - filter: ( - - ), - shortcut: true, - disabled: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith', - label: disambiguateLabel('taggedWith', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - return ( -
    - - -
    - -
    - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(DisableSomeFiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-with-a-data-table.tsx b/polaris.shopify.com/pages/examples/filters-with-a-data-table.tsx deleted file mode 100644 index cd6635fdbe6..00000000000 --- a/polaris.shopify.com/pages/examples/filters-with-a-data-table.tsx +++ /dev/null @@ -1,195 +0,0 @@ -import { - ChoiceList, - TextField, - LegacyCard, - Filters, - DataTable, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DataTableFiltersExample() { - const [availability, setAvailability] = useState(null); - const [productType, setProductType] = useState(null); - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleAvailabilityChange = useCallback( - (value) => setAvailability(value), - [], - ); - const handleProductTypeChange = useCallback( - (value) => setProductType(value), - [], - ); - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleFiltersQueryChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleAvailabilityRemove = useCallback(() => setAvailability(null), []); - const handleProductTypeRemove = useCallback(() => setProductType(null), []); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleFiltersClearAll = useCallback(() => { - handleAvailabilityRemove(); - handleProductTypeRemove(); - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [ - handleAvailabilityRemove, - handleQueryValueRemove, - handleProductTypeRemove, - handleTaggedWithRemove, - ]); - - const filters = [ - { - key: 'availability', - label: 'Availability', - filter: ( - - ), - shortcut: true, - }, - { - key: 'productType', - label: 'Product type', - filter: ( - - ), - }, - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - }, - ]; - - const appliedFilters = []; - if (!isEmpty(availability)) { - const key = 'availability'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, availability), - onRemove: handleAvailabilityRemove, - }); - } - if (!isEmpty(productType)) { - const key = 'productType'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, productType), - onRemove: handleProductTypeRemove, - }); - } - if (!isEmpty(taggedWith)) { - const key = 'taggedWith'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, taggedWith), - onRemove: handleTaggedWithRemove, - }); - } - - return ( -
    - - - - - - -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith': - return `Tagged with ${value}`; - case 'availability': - return value.map((val) => `Available on ${val}`).join(', '); - case 'productType': - return value.join(', '); - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(DataTableFiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-with-a-resource-list.tsx b/polaris.shopify.com/pages/examples/filters-with-a-resource-list.tsx deleted file mode 100644 index f21961affd5..00000000000 --- a/polaris.shopify.com/pages/examples/filters-with-a-resource-list.tsx +++ /dev/null @@ -1,209 +0,0 @@ -import { - ChoiceList, - TextField, - RangeSlider, - LegacyCard, - ResourceList, - Filters, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListFiltersExample() { - const [accountStatus, setAccountStatus] = useState(null); - const [moneySpent, setMoneySpent] = useState(null); - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleAccountStatusChange = useCallback( - (value) => setAccountStatus(value), - [], - ); - const handleMoneySpentChange = useCallback( - (value) => setMoneySpent(value), - [], - ); - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleFiltersQueryChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleAccountStatusRemove = useCallback( - () => setAccountStatus(null), - [], - ); - const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleFiltersClearAll = useCallback(() => { - handleAccountStatusRemove(); - handleMoneySpentRemove(); - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [ - handleAccountStatusRemove, - handleMoneySpentRemove, - handleQueryValueRemove, - handleTaggedWithRemove, - ]); - - const filters = [ - { - key: 'accountStatus', - label: 'Account status', - filter: ( - - ), - shortcut: true, - }, - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - { - key: 'moneySpent', - label: 'Money spent', - filter: ( - - ), - }, - ]; - - const appliedFilters = []; - if (!isEmpty(accountStatus)) { - const key = 'accountStatus'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, accountStatus), - onRemove: handleAccountStatusRemove, - }); - } - if (!isEmpty(moneySpent)) { - const key = 'moneySpent'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, moneySpent), - onRemove: handleMoneySpentRemove, - }); - } - if (!isEmpty(taggedWith)) { - const key = 'taggedWith'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, taggedWith), - onRemove: handleTaggedWithRemove, - }); - } - - return ( -
    - - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'moneySpent': - return `Money spent is between $${value[0]} and $${value[1]}`; - case 'taggedWith': - return `Tagged with ${value}`; - case 'accountStatus': - return value.map((val) => `Customer ${val}`).join(', '); - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-with-children-content.tsx b/polaris.shopify.com/pages/examples/filters-with-children-content.tsx deleted file mode 100644 index f102edb3aad..00000000000 --- a/polaris.shopify.com/pages/examples/filters-with-children-content.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import { - TextField, - LegacyCard, - ResourceList, - Filters, - Button, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FiltersExample() { - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleQueryValueChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - - const filters = [ - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith', - label: disambiguateLabel('taggedWith', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - return ( -
    - - -
    - -
    - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(FiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-with-help-text.tsx b/polaris.shopify.com/pages/examples/filters-with-help-text.tsx deleted file mode 100644 index 24abf063dc6..00000000000 --- a/polaris.shopify.com/pages/examples/filters-with-help-text.tsx +++ /dev/null @@ -1,211 +0,0 @@ -import { - ChoiceList, - TextField, - RangeSlider, - LegacyCard, - ResourceList, - Filters, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListFiltersExample() { - const [accountStatus, setAccountStatus] = useState(null); - const [moneySpent, setMoneySpent] = useState(null); - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleAccountStatusChange = useCallback( - (value) => setAccountStatus(value), - [], - ); - const handleMoneySpentChange = useCallback( - (value) => setMoneySpent(value), - [], - ); - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleFiltersQueryChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleAccountStatusRemove = useCallback( - () => setAccountStatus(null), - [], - ); - const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleFiltersClearAll = useCallback(() => { - handleAccountStatusRemove(); - handleMoneySpentRemove(); - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [ - handleAccountStatusRemove, - handleMoneySpentRemove, - handleQueryValueRemove, - handleTaggedWithRemove, - ]); - - const filters = [ - { - key: 'accountStatus', - label: 'Account status', - filter: ( - - ), - shortcut: true, - }, - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - { - key: 'moneySpent', - label: 'Money spent', - filter: ( - - ), - }, - ]; - - const appliedFilters = []; - if (!isEmpty(accountStatus)) { - const key = 'accountStatus'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, accountStatus), - onRemove: handleAccountStatusRemove, - }); - } - if (!isEmpty(moneySpent)) { - const key = 'moneySpent'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, moneySpent), - onRemove: handleMoneySpentRemove, - }); - } - if (!isEmpty(taggedWith)) { - const key = 'taggedWith'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, taggedWith), - onRemove: handleTaggedWithRemove, - }); - } - - return ( -
    - - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'moneySpent': - return `Money spent is between $${value[0]} and $${value[1]}`; - case 'taggedWith': - return `Tagged with ${value}`; - case 'accountStatus': - return value.map((val) => `Customer ${val}`).join(', '); - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-with-query-field-disabled.tsx b/polaris.shopify.com/pages/examples/filters-with-query-field-disabled.tsx deleted file mode 100644 index 7f6e42fe156..00000000000 --- a/polaris.shopify.com/pages/examples/filters-with-query-field-disabled.tsx +++ /dev/null @@ -1,210 +0,0 @@ -import { - ChoiceList, - TextField, - RangeSlider, - LegacyCard, - ResourceList, - Filters, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListFiltersExample() { - const [accountStatus, setAccountStatus] = useState(null); - const [moneySpent, setMoneySpent] = useState(null); - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleAccountStatusChange = useCallback( - (value) => setAccountStatus(value), - [], - ); - const handleMoneySpentChange = useCallback( - (value) => setMoneySpent(value), - [], - ); - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleFiltersQueryChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleAccountStatusRemove = useCallback( - () => setAccountStatus(null), - [], - ); - const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleFiltersClearAll = useCallback(() => { - handleAccountStatusRemove(); - handleMoneySpentRemove(); - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [ - handleAccountStatusRemove, - handleMoneySpentRemove, - handleQueryValueRemove, - handleTaggedWithRemove, - ]); - - const filters = [ - { - key: 'accountStatus', - label: 'Account status', - filter: ( - - ), - shortcut: true, - }, - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - { - key: 'moneySpent', - label: 'Money spent', - filter: ( - - ), - }, - ]; - - const appliedFilters = []; - if (!isEmpty(accountStatus)) { - const key = 'accountStatus'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, accountStatus), - onRemove: handleAccountStatusRemove, - }); - } - if (!isEmpty(moneySpent)) { - const key = 'moneySpent'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, moneySpent), - onRemove: handleMoneySpentRemove, - }); - } - if (!isEmpty(taggedWith)) { - const key = 'taggedWith'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, taggedWith), - onRemove: handleTaggedWithRemove, - }); - } - - return ( -
    - - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'moneySpent': - return `Money spent is between $${value[0]} and $${value[1]}`; - case 'taggedWith': - return `Tagged with ${value}`; - case 'accountStatus': - return value.map((val) => `Customer ${val}`).join(', '); - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-with-query-field-hidden.tsx b/polaris.shopify.com/pages/examples/filters-with-query-field-hidden.tsx deleted file mode 100644 index ff131805981..00000000000 --- a/polaris.shopify.com/pages/examples/filters-with-query-field-hidden.tsx +++ /dev/null @@ -1,210 +0,0 @@ -import { - ChoiceList, - TextField, - RangeSlider, - LegacyCard, - ResourceList, - Filters, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListFiltersExample() { - const [accountStatus, setAccountStatus] = useState(null); - const [moneySpent, setMoneySpent] = useState(null); - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleAccountStatusChange = useCallback( - (value) => setAccountStatus(value), - [], - ); - const handleMoneySpentChange = useCallback( - (value) => setMoneySpent(value), - [], - ); - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleFiltersQueryChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleAccountStatusRemove = useCallback( - () => setAccountStatus(null), - [], - ); - const handleMoneySpentRemove = useCallback(() => setMoneySpent(null), []); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleFiltersClearAll = useCallback(() => { - handleAccountStatusRemove(); - handleMoneySpentRemove(); - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [ - handleAccountStatusRemove, - handleMoneySpentRemove, - handleQueryValueRemove, - handleTaggedWithRemove, - ]); - - const filters = [ - { - key: 'accountStatus', - label: 'Account status', - filter: ( - - ), - shortcut: true, - }, - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - { - key: 'moneySpent', - label: 'Money spent', - filter: ( - - ), - }, - ]; - - const appliedFilters = []; - if (!isEmpty(accountStatus)) { - const key = 'accountStatus'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, accountStatus), - onRemove: handleAccountStatusRemove, - }); - } - if (!isEmpty(moneySpent)) { - const key = 'moneySpent'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, moneySpent), - onRemove: handleMoneySpentRemove, - }); - } - if (!isEmpty(taggedWith)) { - const key = 'taggedWith'; - appliedFilters.push({ - key, - label: disambiguateLabel(key, taggedWith), - onRemove: handleTaggedWithRemove, - }); - } - - return ( -
    - - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'moneySpent': - return `Money spent is between $${value[0]} and $${value[1]}`; - case 'taggedWith': - return `Tagged with ${value}`; - case 'accountStatus': - return value.map((val) => `Customer ${val}`).join(', '); - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(ResourceListFiltersExample); diff --git a/polaris.shopify.com/pages/examples/filters-without-clear-button.tsx b/polaris.shopify.com/pages/examples/filters-without-clear-button.tsx deleted file mode 100644 index bd4f996746f..00000000000 --- a/polaris.shopify.com/pages/examples/filters-without-clear-button.tsx +++ /dev/null @@ -1,141 +0,0 @@ -import { - TextField, - LegacyCard, - ResourceList, - Filters, - Button, - Avatar, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Playground() { - const [taggedWith, setTaggedWith] = useState(null); - const [queryValue, setQueryValue] = useState(null); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleQueryValueChange = useCallback( - (value) => setQueryValue(value), - [], - ); - - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - - const filters = [ - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - hideClearButton: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith', - label: disambiguateLabel('taggedWith', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - return ( -
    - - -
    - -
    - - } - items={[ - { - id: 341, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 256, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]} - renderItem={(item) => { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(Playground); diff --git a/polaris.shopify.com/pages/examples/footer-help-default.tsx b/polaris.shopify.com/pages/examples/footer-help-default.tsx deleted file mode 100644 index 4eb2bc710d5..00000000000 --- a/polaris.shopify.com/pages/examples/footer-help-default.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {FooterHelp, Link} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FooterHelpExample() { - return ( - - Learn more about{' '} - - fulfilling orders - - - ); -} - -export default withPolarisExample(FooterHelpExample); diff --git a/polaris.shopify.com/pages/examples/form-custom-on-submit.tsx b/polaris.shopify.com/pages/examples/form-custom-on-submit.tsx deleted file mode 100644 index 3a60eb440b6..00000000000 --- a/polaris.shopify.com/pages/examples/form-custom-on-submit.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import {Form, FormLayout, Checkbox, TextField, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FormOnSubmitExample() { - const [newsletter, setNewsletter] = useState(false); - const [email, setEmail] = useState(''); - - const handleSubmit = useCallback((_event) => { - setEmail(''); - setNewsletter(false); - }, []); - - const handleNewsLetterChange = useCallback( - (value) => setNewsletter(value), - [], - ); - - const handleEmailChange = useCallback((value) => setEmail(value), []); - - return ( -
    - - - - - We’ll use this email address to inform you on future changes to - Polaris. - - } - /> - - - -
    - ); -} - -export default withPolarisExample(FormOnSubmitExample); diff --git a/polaris.shopify.com/pages/examples/form-layout-condensed-field-group.tsx b/polaris.shopify.com/pages/examples/form-layout-condensed-field-group.tsx deleted file mode 100644 index 4610ff0e895..00000000000 --- a/polaris.shopify.com/pages/examples/form-layout-condensed-field-group.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import {FormLayout, TextField} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( - - - {}} autoComplete="off" /> - {}} autoComplete="off" /> - {}} autoComplete="off" /> - {}} autoComplete="off" /> - - - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/form-layout-default.tsx b/polaris.shopify.com/pages/examples/form-layout-default.tsx deleted file mode 100644 index 32858bde808..00000000000 --- a/polaris.shopify.com/pages/examples/form-layout-default.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import {FormLayout, TextField} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( - - {}} autoComplete="off" /> - {}} - autoComplete="email" - /> - - ); -} - -export default withPolarisExample(() => ); diff --git a/polaris.shopify.com/pages/examples/form-layout-field-group.tsx b/polaris.shopify.com/pages/examples/form-layout-field-group.tsx deleted file mode 100644 index 641e9d5abe7..00000000000 --- a/polaris.shopify.com/pages/examples/form-layout-field-group.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import {FormLayout, TextField} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function Example() { - return ( - - - {}} - autoComplete="off" - /> - {}} - autoComplete="off" - /> - - - ); -} - -export default withPolarisExample(Example); diff --git a/polaris.shopify.com/pages/examples/form-without-native-validation.tsx b/polaris.shopify.com/pages/examples/form-without-native-validation.tsx deleted file mode 100644 index fc94632ded1..00000000000 --- a/polaris.shopify.com/pages/examples/form-without-native-validation.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import {Form, FormLayout, TextField, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FormWithoutNativeValidationExample() { - const [url, setUrl] = useState(''); - - const handleSubmit = useCallback((_event) => setUrl(''), []); - - const handleUrlChange = useCallback((value) => setUrl(value), []); - - return ( -
    - - - - - -
    - ); -} - -export default withPolarisExample(FormWithoutNativeValidationExample); diff --git a/polaris.shopify.com/pages/examples/frame-in-an-application.tsx b/polaris.shopify.com/pages/examples/frame-in-an-application.tsx deleted file mode 100644 index 440b9f2f13a..00000000000 --- a/polaris.shopify.com/pages/examples/frame-in-an-application.tsx +++ /dev/null @@ -1,360 +0,0 @@ -import { - ActionList, - AppProvider, - LegacyCard, - ContextualSaveBar, - FormLayout, - Frame, - Layout, - Loading, - Modal, - Navigation, - Page, - SkeletonBodyText, - SkeletonDisplayText, - SkeletonPage, - TextContainer, - TextField, - Toast, - TopBar, -} from '@shopify/polaris'; -import { - ArrowLeftMinor, - HomeMajor, - OrdersMajor, - ConversationMinor, -} from '@shopify/polaris-icons'; -import {useState, useCallback, useRef} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FrameExample() { - const defaultState = useRef({ - emailFieldValue: 'dharma@jadedpixel.com', - nameFieldValue: 'Jaded Pixel', - }); - const skipToContentRef = useRef(null); - - const [toastActive, setToastActive] = useState(false); - const [isLoading, setIsLoading] = useState(false); - const [isDirty, setIsDirty] = useState(false); - const [searchActive, setSearchActive] = useState(false); - const [searchValue, setSearchValue] = useState(''); - const [userMenuActive, setUserMenuActive] = useState(false); - const [mobileNavigationActive, setMobileNavigationActive] = useState(false); - const [modalActive, setModalActive] = useState(false); - const [nameFieldValue, setNameFieldValue] = useState( - defaultState.current.nameFieldValue, - ); - const [emailFieldValue, setEmailFieldValue] = useState( - defaultState.current.emailFieldValue, - ); - const [storeName, setStoreName] = useState( - defaultState.current.nameFieldValue, - ); - const [supportSubject, setSupportSubject] = useState(''); - const [supportMessage, setSupportMessage] = useState(''); - - const handleSubjectChange = useCallback( - (value) => setSupportSubject(value), - [], - ); - const handleMessageChange = useCallback( - (value) => setSupportMessage(value), - [], - ); - const handleDiscard = useCallback(() => { - setEmailFieldValue(defaultState.current.emailFieldValue); - setNameFieldValue(defaultState.current.nameFieldValue); - setIsDirty(false); - }, []); - const handleSave = useCallback(() => { - defaultState.current.nameFieldValue = nameFieldValue; - defaultState.current.emailFieldValue = emailFieldValue; - - setIsDirty(false); - setToastActive(true); - setStoreName(defaultState.current.nameFieldValue); - }, [emailFieldValue, nameFieldValue]); - const handleNameFieldChange = useCallback((value) => { - setNameFieldValue(value); - value && setIsDirty(true); - }, []); - const handleEmailFieldChange = useCallback((value) => { - setEmailFieldValue(value); - value && setIsDirty(true); - }, []); - const handleSearchResultsDismiss = useCallback(() => { - setSearchActive(false); - setSearchValue(''); - }, []); - const handleSearchFieldChange = useCallback((value) => { - setSearchValue(value); - setSearchActive(value.length > 0); - }, []); - const toggleToastActive = useCallback( - () => setToastActive((toastActive) => !toastActive), - [], - ); - const toggleUserMenuActive = useCallback( - () => setUserMenuActive((userMenuActive) => !userMenuActive), - [], - ); - const toggleMobileNavigationActive = useCallback( - () => - setMobileNavigationActive( - (mobileNavigationActive) => !mobileNavigationActive, - ), - [], - ); - const toggleIsLoading = useCallback( - () => setIsLoading((isLoading) => !isLoading), - [], - ); - const toggleModalActive = useCallback( - () => setModalActive((modalActive) => !modalActive), - [], - ); - - const toastMarkup = toastActive ? ( - - ) : null; - - const userMenuActions = [ - { - items: [{content: 'Community forums'}], - }, - ]; - - const contextualSaveBarMarkup = isDirty ? ( - - ) : null; - - const userMenuMarkup = ( - - ); - - const searchResultsMarkup = ( - - ); - - const searchFieldMarkup = ( - - ); - - const topBarMarkup = ( - - ); - - const navigationMarkup = ( - - - - - ); - - const loadingMarkup = isLoading ? : null; - - const skipToContentTarget = ( - - ); - - const actualPageMarkup = ( - - - {skipToContentTarget} - - - - - - - - - - - ); - - const loadingPageMarkup = ( - - - - - - - - - - - - - ); - - const pageMarkup = isLoading ? loadingPageMarkup : actualPageMarkup; - - const modalMarkup = ( - - - - - - - - - ); - - const logo = { - width: 124, - topBarSource: - 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999', - contextualSaveBarSource: - 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-gray.svg?6215648040070010999', - url: '#', - accessibilityLabel: 'Jaded Pixel', - }; - - return ( -
    - - - {contextualSaveBarMarkup} - {loadingMarkup} - {pageMarkup} - {toastMarkup} - {modalMarkup} - - -
    - ); -} - -export default withPolarisExample(FrameExample); diff --git a/polaris.shopify.com/pages/examples/frame-with-an-offset.tsx b/polaris.shopify.com/pages/examples/frame-with-an-offset.tsx deleted file mode 100644 index ecc3f4d4a0f..00000000000 --- a/polaris.shopify.com/pages/examples/frame-with-an-offset.tsx +++ /dev/null @@ -1,366 +0,0 @@ -import { - ActionList, - AppProvider, - LegacyCard, - ContextualSaveBar, - FormLayout, - Frame, - Layout, - Loading, - Modal, - Navigation, - Page, - SkeletonBodyText, - SkeletonDisplayText, - SkeletonPage, - TextContainer, - TextField, - Toast, - TopBar, -} from '@shopify/polaris'; -import { - ArrowLeftMinor, - HomeMajor, - OrdersMajor, - ConversationMinor, -} from '@shopify/polaris-icons'; -import {useState, useCallback, useRef} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FrameExample() { - const defaultState = useRef({ - emailFieldValue: 'dharma@jadedpixel.com', - nameFieldValue: 'Jaded Pixel', - }); - const skipToContentRef = useRef(null); - - const [toastActive, setToastActive] = useState(false); - const [isLoading, setIsLoading] = useState(false); - const [isDirty, setIsDirty] = useState(false); - const [searchActive, setSearchActive] = useState(false); - const [searchValue, setSearchValue] = useState(''); - const [userMenuActive, setUserMenuActive] = useState(false); - const [mobileNavigationActive, setMobileNavigationActive] = useState(false); - const [modalActive, setModalActive] = useState(false); - const [nameFieldValue, setNameFieldValue] = useState( - defaultState.current.nameFieldValue, - ); - const [emailFieldValue, setEmailFieldValue] = useState( - defaultState.current.emailFieldValue, - ); - const [storeName, setStoreName] = useState( - defaultState.current.nameFieldValue, - ); - const [supportSubject, setSupportSubject] = useState(''); - const [supportMessage, setSupportMessage] = useState(''); - - const handleSubjectChange = useCallback( - (value) => setSupportSubject(value), - [], - ); - const handleMessageChange = useCallback( - (value) => setSupportMessage(value), - [], - ); - const handleDiscard = useCallback(() => { - setEmailFieldValue(defaultState.current.emailFieldValue); - setNameFieldValue(defaultState.current.nameFieldValue); - setIsDirty(false); - }, []); - const handleSave = useCallback(() => { - defaultState.current.nameFieldValue = nameFieldValue; - defaultState.current.emailFieldValue = emailFieldValue; - - setIsDirty(false); - setToastActive(true); - setStoreName(defaultState.current.nameFieldValue); - }, [emailFieldValue, nameFieldValue]); - const handleNameFieldChange = useCallback((value) => { - setNameFieldValue(value); - value && setIsDirty(true); - }, []); - const handleEmailFieldChange = useCallback((value) => { - setEmailFieldValue(value); - value && setIsDirty(true); - }, []); - const handleSearchResultsDismiss = useCallback(() => { - setSearchActive(false); - setSearchValue(''); - }, []); - const handleSearchFieldChange = useCallback((value) => { - setSearchValue(value); - setSearchActive(value.length > 0); - }, []); - const toggleToastActive = useCallback( - () => setToastActive((toastActive) => !toastActive), - [], - ); - const toggleUserMenuActive = useCallback( - () => setUserMenuActive((userMenuActive) => !userMenuActive), - [], - ); - const toggleMobileNavigationActive = useCallback( - () => - setMobileNavigationActive( - (mobileNavigationActive) => !mobileNavigationActive, - ), - [], - ); - const toggleIsLoading = useCallback( - () => setIsLoading((isLoading) => !isLoading), - [], - ); - const toggleModalActive = useCallback( - () => setModalActive((modalActive) => !modalActive), - [], - ); - - const toastMarkup = toastActive ? ( - - ) : null; - - const userMenuActions = [ - { - items: [{content: 'Community forums'}], - }, - ]; - - const contextualSaveBarMarkup = isDirty ? ( - - ) : null; - - const userMenuMarkup = ( - - ); - - const searchResultsMarkup = ( - - ); - - const searchFieldMarkup = ( - - ); - - const topBarMarkup = ( - - ); - - const navigationMarkup = ( - - - - - ); - - const loadingMarkup = isLoading ? : null; - - const skipToContentTarget = ( -
    - ); - - const actualPageMarkup = ( - - - {skipToContentTarget} - - - - - - - - - - - ); - - const loadingPageMarkup = ( - - - - - - - - - - - - - ); - - const pageMarkup = isLoading ? loadingPageMarkup : actualPageMarkup; - - const modalMarkup = ( - - - - - - - - - ); - - const logo = { - width: 124, - topBarSource: - 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999', - contextualSaveBarSource: - 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-gray.svg?6215648040070010999', - url: '#', - accessibilityLabel: 'Jaded Pixel', - }; - - return ( -
    - - - Global ribbon -
    - } - topBar={topBarMarkup} - navigation={navigationMarkup} - showMobileNavigation={mobileNavigationActive} - onNavigationDismiss={toggleMobileNavigationActive} - skipToContentTarget={skipToContentRef.current} - > - {contextualSaveBarMarkup} - {loadingMarkup} - {pageMarkup} - {toastMarkup} - {modalMarkup} - - -
    - ); -} - -export default withPolarisExample(FrameExample); diff --git a/polaris.shopify.com/pages/examples/fullscreen-bar-no-children.tsx b/polaris.shopify.com/pages/examples/fullscreen-bar-no-children.tsx deleted file mode 100644 index f2133ec8fec..00000000000 --- a/polaris.shopify.com/pages/examples/fullscreen-bar-no-children.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import {FullscreenBar, Button, Text} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FullscreenBarExample() { - const [isFullscreen, setFullscreen] = useState(true); - - const handleActionClick = useCallback(() => { - setFullscreen(false); - }, []); - - const fullscreenBarMarkup = ; - - return ( -
    - {isFullscreen && fullscreenBarMarkup} -
    - {!isFullscreen && ( - - )} - - Page content - -
    -
    - ); -} - -export default withPolarisExample(FullscreenBarExample); diff --git a/polaris.shopify.com/pages/examples/fullscreen-bar-with-children.tsx b/polaris.shopify.com/pages/examples/fullscreen-bar-with-children.tsx deleted file mode 100644 index c1388e16843..00000000000 --- a/polaris.shopify.com/pages/examples/fullscreen-bar-with-children.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { - Badge, - ButtonGroup, - FullscreenBar, - Button, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FullscreenBarExample() { - const [isFullscreen, setFullscreen] = useState(true); - - const handleActionClick = useCallback(() => { - setFullscreen(false); - }, []); - - const fullscreenBarMarkup = ( - -
    - Draft -
    - - Page title - -
    - - - - -
    -
    - ); - - return ( -
    - {isFullscreen && fullscreenBarMarkup} -
    - {!isFullscreen && ( - - )} - - Page content - -
    -
    - ); -} - -export default withPolarisExample(FullscreenBarExample); diff --git a/polaris.shopify.com/pages/examples/grid-custom-layout.tsx b/polaris.shopify.com/pages/examples/grid-custom-layout.tsx deleted file mode 100644 index 836d4c0bbe4..00000000000 --- a/polaris.shopify.com/pages/examples/grid-custom-layout.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import {Page, Grid, LegacyCard} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function GridExample() { - return ( - - - - -
    - - -
    - - -
    - - - - - ); -} - -export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/pages/examples/grid-three-one-third-column.tsx b/polaris.shopify.com/pages/examples/grid-three-one-third-column.tsx deleted file mode 100644 index afe442b21f4..00000000000 --- a/polaris.shopify.com/pages/examples/grid-three-one-third-column.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Page, Grid, LegacyCard} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function GridExample() { - return ( - - - - -

    View a summary of your online store’s sales.

    -
    -
    - - -

    View a summary of your online store’s orders.

    -
    -
    -
    -
    - ); -} - -export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/pages/examples/grid-two-column.tsx b/polaris.shopify.com/pages/examples/grid-two-column.tsx deleted file mode 100644 index cba751d7c36..00000000000 --- a/polaris.shopify.com/pages/examples/grid-two-column.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Page, Grid, LegacyCard} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function GridExample() { - return ( - - - - -

    View a summary of your online store’s sales.

    -
    -
    - - -

    View a summary of your online store’s orders.

    -
    -
    -
    -
    - ); -} - -export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/pages/examples/grid-two-thirds-and-one-third-column.tsx b/polaris.shopify.com/pages/examples/grid-two-thirds-and-one-third-column.tsx deleted file mode 100644 index afe442b21f4..00000000000 --- a/polaris.shopify.com/pages/examples/grid-two-thirds-and-one-third-column.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Page, Grid, LegacyCard} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function GridExample() { - return ( - - - - -

    View a summary of your online store’s sales.

    -
    -
    - - -

    View a summary of your online store’s orders.

    -
    -
    -
    -
    - ); -} - -export default withPolarisExample(GridExample); diff --git a/polaris.shopify.com/pages/examples/icon-colored.tsx b/polaris.shopify.com/pages/examples/icon-colored.tsx deleted file mode 100644 index 3308e1f3e32..00000000000 --- a/polaris.shopify.com/pages/examples/icon-colored.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {Icon} from '@shopify/polaris'; -import {CirclePlusMinor} from '@shopify/polaris-icons'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IconExample() { - return ( -
    - - - - - - - -
    - ); -} - -export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/pages/examples/icon-default.tsx b/polaris.shopify.com/pages/examples/icon-default.tsx deleted file mode 100644 index c6a13e48663..00000000000 --- a/polaris.shopify.com/pages/examples/icon-default.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import {Icon} from '@shopify/polaris'; -import {CirclePlusMinor} from '@shopify/polaris-icons'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IconExample() { - return ; -} - -export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/pages/examples/icon-with-backdrop.tsx b/polaris.shopify.com/pages/examples/icon-with-backdrop.tsx deleted file mode 100644 index f73d4c9e310..00000000000 --- a/polaris.shopify.com/pages/examples/icon-with-backdrop.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import {Icon} from '@shopify/polaris'; -import {CirclePlusMinor} from '@shopify/polaris-icons'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IconExample() { - return ( -
    - - - - - -
    - ); -} - -export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/pages/examples/icon-with-custom-svg-and-color.tsx b/polaris.shopify.com/pages/examples/icon-with-custom-svg-and-color.tsx deleted file mode 100644 index ebaac89e8ee..00000000000 --- a/polaris.shopify.com/pages/examples/icon-with-custom-svg-and-color.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import {Icon} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IconWithReactChild() { - const iconContent = () => { - return ( - - - - - - ); - }; - - return ; -} - -export default withPolarisExample(IconWithReactChild); diff --git a/polaris.shopify.com/pages/examples/icon-with-custom-svg.tsx b/polaris.shopify.com/pages/examples/icon-with-custom-svg.tsx deleted file mode 100644 index 6f44a6f4fae..00000000000 --- a/polaris.shopify.com/pages/examples/icon-with-custom-svg.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import {Icon} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IconExample() { - return ( - - ); -} - -export default withPolarisExample(IconExample); diff --git a/polaris.shopify.com/pages/examples/index-table-default.tsx b/polaris.shopify.com/pages/examples/index-table-default.tsx deleted file mode 100644 index a1dc77b2228..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-default.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import { - IndexTable, - LegacyCard, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SimpleIndexTableExample() { - const customers = [ - { - id: '3411', - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - orders: 20, - amountSpent: '$2,400', - }, - { - id: '2561', - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - orders: 30, - amountSpent: '$140', - }, - ]; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - - const rowMarkup = customers.map( - ({id, name, location, orders, amountSpent}, index) => ( - - - - {name} - - - {location} - - - {orders} - - - - - {amountSpent} - - - - ), - ); - - return ( - - - Order count - - ), - }, - { - id: 'amount-spent', - title: ( - - Amount spent - - ), - }, - , - ]} - > - {rowMarkup} - - - ); -} - -export default withPolarisExample(SimpleIndexTableExample); diff --git a/polaris.shopify.com/pages/examples/index-table-flush.tsx b/polaris.shopify.com/pages/examples/index-table-flush.tsx deleted file mode 100644 index 57a366bcae2..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-flush.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import { - IndexTable, - LegacyCard, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SimpleFlushIndexTableExample() { - const customers = [ - { - id: '3411', - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - orders: 20, - amountSpent: '$2,400', - }, - { - id: '2561', - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - orders: 30, - amountSpent: '$140', - }, - ]; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - - const rowMarkup = customers.map( - ({id, name, location, orders, amountSpent}, index) => ( - - - - {name} - - - {location} - - - {orders} - - - - - {amountSpent} - - - - ), - ); - - return ( - - - Order count - - ), - }, - { - id: 'amount-spent', - flush: true, - title: ( - - Amount spent - - ), - }, - ]} - > - {rowMarkup} - - - ); -} - -export default withPolarisExample(SimpleFlushIndexTableExample); diff --git a/polaris.shopify.com/pages/examples/index-table-small-screen-with-all-of-its-elements.tsx b/polaris.shopify.com/pages/examples/index-table-small-screen-with-all-of-its-elements.tsx deleted file mode 100644 index 5a223ad4778..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-small-screen-with-all-of-its-elements.tsx +++ /dev/null @@ -1,224 +0,0 @@ -import { - TextField, - IndexTable, - LegacyCard, - Filters, - Select, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SmallScreenIndexTableWithAllElementsExample() { - const customers = [ - { - id: '3418', - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - orders: 20, - amountSpent: '$2,400', - }, - { - id: '2568', - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - orders: 30, - amountSpent: '$140', - }, - ]; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - const [taggedWith, setTaggedWith] = useState('VIP'); - const [queryValue, setQueryValue] = useState(null); - const [sortValue, setSortValue] = useState('today'); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - const handleSortChange = useCallback((value) => setSortValue(value), []); - - const promotedBulkActions = [ - { - content: 'Edit customers', - onAction: () => console.log('Todo: implement bulk edit'), - }, - ]; - const bulkActions = [ - { - content: 'Add tags', - onAction: () => console.log('Todo: implement bulk add tags'), - }, - { - content: 'Remove tags', - onAction: () => console.log('Todo: implement bulk remove tags'), - }, - { - content: 'Delete customers', - onAction: () => console.log('Todo: implement bulk delete'), - }, - ]; - - const filters = [ - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith', - label: disambiguateLabel('taggedWith', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - const sortOptions = [ - {label: 'Today', value: 'today'}, - {label: 'Yesterday', value: 'yesterday'}, - {label: 'Last 7 days', value: 'lastWeek'}, - ]; - - const rowMarkup = customers.map( - ({id, name, location, orders, amountSpent}, index) => ( - -
    - - {name} - -

    {location}

    - - {orders} - - - {amountSpent} - -
    -
    - ), - ); - - return ( -
    - -
    -
    - -
    -
    - -
    -
    - - Order count - - ), - }, - { - id: 'amount-spent', - hidden: false, - title: ( - - Amount spent - - ), - }, - ]} - > - {rowMarkup} - -
    - ); - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(IndexTableWithAllElementsExample); diff --git a/polaris.shopify.com/pages/examples/index-table-with-bulk-actions-and-selection-across-pages.tsx b/polaris.shopify.com/pages/examples/index-table-with-bulk-actions-and-selection-across-pages.tsx deleted file mode 100644 index 1d9db6df0c3..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-with-bulk-actions-and-selection-across-pages.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { - IndexTable, - LegacyCard, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IndexTableWithBulkActionsAndSelectionAcrossPagesExample() { - const customers = [ - { - id: '3414', - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - orders: 20, - amountSpent: '$2,400', - }, - { - id: '2564', - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - orders: 30, - amountSpent: '$140', - }, - ]; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - - const promotedBulkActions = [ - { - content: 'Edit customers', - onAction: () => console.log('Todo: implement bulk edit'), - }, - ]; - const bulkActions = [ - { - content: 'Add tags', - onAction: () => console.log('Todo: implement bulk add tags'), - }, - { - content: 'Remove tags', - onAction: () => console.log('Todo: implement bulk remove tags'), - }, - { - content: 'Delete customers', - onAction: () => console.log('Todo: implement bulk delete'), - }, - ]; - - const rowMarkup = customers.map( - ({id, name, location, orders, amountSpent}, index) => ( - - - - {name} - - - {location} - - - {orders} - - - - - {amountSpent} - - - - ), - ); - - return ( - - - Order count - - ), - }, - { - id: 'amount-spent', - title: ( - - Amount spent - - ), - }, - , - ]} - > - {rowMarkup} - - - ); -} - -export default withPolarisExample( - IndexTableWithBulkActionsAndSelectionAcrossPagesExample, -); diff --git a/polaris.shopify.com/pages/examples/index-table-with-bulk-actions.tsx b/polaris.shopify.com/pages/examples/index-table-with-bulk-actions.tsx deleted file mode 100644 index 172e5412eef..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-with-bulk-actions.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import { - IndexTable, - LegacyCard, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IndexTableWithBulkActionsExample() { - const customers = [ - { - id: '3413', - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - orders: 20, - amountSpent: '$2,400', - }, - { - id: '2563', - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - orders: 30, - amountSpent: '$140', - }, - ]; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - - const promotedBulkActions = [ - { - content: 'Edit customers', - onAction: () => console.log('Todo: implement bulk edit'), - }, - ]; - const bulkActions = [ - { - content: 'Add tags', - onAction: () => console.log('Todo: implement bulk add tags'), - }, - { - content: 'Remove tags', - onAction: () => console.log('Todo: implement bulk remove tags'), - }, - { - content: 'Delete customers', - onAction: () => console.log('Todo: implement bulk delete'), - }, - ]; - - const rowMarkup = customers.map( - ({id, name, location, orders, amountSpent}, index) => ( - - - - {name} - - - {location} - - - {orders} - - - - - {amountSpent} - - - - ), - ); - - return ( - - - Order count - - ), - }, - { - id: 'amount-spent', - title: ( - - Amount spent - - ), - }, - , - ]} - > - {rowMarkup} - - - ); -} - -export default withPolarisExample(IndexTableWithBulkActionsExample); diff --git a/polaris.shopify.com/pages/examples/index-table-with-clickable-button-column.tsx b/polaris.shopify.com/pages/examples/index-table-with-clickable-button-column.tsx deleted file mode 100644 index 02dc2230a31..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-with-clickable-button-column.tsx +++ /dev/null @@ -1,119 +0,0 @@ -import { - IndexTable, - LegacyCard, - Button, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ClickThroughButtonIndexTableExample() { - const customers = [ - { - id: '3411', - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - orders: 20, - amountSpent: '$2,400', - }, - { - id: '2561', - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - orders: 30, - amountSpent: '$140', - }, - ]; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - - const rowMarkup = customers.map( - ({id, url, name, location, orders, amountSpent}, index) => ( - - - - - {location} - - - {orders} - - - - - {amountSpent} - - - - ), - ); - - return ( - - - Order count - - ), - }, - { - id: 'amount-spent', - hidden: false, - title: ( - - Amount spent - - ), - }, - ]} - > - {rowMarkup} - - - ); -} - -export default withPolarisExample(ClickThroughButtonIndexTableExample); diff --git a/polaris.shopify.com/pages/examples/index-table-with-empty-state.tsx b/polaris.shopify.com/pages/examples/index-table-with-empty-state.tsx deleted file mode 100644 index fd96d7ff1d1..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-with-empty-state.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import { - EmptySearchResult, - IndexTable, - LegacyCard, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IndexTableWithCustomEmptyStateExample() { - const customers = []; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - - const emptyStateMarkup = ( - - ); - - const rowMarkup = customers.map( - ({id, name, location, orders, amountSpent}, index) => ( - - - - {name} - - - {location} - - - {orders} - - - - - {amountSpent} - - - - ), - ); - - return ( - - - Order count - - ), - }, - { - id: 'amount-spent', - title: ( - - Amount spent - - ), - }, - , - ]} - > - {rowMarkup} - - - ); -} - -export default withPolarisExample(IndexTableWithCustomEmptyStateExample); diff --git a/polaris.shopify.com/pages/examples/index-table-with-filtering.tsx b/polaris.shopify.com/pages/examples/index-table-with-filtering.tsx deleted file mode 100644 index 687f63de39f..00000000000 --- a/polaris.shopify.com/pages/examples/index-table-with-filtering.tsx +++ /dev/null @@ -1,201 +0,0 @@ -import { - TextField, - IndexTable, - LegacyCard, - Filters, - Select, - useIndexResourceState, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function IndexTableWithFilteringExample() { - const customers = [ - { - id: '3416', - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - orders: 20, - amountSpent: '$2,400', - }, - { - id: '2566', - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - orders: 30, - amountSpent: '$140', - }, - ]; - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const {selectedResources, allResourcesSelected, handleSelectionChange} = - useIndexResourceState(customers); - const [taggedWith, setTaggedWith] = useState('VIP'); - const [queryValue, setQueryValue] = useState(null); - const [sortValue, setSortValue] = useState('today'); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - const handleSortChange = useCallback((value) => setSortValue(value), []); - - const filters = [ - { - key: 'taggedWith', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith', - label: disambiguateLabel('taggedWith', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - const sortOptions = [ - {label: 'Today', value: 'today'}, - {label: 'Yesterday', value: 'yesterday'}, - {label: 'Last 7 days', value: 'lastWeek'}, - ]; - - const rowMarkup = customers.map( - ({id, name, location, orders, amountSpent}, index) => ( - - - - {name} - - - {location} - - - {orders} - - - - - {amountSpent} - - - - ), - ); - - return ( - -
    -
    - -
    -
    - - - - - -
    - ); -} - -export default withPolarisExample(PopoverFormExample); diff --git a/polaris.shopify.com/pages/examples/popover-with-lazy-loaded-list.tsx b/polaris.shopify.com/pages/examples/popover-with-lazy-loaded-list.tsx deleted file mode 100644 index 12982c76377..00000000000 --- a/polaris.shopify.com/pages/examples/popover-with-lazy-loaded-list.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import {Button, LegacyCard, Popover, ResourceList, Avatar} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function PopoverLazyLoadExample() { - const [popoverActive, setPopoverActive] = useState(true); - const [visibleStaffIndex, setVisibleStaffIndex] = useState(5); - const staff = [ - 'Abbey Mayert', - 'Abbi Senger', - 'Abdul Goodwin', - 'Abdullah Borer', - 'Abe Nader', - 'Abigayle Smith', - 'Abner Torphy', - 'Abraham Towne', - 'Abraham Vik', - 'Ada Fisher', - 'Adah Pouros', - 'Adam Waelchi', - 'Adan Zemlak', - 'Addie Wehner', - 'Addison Wexler', - 'Alex Hernandez', - ]; - - const togglePopoverActive = useCallback( - () => setPopoverActive((popoverActive) => !popoverActive), - [], - ); - - const handleScrolledToBottom = useCallback(() => { - const totalIndexes = staff.length; - const interval = - visibleStaffIndex + 3 < totalIndexes - ? 3 - : totalIndexes - visibleStaffIndex; - - if (interval > 0) { - setVisibleStaffIndex(visibleStaffIndex + interval); - } - }, [staff.length, visibleStaffIndex]); - - const handleResourceListItemClick = useCallback(() => {}, []); - - const activator = ( - - ); - - const staffList = staff.slice(0, visibleStaffIndex).map((name) => ({ - name, - initials: getInitials(name), - })); - - return ( - -
    - - - - - -
    -
    - ); - - function renderItem({name, initials}) { - return ( - } - onClick={handleResourceListItemClick} - > - {name} - - ); - } - - function getInitials(name) { - return name - .split(' ') - .map((surnameOrFamilyName) => { - return surnameOrFamilyName.slice(0, 1); - }) - .join(''); - } -} - -export default withPolarisExample(PopoverLazyLoadExample); diff --git a/polaris.shopify.com/pages/examples/popover-with-searchable-listbox.tsx b/polaris.shopify.com/pages/examples/popover-with-searchable-listbox.tsx deleted file mode 100644 index ef6cf5f6f5c..00000000000 --- a/polaris.shopify.com/pages/examples/popover-with-searchable-listbox.tsx +++ /dev/null @@ -1,331 +0,0 @@ -import React, {useState} from 'react'; -import { - Listbox, - TextField, - Icon, - Link, - Popover, - AutoSelection, - Scrollable, - EmptySearchResult, - Text, -} from '@shopify/polaris'; -import {SearchMinor} from '@shopify/polaris-icons'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -const actionValue = '__ACTION__'; - -const segments = [ - { - label: 'All customers', - id: 'gid://shopify/CustomerSegment/1', - value: '0', - }, - { - label: 'VIP customers', - id: 'gid://shopify/CustomerSegment/2', - value: '1', - }, - { - label: 'New customers', - id: 'gid://shopify/CustomerSegment/3', - value: '2', - }, - { - label: 'Abandoned carts - last 30 days', - id: 'gid://shopify/CustomerSegment/4', - value: '3', - }, - { - label: 'Wholesale customers', - id: 'gid://shopify/CustomerSegment/5', - value: '4', - }, - { - label: 'Email subscribers', - id: 'gid://shopify/CustomerSegment/6', - value: '5', - }, - { - label: 'From New York', - id: 'gid://shopify/CustomerSegment/7', - value: '6', - }, - { - label: 'Repeat buyers', - id: 'gid://shopify/CustomerSegment/8', - value: '7', - }, - { - label: 'First time buyers', - id: 'gid://shopify/CustomerSegment/9', - value: '8', - }, - { - label: 'From Canada', - id: 'gid://shopify/CustomerSegment/10', - value: '9', - }, - { - label: 'Bought in last 60 days', - id: 'gid://shopify/CustomerSegment/11', - value: '10', - }, - { - label: 'Bought last BFCM', - id: 'gid://shopify/CustomerSegment/12', - value: '11', - }, -]; - -const lazyLoadSegments = Array.from(Array(100)).map((_, index) => ({ - label: `Other customers ${index + 13}`, - id: `gid://shopify/CustomerSegment/${index + 13}`, - value: `${index + 12}`, -})); - -segments.push(...lazyLoadSegments); - -const interval = 25; - -function PopoverWithSearchableListboxExample() { - const [pickerOpen, setPickerOpen] = useState(false); - const [showFooterAction, setShowFooterAction] = useState(true); - const [query, setQuery] = useState(''); - const [lazyLoading, setLazyLoading] = useState(false); - const [willLoadMoreResults, setWillLoadMoreResults] = useState(true); - const [visibleOptionIndex, setVisibleOptionIndex] = useState(6); - const [activeOptionId, setActiveOptionId] = useState(segments[0].id); - const [selectedSegmentIndex, setSelectedSegmentIndex] = useState(0); - const [filteredSegments, setFilteredSegments] = useState([]); - - const handleClickShowAll = () => { - setShowFooterAction(false); - setVisibleOptionIndex(interval); - }; - - const handleFilterSegments = (query: string) => { - const nextFilteredSegments = segments.filter((segment) => { - return segment.label - .toLocaleLowerCase() - .includes(query.toLocaleLowerCase().trim()); - }); - - setFilteredSegments(nextFilteredSegments); - }; - - const handleQueryChange = (query: string) => { - setQuery(query); - - if (query.length >= 2) handleFilterSegments(query); - }; - - const handleQueryClear = () => { - handleQueryChange(''); - }; - - const handleOpenPicker = () => { - setPickerOpen(true); - }; - - const handleClosePicker = () => { - setPickerOpen(false); - handleQueryChange(''); - }; - - const handleSegmentSelect = (segmentIndex: string) => { - if (segmentIndex === actionValue) { - return handleClickShowAll(); - } - - setSelectedSegmentIndex(Number(segmentIndex)); - handleClosePicker(); - }; - - const handleActiveOptionChange = (_: string, domId: string) => { - setActiveOptionId(domId); - }; - - /* This is just to illustrate lazy loading state vs loading state. This is an example, so we aren't fetching from GraphQL. You'd use `pageInfo.hasNextPage` from your GraphQL query data instead of this fake "willLoadMoreResults" state along with setting `first` your GraphQL query's variables to your app's default max edges limit (e.g., 250). */ - - const handleLazyLoadSegments = () => { - if (willLoadMoreResults && !showFooterAction) { - setLazyLoading(true); - - const options = query ? filteredSegments : segments; - - setTimeout(() => { - const remainingOptionCount = options.length - visibleOptionIndex; - const nextVisibleOptionIndex = - remainingOptionCount >= interval - ? visibleOptionIndex + interval - : visibleOptionIndex + remainingOptionCount; - - setLazyLoading(false); - setVisibleOptionIndex(nextVisibleOptionIndex); - - if (remainingOptionCount <= interval) { - setWillLoadMoreResults(false); - } - }, 1000); - } - }; - - const listboxId = 'SearchableListboxInPopover'; - - /* Your app's feature/context specific activator here */ - const activator = ( -
    - - - {segments[selectedSegmentIndex].label} - - -
    - ); - - const textFieldMarkup = ( -
    - - } - ariaActiveDescendant={activeOptionId} - ariaControls={listboxId} - onChange={handleQueryChange} - onClearButtonClick={handleQueryClear} - /> - -
    - ); - - const segmentOptions = query ? filteredSegments : segments; - - const segmentList = - segmentOptions.length > 0 - ? segmentOptions - .slice(0, visibleOptionIndex) - .map(({label, id, value}) => { - const selected = segments[selectedSegmentIndex].id === id; - - return ( - - - {label} - - - ); - }) - : null; - - const showAllMarkup = showFooterAction ? ( - - Show all 111 segments - - ) : null; - - const lazyLoadingMarkup = lazyLoading ? ( - - ) : null; - - const noResultsMarkup = - segmentOptions.length === 0 ? ( - - ) : null; - - const listboxMarkup = ( - - {segmentList} - {showAllMarkup} - {noResultsMarkup} - {lazyLoadingMarkup} - - ); - - return ( -
    - - -
    - {textFieldMarkup} - - - {listboxMarkup} - -
    -
    -
    -
    - ); -} - -const StopPropagation = ({children}: React.PropsWithChildren) => { - const stopEventPropagation = (event: React.MouseEvent | React.TouchEvent) => { - event.stopPropagation(); - }; - - return ( -
    - {children} -
    - ); -}; - -export default withPolarisExample(PopoverWithSearchableListboxExample); diff --git a/polaris.shopify.com/pages/examples/progress-bar-colored.tsx b/polaris.shopify.com/pages/examples/progress-bar-colored.tsx deleted file mode 100644 index 32923548272..00000000000 --- a/polaris.shopify.com/pages/examples/progress-bar-colored.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {ProgressBar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ProgressBarExample() { - return ( -
    - -
    - -
    - ); -} - -export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/pages/examples/progress-bar-default.tsx b/polaris.shopify.com/pages/examples/progress-bar-default.tsx deleted file mode 100644 index 6d6a7e1c3fb..00000000000 --- a/polaris.shopify.com/pages/examples/progress-bar-default.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {ProgressBar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ProgressBarExample() { - return ( -
    - -
    - ); -} - -export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/pages/examples/progress-bar-non-animated.tsx b/polaris.shopify.com/pages/examples/progress-bar-non-animated.tsx deleted file mode 100644 index 43b866f729f..00000000000 --- a/polaris.shopify.com/pages/examples/progress-bar-non-animated.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {ProgressBar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ProgressBarExample() { - return ( -
    - -
    - ); -} - -export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/pages/examples/progress-bar-small.tsx b/polaris.shopify.com/pages/examples/progress-bar-small.tsx deleted file mode 100644 index ce471063f7e..00000000000 --- a/polaris.shopify.com/pages/examples/progress-bar-small.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {ProgressBar} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ProgressBarExample() { - return ( -
    - -
    - ); -} - -export default withPolarisExample(ProgressBarExample); diff --git a/polaris.shopify.com/pages/examples/radio-button-default.tsx b/polaris.shopify.com/pages/examples/radio-button-default.tsx deleted file mode 100644 index 4dfa40529e5..00000000000 --- a/polaris.shopify.com/pages/examples/radio-button-default.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import {LegacyStack, RadioButton} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RadioButtonExample() { - const [value, setValue] = useState('disabled'); - - const handleChange = useCallback( - (_checked, newValue) => setValue(newValue), - [], - ); - - return ( - - - - - ); -} - -export default withPolarisExample(RadioButtonExample); diff --git a/polaris.shopify.com/pages/examples/range-slider-default.tsx b/polaris.shopify.com/pages/examples/range-slider-default.tsx deleted file mode 100644 index 7f6acfff956..00000000000 --- a/polaris.shopify.com/pages/examples/range-slider-default.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {LegacyCard, RangeSlider} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RangeSliderExample() { - const [rangeValue, setRangeValue] = useState(32); - - const handleRangeSliderChange = useCallback( - (value) => setRangeValue(value), - [], - ); - - return ( - - - - ); -} - -export default withPolarisExample(RangeSliderExample); diff --git a/polaris.shopify.com/pages/examples/range-slider-with-dual-thumb.tsx b/polaris.shopify.com/pages/examples/range-slider-with-dual-thumb.tsx deleted file mode 100644 index e939163a58d..00000000000 --- a/polaris.shopify.com/pages/examples/range-slider-with-dual-thumb.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { - LegacyCard, - RangeSlider, - LegacyStack, - TextField, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function DualThumbRangeSliderExample() { - const initialValue = [900, 1000]; - const prefix = '$'; - const min = 0; - const max = 2000; - const step = 10; - - const [intermediateTextFieldValue, setIntermediateTextFieldValue] = - useState(initialValue); - const [rangeValue, setRangeValue] = useState(initialValue); - - const handleRangeSliderChange = useCallback((value) => { - setRangeValue(value); - setIntermediateTextFieldValue(value); - }, []); - - const handleLowerTextFieldChange = useCallback( - (value) => { - const upperValue = rangeValue[1]; - setIntermediateTextFieldValue([parseInt(value, 10), upperValue]); - }, - [rangeValue], - ); - - const handleUpperTextFieldChange = useCallback( - (value) => { - const lowerValue = rangeValue[0]; - setIntermediateTextFieldValue([lowerValue, parseInt(value, 10)]); - }, - [rangeValue], - ); - - const handleLowerTextFieldBlur = useCallback(() => { - const upperValue = rangeValue[1]; - const value = intermediateTextFieldValue[0]; - - setRangeValue([parseInt(value, 10), upperValue]); - }, [intermediateTextFieldValue, rangeValue]); - - const handleUpperTextFieldBlur = useCallback(() => { - const lowerValue = rangeValue[0]; - const value = intermediateTextFieldValue[1]; - - setRangeValue([lowerValue, parseInt(value, 10)]); - }, [intermediateTextFieldValue, rangeValue]); - - const handleEnterKeyPress = useCallback( - (event) => { - const newValue = intermediateTextFieldValue; - const oldValue = rangeValue; - - if (event.keyCode === Key.Enter && newValue !== oldValue) { - setRangeValue(newValue); - } - }, - [intermediateTextFieldValue, rangeValue], - ); - - const lowerTextFieldValue = - intermediateTextFieldValue[0] === rangeValue[0] - ? rangeValue[0] - : intermediateTextFieldValue[0]; - - const upperTextFieldValue = - intermediateTextFieldValue[1] === rangeValue[1] - ? rangeValue[1] - : intermediateTextFieldValue[1]; - - return ( - -
    - - - - - -
    -
    - ); -} - -export default withPolarisExample(DualThumbRangeSliderExample); diff --git a/polaris.shopify.com/pages/examples/range-slider-with-min-and-max.tsx b/polaris.shopify.com/pages/examples/range-slider-with-min-and-max.tsx deleted file mode 100644 index 935f7f82d09..00000000000 --- a/polaris.shopify.com/pages/examples/range-slider-with-min-and-max.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import {LegacyCard, RangeSlider} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RangeSliderWithPreciseRangeControlExample() { - const [rangeValue, setRangeValue] = useState(0); - - const handleRangeSliderChange = useCallback( - (value) => setRangeValue(value), - [], - ); - - return ( - - - - ); -} - -export default withPolarisExample(RangeSliderWithPreciseRangeControlExample); diff --git a/polaris.shopify.com/pages/examples/range-slider-with-prefix-and-suffix.tsx b/polaris.shopify.com/pages/examples/range-slider-with-prefix-and-suffix.tsx deleted file mode 100644 index cb116b6c9e6..00000000000 --- a/polaris.shopify.com/pages/examples/range-slider-with-prefix-and-suffix.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import {LegacyCard, RangeSlider} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RangeSliderWithPrefixAndSuffixExample() { - const [rangeValue, setRangeValue] = useState(100); - - const handleRangeSliderChange = useCallback( - (value) => setRangeValue(value), - [], - ); - - const suffixStyles = { - minWidth: '24px', - textAlign: 'right', - }; - - return ( - - Hue

    } - suffix={

    {rangeValue}

    } - /> -
    - ); -} - -export default withPolarisExample(RangeSliderWithPrefixAndSuffixExample); diff --git a/polaris.shopify.com/pages/examples/range-slider-with-steps.tsx b/polaris.shopify.com/pages/examples/range-slider-with-steps.tsx deleted file mode 100644 index a93f88a5e29..00000000000 --- a/polaris.shopify.com/pages/examples/range-slider-with-steps.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import {LegacyCard, RangeSlider} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RangeSliderWithPreciseRangeControlExample() { - const [rangeValue, setRangeValue] = useState(4); - - const handleRangeSliderChange = useCallback( - (value) => setRangeValue(value), - [], - ); - - return ( - - - - ); -} - -export default withPolarisExample(RangeSliderWithPreciseRangeControlExample); diff --git a/polaris.shopify.com/pages/examples/resource-item-default.tsx b/polaris.shopify.com/pages/examples/resource-item-default.tsx deleted file mode 100644 index 74dd51085aa..00000000000 --- a/polaris.shopify.com/pages/examples/resource-item-default.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import {LegacyCard, ResourceList, ResourceItem, Text} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceItemExample() { - const [selectedItems, setSelectedItems] = useState([]); - - return ( - - { - const {id, url, title, author} = item; - const authorMarkup = author ?
    by {author}
    : null; - return ( - - - {title} - - {authorMarkup} - - ); - }} - /> -
    - ); -} - -export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/pages/examples/resource-item-with-media.tsx b/polaris.shopify.com/pages/examples/resource-item-with-media.tsx deleted file mode 100644 index 1246f1e9484..00000000000 --- a/polaris.shopify.com/pages/examples/resource-item-with-media.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import {LegacyCard, ResourceList, ResourceItem, Avatar, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceItemExample() { - return ( - - { - const {id, url, avatarSource, name, location} = item; - - return ( - - } - accessibilityLabel={`View details for ${name}`} - name={name} - > - - {name} - -
    {location}
    -
    - ); - }} - /> -
    - ); -} - -export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/pages/examples/resource-item-with-shortcut-actions.tsx b/polaris.shopify.com/pages/examples/resource-item-with-shortcut-actions.tsx deleted file mode 100644 index aa774e2def8..00000000000 --- a/polaris.shopify.com/pages/examples/resource-item-with-shortcut-actions.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import {LegacyCard, ResourceList, ResourceItem, Avatar, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceItemExample() { - return ( - - { - const {id, url, avatarSource, name, location, latestOrderUrl} = item; - const shortcutActions = latestOrderUrl - ? [{content: 'View latest order', url: latestOrderUrl}] - : null; - - return ( - - } - shortcutActions={shortcutActions} - accessibilityLabel={`View details for ${name}`} - name={name} - > - - {name} - -
    {location}
    -
    - ); - }} - /> -
    - ); -} - -export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/pages/examples/resource-item-with-vertical-alignment.tsx b/polaris.shopify.com/pages/examples/resource-item-with-vertical-alignment.tsx deleted file mode 100644 index 865c24eb6de..00000000000 --- a/polaris.shopify.com/pages/examples/resource-item-with-vertical-alignment.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import {LegacyCard, ResourceList, ResourceItem, Avatar, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceItemExample() { - return ( - - { - const {id, url, avatarSource, name, location, lastOrder} = item; - return ( - - } - accessibilityLabel={`View details for ${name}`} - name={name} - > - - {name} - -
    {location}
    -
    {lastOrder}
    -
    - ); - }} - /> -
    - ); -} - -export default withPolarisExample(ResourceItemExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-default.tsx b/polaris.shopify.com/pages/examples/resource-list-default.tsx deleted file mode 100644 index af9ccc64b86..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-default.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListExample() { - return ( - - { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    - ); -} - -export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-a-custom-empty-search-result-state.tsx b/polaris.shopify.com/pages/examples/resource-list-with-a-custom-empty-search-result-state.tsx deleted file mode 100644 index b6c65b62ac3..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-a-custom-empty-search-result-state.tsx +++ /dev/null @@ -1,125 +0,0 @@ -import { - TextField, - Filters, - Button, - LegacyCard, - ResourceList, - Avatar, - ResourceItem, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithFilteringExample() { - const [taggedWith, setTaggedWith] = useState('VIP'); - const [queryValue, setQueryValue] = useState(null); - const [items, setItems] = useState([]); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleQueryValueChange = useCallback((value) => { - setQueryValue(value); - setItems([]); - }, []); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const filters = [ - { - key: 'taggedWith2', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith2', - label: disambiguateLabel('taggedWith2', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - const filterControl = ( - -
    - -
    -
    - ); - - return ( - - This is a custom empty state
    } - /> -
    - ); - - function renderItem(item) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith2': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(ResourceListWithFilteringExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-all-of-its-elements.tsx b/polaris.shopify.com/pages/examples/resource-list-with-all-of-its-elements.tsx deleted file mode 100644 index 5641a5ac726..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-all-of-its-elements.tsx +++ /dev/null @@ -1,186 +0,0 @@ -import { - TextField, - Filters, - Button, - LegacyCard, - ResourceList, - Avatar, - ResourceItem, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListExample() { - const [selectedItems, setSelectedItems] = useState([]); - const [sortValue, setSortValue] = useState('DATE_MODIFIED_DESC'); - const [taggedWith, setTaggedWith] = useState('VIP'); - const [queryValue, setQueryValue] = useState(null); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleQueryValueChange = useCallback( - (value) => setQueryValue(value), - [], - ); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const items = [ - { - id: 112, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - latestOrderUrl: 'orders/1456', - }, - { - id: 212, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - latestOrderUrl: 'orders/1457', - }, - ]; - - const promotedBulkActions = [ - { - content: 'Edit customers', - onAction: () => console.log('Todo: implement bulk edit'), - }, - ]; - - const bulkActions = [ - { - content: 'Add tags', - onAction: () => console.log('Todo: implement bulk add tags'), - }, - { - content: 'Remove tags', - onAction: () => console.log('Todo: implement bulk remove tags'), - }, - { - content: 'Delete customers', - onAction: () => console.log('Todo: implement bulk delete'), - }, - ]; - - const filters = [ - { - key: 'taggedWith3', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith3', - label: disambiguateLabel('taggedWith3', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - const filterControl = ( - -
    - -
    -
    - ); - - return ( - - { - setSortValue(selected); - console.log(`Sort option changed to ${selected}.`); - }} - filterControl={filterControl} - /> - - ); - - function renderItem(item) { - const {id, url, name, location, latestOrderUrl} = item; - const media = ; - const shortcutActions = latestOrderUrl - ? [{content: 'View latest order', url: latestOrderUrl}] - : null; - return ( - - - {name} - -
    {location}
    -
    - ); - } - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith3': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-alternate-tool.tsx b/polaris.shopify.com/pages/examples/resource-list-with-alternate-tool.tsx deleted file mode 100644 index 2507ced16e7..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-alternate-tool.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { - LegacyCard, - ResourceList, - Button, - Avatar, - ResourceItem, - Text, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithAlternateToolExample() { - const resourceName = { - singular: 'Customer', - plural: 'Customers', - }; - - const items = [ - { - id: 107, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 207, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]; - - return ( - - Email customers} - /> - - ); - - function renderItem(item) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } -} - -export default withPolarisExample(ResourceListWithAlternateToolExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-bulk-actions.tsx b/polaris.shopify.com/pages/examples/resource-list-with-bulk-actions.tsx deleted file mode 100644 index 36a31551a0d..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-bulk-actions.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithBulkActionsExample() { - const [selectedItems, setSelectedItems] = useState([]); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const items = [ - { - id: 103, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 203, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]; - - const promotedBulkActions = [ - { - content: 'Edit customers', - onAction: () => console.log('Todo: implement bulk edit'), - }, - ]; - - const bulkActions = [ - { - content: 'Add tags', - onAction: () => console.log('Todo: implement bulk add tags'), - }, - { - content: 'Remove tags', - onAction: () => console.log('Todo: implement bulk remove tags'), - }, - { - content: 'Delete customers', - onAction: () => console.log('Todo: implement bulk delete'), - }, - ]; - - return ( - - - - ); - - function renderItem(item) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } -} - -export default withPolarisExample(ResourceListWithBulkActionsExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-empty-state.tsx b/polaris.shopify.com/pages/examples/resource-list-with-empty-state.tsx deleted file mode 100644 index 1e1c45e3071..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-empty-state.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { - Filters, - EmptyState, - Page, - Layout, - LegacyCard, - ResourceList, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithEmptyStateExample() { - const items = []; - const appliedFilters = []; - const filters = []; - - const filterControl = ( - - ); - - const emptyStateMarkup = - !appliedFilters.length && !items.length ? ( - -

    - You can use the Files section to upload images, videos, and other - documents -

    -
    - ) : undefined; - - return ( - - - - - {}} - filterControl={filterControl} - resourceName={{singular: 'file', plural: 'files'}} - /> - - - - - ); -} - -export default withPolarisExample(ResourceListWithEmptyStateExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-filtering.tsx b/polaris.shopify.com/pages/examples/resource-list-with-filtering.tsx deleted file mode 100644 index 88f04d18e19..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-filtering.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import { - TextField, - Filters, - Button, - LegacyCard, - ResourceList, - Avatar, - ResourceItem, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithFilteringExample() { - const [taggedWith, setTaggedWith] = useState('VIP'); - const [queryValue, setQueryValue] = useState(null); - - const handleTaggedWithChange = useCallback( - (value) => setTaggedWith(value), - [], - ); - const handleTaggedWithRemove = useCallback(() => setTaggedWith(null), []); - const handleQueryValueRemove = useCallback(() => setQueryValue(null), []); - const handleClearAll = useCallback(() => { - handleTaggedWithRemove(); - handleQueryValueRemove(); - }, [handleQueryValueRemove, handleTaggedWithRemove]); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const items = [ - { - id: 108, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 208, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]; - - const filters = [ - { - key: 'taggedWith1', - label: 'Tagged with', - filter: ( - - ), - shortcut: true, - }, - ]; - - const appliedFilters = !isEmpty(taggedWith) - ? [ - { - key: 'taggedWith1', - label: disambiguateLabel('taggedWith1', taggedWith), - onRemove: handleTaggedWithRemove, - }, - ] - : []; - - const filterControl = ( - -
    - -
    -
    - ); - - return ( - - - - ); - - function renderItem(item) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } - - function disambiguateLabel(key, value) { - switch (key) { - case 'taggedWith1': - return `Tagged with ${value}`; - default: - return value; - } - } - - function isEmpty(value) { - if (Array.isArray(value)) { - return value.length === 0; - } else { - return value === '' || value == null; - } - } -} - -export default withPolarisExample(ResourceListWithFilteringExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-item-shortcut-actions.tsx b/polaris.shopify.com/pages/examples/resource-list-with-item-shortcut-actions.tsx deleted file mode 100644 index bad50508124..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-item-shortcut-actions.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListExample() { - return ( - - { - const {id, url, name, location, latestOrderUrl} = item; - const media = ; - const shortcutActions = latestOrderUrl - ? [ - { - content: 'View latest order', - accessibilityLabel: `View ${name}’s latest order`, - url: latestOrderUrl, - }, - ] - : null; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    - ); -} - -export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-loading-state.tsx b/polaris.shopify.com/pages/examples/resource-list-with-loading-state.tsx deleted file mode 100644 index 22f4d4dd0e5..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-loading-state.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithLoadingExample() { - const [selectedItems, setSelectedItems] = useState([]); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const items = [ - { - id: 104, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 204, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]; - - const promotedBulkActions = [ - { - content: 'Edit customers', - onAction: () => console.log('Todo: implement bulk edit'), - }, - ]; - - const bulkActions = [ - { - content: 'Add tags', - onAction: () => console.log('Todo: implement bulk add tags'), - }, - { - content: 'Remove tags', - onAction: () => console.log('Todo: implement bulk remove tags'), - }, - { - content: 'Delete customers', - onAction: () => console.log('Todo: implement bulk delete'), - }, - ]; - - return ( - - - - ); - - function renderItem(item) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } -} - -export default withPolarisExample(ResourceListWithLoadingExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-multiselect.tsx b/polaris.shopify.com/pages/examples/resource-list-with-multiselect.tsx deleted file mode 100644 index 4b9d9000396..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-multiselect.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListExample() { - const [selectedItems, setSelectedItems] = useState([]); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const items = [ - { - id: 111, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 211, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - { - id: 311, - url: '#', - name: 'Joe Smith', - location: 'Arizona, USA', - }, - { - id: 411, - url: '#', - name: 'Haden Jerado', - location: 'Decatur, USA', - }, - { - id: 511, - url: '#', - name: 'Tom Thommas', - location: 'Florida, USA', - }, - { - id: 611, - url: '#', - name: 'Emily Amrak', - location: 'Texas, USA', - }, - ]; - - const promotedBulkActions = [ - { - content: 'Edit customers', - onAction: () => console.log('Todo: implement bulk edit'), - }, - ]; - - const bulkActions = [ - { - content: 'Add tags', - onAction: () => console.log('Todo: implement bulk add tags'), - }, - { - content: 'Remove tags', - onAction: () => console.log('Todo: implement bulk remove tags'), - }, - { - content: 'Delete customers', - onAction: () => console.log('Todo: implement bulk delete'), - }, - ]; - - return ( - - - - ); - - function renderItem(item, _, index) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } - - function resolveItemIds({id}) { - return id; - } -} - -export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-persistent-item-shortcut-actions.tsx b/polaris.shopify.com/pages/examples/resource-list-with-persistent-item-shortcut-actions.tsx deleted file mode 100644 index df8b3d26edc..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-persistent-item-shortcut-actions.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListExample() { - return ( - - { - const {id, url, name, location, latestOrderUrl} = item; - const media = ; - const shortcutActions = latestOrderUrl - ? [ - { - content: 'View latest order', - accessibilityLabel: `View ${name}’s latest order`, - url: latestOrderUrl, - }, - ] - : null; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - /> -
    - ); -} - -export default withPolarisExample(ResourceListExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-selection-and-no-bulk-actions.tsx b/polaris.shopify.com/pages/examples/resource-list-with-selection-and-no-bulk-actions.tsx deleted file mode 100644 index cd40ebb5a95..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-selection-and-no-bulk-actions.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithSelectionExample() { - const [selectedItems, setSelectedItems] = useState([]); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const items = [ - { - id: 101, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 201, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]; - - return ( - - - - ); - - function renderItem(item) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } -} - -export default withPolarisExample(ResourceListWithSelectionExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-sorting.tsx b/polaris.shopify.com/pages/examples/resource-list-with-sorting.tsx deleted file mode 100644 index ecf6fa256b9..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-sorting.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import {useState} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithSortingExample() { - const [sortValue, setSortValue] = useState('DATE_MODIFIED_DESC'); - - const resourceName = { - singular: 'customer', - plural: 'customers', - }; - - const items = [ - { - id: 106, - url: '#', - name: 'Mae Jemison', - location: 'Decatur, USA', - }, - { - id: 206, - url: '#', - name: 'Ellen Ochoa', - location: 'Los Angeles, USA', - }, - ]; - - return ( - - { - setSortValue(selected); - console.log(`Sort option changed to ${selected}.`); - }} - /> - - ); - - function renderItem(item) { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - } -} - -export default withPolarisExample(ResourceListWithSortingExample); diff --git a/polaris.shopify.com/pages/examples/resource-list-with-total-count.tsx b/polaris.shopify.com/pages/examples/resource-list-with-total-count.tsx deleted file mode 100644 index 198cb1cdaac..00000000000 --- a/polaris.shopify.com/pages/examples/resource-list-with-total-count.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import {LegacyCard, ResourceList, Avatar, ResourceItem, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ResourceListWithTotalItemsCount() { - return ( - - { - const {id, url, name, location} = item; - const media = ; - - return ( - - - {name} - -
    {location}
    -
    - ); - }} - showHeader - totalItemsCount={50} - /> -
    - ); -} - -export default withPolarisExample(ResourceListWithTotalItemsCount); diff --git a/polaris.shopify.com/pages/examples/scrollable-default.tsx b/polaris.shopify.com/pages/examples/scrollable-default.tsx deleted file mode 100644 index 5558bb4b4ef..00000000000 --- a/polaris.shopify.com/pages/examples/scrollable-default.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import {LegacyCard, Scrollable} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ScrollableExample() { - return ( - - -

    - By signing up for the Shopify service (“Service”) or any of the - services of Shopify Inc. (“Shopify”) you are agreeing to be bound by - the following terms and conditions (“Terms of Service”). The Services - offered by Shopify under the Terms of Service include various products - and services to help you create and manage a retail store, whether an - online store (“Online Services”), a physical retail store (“POS - Services”), or both. Any new features or tools which are added to the - current Service shall be also subject to the Terms of Service. You can - review the current version of the Terms of Service at any time at - https://www.shopify.com/legal/terms. Shopify reserves the right to - update and change the Terms of Service by posting updates and changes - to the Shopify website. You are advised to check the Terms of Service - from time to time for any updates or changes that may impact you. -

    -
    -
    - ); -} - -export default withPolarisExample(ScrollableExample); diff --git a/polaris.shopify.com/pages/examples/scrollable-to-child-component.tsx b/polaris.shopify.com/pages/examples/scrollable-to-child-component.tsx deleted file mode 100644 index 1d44267b2cb..00000000000 --- a/polaris.shopify.com/pages/examples/scrollable-to-child-component.tsx +++ /dev/null @@ -1,297 +0,0 @@ -import {LegacyCard, Scrollable} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ScrollableExample() { - return ( - - -
      -
    1. Account Terms
    2. -
    -

    - You must be 18 years or older or at least the age of majority in the - jurisdiction where you reside or from which you use this Service. -

    -

    - To access and use the Services, you must register for a Shopify - account (“Account”) by providing your full legal name, current - address, phone number, a valid email address, and any other - information indicated as required. Shopify may reject your application - for an Account, or cancel an existing Account, for any reason, in our - sole discretion. -

    -

    - You acknowledge that Shopify will use the email address you provide as - the primary method for communication. -

    -

    - You are responsible for keeping your password secure. Shopify cannot - and will not be liable for any loss or damage from your failure to - maintain the security of your Account and password. -

    -

    - You are responsible for all activity and content such as photos, - images, videos, graphics, written content, audio files, code, - information, or data uploaded, collected, generated, stored, - displayed, distributed, transmitted or exhibited on or in connection - with your Account (“Materials”). -

    -

    - A breach or violation of any term in the Terms of Service, including - the AUP, as determined in the sole discretion of Shopify will result - in an immediate termination of your services. -

    -

    Which means

    -

    - You are responsible for your Account and any Materials you upload to - the Shopify Service. Remember that with any violation of these terms - we will cancel your service. -

    - -

    If we need to reach you, we will send you an email.

    - -
      -
    1. Account Activation
    2. -
    - -

    2.1 Shopify Account

    -
    - -

    - Subject to section 2.1.2, the person signing up for the Service will - be the contracting party (“Account Owner”) for the purposes of our - Terms of Service and will be the person who is authorized to use any - corresponding account we may provide to the Account Owner in - connection with the Service. -

    -

    - If you are signing up for the Service on behalf of your employer, your - employer shall be the Account Owner. If you are signing up for the - Service on behalf of your employer, then you represent and warrant - that you have the authority to bind your employer to our Terms of - Service. -

    -

    2.2 PayPal Express Checkout and Shopify Payments Accounts

    - -

    - Upon completion of sign up for the Service, Shopify will create a - PayPal Express Checkout account on your behalf, using your email - address. Depending on your location, Shopify may also create a Shopify - Payments account on your behalf. -

    -

    - You acknowledge that PayPal Express Checkout and/or Shopify Payments - will be your default payments gateway(s) and that it is your sole - responsibility as the Account Owner to activate and maintain these - accounts. If you do not wish to keep either of the payment accounts - active, it is your responsibility to deactivate them. For the - avoidance of doubt, PayPal Express Checkout is a Third Party Service, - as defined in Section 15 of these Terms of Service. -

    -

    2.3 Apple Pay for Safari Account

    - -

    - Upon completion of sign up for the Service, Shopify will create an - Apple Pay for Safari (“Apple Pay”) account on your behalf, using the - URL(s) and business name associated with your Account. Depending on - your location, Shopify may activate your Apple Pay account on your - behalf, otherwise you will be required to activate your Apple Pay - account within your Account admin. If you do not wish to keep your - Apple Pay account active, it is your responsibility to deactivate it. - For the avoidance of doubt, Apple Pay is a Third Party Service, as - defined in Section 15 of these Terms of Service. -

    -

    - If you use an Apple Pay supported payment gateway and your customers - have enabled Apple Pay on their device, customers may purchase goods - and services from your store using Apple Pay. -

    -

    - By using Apple Pay on your store, you are agreeing to be bound by the - Apple Pay Platform Web Merchant Terms and Conditions, as they may be - amended by Apple from time to time. If Apple amends the Apple Pay - Platform Web Merchant Terms and Conditions, the amended and restated - version will be posted here:{' '} - - https://www.shopify.com/legal/apple-pay - - . Such amendments to the Apple Pay Platform Web Merchant Terms are - effective as of the date of posting. Your continued use of Apple Pay - on your store after the amended Apple Pay Platform Web Merchant Terms - are posted constitutes your agreement to, and acceptance of, the - amended Apple Pay Platform Web Merchant Terms. If you do not agree to - any changes to the Apple Pay Platform Web Merchant Terms, de-activate - your Apple Pay account and do not continue to use Apple Pay on your - store. -

    -

    2.4 Google Payment

    - -

    - Upon completion of sign up for the Service, if you have been enrolled - in Shopify Payments, Shopify will also create a Google Payment account - on your behalf. If you do not wish to keep your Google Payment account - active, it is your responsibility to deactivate it. For the avoidance - of doubt, Google Payment is a Third Party Service, as defined in - Section 15 of these Terms of Service. -

    - -

    - If you use a Google Payment supported payment gateway and your - customers have enabled Google Payment, customers may purchase goods - and services from your store using Google Payment. -

    - -

    - By using Google Payment on your store, you are agreeing to be bound by - the Google Payment API Terms of Service, as they may be amended by - Google from time to time. If Google amends the Google Payment API - Terms of Service, the amended and restated version will be posted - here:{' '} - - https://payments.developers.google.com/terms/sellertos - - . Such amendments to the Google Payment API Terms of Service are - effective as of the date of posting. Your continued use of Google - Payment on your store after the amended Google Payment API Terms of - Service are posted constitutes your agreement to, and acceptance of, - the amended Google Payment API Terms of Service. If you do not agree - to any changes to the Google Payment API Terms of Service, de-activate - your Google Payment account and do not continue to use Google Payment - on your store. -

    - -

    2.5 Domain Names

    - -

    - Upon purchasing a domain name through Shopify, domain registration - will be preset to automatically renew each year so long as your - Shopify Account remains active. You acknowledge that it is your sole - responsibility to deactivate the auto-renewal function should you - choose to do so. -

    -

    Which means

    -

    - The person signing up for the Shopify Service is responsible for the - account and is bound by these Terms of Service. If you signup on - behalf of your employer, your employer owns the account and is also - bound by our Terms of Service. -

    - -

    - We automatically create accounts for you to accept payments. You are - responsible for activating and deactivating these accounts. -

    - -

    - Any domain you purchase through us will automatically renew unless you - opt out. -

    - -
      -
    1. General Conditions
    2. -
    -

    - You must read, agree with and accept all of the terms and conditions - contained in these Terms of Service, including the AUP and the Privacy - Policy before you may become a member of Shopify. -

    - -

    - Technical support is only provided to paying Account holders and is - only available via email. -

    -

    - The Terms of Service shall be governed by and interpreted in - accordance with the laws of the Province of Ontario and the laws of - Canada applicable therein, without regard to principles of conflicts - of laws. The parties irrevocably and unconditionally submit to the - exclusive jurisdiction of the courts of the Province of Ontario with - respect to any dispute or claim arising out of or in connection with - the Terms of Service. The United Nations Convention on Contracts for - the International Sale of Goods will not apply to these Terms of - Service and is hereby expressly excluded. -

    -

    - You acknowledge and agree that Shopify may amend these Terms of - Service at any time by posting the relevant amended and restated Terms - of Service on Shopify’s website, available at{' '} - - https://www.shopify.com/legal/terms - {' '} - and such amendments to the Terms of Service are effective as of the - date of posting. Your continued use of the Services after the amended - Terms of Service are posted to Shopify’s website constitutes your - agreement to, and acceptance of, the amended Terms of Service. If you - do not agree to any changes to the Terms of Service, do not continue - to use the Service. -

    -

    - You may not use the Shopify service for any illegal or unauthorized - purpose nor may you, in the use of the Service, violate any laws in - your jurisdiction (including but not limited to copyright laws), the - laws applicable to you in your customer’s jurisdiction, or the laws of - Canada and the Province of Ontario. You will comply with all - applicable laws, rules and regulations in your use of the Service. -

    -

    - You agree not to reproduce, duplicate, copy, sell, resell or exploit - any portion of the Service, use of the Service, or access to the - Service without the express written permission by Shopify. -

    -

    - You shall not purchase search engine or other pay per click keywords - (such as Google AdWords), or domain names that use Shopify or Shopify - trademarks and/or variations and misspellings thereof. -

    -

    - Questions about the Terms of Service should be sent to{' '} - support@shopify.com. -

    -

    - You understand that your Materials (not including credit card - information), may be transferred unencrypted and involve (a) - transmissions over various networks; and (b) changes to conform and - adapt to technical requirements of connecting networks or devices. - Credit Card information is always encrypted during transfer over - networks. -

    -

    - You acknowledge and agree that your use of the Service, including - information transmitted to or stored by Shopify, is governed by its - privacy policy at{' '} - - https://www.shopify.com/legal/privacy - -

    -

    - The Terms of Service may be available in languages other than English. - To the extent of any inconsistencies or conflicts between these - English Terms of Service and Shopify’s Terms of Service available in - another language, the most current English version of the Terms of - Service at{' '} - - https://www.shopify.com/legal/terms - {' '} - will prevail. -

    -

    Which means

    -

    - The Shopify service belongs to us. You are not allowed to rip it off - or use it for any illegal or sketchy purpose. -

    - -

    - If a dispute arises the issue will be dealt with in the Province of - Ontario. -

    - -

    - Your Materials may be transferred unencrypted and may be altered, but - credit card information is always encrypted. -

    - - - ); -} -export default withPolarisExample(ScrollableExample); diff --git a/polaris.shopify.com/pages/examples/select-default.tsx b/polaris.shopify.com/pages/examples/select-default.tsx deleted file mode 100644 index ea080c1f90b..00000000000 --- a/polaris.shopify.com/pages/examples/select-default.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import {Select} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SelectExample() { - const [selected, setSelected] = useState('today'); - - const handleSelectChange = useCallback((value) => setSelected(value), []); - - const options = [ - {label: 'Today', value: 'today'}, - {label: 'Yesterday', value: 'yesterday'}, - {label: 'Last 7 days', value: 'lastWeek'}, - ]; - - return ( - - ); -} - -export default withPolarisExample(SelectExample); diff --git a/polaris.shopify.com/pages/examples/select-with-inline-label.tsx b/polaris.shopify.com/pages/examples/select-with-inline-label.tsx deleted file mode 100644 index 25bb1f570d1..00000000000 --- a/polaris.shopify.com/pages/examples/select-with-inline-label.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import {Select} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function InlineLabelExample() { - const [selected, setSelected] = useState('newestUpdate'); - - const handleSelectChange = useCallback((value) => setSelected(value), []); - - const options = [ - {label: 'Newest update', value: 'newestUpdate'}, - {label: 'Oldest update', value: 'oldestUpdate'}, - {label: 'Most spent', value: 'mostSpent'}, - {label: 'Most orders', value: 'mostOrders'}, - {label: 'Last name A–Z', value: 'lastNameAlpha'}, - {label: 'Last name Z–A', value: 'lastNameReverseAlpha'}, - ]; - - return ( - - ); -} - -export default withPolarisExample(PrefixExample); diff --git a/polaris.shopify.com/pages/examples/select-with-separate-validation-error.tsx b/polaris.shopify.com/pages/examples/select-with-separate-validation-error.tsx deleted file mode 100644 index ce08dfe8d94..00000000000 --- a/polaris.shopify.com/pages/examples/select-with-separate-validation-error.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { - LegacyStack, - FormLayout, - TextField, - Select, - InlineError, - LegacyCard, - Link, - Text, -} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SeparateValidationErrorExample() { - const [weight, setWeight] = useState('12'); - const [unit, setUnit] = useState(''); - - const handleWeightChange = useCallback((value) => setWeight(value), []); - const handleUnitChange = useCallback((value) => setUnit(value), []); - - const unitSelectID = 'unit'; - const errorMessage = generateErrorMessage(); - const formGroupMarkup = ( - - - - - - ); -} - -export default withPolarisExample(ValidationErrorExample); diff --git a/polaris.shopify.com/pages/examples/setting-toggle-default.tsx b/polaris.shopify.com/pages/examples/setting-toggle-default.tsx deleted file mode 100644 index 8183e5a0e06..00000000000 --- a/polaris.shopify.com/pages/examples/setting-toggle-default.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import {SettingToggle, Text} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SettingToggleExample() { - const [active, setActive] = useState(false); - - const handleToggle = useCallback(() => setActive((active) => !active), []); - - const contentStatus = active ? 'Deactivate' : 'Activate'; - const textStatus = active ? 'activated' : 'deactivated'; - - return ( - - This setting is{' '} - - {textStatus} - - . - - ); -} - -export default withPolarisExample(SettingToggleExample); diff --git a/polaris.shopify.com/pages/examples/sheet-default.tsx b/polaris.shopify.com/pages/examples/sheet-default.tsx deleted file mode 100644 index c5e772d2698..00000000000 --- a/polaris.shopify.com/pages/examples/sheet-default.tsx +++ /dev/null @@ -1,150 +0,0 @@ -import { - List, - Button, - Page, - LegacyCard, - Sheet, - Scrollable, - ChoiceList, - Text, -} from '@shopify/polaris'; -import {MobileCancelMajor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SheetExample() { - const [sheetActive, setSheetActive] = useState(true); - const [title, setTitle] = useState('Big yellow socks'); - const [description, setDescription] = useState( - "They’re big, yellow socks. What more could you possibly want from socks? These socks will change your life.\n\nThey’re made from light, hand-loomed cotton that’s so soft, you'll feel like you are walking on a cloud.", - ); - const [salesChannels, setSalesChannels] = useState([ - {value: 'onlineStore', label: 'Online Store'}, - {value: 'facebook', label: 'Facebook'}, - {value: 'googleShopping', label: 'Google shopping'}, - {value: 'facebookMarketing', label: 'Facebook Marketing'}, - ]); - const [selected, setSelected] = useState([]); - - const toggleSheetActive = useCallback( - () => setSheetActive((sheetActive) => !sheetActive), - [], - ); - const handleSelectedChange = useCallback((value) => setSelected(value), []); - const handleTitleChange = useCallback((value) => setTitle(value), []); - const handleDescriptionChange = useCallback( - (value) => setDescription(value), - [], - ); - - const selectedSalesChannels = selected.map((key) => { - return salesChannels.reduce((accumulator, current) => { - accumulator[current.value] = current.label; - return accumulator; - }, {})[key]; - }); - const hasSelectedSalesChannels = selectedSalesChannels.length > 0; - - const salesChannelsCardMarkup = hasSelectedSalesChannels ? ( - - {selectedSalesChannels.map((channel, index) => ( - {channel} - ))} - - ) : ( -
    -

    No sales channels selected

    - -
    - ); - - const salesChannelAction = hasSelectedSalesChannels - ? [ - { - onAction: toggleSheetActive, - content: 'Manage sales channels', - }, - ] - : null; - - return ( - - - {salesChannelsCardMarkup} - - -
    -
    - - Manage sales channels - -
    - - - -
    - - -
    -
    -
    -
    - ); -} - -export default withPolarisExample(SheetExample); diff --git a/polaris.shopify.com/pages/examples/sheet-with-searchable-listbox.tsx b/polaris.shopify.com/pages/examples/sheet-with-searchable-listbox.tsx deleted file mode 100644 index 4047c0b029f..00000000000 --- a/polaris.shopify.com/pages/examples/sheet-with-searchable-listbox.tsx +++ /dev/null @@ -1,385 +0,0 @@ -import React, {useState, useCallback} from 'react'; -import { - TextField, - LegacyStack, - Listbox, - Page, - Sheet, - Scrollable, - AutoSelection, - Icon, - Button, - EmptySearchResult, - TextContainer, - Text, -} from '@shopify/polaris'; -import {MobileCancelMajor, SearchMinor} from '@shopify/polaris-icons'; - -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -const actionValue = '__ACTION__'; - -const segments = [ - { - label: 'All customers', - id: 'gid://shopify/CustomerSegment/1', - value: '0', - }, - { - label: 'VIP customers', - id: 'gid://shopify/CustomerSegment/2', - value: '1', - }, - { - label: 'New customers', - id: 'gid://shopify/CustomerSegment/3', - value: '2', - }, - { - label: 'Abandoned carts - last 30 days', - id: 'gid://shopify/CustomerSegment/4', - value: '3', - }, - { - label: 'Wholesale customers', - id: 'gid://shopify/CustomerSegment/5', - value: '4', - }, - { - label: 'Email subscribers', - id: 'gid://shopify/CustomerSegment/6', - value: '5', - }, - { - label: 'From New York', - id: 'gid://shopify/CustomerSegment/7', - value: '6', - }, - { - label: 'Repeat buyers', - id: 'gid://shopify/CustomerSegment/8', - value: '7', - }, - { - label: 'First time buyers', - id: 'gid://shopify/CustomerSegment/9', - value: '8', - }, - { - label: 'From Canada', - id: 'gid://shopify/CustomerSegment/10', - value: '9', - }, - { - label: 'Bought in last 60 days', - id: 'gid://shopify/CustomerSegment/11', - value: '10', - }, - { - label: 'Bought last BFCM', - id: 'gid://shopify/CustomerSegment/12', - value: '11', - }, -]; - -const lazyLoadSegments = Array.from(Array(100)).map((_, index) => ({ - label: `Other customers ${index + 13}`, - id: `gid://shopify/CustomerSegment/${index + 13}`, - value: `${index + 12}`, -})); - -segments.push(...lazyLoadSegments); - -const interval = 25; - -function SheetWithSearchableListboxExample() { - const [sheetOpen, setSheetOpen] = useState(true); - const [showFooterAction, setShowFooterAction] = useState(true); - const [query, setQuery] = useState(''); - const [lazyLoading, setLazyLoading] = useState(false); - const [willLoadMoreResults, setWillLoadMoreResults] = useState(true); - const [visibleOptionIndex, setVisibleOptionIndex] = useState(6); - const [activeOptionId, setActiveOptionId] = useState(segments[0].id); - const [selectedSegmentIndex, setSelectedSegmentIndex] = useState(0); - const [filteredSegments, setFilteredSegments] = useState([]); - - const handleClickShowAll = () => { - setShowFooterAction(false); - setVisibleOptionIndex(segments.length); - }; - - const handleFilterSegments = (query: string) => { - const nextFilteredSegments = segments.filter((segment) => { - return segment.label - .toLocaleLowerCase() - .includes(query.toLocaleLowerCase().trim()); - }); - - setFilteredSegments(nextFilteredSegments); - }; - - const handleQueryChange = (query: string) => { - setQuery(query); - - if (query.length >= 2) handleFilterSegments(query); - }; - - const handleQueryClear = () => { - handleQueryChange(''); - }; - - const handleResetVisibleOptionIndex = () => { - setVisibleOptionIndex(interval); - }; - - const handleOpenSheet = () => { - setSheetOpen(true); - }; - - const handleCloseSheet = () => { - setSheetOpen(false); - handleQueryChange(''); - handleResetVisibleOptionIndex(); - }; - - const handleSegmentSelect = (segmentIndex: string) => { - if (segmentIndex === actionValue) { - return handleClickShowAll(); - } - - setSelectedSegmentIndex(Number(segmentIndex)); - handleCloseSheet(); - }; - - const handleActiveOptionChange = (_: string, domId: string) => { - setActiveOptionId(domId); - }; - - /* This is just to illustrate lazy loading state vs loading state. This is an example, so we aren't fetching from GraphQL. You'd use `pageInfo.hasNextPage` from your GraphQL query data instead of this fake "willLoadMoreResults" state along with setting `first` your GraphQL query's variables to your app's default max edges limit (e.g., 250). */ - - const handleLazyLoadSegments = () => { - if (willLoadMoreResults && !showFooterAction) { - setLazyLoading(true); - - const options = query ? filteredSegments : segments; - - setTimeout(() => { - const remainingOptionCount = options.length - visibleOptionIndex; - const nextVisibleOptionIndex = - remainingOptionCount >= interval - ? visibleOptionIndex + interval - : visibleOptionIndex + remainingOptionCount; - - setLazyLoading(false); - setVisibleOptionIndex(nextVisibleOptionIndex); - - if (remainingOptionCount <= interval) { - setWillLoadMoreResults(false); - } - }, 1000); - } - }; - - const listboxId = 'SearchableListboxInSheet'; - - /* Your app's feature/context specific activator here */ - const activator = ( - - ); - - const textFieldMarkup = ( -
    - - } - ariaActiveDescendant={activeOptionId} - ariaControls={listboxId} - onChange={handleQueryChange} - onClearButtonClick={handleQueryClear} - /> - -
    - ); - - const segmentOptions = query ? filteredSegments : segments; - - const segmentList = - segmentOptions.length > 0 - ? segmentOptions - .slice(0, visibleOptionIndex) - .map(({label, id, value}) => { - const selected = segments[selectedSegmentIndex].id === id; - - return ( - - - {label} - - - ); - }) - : null; - - const showAllMarkup = showFooterAction ? ( - - Show all 111 segments - - ) : null; - - const lazyLoadingMarkup = lazyLoading ? ( - - ) : null; - - const noResultsMarkup = - segmentOptions.length === 0 ? ( - - ) : null; - - const listboxMarkup = ( -
    - - {segmentList} - {showAllMarkup} - {noResultsMarkup} - {lazyLoadingMarkup} - -
    - ); - - return ( -
    - {activator} - -
    -
    -
    - - Action - -
    - - - Look up customer segmentation membership - - - Look up whether a customer is included in a segment. - - -
    -
    - {textFieldMarkup} - - - {listboxMarkup} - -
    -
    -
    -
    - ); -} - -const StopPropagation = ({children}: React.PropsWithChildren) => { - const stopEventPropagation = (event: React.MouseEvent | React.TouchEvent) => { - event.stopPropagation(); - }; - - return ( -
    - {children} -
    - ); -}; - -export default withPolarisExample(SheetWithSearchableListboxExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-body-text-default.tsx b/polaris.shopify.com/pages/examples/skeleton-body-text-default.tsx deleted file mode 100644 index 5cb6db9d970..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-body-text-default.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonBodyText} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-body-text-single-line-content.tsx b/polaris.shopify.com/pages/examples/skeleton-body-text-single-line-content.tsx deleted file mode 100644 index 69419c8f69b..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-body-text-single-line-content.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonBodyText} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-display-text-extra-large.tsx b/polaris.shopify.com/pages/examples/skeleton-display-text-extra-large.tsx deleted file mode 100644 index dfc849a12fe..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-display-text-extra-large.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonDisplayText} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-display-text-medium-and-large.tsx b/polaris.shopify.com/pages/examples/skeleton-display-text-medium-and-large.tsx deleted file mode 100644 index fa939b4f964..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-display-text-medium-and-large.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonDisplayText} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-display-text-small.tsx b/polaris.shopify.com/pages/examples/skeleton-display-text-small.tsx deleted file mode 100644 index 064398a6e14..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-display-text-small.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonDisplayText} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-page-with-dynamic-content.tsx b/polaris.shopify.com/pages/examples/skeleton-page-with-dynamic-content.tsx deleted file mode 100644 index 86592463c85..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-page-with-dynamic-content.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { - SkeletonPage, - Layout, - LegacyCard, - SkeletonBodyText, - TextContainer, - SkeletonDisplayText, -} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-page-with-static-content.tsx b/polaris.shopify.com/pages/examples/skeleton-page-with-static-content.tsx deleted file mode 100644 index 77b9975a6e4..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-page-with-static-content.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import {SkeletonPage, Layout, LegacyCard, SkeletonBodyText} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-tabs-default.tsx b/polaris.shopify.com/pages/examples/skeleton-tabs-default.tsx deleted file mode 100644 index 693e719ac5e..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-tabs-default.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {LegacyCard, SkeletonTabs} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ( - - - - ); -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-tabs-with-a-custom-count.tsx b/polaris.shopify.com/pages/examples/skeleton-tabs-with-a-custom-count.tsx deleted file mode 100644 index 79feef0019e..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-tabs-with-a-custom-count.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import {LegacyCard, SkeletonTabs} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ( - - - - ); -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-thumbnail-extra-small.tsx b/polaris.shopify.com/pages/examples/skeleton-thumbnail-extra-small.tsx deleted file mode 100644 index de5215fb6e3..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-thumbnail-extra-small.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonThumbnail} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-thumbnail-large.tsx b/polaris.shopify.com/pages/examples/skeleton-thumbnail-large.tsx deleted file mode 100644 index f7fbd1318a5..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-thumbnail-large.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonThumbnail} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-thumbnail-medium.tsx b/polaris.shopify.com/pages/examples/skeleton-thumbnail-medium.tsx deleted file mode 100644 index 1792b2d22c2..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-thumbnail-medium.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonThumbnail} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/skeleton-thumbnail-small.tsx b/polaris.shopify.com/pages/examples/skeleton-thumbnail-small.tsx deleted file mode 100644 index f1448cf4f62..00000000000 --- a/polaris.shopify.com/pages/examples/skeleton-thumbnail-small.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {SkeletonThumbnail} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SkeletonExample() { - return ; -} - -export default withPolarisExample(SkeletonExample); diff --git a/polaris.shopify.com/pages/examples/spinner-default.tsx b/polaris.shopify.com/pages/examples/spinner-default.tsx deleted file mode 100644 index 76f072e9d4d..00000000000 --- a/polaris.shopify.com/pages/examples/spinner-default.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Spinner} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SpinnerExample() { - return ; -} - -export default withPolarisExample(SpinnerExample); diff --git a/polaris.shopify.com/pages/examples/spinner-small.tsx b/polaris.shopify.com/pages/examples/spinner-small.tsx deleted file mode 100644 index 277a61b3364..00000000000 --- a/polaris.shopify.com/pages/examples/spinner-small.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Spinner} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SpinnerExample() { - return ; -} - -export default withPolarisExample(SpinnerExample); diff --git a/polaris.shopify.com/pages/examples/spinner-with-focus-management.tsx b/polaris.shopify.com/pages/examples/spinner-with-focus-management.tsx deleted file mode 100644 index 85e127df3dd..00000000000 --- a/polaris.shopify.com/pages/examples/spinner-with-focus-management.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { - Spinner, - Form, - FormLayout, - TextField, - Button, - LegacyCard, - Tabs, -} from '@shopify/polaris'; -import {useState, useEffect, useCallback, useRef} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SpinnerWithFocusManagement() { - const tabs = useRef([ - { - id: 'all-customers', - content: 'All', - accessibilityLabel: 'All customers', - panelID: 'all-customers-content', - }, - { - id: 'accepts-marketing', - content: 'Accepts marketing', - panelID: 'accepts-marketing-content', - }, - ]); - - const [selected, setSelected] = useState(0); - const [loading, setLoading] = useState(false); - const [value, setValue] = useState(''); - const [textFieldFocused, setTextFieldFocused] = useState(false); - - useEffect(() => { - setTextFieldFocused(!loading); - }, [loading]); - - const handleTabChange = useCallback((selectedTab) => { - setLoading(true); - setSelected(selectedTab); - setTimeout(() => { - setValue(''); - return setLoading(false); - }, 1500); - }, []); - - const handleUrlChange = useCallback((value) => setValue(value), []); - - const handleSubmit = useCallback((_event) => setValue(''), []); - - const label = selected ? 'Marketing' : 'Customers'; - const sectionMarkup = loading ? ( - - ) : ( -
    - - - - -
    - ); - - return ( - - - - {sectionMarkup} - - - - ); -} - -export default withPolarisExample(SpinnerWithFocusManagement); diff --git a/polaris.shopify.com/pages/examples/stack-default.tsx b/polaris.shopify.com/pages/examples/stack-default.tsx deleted file mode 100644 index 639dac7df51..00000000000 --- a/polaris.shopify.com/pages/examples/stack-default.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {Stack, Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function StackExample() { - return ( - - Paid - Processing - Fulfilled - Completed - - ); -} - -export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/pages/examples/stack-fill-available-space-proportionally.tsx b/polaris.shopify.com/pages/examples/stack-fill-available-space-proportionally.tsx deleted file mode 100644 index 572d9af85f2..00000000000 --- a/polaris.shopify.com/pages/examples/stack-fill-available-space-proportionally.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import {Stack, Badge, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function StackExample() { - return ( - - - Order #1136 - - Paid - Fulfilled - - ); -} - -export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/pages/examples/stack-non-wrapping.tsx b/polaris.shopify.com/pages/examples/stack-non-wrapping.tsx deleted file mode 100644 index 0069e4199c3..00000000000 --- a/polaris.shopify.com/pages/examples/stack-non-wrapping.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import {Stack, Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function StackExample() { - return ( - - Paid - Processing - Fulfilled - Completed - - ); -} - -export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/pages/examples/stack-spacing.tsx b/polaris.shopify.com/pages/examples/stack-spacing.tsx deleted file mode 100644 index 7e5bd3535c6..00000000000 --- a/polaris.shopify.com/pages/examples/stack-spacing.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import {Stack, Badge} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function StackExample() { - return ( - - Paid - Fulfilled - - ); -} - -export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/pages/examples/stack-vertical-centering.tsx b/polaris.shopify.com/pages/examples/stack-vertical-centering.tsx deleted file mode 100644 index 5afbf183379..00000000000 --- a/polaris.shopify.com/pages/examples/stack-vertical-centering.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {Stack, Badge, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function StackExample() { - return ( - - - Order -
    - #1136 -
    - was paid -
    - Paid - Fulfilled -
    - ); -} - -export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/pages/examples/stack-where-a-single-item-fills-the-remaining-space.tsx b/polaris.shopify.com/pages/examples/stack-where-a-single-item-fills-the-remaining-space.tsx deleted file mode 100644 index 567327e49b8..00000000000 --- a/polaris.shopify.com/pages/examples/stack-where-a-single-item-fills-the-remaining-space.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import {Stack, Badge, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function StackExample() { - return ( - - - - Order #1136 - - - - Paid - - - Fulfilled - - - ); -} - -export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/pages/examples/stack-where-items-fill-space-evenly.tsx b/polaris.shopify.com/pages/examples/stack-where-items-fill-space-evenly.tsx deleted file mode 100644 index 511f3db5909..00000000000 --- a/polaris.shopify.com/pages/examples/stack-where-items-fill-space-evenly.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import {Stack, Badge, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function StackExample() { - return ( - - - Order #1136 - - Paid - Fulfilled - - ); -} - -export default withPolarisExample(StackExample); diff --git a/polaris.shopify.com/pages/examples/tabs-default.tsx b/polaris.shopify.com/pages/examples/tabs-default.tsx deleted file mode 100644 index 77d9a18d137..00000000000 --- a/polaris.shopify.com/pages/examples/tabs-default.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import {LegacyCard, Tabs} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TabsExample() { - const [selected, setSelected] = useState(0); - - const handleTabChange = useCallback( - (selectedTabIndex) => setSelected(selectedTabIndex), - [], - ); - - const tabs = [ - { - id: 'all-customers-1', - content: 'All', - accessibilityLabel: 'All customers', - panelID: 'all-customers-content-1', - }, - { - id: 'accepts-marketing-1', - content: 'Accepts marketing', - panelID: 'accepts-marketing-content-1', - }, - { - id: 'repeat-customers-1', - content: 'Repeat customers', - panelID: 'repeat-customers-content-1', - }, - { - id: 'prospects-1', - content: 'Prospects', - panelID: 'prospects-content-1', - }, - ]; - - return ( - - - -

    Tab {selected} selected

    -
    -
    -
    - ); -} - -export default withPolarisExample(TabsExample); diff --git a/polaris.shopify.com/pages/examples/tabs-fitted.tsx b/polaris.shopify.com/pages/examples/tabs-fitted.tsx deleted file mode 100644 index 7a116db2a68..00000000000 --- a/polaris.shopify.com/pages/examples/tabs-fitted.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import {LegacyCard, Tabs} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function FittedTabsExample() { - const [selected, setSelected] = useState(0); - - const handleTabChange = useCallback( - (selectedTabIndex) => setSelected(selectedTabIndex), - [], - ); - - const tabs = [ - { - id: 'all-customers-fitted-2', - content: 'All', - accessibilityLabel: 'All customers', - panelID: 'all-customers-fitted-content-2', - }, - { - id: 'accepts-marketing-fitted-2', - content: 'Accepts marketing', - panelID: 'accepts-marketing-fitted-Ccontent-2', - }, - ]; - - return ( - - - -

    Tab {selected} selected

    -
    -
    -
    - ); -} - -export default withPolarisExample(FittedTabsExample); diff --git a/polaris.shopify.com/pages/examples/tabs-with-badge-content.tsx b/polaris.shopify.com/pages/examples/tabs-with-badge-content.tsx deleted file mode 100644 index c8171899dfa..00000000000 --- a/polaris.shopify.com/pages/examples/tabs-with-badge-content.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import {Badge, LegacyCard, Tabs} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TabsWithBadgeExample() { - const [selected, setSelected] = useState(0); - - const handleTabChange = useCallback( - (selectedTabIndex) => setSelected(selectedTabIndex), - [], - ); - - const tabs = [ - { - id: 'all-customers-fitted-3', - content: ( - - All 10+ - - ), - accessibilityLabel: 'All customers', - panelID: 'all-customers-fitted-content-3', - }, - { - id: 'accepts-marketing-fitted-3', - content: ( - - Accepts marketing 4 - - ), - panelID: 'accepts-marketing-fitted-content-3', - }, - ]; - - return ( - - - -

    Tab {selected} selected

    -
    -
    -
    - ); -} - -export default withPolarisExample(TabsWithBadgeExample); diff --git a/polaris.shopify.com/pages/examples/tabs-with-custom-disclosure.tsx b/polaris.shopify.com/pages/examples/tabs-with-custom-disclosure.tsx deleted file mode 100644 index 5869b85bb34..00000000000 --- a/polaris.shopify.com/pages/examples/tabs-with-custom-disclosure.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import {LegacyCard, Tabs} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TabsWithCustomDisclosureExample() { - const [selected, setSelected] = useState(0); - - const handleTabChange = useCallback( - (selectedTabIndex) => setSelected(selectedTabIndex), - [], - ); - - const tabs = [ - { - id: 'all-customers-4', - content: 'All', - accessibilityLabel: 'All customers', - panelID: 'all-customers-content-4', - }, - { - id: 'accepts-marketing-4', - content: 'Accepts marketing', - panelID: 'accepts-marketing-content-4', - }, - { - id: 'repeat-customers-4', - content: 'Repeat customers', - panelID: 'repeat-customers-content-4', - }, - { - id: 'prospects-4', - content: 'Prospects', - panelID: 'prospects-content-4', - }, - ]; - - return ( - - - -

    Tab {selected} selected

    -
    -
    -
    - ); -} - -export default withPolarisExample(TabsWithCustomDisclosureExample); diff --git a/polaris.shopify.com/pages/examples/tag-clickable.tsx b/polaris.shopify.com/pages/examples/tag-clickable.tsx deleted file mode 100644 index d75e3e5c78c..00000000000 --- a/polaris.shopify.com/pages/examples/tag-clickable.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Tag} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TagExample() { - return console.log('Clicked')}>Wholesale; -} - -export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/pages/examples/tag-default.tsx b/polaris.shopify.com/pages/examples/tag-default.tsx deleted file mode 100644 index c4d506ca426..00000000000 --- a/polaris.shopify.com/pages/examples/tag-default.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Tag} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TagExample() { - return Wholesale; -} - -export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/pages/examples/tag-removable-with-link.tsx b/polaris.shopify.com/pages/examples/tag-removable-with-link.tsx deleted file mode 100644 index 6a7d06e5f9e..00000000000 --- a/polaris.shopify.com/pages/examples/tag-removable-with-link.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import {Tag, LegacyStack} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RemovableTagWithLinkExample() { - const [selectedTags, setSelectedTags] = useState([ - 'Rustic', - 'Antique', - 'Vinyl', - 'Refurbished', - ]); - - const removeTag = useCallback( - (tag) => () => { - setSelectedTags((previousTags) => - previousTags.filter((previousTag) => previousTag !== tag), - ); - }, - [], - ); - - const tagMarkup = selectedTags.map((option) => ( - - {option} - - )); - - return {tagMarkup}; -} - -export default withPolarisExample(RemovableTagWithLinkExample); diff --git a/polaris.shopify.com/pages/examples/tag-removable.tsx b/polaris.shopify.com/pages/examples/tag-removable.tsx deleted file mode 100644 index a6e883cd77e..00000000000 --- a/polaris.shopify.com/pages/examples/tag-removable.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import {Tag, LegacyStack} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RemovableTagExample() { - const [selectedTags, setSelectedTags] = useState([ - 'Rustic', - 'Antique', - 'Vinyl', - 'Refurbished', - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ipsum quam. Aliquam fermentum bibendum vestibulum. Vestibulum condimentum luctus metus, sed sagittis magna pellentesque eget. Duis dapibus pretium nisi, et venenatis tortor dignissim ut. Quisque eget lacus ac ex eleifend ultrices. Phasellus facilisis ex sit amet leo elementum condimentum. Ut vel maximus felis. Etiam eget diam eu eros blandit interdum. Sed eu metus sed justo aliquam iaculis ac sit amet ex. Curabitur justo magna, porttitor non pulvinar eu, malesuada at leo. Cras mollis consectetur eros, quis maximus lorem dignissim at. Proin in rhoncus massa. Vivamus lectus nunc, fringilla euismod risus commodo, mattis blandit nulla.', - ]); - - const removeTag = useCallback( - (tag) => () => { - setSelectedTags((previousTags) => - previousTags.filter((previousTag) => previousTag !== tag), - ); - }, - [], - ); - - const tagMarkup = selectedTags.map((option) => ( - - {option} - - )); - - return {tagMarkup}; -} - -export default withPolarisExample(RemovableTagExample); diff --git a/polaris.shopify.com/pages/examples/tag-with-custom-content.tsx b/polaris.shopify.com/pages/examples/tag-with-custom-content.tsx deleted file mode 100644 index e3e85afa8bb..00000000000 --- a/polaris.shopify.com/pages/examples/tag-with-custom-content.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import {Tag, LegacyStack, Icon} from '@shopify/polaris'; -import {WandMinor} from '@shopify/polaris-icons'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TagExample() { - return ( - - - - Wholesale - - - ); -} - -export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/pages/examples/tag-with-link.tsx b/polaris.shopify.com/pages/examples/tag-with-link.tsx deleted file mode 100644 index d93bc1b88d3..00000000000 --- a/polaris.shopify.com/pages/examples/tag-with-link.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {Tag} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TagExample() { - return Wholesale; -} - -export default withPolarisExample(TagExample); diff --git a/polaris.shopify.com/pages/examples/text-align.tsx b/polaris.shopify.com/pages/examples/text-align.tsx deleted file mode 100644 index 76cd1511844..00000000000 --- a/polaris.shopify.com/pages/examples/text-align.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import {Text, LegacyStack} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextExample() { - return ( - - - Manage your Shopify store on-the-go with real-time notifications, access - to your dashboard, and order management, all from your smartphone. - - - Manage your Shopify store on-the-go with real-time notifications, access - to your dashboard, and order management, all from your smartphone. - - - Manage your Shopify store on-the-go with real-time notifications, access - to your dashboard, and order management, all from your smartphone. - - - Manage your Shopify store on-the-go with real-time notifications, access - to your dashboard, and order management, all from your smartphone. - - - ); -} - -export default withPolarisExample(TextExample); diff --git a/polaris.shopify.com/pages/examples/text-body.tsx b/polaris.shopify.com/pages/examples/text-body.tsx deleted file mode 100644 index d2387094260..00000000000 --- a/polaris.shopify.com/pages/examples/text-body.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Text, LegacyStack} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextExample() { - return ( - - - Shopify POS is the easiest way to sell your products in person. - Available for iPad, iPhone, and Android. - - - Shopify POS is the easiest way to sell your products in person. - Available for iPad, iPhone, and Android. - - - Shopify POS is the easiest way to sell your products in person. - Available for iPad, iPhone, and Android. - - - ); -} - -export default withPolarisExample(TextExample); diff --git a/polaris.shopify.com/pages/examples/text-color.tsx b/polaris.shopify.com/pages/examples/text-color.tsx deleted file mode 100644 index 85e1e474bb4..00000000000 --- a/polaris.shopify.com/pages/examples/text-color.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import {Text, LegacyStack} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextExample() { - return ( - - - Use to de-emphasize a piece of text that is less important to merchants - than other nearby text. May also be used to indicate when normal content - is absent, for example, “No supplier listed”. Don’t use only for - aesthetic effect. - - - Use in combination with a symbol showing an increasing value to indicate - an upward trend. - - - Use to denote something that needs attention, or that merchants need to - take action on. - - - Use in combination with a symbol showing a decreasing value to indicate - a downward trend. - - - ); -} - -export default withPolarisExample(TextExample); diff --git a/polaris.shopify.com/pages/examples/text-container-default.tsx b/polaris.shopify.com/pages/examples/text-container-default.tsx deleted file mode 100644 index 43c04f43484..00000000000 --- a/polaris.shopify.com/pages/examples/text-container-default.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import {TextContainer, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextContainerExample() { - return ( - - - Install the Shopify POS App - -

    - Shopify POS is the easiest way to sell your products in person. - Available for iPad, iPhone, and Android. -

    -
    - ); -} - -export default withPolarisExample(TextContainerExample); diff --git a/polaris.shopify.com/pages/examples/text-container-loose.tsx b/polaris.shopify.com/pages/examples/text-container-loose.tsx deleted file mode 100644 index f53a0ccd218..00000000000 --- a/polaris.shopify.com/pages/examples/text-container-loose.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {TextContainer} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextContainerExample() { - return ( - -

    - Manage your Shopify store on-the-go with real-time notifications, access - to your dashboard, and order management, all from your smartphone. -

    -

    - Shopify POS is the fastest and easiest way to start accepting Visa, - Mastercard, American Express, and Discover right from your smartphone or - tablet. -

    -
    - ); -} - -export default withPolarisExample(TextContainerExample); diff --git a/polaris.shopify.com/pages/examples/text-container-tight.tsx b/polaris.shopify.com/pages/examples/text-container-tight.tsx deleted file mode 100644 index 2a47be251a9..00000000000 --- a/polaris.shopify.com/pages/examples/text-container-tight.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import {TextContainer, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextContainerExample() { - return ( - - - Install the Shopify POS App - -

    - Shopify POS is the easiest way to sell your products in person. - Available for iPad, iPhone, and Android. -

    -
    - ); -} - -export default withPolarisExample(TextContainerExample); diff --git a/polaris.shopify.com/pages/examples/text-field-default.tsx b/polaris.shopify.com/pages/examples/text-field-default.tsx deleted file mode 100644 index b0e8c2ef688..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-default.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextFieldExample() { - const [value, setValue] = useState('Jaded Pixel'); - - const handleChange = useCallback((newValue) => setValue(newValue), []); - - return ( - - ); -} - -export default withPolarisExample(TextFieldExample); diff --git a/polaris.shopify.com/pages/examples/text-field-disabled.tsx b/polaris.shopify.com/pages/examples/text-field-disabled.tsx deleted file mode 100644 index deb00fe8873..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-disabled.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextFieldExample() { - return ; -} - -export default withPolarisExample(TextFieldExample); diff --git a/polaris.shopify.com/pages/examples/text-field-email.tsx b/polaris.shopify.com/pages/examples/text-field-email.tsx deleted file mode 100644 index b69de4165db..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-email.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function EmailFieldExample() { - const [value, setValue] = useState('bernadette.lapresse@jadedpixel.com'); - - const handleChange = useCallback((newValue) => setValue(newValue), []); - - return ( - - ); -} - -export default withPolarisExample(EmailFieldExample); diff --git a/polaris.shopify.com/pages/examples/text-field-multiline.tsx b/polaris.shopify.com/pages/examples/text-field-multiline.tsx deleted file mode 100644 index a8fe0774cdc..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-multiline.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultilineFieldExample() { - const [value, setValue] = useState('1776 Barnes Street\nOrlando, FL 32801'); - - const handleChange = useCallback((newValue) => setValue(newValue), []); - - return ( - - ); -} - -export default withPolarisExample(MultilineFieldExample); diff --git a/polaris.shopify.com/pages/examples/text-field-number.tsx b/polaris.shopify.com/pages/examples/text-field-number.tsx deleted file mode 100644 index ace2651cc2d..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-number.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function NumberFieldExample() { - const [value, setValue] = useState('1'); - - const handleChange = useCallback((newValue) => setValue(newValue), []); - - return ( - - ); -} - -export default withPolarisExample(NumberFieldExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-character-count.tsx b/polaris.shopify.com/pages/examples/text-field-with-character-count.tsx deleted file mode 100644 index 5b304f64eae..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-character-count.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextFieldWithCharacterCountExample() { - const [textFieldValue, setTextFieldValue] = useState('Jaded Pixel'); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(TextFieldWithCharacterCountExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-clear-button.tsx b/polaris.shopify.com/pages/examples/text-field-with-clear-button.tsx deleted file mode 100644 index 9d4702b7d80..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-clear-button.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextFieldWithClearButtonExample() { - const [textFieldValue, setTextFieldValue] = useState('Jaded Pixel'); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - const handleClearButtonClick = useCallback(() => setTextFieldValue(''), []); - - return ( - - ); -} - -export default withPolarisExample(TextFieldWithClearButtonExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-connected-fields.tsx b/polaris.shopify.com/pages/examples/text-field-with-connected-fields.tsx deleted file mode 100644 index 3d1bc2747ca..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-connected-fields.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import {TextField, Select, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ConnectedFieldsExample() { - const [textFieldValue, setTextFieldValue] = useState('10.6'); - const [selectValue, setSelectValue] = useState('kg'); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - const handleSelectChange = useCallback((value) => setSelectValue(value), []); - - return ( - - } - connectedRight={} - /> - ); -} - -export default withPolarisExample(ConnectedFieldsExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-help-text.tsx b/polaris.shopify.com/pages/examples/text-field-with-help-text.tsx deleted file mode 100644 index f0d8670519b..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-help-text.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function HelpTextExample() { - const [textFieldValue, setTextFieldValue] = useState( - 'bernadette.lapresse@jadedpixel.com', - ); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(HelpTextExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-hidden-label.tsx b/polaris.shopify.com/pages/examples/text-field-with-hidden-label.tsx deleted file mode 100644 index 3a86e4216b5..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-hidden-label.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import {FormLayout, ChoiceList, TextField, Select} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function HiddenLabelExample() { - const [value, setValue] = useState('12'); - const [selected, setSelected] = useState('yes'); - - const handleTextChange = useCallback((newValue) => setValue(newValue), []); - - const handleChoiceChange = useCallback( - (selections) => setSelected(selections[0]), - [], - ); - - return ( - - - - } - /> - - ); -} - -export default withPolarisExample(HiddenLabelExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-inline-suggestion.tsx b/polaris.shopify.com/pages/examples/text-field-with-inline-suggestion.tsx deleted file mode 100644 index d836fcd72aa..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-inline-suggestion.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useEffect, useCallback, useMemo} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextFieldWithSuggestionExample() { - const suggestions = useMemo( - () => [ - 'Alabama', - 'Alaska', - 'American Samoa', - 'Arizona', - 'Arkansas', - 'California', - 'Colorado', - 'Connecticut', - 'Delaware', - 'District of Columbia', - 'Florida', - 'Georgia', - 'Guam', - 'Hawaii', - 'Idaho', - 'Illinois', - 'Indiana', - 'Iowa', - 'Kansas', - 'Kentucky', - 'Louisiana', - 'Maine', - 'Maryland', - 'Massachusetts', - 'Michigan', - 'Minnesota', - 'Minor Outlying Islands', - 'Mississippi', - 'Missouri', - 'Montana', - 'Nebraska', - 'Nevada', - 'New Hampshire', - 'New Jersey', - 'New Mexico', - 'New York', - 'North Carolina', - 'North Dakota', - 'Northern Mariana Islands', - 'Ohio', - 'Oklahoma', - 'Oregon', - 'Pennsylvania', - 'Puerto Rico', - 'Rhode Island', - 'South Carolina', - 'South Dakota', - 'Tennessee', - 'Texas', - 'U.S. Virgin Islands', - 'Utah', - 'Vermont', - 'Virginia', - 'Washington', - 'West Virginia', - 'Wisconsin', - 'Wyoming', - ], - [], - ); - - const [value, setValue] = useState(''); - const [suggestion, setSuggestion] = useState(''); - - const handleSuggestion = useCallback( - (nextValue) => { - const nextSuggestion = suggestions.find((suggestion) => - suggestion.toLowerCase().startsWith(nextValue.toLowerCase()), - ); - - if (nextSuggestion) setSuggestion(nextSuggestion); - }, - [suggestions], - ); - - useEffect(() => { - if (value !== suggestion) handleSuggestion(value); - }, [handleSuggestion, suggestion, value]); - - const handleChange = useCallback((value) => { - setValue(value); - setSuggestion(''); - }, []); - - const handleKeyDown = useCallback( - (event) => { - if (event.key === 'Enter') { - handleChange(suggestion); - } - }, - [suggestion, handleChange], - ); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(TextFieldWithSuggestionExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-label-action.tsx b/polaris.shopify.com/pages/examples/text-field-with-label-action.tsx deleted file mode 100644 index c7e63510a2d..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-label-action.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function LabelActionExample() { - const [textFieldValue, setTextFieldValue] = useState('6201.11.0000'); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(LabelActionExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-monospaced-font.tsx b/polaris.shopify.com/pages/examples/text-field-with-monospaced-font.tsx deleted file mode 100644 index 785b4f177b6..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-monospaced-font.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TextFieldWithMonospacedFontExample() { - const [textFieldValue, setTextFieldValue] = useState('Jaded Pixel'); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(TextFieldWithMonospacedFontExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-placeholder-text.tsx b/polaris.shopify.com/pages/examples/text-field-with-placeholder-text.tsx deleted file mode 100644 index f21844b08bf..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-placeholder-text.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function PlaceholderExample() { - const [textFieldValue, setTextFieldValue] = useState(''); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(PlaceholderExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-prefix-or-suffix.tsx b/polaris.shopify.com/pages/examples/text-field-with-prefix-or-suffix.tsx deleted file mode 100644 index 1321b9bc33c..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-prefix-or-suffix.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function PrefixExample() { - const [textFieldValue, setTextFieldValue] = useState('2.00'); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - return ( - - ); -} - -export default withPolarisExample(PrefixExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-right-aligned-text.tsx b/polaris.shopify.com/pages/examples/text-field-with-right-aligned-text.tsx deleted file mode 100644 index c17289046d6..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-right-aligned-text.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import {LegacyStack, TextField} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function RightAlignExample() { - const [textFieldValue, setTextFieldValue] = useState('1'); - - const handleTextFieldChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - return ( - - Price - - - ); -} - -export default withPolarisExample(RightAlignExample); diff --git a/polaris.shopify.com/pages/examples/text-field-with-separate-validation-error.tsx b/polaris.shopify.com/pages/examples/text-field-with-separate-validation-error.tsx deleted file mode 100644 index 09804b37690..00000000000 --- a/polaris.shopify.com/pages/examples/text-field-with-separate-validation-error.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { - LegacyStack, - FormLayout, - Select, - TextField, - InlineError, - Button, - LegacyCard, -} from '@shopify/polaris'; -import {DeleteMinor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function SeparateValidationErrorExample() { - const [textFieldValue, setTextFieldValue] = useState(''); - const [selectTypeValue, setSelectTypeValue] = useState('Product type'); - const [selectConditionValue, setSelectConditionValue] = - useState('is equal to'); - - const handleTextFieldValueChange = useCallback( - (value) => setTextFieldValue(value), - [], - ); - - const handleSelectTypeChange = useCallback( - (value) => setSelectTypeValue(value), - [], - ); - - const handleSelectConditionChange = useCallback( - (value) => setSelectConditionValue(value), - [], - ); - - const textFieldID = 'ruleContent'; - const isInvalid = isValueInvalid(textFieldValue); - const errorMessage = isInvalid - ? 'Enter 3 or more characters for product type is equal to' - : ''; - - const formGroupMarkup = ( - - - - - - - - -
    - -
    -
    - - {toastMarkup} - - -
    - ); -} - -export default withPolarisExample(ToastExample); diff --git a/polaris.shopify.com/pages/examples/toast-error.tsx b/polaris.shopify.com/pages/examples/toast-error.tsx deleted file mode 100644 index 56ddc068b4b..00000000000 --- a/polaris.shopify.com/pages/examples/toast-error.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import {Toast, Frame, Page, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ErrorToastExample() { - const [active, setActive] = useState(false); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const toastMarkup = active ? ( - - ) : null; - - return ( -
    - - - - {toastMarkup} - - -
    - ); -} - -export default withPolarisExample(ErrorToastExample); diff --git a/polaris.shopify.com/pages/examples/toast-multiple-messages.tsx b/polaris.shopify.com/pages/examples/toast-multiple-messages.tsx deleted file mode 100644 index d732fb331d3..00000000000 --- a/polaris.shopify.com/pages/examples/toast-multiple-messages.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import {Toast, Frame, Page, ButtonGroup, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function MultipleToastExample() { - const [activeOne, setActiveOne] = useState(false); - const [activeTwo, setActiveTwo] = useState(false); - - const toggleActiveOne = useCallback( - () => setActiveOne((activeOne) => !activeOne), - [], - ); - - const toggleActiveTwo = useCallback( - () => setActiveTwo((activeTwo) => !activeTwo), - [], - ); - - const toastMarkup1 = activeOne ? ( - - ) : null; - - const toastMarkup2 = activeTwo ? ( - - ) : null; - - return ( -
    - - - - - - - {toastMarkup1} - {toastMarkup2} - - -
    - ); -} - -export default withPolarisExample(MultipleToastExample); diff --git a/polaris.shopify.com/pages/examples/toast-with-action.tsx b/polaris.shopify.com/pages/examples/toast-with-action.tsx deleted file mode 100644 index 73e7e9b3b06..00000000000 --- a/polaris.shopify.com/pages/examples/toast-with-action.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import {Toast, Frame, Page, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ToastWithActionExample() { - const [active, setActive] = useState(false); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const toastMarkup = active ? ( - {}, - }} - duration={10000} - onDismiss={toggleActive} - /> - ) : null; - - return ( -
    - - - - {toastMarkup} - - -
    - ); -} - -export default withPolarisExample(ToastWithActionExample); diff --git a/polaris.shopify.com/pages/examples/toast-with-custom-duration.tsx b/polaris.shopify.com/pages/examples/toast-with-custom-duration.tsx deleted file mode 100644 index 581a7c7f437..00000000000 --- a/polaris.shopify.com/pages/examples/toast-with-custom-duration.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import {Toast, Frame, Page, Button} from '@shopify/polaris'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function ToastWithCustomDurationExample() { - const [active, setActive] = useState(false); - - const toggleActive = useCallback(() => setActive((active) => !active), []); - - const toastMarkup = active ? ( - - ) : null; - - return ( -
    - - - - {toastMarkup} - - -
    - ); -} - -export default withPolarisExample(ToastWithCustomDurationExample); diff --git a/polaris.shopify.com/pages/examples/tooltip-default.tsx b/polaris.shopify.com/pages/examples/tooltip-default.tsx deleted file mode 100644 index 21d500dc8eb..00000000000 --- a/polaris.shopify.com/pages/examples/tooltip-default.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import {Tooltip, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TooltipExample() { - return ( -
    - - - Order #1001 - - -
    - ); -} - -export default withPolarisExample(TooltipExample); diff --git a/polaris.shopify.com/pages/examples/tooltip-visible-only-with-child-interaction.tsx b/polaris.shopify.com/pages/examples/tooltip-visible-only-with-child-interaction.tsx deleted file mode 100644 index 383fe6ec457..00000000000 --- a/polaris.shopify.com/pages/examples/tooltip-visible-only-with-child-interaction.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import {ButtonGroup, Tooltip, Button, TextField} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TooltipExample() { - return ( -
    - - - - - - - - - - - - - - - -
    - ); -} - -export default withPolarisExample(TooltipExample); diff --git a/polaris.shopify.com/pages/examples/tooltip-with-suffix.tsx b/polaris.shopify.com/pages/examples/tooltip-with-suffix.tsx deleted file mode 100644 index af7cca586d8..00000000000 --- a/polaris.shopify.com/pages/examples/tooltip-with-suffix.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Tooltip, Button, Inline, Text} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TooltipExample() { - return ( -
    - - Bold - - ⌘B - - - } - > - - -
    - ); -} - -export default withPolarisExample(TooltipExample); diff --git a/polaris.shopify.com/pages/examples/top-bar-default.tsx b/polaris.shopify.com/pages/examples/top-bar-default.tsx deleted file mode 100644 index 47d400ca48e..00000000000 --- a/polaris.shopify.com/pages/examples/top-bar-default.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import {TopBar, ActionList, Icon, Frame, Text} from '@shopify/polaris'; -import {ArrowLeftMinor, QuestionMarkMajor} from '@shopify/polaris-icons'; -import {useState, useCallback} from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function TopBarExample() { - const [isUserMenuOpen, setIsUserMenuOpen] = useState(false); - const [isSecondaryMenuOpen, setIsSecondaryMenuOpen] = useState(false); - const [isSearchActive, setIsSearchActive] = useState(false); - const [searchValue, setSearchValue] = useState(''); - - const toggleIsUserMenuOpen = useCallback( - () => setIsUserMenuOpen((isUserMenuOpen) => !isUserMenuOpen), - [], - ); - - const toggleIsSecondaryMenuOpen = useCallback( - () => setIsSecondaryMenuOpen((isSecondaryMenuOpen) => !isSecondaryMenuOpen), - [], - ); - - const handleSearchResultsDismiss = useCallback(() => { - setIsSearchActive(false); - setSearchValue(''); - }, []); - - const handleSearchChange = useCallback((value) => { - setSearchValue(value); - setIsSearchActive(value.length > 0); - }, []); - - const handleNavigationToggle = useCallback(() => { - console.log('toggle navigation visibility'); - }, []); - - const logo = { - width: 124, - topBarSource: - 'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999', - url: '#', - accessibilityLabel: 'Jaded Pixel', - }; - - const userMenuMarkup = ( - - ); - - const searchResultsMarkup = ( - - ); - - const searchFieldMarkup = ( - - ); - - const secondaryMenuMarkup = ( - - - - Secondary menu - - - } - open={isSecondaryMenuOpen} - onOpen={toggleIsSecondaryMenuOpen} - onClose={toggleIsSecondaryMenuOpen} - actions={[ - { - items: [{content: 'Community forums'}], - }, - ]} - /> - ); - - const topBarMarkup = ( - - ); - - return ( -
    - -
    - ); -} - -export default withPolarisExample(TopBarExample); diff --git a/polaris.shopify.com/pages/examples/video-thumbnail-default.tsx b/polaris.shopify.com/pages/examples/video-thumbnail-default.tsx deleted file mode 100644 index 3c871f6dd6a..00000000000 --- a/polaris.shopify.com/pages/examples/video-thumbnail-default.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {MediaCard, VideoThumbnail} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function VideoThumbnailExample() { - return ( - {}, - }} - description={`In this course, you’ll learn how the Kular family turned their mom’s recipe book into a global business.`} - popoverActions={[{content: 'Dismiss', onAction: () => {}}]} - > - - - ); -} - -export default withPolarisExample(() => ); diff --git a/polaris.shopify.com/pages/examples/video-thumbnail-with-progress.tsx b/polaris.shopify.com/pages/examples/video-thumbnail-with-progress.tsx deleted file mode 100644 index 631ed7f6a01..00000000000 --- a/polaris.shopify.com/pages/examples/video-thumbnail-with-progress.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import {MediaCard, VideoThumbnail} from '@shopify/polaris'; -import React from 'react'; -import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; - -function VideoThumbnailExample() { - return ( - {}, - }} - description={`In this course, you’ll learn how the Kular family turned their mom’s recipe book into a global business.`} - popoverActions={[{content: 'Dismiss', onAction: () => {}}]} - > - - - ); -} - -export default withPolarisExample(VideoThumbnailExample); diff --git a/polaris.shopify.com/scripts/fix-examples.mjs b/polaris.shopify.com/scripts/fix-examples.mjs new file mode 100644 index 00000000000..08d73b2b228 --- /dev/null +++ b/polaris.shopify.com/scripts/fix-examples.mjs @@ -0,0 +1,18 @@ +import path from 'path'; +import fs from 'fs'; +import globby from 'globby'; + +const pathGlob = path.join(process.cwd(), 'app/examples/**/page.tsx'); +const filePaths = globby.sync(pathGlob); + +filePaths.forEach((filePath) => { + let fileContent = fs.readFileSync(filePath, 'utf-8'); + if (!fileContent.includes('use client')) { + fileContent = `'use client';\n\n${fileContent}`; + } + fileContent = fileContent.replace( + "{withPolarisExample} from '../../src", + "{withPolarisExample} from '../../../src", + ); + fs.writeFileSync(filePath, fileContent, 'utf-8'); +}); diff --git a/polaris.shopify.com/scripts/gen-site-map.mjs b/polaris.shopify.com/scripts/gen-site-map.mjs index ba101ce1b4b..84a206eaa68 100644 --- a/polaris.shopify.com/scripts/gen-site-map.mjs +++ b/polaris.shopify.com/scripts/gen-site-map.mjs @@ -4,9 +4,13 @@ import path from 'path'; const genSiteMap = async () => { const outputFile = 'public/sitemap.xml'; + console.log('⚙️ Generating sitemap.xml...'); + console.log('⚙️ Starting dev server using next dev...'); const nextBin = path.join(process.cwd(), 'node_modules/.bin/next'); const server = execa(nextBin, ['dev']); + server.stdout.pipe(process.stdout); + const {stdout} = await execa('npx', [ 'get-site-urls', 'http://localhost:3000', @@ -18,4 +22,10 @@ const genSiteMap = async () => { await server.kill(); }; +function sleep(ms) { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); +} + export default genSiteMap; diff --git a/polaris.shopify.com/scripts/move-examples.mjs b/polaris.shopify.com/scripts/move-examples.mjs new file mode 100644 index 00000000000..6e8fdd47154 --- /dev/null +++ b/polaris.shopify.com/scripts/move-examples.mjs @@ -0,0 +1,19 @@ +import path from 'path'; +import fs from 'fs'; +import globby from 'globby'; + +const pathGlob = path.join(process.cwd(), 'pages/examples/*.tsx'); + +const filePaths = globby.sync(pathGlob); + +filePaths.forEach((filePath) => { + const segments = filePath.split('/'); + const dir = `app/examples/${segments[segments.length - 1].replace( + '.tsx', + '', + )}`; + console.log({dir}); + fs.mkdirSync(dir); + const newPath = `${dir}/page.tsx`; + fs.copyFileSync(filePath, newPath); +}); diff --git a/polaris.shopify.com/src/components/Container/Container.module.scss b/polaris.shopify.com/src/components/Container/Container.module.scss index 223908d3232..c2ba786597e 100644 --- a/polaris.shopify.com/src/components/Container/Container.module.scss +++ b/polaris.shopify.com/src/components/Container/Container.module.scss @@ -5,7 +5,7 @@ margin-left: auto; margin-right: auto; max-width: $pageMaxWidth; - padding: 0 1.5rem; + padding: 0 2.5rem; // The header is always a fixed height // This is added in order to ensure native browser scroll-snap behaviour in our content area // Also accounts for the height of the header element. diff --git a/polaris.shopify.com/src/components/Grid/Grid.tsx b/polaris.shopify.com/src/components/Grid/Grid.tsx index 48d18d426d5..6d5059e0798 100644 --- a/polaris.shopify.com/src/components/Grid/Grid.tsx +++ b/polaris.shopify.com/src/components/Grid/Grid.tsx @@ -44,11 +44,17 @@ export const Grid = forwardRef( style={{ // @ts-expect-error The types for `style` don't support css vars '--props-grid-gap': - typeof gap !== 'undefined' ? `var(--p-space-${gap})` : undefined, + typeof gap !== 'undefined' + ? `${0.25 * parseFloat(gap)}rem)` + : undefined, '--props-grid-gap-x': - typeof gapX !== 'undefined' ? `var(--p-space-${gapX})` : undefined, + typeof gapX !== 'undefined' + ? `${0.25 * parseFloat(gapX)}rem)` + : undefined, '--props-grid-gap-y': - typeof gapY !== 'undefined' ? `var(--p-space-${gapY})` : undefined, + typeof gapY !== 'undefined' + ? `${0.25 * parseFloat(gapY)}rem)` + : undefined, '--props-grid-item-min-width': itemMinWidth, }} className={[styles.Grid, condensed && styles.condensed, className]} diff --git a/polaris.shopify.com/src/components/PatternPage/PatternPage.module.scss b/polaris.shopify.com/src/components/PatternPage/PatternPage.module.scss index 4efa904128a..4b01dc54e20 100644 --- a/polaris.shopify.com/src/components/PatternPage/PatternPage.module.scss +++ b/polaris.shopify.com/src/components/PatternPage/PatternPage.module.scss @@ -7,7 +7,7 @@ } .TabGroup { - --tab-background: var(--p-surface-subdued); + --tab-background: var(--surface-subdued); --tab-background-pressed: rgba(250, 250, 250, 1); --tab-background-hover: rgba(241, 241, 241, 1); --tab-border: 1px solid #c9cccf; @@ -90,7 +90,7 @@ font-size: var(--font-size-400); font-weight: var(--font-weight-500); line-height: 1.33; - color: var(--p-text-disabled); + color: var(--text-subdied); &[aria-selected='true'] { color: var(--text-strong); @@ -136,14 +136,14 @@ .HowItHelps { .ImageWrapper { display: block; - border: 1px solid var(--p-border-subdued); + border: 1px solid var(--border-color); position: relative; flex: auto; overflow: hidden; aspect-ratio: 361.9/180.9; width: 100%; border-radius: 0.25rem; - background: var(--p-surface-depressed); + background: var(--surface-subdued); > img { width: 100%; object-fit: fill; @@ -174,8 +174,8 @@ .UsageGuidelinesGrid { display: grid; - column-gap: var(--p-space-4); - row-gap: var(--p-space-8); + column-gap: 1rem; + row-gap: 2rem; --txt-column-width: 35%; /* @@ -205,7 +205,7 @@ @media screen and (max-width: $breakpointMobile) { grid-template-columns: 1fr; - row-gap: var(--p-space-4); + row-gap: 1rem; } .UsageGuidelinesRow { @@ -215,7 +215,7 @@ .ImageWrapper { aspect-ratio: 485/315; position: relative; - background: var(--p-surface-depressed); + background: var(--surface-subdued); display: block; overflow: hidden; > img { diff --git a/polaris.shopify.com/src/components/PatternsExample/PatternsExample.module.scss b/polaris.shopify.com/src/components/PatternsExample/PatternsExample.module.scss index 6e875d56adb..91bd6a90899 100644 --- a/polaris.shopify.com/src/components/PatternsExample/PatternsExample.module.scss +++ b/polaris.shopify.com/src/components/PatternsExample/PatternsExample.module.scss @@ -10,7 +10,7 @@ .SpecificityBuster { .ExampleWrapper { box-shadow: none; - border: 1px solid var(--p-border-subdued); + border: 1px solid var(--border-color); @media screen and (max-width: $breakpointMobile) { border-left: 0; border-right: 0; diff --git a/polaris.shopify.com/src/components/PatternsPage/PatternsPage.module.scss b/polaris.shopify.com/src/components/PatternsPage/PatternsPage.module.scss index e09d52445d6..d5ddf7a1747 100644 --- a/polaris.shopify.com/src/components/PatternsPage/PatternsPage.module.scss +++ b/polaris.shopify.com/src/components/PatternsPage/PatternsPage.module.scss @@ -6,7 +6,7 @@ gap: 0.5em; } .UpdateBanner { - width: 50%; + width: 60%; @media screen and (max-width: $breakpointDesktopSmall) { width: 100%; } @@ -18,7 +18,7 @@ border-bottom-right-radius: 0; border-bottom-left-radius: 0; overflow: hidden; - background: var(--p-surface-neutral-subdued); + background: var(--surface-subdued); padding: 0 9%; display: flex; align-items: flex-end; @@ -27,11 +27,11 @@ .PreviewInner { flex-grow: 1; aspect-ratio: inherit; - border: 1.4px var(--p-border-subdued); + border: 1px var(--border-color); border-radius: var(--border-radius-600); border-bottom-right-radius: 0; border-bottom-left-radius: 0; overflow: hidden; - background: var(--p-surface-subdued); + background: var(--surface-subdued); box-shadow: 0px 0px 3px 0px rgba(31, 33, 36, 0.24); } diff --git a/polaris.shopify.com/src/components/Stack/Stack.module.scss b/polaris.shopify.com/src/components/Stack/Stack.module.scss index 646d5939a62..5a0d8bff706 100644 --- a/polaris.shopify.com/src/components/Stack/Stack.module.scss +++ b/polaris.shopify.com/src/components/Stack/Stack.module.scss @@ -1,7 +1,7 @@ .Stack { display: flex; flex-direction: column; - gap: var(--stack-gap-prop, var(--p-space-0)); + gap: var(--stack-gap-prop, 0); } .Row { diff --git a/polaris.shopify.com/src/components/Stack/index.tsx b/polaris.shopify.com/src/components/Stack/index.tsx index d517434cff4..9ad95a3d4ea 100644 --- a/polaris.shopify.com/src/components/Stack/index.tsx +++ b/polaris.shopify.com/src/components/Stack/index.tsx @@ -15,7 +15,7 @@ export const Stack = forwardRef( style={{ // @ts-expect-error The types for `style` don't support css vars for // some reason - '--stack-gap-prop': `var(--p-space-${gap})`, + '--stack-gap-prop': `${gap * 0.25}rem`, ...style, }} {...props} diff --git a/polaris.shopify.com/src/components/ThumbnailPreview/ThumbnailPreview.module.scss b/polaris.shopify.com/src/components/ThumbnailPreview/ThumbnailPreview.module.scss index a48c273d366..548fbbb2a64 100644 --- a/polaris.shopify.com/src/components/ThumbnailPreview/ThumbnailPreview.module.scss +++ b/polaris.shopify.com/src/components/ThumbnailPreview/ThumbnailPreview.module.scss @@ -2,6 +2,6 @@ aspect-ratio: 16/9; border-radius: var(--border-radius-600); overflow: hidden; - background: var(--p-surface-neutral-subdued); + background: var(--surface-subdued); position: relative; } diff --git a/polaris.shopify.com/src/components/TipBanner/TipBanner.module.scss b/polaris.shopify.com/src/components/TipBanner/TipBanner.module.scss index 44b05db25b1..a19413c01f0 100644 --- a/polaris.shopify.com/src/components/TipBanner/TipBanner.module.scss +++ b/polaris.shopify.com/src/components/TipBanner/TipBanner.module.scss @@ -1,8 +1,8 @@ .TipBanner { - padding: var(--p-space-4) var(--p-space-6); - background: var(--p-surface-highlight-subdued); - border-radius: var(--p-border-radius-2); + padding: 1rem 1.5rem; + background: var(--surface); + border-radius: var(--border-radius-100); color: #00565e; - margin: var(--p-space-6) 0; - margin-bottom: var(--p-space-16); + margin: 1.5rem 0; + margin-bottom: 4rem; } diff --git a/polaris.shopify.com/src/components/UpdateBanner/UpdateBanner.module.scss b/polaris.shopify.com/src/components/UpdateBanner/UpdateBanner.module.scss index 5c95072c9b2..c4951f3846e 100644 --- a/polaris.shopify.com/src/components/UpdateBanner/UpdateBanner.module.scss +++ b/polaris.shopify.com/src/components/UpdateBanner/UpdateBanner.module.scss @@ -1,17 +1,19 @@ .Banner { border-radius: var(--border-radius-700); background-color: var(--surface-subdued); - box-shadow: var(--p-shadow-card); + box-shadow: var(--shadow-card); display: flex; - align-items: center; - gap: var(--p-space-6); - padding: var(--p-space-5) var(--p-space-6); + align-items: flex-start; + gap: 1rem; + padding: 1.5rem; + & > svg { flex-shrink: 0; - fill: var(--p-icon-highlight); + fill: var(--text); /* Undo these overly perscriptive styles from Polaris Icons */ filter: none; opacity: 1; + margin-top: 0.33rem; } & > p { margin: 0; diff --git a/polaris.shopify.com/src/styles/globals.scss b/polaris.shopify.com/src/styles/globals.scss index 08fe7b28f58..77c28f09567 100644 --- a/polaris.shopify.com/src/styles/globals.scss +++ b/polaris.shopify.com/src/styles/globals.scss @@ -366,48 +366,3 @@ button { } } } - -.components-grid { - display: grid; - gap: var(--p-space-4); - grid-template-columns: repeat(1, 1fr); -} - -@media (min-width: 490px) { - .components-grid { - grid-template-columns: repeat(2, 1fr); - } -} - -@media (min-width: 1040px) { - .components-grid { - grid-template-columns: repeat(3, 1fr); - } -} - -.components-grid__title { - font-weight: var(--p-font-weight-semibold); - line-height: var(--p-font-line-height-3); - margin: 0 !important; - margin-bottom: var(--p-space-1) !important; - color: #4e52b8; -} - -.tip-banner { - padding: var(--p-space-4) var(--p-space-6); - background: var(--p-surface-highlight-subdued); - border-radius: var(--p-border-radius-2); - color: #00565e !important; - margin: var(--p-space-6) 0; - margin-bottom: var(--p-space-16); -} - -.tip-banner__header { - display: flex; - align-items: center; - gap: var(--p-space-2); -} - -.tip-banner__header h4 { - margin: 0 !important; -} diff --git a/polaris.shopify.com/tsconfig.json b/polaris.shopify.com/tsconfig.json index 356f7512c1a..4b2b3bfd13d 100644 --- a/polaris.shopify.com/tsconfig.json +++ b/polaris.shopify.com/tsconfig.json @@ -18,20 +18,23 @@ "jsx": "preserve", "composite": true, "noUnusedLocals": true, - "noUnusedParameters": true + "noUnusedParameters": true, + "plugins": [ + { + "name": "next" + } + ] }, "include": [ "src", "pages", + "app", ".cache/*.json", "**/*.json", "next-env.d.ts", "scripts/get-props/src/get-props.ts", - "constants.js" + "constants.js", + ".next/types/**/*.ts" ], - "exclude": [ - "node_modules", - "pages/examples/**/*", - "scripts/get-props/testData" - ] + "exclude": ["node_modules", "app/examples/**/*", "scripts/get-props/testData"] } diff --git a/yarn.lock b/yarn.lock index 9703b5d9f4a..8554f095a60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2837,10 +2837,10 @@ call-me-maybe "^1.0.1" glob-to-regexp "^0.3.0" -"@next/env@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/env/-/env-13.0.6.tgz#3fcab11ffbe95bff127827d9f7f3139bc5e6adff" - integrity sha512-yceT6DCHKqPRS1cAm8DHvDvK74DLIkDQdm5iV+GnIts8h0QbdHvkUIkdOvQoOODgpr6018skbmSQp12z5OWIQQ== +"@next/env@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/env/-/env-13.2.3.tgz#77ca49edb3c1d7c5263bb8f2ebe686080e98279e" + integrity sha512-FN50r/E+b8wuqyRjmGaqvqNDuWBWYWQiigfZ50KnSFH0f+AMQQyaZl+Zm2+CIpKk0fL9QxhLxOpTVA3xFHgFow== "@next/eslint-plugin-next@13.0.0": version "13.0.0" @@ -2856,70 +2856,70 @@ dependencies: glob "7.1.7" -"@next/swc-android-arm-eabi@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.6.tgz#c971e5a3f8aae875ac1d9fdb159b7e126d8d98d5" - integrity sha512-FGFSj3v2Bluw8fD/X+1eXIEB0PhoJE0zfutsAauRhmNpjjZshLDgoXMWm1jTRL/04K/o9gwwO2+A8+sPVCH1uw== - -"@next/swc-android-arm64@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-13.0.6.tgz#ecacae60f1410136cc31f9e1e09e78e624ca2d68" - integrity sha512-7MgbtU7kimxuovVsd7jSJWMkIHBDBUsNLmmlkrBRHTvgzx5nDBXogP0hzZm7EImdOPwVMPpUHRQMBP9mbsiJYQ== - -"@next/swc-darwin-arm64@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.0.6.tgz#266e9e0908024760eba0dfce17edc90ffcba5fdc" - integrity sha512-AUVEpVTxbP/fxdFsjVI9d5a0CFn6NVV7A/RXOb0Y+pXKIIZ1V5rFjPwpYfIfyOo2lrqgehMNQcyMRoTrhq04xg== - -"@next/swc-darwin-x64@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.6.tgz#4be4ca7bc37f9c93d2e38be5ff313873ad758c09" - integrity sha512-SasCDJlshglsPnbzhWaIF6VEGkQy2NECcAOxPwaPr0cwbbt4aUlZ7QmskNzgolr5eAjFS/xTr7CEeKJtZpAAtQ== - -"@next/swc-freebsd-x64@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.6.tgz#42eb9043ee65ea5927ba550f4b59827d7064c47b" - integrity sha512-6Lbxd9gAdXneTkwHyYW/qtX1Tdw7ND9UbiGsGz/SP43ZInNWnW6q0au4hEVPZ9bOWWRKzcVoeTBdoMpQk9Hx9w== - -"@next/swc-linux-arm-gnueabihf@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.6.tgz#aab663282b5f15d12bf9de1120175f438a44c924" - integrity sha512-wNdi5A519e1P+ozEuYOhWPzzE6m1y7mkO6NFwn6watUwO0X9nZs7fT9THmnekvmFQpaZ6U+xf2MQ9poQoCh6jQ== - -"@next/swc-linux-arm64-gnu@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.6.tgz#5e2b6df4636576a00befb7bd414820a12161a9af" - integrity sha512-e8KTRnleQY1KLk5PwGV5hrmvKksCc74QRpHl5ffWnEEAtL2FE0ave5aIkXqErsPdXkiKuA/owp3LjQrP+/AH7Q== - -"@next/swc-linux-arm64-musl@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.6.tgz#4a5e91a36cf140cad974df602d647e64b1b9473f" - integrity sha512-/7RF03C3mhjYpHN+pqOolgME3guiHU5T3TsejuyteqyEyzdEyLHod+jcYH6ft7UZ71a6TdOewvmbLOtzHW2O8A== - -"@next/swc-linux-x64-gnu@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.6.tgz#accb8a721a99e704565b936f16e96fa0c67e8db1" - integrity sha512-kxyEXnYHpOEkFnmrlwB1QlzJtjC6sAJytKcceIyFUHbCaD3W/Qb5tnclcnHKTaFccizZRePXvV25Ok/eUSpKTw== - -"@next/swc-linux-x64-musl@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.6.tgz#2affaa2f4f01bc190a539d895118a6ad1a477645" - integrity sha512-N0c6gubS3WW1oYYgo02xzZnNatfVQP/CiJq2ax+DJ55ePV62IACbRCU99TZNXXg+Kos6vNW4k+/qgvkvpGDeyA== - -"@next/swc-win32-arm64-msvc@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.6.tgz#28e5c042772865efd05197a8d1db5920156997fc" - integrity sha512-QjeMB2EBqBFPb/ac0CYr7GytbhUkrG4EwFWbcE0vsRp4H8grt25kYpFQckL4Jak3SUrp7vKfDwZ/SwO7QdO8vw== - -"@next/swc-win32-ia32-msvc@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.6.tgz#30d91a6d847fa8bce9f8a0f9d2b469d574270be5" - integrity sha512-EQzXtdqRTcmhT/tCq81rIwE36Y3fNHPInaCuJzM/kftdXfa0F+64y7FAoMO13npX8EG1+SamXgp/emSusKrCXg== - -"@next/swc-win32-x64-msvc@13.0.6": - version "13.0.6" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.6.tgz#dfa28ddb335c16233d22cf39ec8cdf723e6587a1" - integrity sha512-pSkqZ//UP/f2sS9T7IvHLfEWDPTX0vRyXJnAUNisKvO3eF3e1xdhDX7dix/X3Z3lnN4UjSwOzclAI87JFbOwmQ== +"@next/swc-android-arm-eabi@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.2.3.tgz#85eed560c87c7996558c868a117be9780778f192" + integrity sha512-mykdVaAXX/gm+eFO2kPeVjnOCKwanJ9mV2U0lsUGLrEdMUifPUjiXKc6qFAIs08PvmTMOLMNnUxqhGsJlWGKSw== + +"@next/swc-android-arm64@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-13.2.3.tgz#8ac54ca9795a48afc4631b4823a4864bd5db0129" + integrity sha512-8XwHPpA12gdIFtope+n9xCtJZM3U4gH4vVTpUwJ2w1kfxFmCpwQ4xmeGSkR67uOg80yRMuF0h9V1ueo05sws5w== + +"@next/swc-darwin-arm64@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.2.3.tgz#f674e3c65aec505b6d218a662ade3fe248ccdbda" + integrity sha512-TXOubiFdLpMfMtaRu1K5d1I9ipKbW5iS2BNbu8zJhoqrhk3Kp7aRKTxqFfWrbliAHhWVE/3fQZUYZOWSXVQi1w== + +"@next/swc-darwin-x64@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.2.3.tgz#a15ea7fb4c46034a8f5e387906d0cad08387075a" + integrity sha512-GZctkN6bJbpjlFiS5pylgB2pifHvgkqLAPumJzxnxkf7kqNm6rOGuNjsROvOWVWXmKhrzQkREO/WPS2aWsr/yw== + +"@next/swc-freebsd-x64@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.2.3.tgz#f7ac6ae4f7d706ff2431f33e40230a554c8c2cbc" + integrity sha512-rK6GpmMt/mU6MPuav0/M7hJ/3t8HbKPCELw/Uqhi4732xoq2hJ2zbo2FkYs56y6w0KiXrIp4IOwNB9K8L/q62g== + +"@next/swc-linux-arm-gnueabihf@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.2.3.tgz#84ad9e9679d55542a23b590ad9f2e1e9b2df62f7" + integrity sha512-yeiCp/Odt1UJ4KUE89XkeaaboIDiVFqKP4esvoLKGJ0fcqJXMofj4ad3tuQxAMs3F+qqrz9MclqhAHkex1aPZA== + +"@next/swc-linux-arm64-gnu@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.2.3.tgz#56f9175bc632d647c60b9e8bedc0875edf92d8b7" + integrity sha512-/miIopDOUsuNlvjBjTipvoyjjaxgkOuvlz+cIbbPcm1eFvzX2ltSfgMgty15GuOiR8Hub4FeTSiq3g2dmCkzGA== + +"@next/swc-linux-arm64-musl@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.2.3.tgz#7d4cf00e8f1729a3de464da0624773f5d0d14888" + integrity sha512-sujxFDhMMDjqhruup8LLGV/y+nCPi6nm5DlFoThMJFvaaKr/imhkXuk8uCTq4YJDbtRxnjydFv2y8laBSJVC2g== + +"@next/swc-linux-x64-gnu@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.2.3.tgz#17de404910c4ebf7a1d366b19334d7e27e126ab0" + integrity sha512-w5MyxPknVvC9LVnMenAYMXMx4KxPwXuJRMQFvY71uXg68n7cvcas85U5zkdrbmuZ+JvsO5SIG8k36/6X3nUhmQ== + +"@next/swc-linux-x64-musl@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.2.3.tgz#07cb7b7f3a3a98034e2533f82638a9b099ba4ab1" + integrity sha512-CTeelh8OzSOVqpzMFMFnVRJIFAFQoTsI9RmVJWW/92S4xfECGcOzgsX37CZ8K982WHRzKU7exeh7vYdG/Eh4CA== + +"@next/swc-win32-arm64-msvc@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.2.3.tgz#b9ac98c954c71ec9de45d3497a8585096b873152" + integrity sha512-7N1KBQP5mo4xf52cFCHgMjzbc9jizIlkTepe9tMa2WFvEIlKDfdt38QYcr9mbtny17yuaIw02FXOVEytGzqdOQ== + +"@next/swc-win32-ia32-msvc@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.2.3.tgz#5ec48653a48fd664e940c69c96bba698fdae92eb" + integrity sha512-LzWD5pTSipUXTEMRjtxES/NBYktuZdo7xExJqGDMnZU8WOI+v9mQzsmQgZS/q02eIv78JOCSemqVVKZBGCgUvA== + +"@next/swc-win32-x64-msvc@13.2.3": + version "13.2.3" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.2.3.tgz#cd432f280beb8d8de5b7cd2501e9f502e9f3dd72" + integrity sha512-aLG2MaFs4y7IwaMTosz2r4mVbqRyCnMoFqOcmfTi7/mAS+G4IMH0vJp4oLdbshqiVoiVuKrAfqtXj55/m7Qu1Q== "@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3": version "2.1.8-no-fsevents.3" @@ -16066,30 +16066,30 @@ nested-error-stacks@^2.0.0, nested-error-stacks@^2.1.0: resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-2.1.1.tgz#26c8a3cee6cc05fbcf1e333cd2fc3e003326c0b5" integrity sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw== -next@^13.0.6: - version "13.0.6" - resolved "https://registry.yarnpkg.com/next/-/next-13.0.6.tgz#f9a2e9e2df9ad60e1b6b716488c9ad501a383621" - integrity sha512-COvigvms2LRt1rrzfBQcMQ2GZd86Mvk1z+LOLY5pniFtL4VrTmhZ9salrbKfSiXbhsD01TrDdD68ec3ABDyscA== +next@^13.2.3: + version "13.2.3" + resolved "https://registry.yarnpkg.com/next/-/next-13.2.3.tgz#92d170e7aca421321f230ff80c35c4751035f42e" + integrity sha512-nKFJC6upCPN7DWRx4+0S/1PIOT7vNlCT157w9AzbXEgKy6zkiPKEt5YyRUsRZkmpEqBVrGgOqNfwecTociyg+w== dependencies: - "@next/env" "13.0.6" + "@next/env" "13.2.3" "@swc/helpers" "0.4.14" caniuse-lite "^1.0.30001406" postcss "8.4.14" - styled-jsx "5.1.0" + styled-jsx "5.1.1" optionalDependencies: - "@next/swc-android-arm-eabi" "13.0.6" - "@next/swc-android-arm64" "13.0.6" - "@next/swc-darwin-arm64" "13.0.6" - "@next/swc-darwin-x64" "13.0.6" - "@next/swc-freebsd-x64" "13.0.6" - "@next/swc-linux-arm-gnueabihf" "13.0.6" - "@next/swc-linux-arm64-gnu" "13.0.6" - "@next/swc-linux-arm64-musl" "13.0.6" - "@next/swc-linux-x64-gnu" "13.0.6" - "@next/swc-linux-x64-musl" "13.0.6" - "@next/swc-win32-arm64-msvc" "13.0.6" - "@next/swc-win32-ia32-msvc" "13.0.6" - "@next/swc-win32-x64-msvc" "13.0.6" + "@next/swc-android-arm-eabi" "13.2.3" + "@next/swc-android-arm64" "13.2.3" + "@next/swc-darwin-arm64" "13.2.3" + "@next/swc-darwin-x64" "13.2.3" + "@next/swc-freebsd-x64" "13.2.3" + "@next/swc-linux-arm-gnueabihf" "13.2.3" + "@next/swc-linux-arm64-gnu" "13.2.3" + "@next/swc-linux-arm64-musl" "13.2.3" + "@next/swc-linux-x64-gnu" "13.2.3" + "@next/swc-linux-x64-musl" "13.2.3" + "@next/swc-win32-arm64-msvc" "13.2.3" + "@next/swc-win32-ia32-msvc" "13.2.3" + "@next/swc-win32-x64-msvc" "13.2.3" nice-try@^1.0.4: version "1.0.5" @@ -20755,10 +20755,10 @@ style-value-types@5.0.0: hey-listen "^1.0.8" tslib "^2.1.0" -styled-jsx@5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.1.0.tgz#4a5622ab9714bd3fcfaeec292aa555871f057563" - integrity sha512-/iHaRJt9U7T+5tp6TRelLnqBqiaIT0HsO0+vgyj8hK2KUk7aejFqRrumqPUlAqDwAj8IbS/1hk3IhBAAK/FCUQ== +styled-jsx@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.1.1.tgz#839a1c3aaacc4e735fed0781b8619ea5d0009d1f" + integrity sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw== dependencies: client-only "0.0.1"