Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hixme/modal

Package Overview
Dependencies
Maintainers
8
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hixme/modal

Hixme Modal

  • 2.8.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
8
Created
Source

Mr. Modal

Implementation of a global modal component with Redux and the @hixme-ui/modal package and -- by extension -- the react-modal package for use within the Hixme ecosystem. For more information on props for use with the MrModal component, see the @hixme-ui/modal README

Usage

import { MrModal } from '@hixme/modal'

<MrModal 
  dialog 
  medium
  title='All your base are belong to us' 
  confirmLabel='Get down!' 
  cancelLabel='Eh, maybe not...'
>
  {/* Modal content here */}
</MrModal>

After creating your modals, you will need to pass them to your <MrModalManager /> component, located at your project's root.

import { MrModalManager } from '@hixme/modal'

// In project root
import TestModal from '/modal/path/here'

<MrModalManager 
  appElementId='app-element-node'
  modals={{
    TEST: TestModal,
  }}
/>

Important: In the modals object, the key is your modal string constant and the value is your modal component itself.

Additionally, you can supply the MrModalManager with your own appElement ID. This is the ID which needs to be assigned to the element wrapping the rest of your application.


To open the modal, you'll need to dispatch the setModal action, passing in the string constant you've defined for your modal.

dispatch(setModal(YOUR_MODAL))

You can also pass some data to your modal as a second argument in the dispatch.

dispatch(setModal(YOUR_MODAL, { myData }))

myData can then be accesed on the component props.

const MyModalComponent = ({
  data: { myData }
}) => (
  <MrModal>
    ...
  </MrModal>
)

Redux Actions

NameDescription
setModalSet current modal with modal constant name
setDataAdd argument to data object
clearModalClear entire current modal store (including data and viewList)
addViewToListAdd modal constant name to view list
removeViewFromListRemove modal constant name to view list

Redux Selectors

NameDescription
getModalReturns the entire modal store
getCurrentViewReturns only the current modal constant
getViewListReturns the current viewList key
hasActiveModalReturns if there is a currently active modal
getModalDataReturns the current data object

Keywords

FAQs

Package last updated on 21 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc