{"id":22378882,"url":"https://github.com/codebrahma/react-stateless-modal","last_synced_at":"2025-03-26T18:47:38.486Z","repository":{"id":70955120,"uuid":"230215107","full_name":"Codebrahma/react-stateless-modal","owner":"Codebrahma","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-23T01:43:27.000Z","size":1135,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-19T12:02:07.477Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Codebrahma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-12-26T07:14:51.000Z","updated_at":"2020-03-03T17:46:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"76c27c7e-53e9-46df-8bbb-342688643c11","html_url":"https://github.com/Codebrahma/react-stateless-modal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codebrahma%2Freact-stateless-modal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codebrahma%2Freact-stateless-modal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codebrahma%2Freact-stateless-modal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codebrahma%2Freact-stateless-modal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Codebrahma","download_url":"https://codeload.github.com/Codebrahma/react-stateless-modal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245718005,"owners_count":20661154,"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-12-04T23:08:13.957Z","updated_at":"2025-03-26T18:47:38.469Z","avatar_url":"https://github.com/Codebrahma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-stateless-modal\n\n\u003e A modal library that does not require state maintenance\n\n[![NPM](https://img.shields.io/npm/v/react-stateless-modal.svg)](https://www.npmjs.com/package/react-stateless-modal) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Install\n\n```bash\nnpm install --save react-stateless-modal\n```\n\n## documentation\n\nRead the full Documentation [here](https://cb-react-modal-docs.netlify.com/)\n\n## Advantages\n\nCreate modals wherever you want without having to maintain state variables.\n\n## Motivation\n\nThe modal libraries in existence such as `react-responsive-modal` requires users to maintain state variables for the creation of each modal, which can become painful while maintaining a large codebase that involves multiple modals. This library eliminates the above problem and lets users create modals without having to create and maintain state variables.\n\n## Usage\n\n```jsx\nimport React, { Component } from \"react\";\nimport { openModal } from \"react-stateless-modal\";\nclass Example extends Component {\n  openModal = () =\u003e {\n    openModal({\n      header: () =\u003e (\n        /* component or string to render header */\n      ),\n      body: () =\u003e (\n        /* component or string to render body */\n      ),\n      footer: () =\u003e (\n        /* component or string to render footer */\n      ),\n      classNames: { overlay: className for overlay, modal: className for the modal, closeIcon: className for close icon},\n      closeOnEscape: /* Setting true closes the modal on pressing escape key setting false does the opposite (Optional)*/,\n      closeIcon: { src: IconObject, alt: alt text for the icon},\n      animation: { name: choose from 'bounce', 'fade-in' and 'zoom' animation, duration: 'animationDuration'},\n      containerId: /* Id of the custom container over which you would like the modal to be mounted */\n      modalId: { /* make the modal take the id of your choosing */}\n    });\n  };\n  render() {\n    return \u003cbutton onClick={this.openModal}\u003eOpen Modal\u003c/button\u003e;\n  }\n}\n```\n\nThe `openModal` method will mount the container for you.\n\nYou may optionally choose to use the component mode of the library by importing and mounting the `Modal` component. you may use all the properties used in the object passed to the `openModal` function. The example below shows how to create a simple modal using component mode. You additionally need to pass `open` and `onClose` prop. Refer docs for more information.\n\n```jsx\nimport React, { Component } from \"react\";\nimport \"./styles.css\";\nimport { Modal } from \"react-stateless-modal\";\n\nclass App extends Component {\n  state = {\n    open: false\n  };\n\n  handleClose = () =\u003e {\n    this.setState({ open: false });\n  };\n\n  handleOpen = () =\u003e {\n    this.setState({ open: true });\n  };\n\n  render() {\n    const { open } = this.state;\n    return (\n      \u003cdiv\u003e\n        \u003cbutton onClick={this.handleOpen}\u003eOpen Modal via Component mode\u003c/button\u003e\n        \u003cModal\n          head=\"head\"\n          body=\"Inner Body  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam\n          pulvinar risus non risus hendrerit venenatis. Pellentesque sit amet\n          hendrerit risus, sed porttitor quam  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam\n          pulvinar risus non risus hendrerit venenatis. Pellentesque sit amet\n          hendrerit risus, sed porttitor quam  Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n          onClose={this.handleClose}\n          open={open}\n        /\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n\nexport default App;\n```\n\n### Nested modal support\n\nThe library additionally gives you the flexibility of mounting a modal container over an already existing modal. The example below describes the same\n\n```jsx\nimport React, { Component } from 'react';\nimport { openModal } from 'react-stateless-modal';\n\nexport default class App extends Component {\n  openModal = () =\u003e {\n    openModal({\n      head: () =\u003e \u003ch2\u003eRandom Heading\u003c/h2\u003e,\n      body: () =\u003e (\n        \u003cp\u003e\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pulvinar risus non risus\n          hendrerit venenatis. Pellentesque sit amet hendrerit risus, sed porttitor quam.\n        \u003c/p\u003e\n      ),\n      footer: () =\u003e \u003cbutton onClick={this.openInnerModal}\u003eOpen Inner Modal\u003c/button\u003e\n    });\n  };\n\n  openInnerModal = () =\u003e {\n    openModal({\n      head: () =\u003e 'Inner Heading',\n      body: () =\u003e \u003cp\u003eInner Body\u003c/p\u003e,\n      footer: () =\u003e \u003cp\u003eInner Footer\u003c/p\u003e\n    });\n  };\n\n  render() {\n    return \u003cbutton onClick={this.openModal}\u003eShow\u003c/button\u003e;\n  }\n}\n```\n\n## License\n\nMIT © [Sigkill32](https://github.com/Sigkill32)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebrahma%2Freact-stateless-modal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebrahma%2Freact-stateless-modal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebrahma%2Freact-stateless-modal/lists"}