Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add picker API #2379

Open
wants to merge 5 commits into
base: unstable
Choose a base branch
from
Open

Add picker API #2379

wants to merge 5 commits into from

Conversation

MitchLillie
Copy link
Contributor

@MitchLillie MitchLillie commented Sep 26, 2024

Background

Resolves https://github.com/Shopify/app-ui/issues/1575

Related https://github.com/Shopify/shopify-dev/pull/49753, https://github.com/Shopify/extensibility/pull/178

Adds the imperative picker() API to UI Extensions to open the generic picker.

The API is used like this:

const {picker} = useApi();

const pickerInstance = await picker({
  heading: 'Select an item',
  headers: [{content: 'Main heading'}],
  items: [
    {
      id: '1',
      heading: 'Item 1',
    },
    {
      id: '2',
      heading: 'Item 2',
    },
  ],
});

const selected = await picker.selected;

This matches the API provided to App Bridge in https://github.com/Shopify/extensibility/pull/178.

🎩

  1. Setup a local extension following these instructions or by running shopify app generate extension
  2. Update your extension's dependencies to the latest snapshots on this PR:
"@shopify/ui-extensions": "0.0.0-snapshot-20241115174631",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20241115174631"
  1. In your extension code, add thw following example:
const {picker} = useApi();

const pickerInstance = await picker({
  heading: 'Select an item',
  headers: [{content: 'Main heading'}],
  items: [
    {
      id: '1',
      heading: 'Item 1',
    },
    {
      id: '2',
      heading: 'Item 2',
    },
  ],
});

const selected = await picker.selected;

Checklist

  • I have 🎩'd these changes
  • I have updated relevant documentation

@MitchLillie
Copy link
Contributor Author

/snapit

@shopify-github-actions-access
Copy link
Contributor

🫰✨ Thanks @MitchLillie! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/ui-extensions": "0.0.0-snapshot-20240926213211",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20240926213211"

@MitchLillie
Copy link
Contributor Author

/snapit

@shopify-github-actions-access
Copy link
Contributor

🫰✨ Thanks @MitchLillie! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/ui-extensions": "0.0.0-snapshot-20241021162735",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20241021162735"

@MitchLillie
Copy link
Contributor Author

/snapit

@shopify-github-actions-access
Copy link
Contributor

🫰✨ Thanks @MitchLillie! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/ui-extensions": "0.0.0-snapshot-20241022151631",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20241022151631"

@charlesdobson
Copy link
Contributor

/snapit

@shopify-github-actions-access
Copy link
Contributor

🫰✨ Thanks @charlesdobson! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/data-extensions": "0.0.0-snapshot-20241112220206",
"@shopify/ui-extensions": "0.0.0-snapshot-20241112220206",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20241112220206"

@charlesdobson charlesdobson marked this pull request as ready for review November 12, 2024 22:13

This comment has been minimized.

@MitchLillie
Copy link
Contributor Author

/snapit

@shopify-github-actions-access
Copy link
Contributor

🫰✨ Thanks @MitchLillie! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/data-extensions": "0.0.0-snapshot-20241115174631",
"@shopify/ui-extensions": "0.0.0-snapshot-20241115174631",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20241115174631"

@charlesdobson
Copy link
Contributor

/snapit

@shopify-github-actions-access
Copy link
Contributor

🫰✨ Thanks @charlesdobson! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

"@shopify/data-extensions": "0.0.0-snapshot-20241119031327",
"@shopify/ui-extensions": "0.0.0-snapshot-20241119031327",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20241119031327"

@charlesdobson charlesdobson changed the title Add generic picker API Add picker API Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants