{"id":21043373,"url":"https://github.com/crystallizeapi/react-dialog","last_synced_at":"2025-05-15T17:31:40.892Z","repository":{"id":32282788,"uuid":"131831095","full_name":"CrystallizeAPI/react-dialog","owner":"CrystallizeAPI","description":"React component to display accessible dialogs","archived":false,"fork":false,"pushed_at":"2023-03-03T20:37:12.000Z","size":5183,"stargazers_count":5,"open_issues_count":16,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-06T12:23:50.631Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CrystallizeAPI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-02T09:49:56.000Z","updated_at":"2022-10-24T11:20:21.000Z","dependencies_parsed_at":"2024-10-30T12:12:46.617Z","dependency_job_id":null,"html_url":"https://github.com/CrystallizeAPI/react-dialog","commit_stats":{"total_commits":112,"total_committers":5,"mean_commits":22.4,"dds":0.1875,"last_synced_commit":"8ef3cf170d92df086e855ced7b9587850b13fe4c"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrystallizeAPI%2Freact-dialog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrystallizeAPI%2Freact-dialog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrystallizeAPI%2Freact-dialog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrystallizeAPI%2Freact-dialog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrystallizeAPI","download_url":"https://codeload.github.com/CrystallizeAPI/react-dialog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225365807,"owners_count":17462973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T14:12:35.682Z","updated_at":"2024-11-19T14:12:36.688Z","avatar_url":"https://github.com/CrystallizeAPI.png","language":"JavaScript","readme":"![alt text](https://raw.githubusercontent.com/CrystallizeAPI/react-dialog/HEAD/media/logo.png \"Speech bubble\")\n\n# @crystallize/react-dialog\n\nReact component to display accessible dialogs. This is a [general purpose component to build awesome and accessible dialogs in react](https://crystallize.com/developers/react-components/react-dialog). Built initially for use in the [Crystallize headless commerce service](https://crystallize.com).\n\nUses [styled-components](https://npmjs.org/package/styled-components) and [a11y-dialog](https://www.npmjs.com/package/a11y-dialog). Leverages the [native dialog HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) when possible\n\nThis module uses **Promises** and does *not* provide a polyfill. To easily\nprovide Promise polyfills for your users, try [polyfills.io](https://polyfill.io/v2/docs/)\n\n## Demo\n[Demo](https://react-dialog.milliseconds.io)\n\n![alt text](https://raw.githubusercontent.com/CrystallizeAPI/react-dialog/HEAD/media/react-dialog.gif \"React dialog in action\")\n\n## Usage\n\n```\nyarn add @crystallize/react-dialog styled-components\n```\n\n### In your app root\n\n```\nimport { Wrapper } from '@crystallize/react-dialog';\n\nexport default () =\u003e (\n  \u003cmain\u003e\n    \u003cYourApp /\u003e\n  \u003c/main\u003e\n  \u003cWrapper /\u003e\n);\n```\n\n### Use it\n\n```\nimport { showDialog, showAlert, showConfirm, closeCurrent } from '@crystallize/react-dialog';\n\nawait showDialog('Hey dude');\nawait showDialog({\n  body: \u003cstrong\u003eHey dude\u003c/strong\u003e\n});\n\nawait showAlert('Wow');\nconst confirmResult = await showConfirm('Are you sure?');\n\nconst confirmResult = await showConfirm({\n  body: \u003cdiv\u003eJSX rules\u003c/div\u003e,\n  buttons: {\n    ok: p =\u003e \u003cbutton {...p}\u003eAllrighty\u003c/button\u003e,\n    cancel: p =\u003e \u003cbutton {...p}\u003eNope\u003c/button\u003e\n  }\n});\n\n// Closes any open dialog\ncloseCurrent();\n```\n\n## Wrapper props\n| Prop Name    | Default | Type | Description                                |\n| ------------ | ------- | ---- | ------------------------------------------ |\n| cleanTheme   | false   | bool | Use the clean theme instead of the default |\n| ButtonOk     | false   | jsx  | Set a custom default Ok button             |\n| ButtonCancel | false   | jsx  | Set a custom default Cancel button         |\n| ButtonClose  | false   | jsx  | Set a custom default Close button          |\n| Heading      | false   | jsx  | Set a custom default Heading               |\n\n## Dialog functions\nAll of the show dialog functions (showDialog, showAlert, showConfirm) returns a promise when called. The promise is resolved when the dialog is closed. The return value of the\npromise changes depending on which type of dialog it is\n\nThe functions accepts a single string argument. They also support a single object as argument with these common properties:\n\n```\n{\n  title\u003cstring|jsx\u003e: \u003ch1\u003eHi there\u003c/h1\u003e\n  body\u003cstring|jsx\u003e: 'you',\n  showCloseButton\u003cbool\u003e: false (default is true),\n  disableBackdropClick\u003cbool\u003e: false\n}\n```\n\nshowConfirm does however accept a few more:\n```\n...\nbuttons: {\n  ok: props =\u003e \u003cbutton {...props}\u003e{props.children}\u003c/button\u003e,\n  cancel: \"Nope nope!\"\n}\n```\nshowConfirm resolves its promise with either \"ok\" or \"cancel\"\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrystallizeapi%2Freact-dialog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrystallizeapi%2Freact-dialog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrystallizeapi%2Freact-dialog/lists"}