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 generic picker API #2379

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

Add generic picker API #2379

wants to merge 3 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: [{title: '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-20241112220206",
"@shopify/ui-extensions-react": "0.0.0-snapshot-20241112220206"
  1. In your extension code, add thw following example:
const {picker} = useApi();

const pickerInstance = await picker({
  heading: 'Select an item',
  headers: [{title: '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
Copy link
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset directory. If the changes are user-facing and should cause a version bump, run yarn changeset to track your changes and include them in the next release CHANGELOG. If you are making simple updates to repo configuration, examples, or documentation, you do not need to add a changeset.

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