2.8.1 • Published 2 months ago

@hixme/modal v2.8.1

Weekly downloads
1
License
MIT
Repository
-
Last release
2 months ago

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
2.8.1

2 months ago

4.4.0

9 months ago

4.2.0

10 months ago

4.1.0

11 months ago

4.0.0

1 year ago

3.3.2

3 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.8.0

6 years ago

2.6.1

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.11

6 years ago

2.4.10

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.11

6 years ago

2.1.10

6 years ago

2.1.9

6 years ago

2.1.8

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

1.1.4

6 years ago

1.1.2

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.1

6 years ago