-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose picker only to block extensions and add static doc section
- Loading branch information
1 parent
d37623a
commit 432358a
Showing
5 changed files
with
129 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/ui-extensions/docs/surfaces/admin/staticPages/examples/picker-email-template.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
reactExtension, | ||
useApi, | ||
Button, | ||
} from '@shopify/ui-extensions-react/admin'; | ||
|
||
const TARGET = 'admin.product-details.block.render'; | ||
|
||
export default reactExtension(TARGET, () => <App />); | ||
|
||
function App() { | ||
const {picker} = useApi(TARGET); | ||
|
||
const handleSelectEmailTemplate = async () => { | ||
const pickerInstance = await picker({ | ||
heading: 'Select a template', | ||
multiple: false, | ||
headers: [ | ||
{content: 'Templates'}, | ||
{content: 'Created by'}, | ||
{content: 'Times used', type: 'number'}, | ||
], | ||
items: [ | ||
{ | ||
id: '1', | ||
heading: 'Full width, 1 column', | ||
data: ['Karine Ruby', '0'], | ||
badges: [{content: 'Draft', tone: 'info'}, {content: 'Marketing'}], | ||
}, | ||
{ | ||
id: '2', | ||
heading: 'Large graphic, 3 column', | ||
data: ['Charlie Mitchell', '5'], | ||
badges: [ | ||
{content: 'Published', tone: 'success'}, | ||
{content: 'New feature'}, | ||
], | ||
selected: true, | ||
}, | ||
{ | ||
id: '3', | ||
heading: 'Promo header, 2 column', | ||
data: ['Russell Winfield', '10'], | ||
badges: [{content: 'Published', tone: 'success'}], | ||
}, | ||
], | ||
}); | ||
|
||
const selected = await pickerInstance.selected; | ||
console.log(selected); | ||
}; | ||
|
||
return ( | ||
<Button onClick={handleSelectEmailTemplate}>Select email template</Button> | ||
); | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/ui-extensions/docs/surfaces/admin/staticPages/examples/resource-picker-product.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
reactExtension, | ||
useApi, | ||
Button, | ||
} from '@shopify/ui-extensions-react/admin'; | ||
|
||
const TARGET = 'admin.product-details.block.render'; | ||
|
||
export default reactExtension(TARGET, () => <App />); | ||
|
||
function App() { | ||
const {resourcePicker} = useApi(TARGET); | ||
|
||
const handleSelectProduct = async () => { | ||
const selected = await resourcePicker({type: 'product'}); | ||
console.log(selected); | ||
}; | ||
|
||
return <Button onClick={handleSelectProduct}>Select product</Button>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters