idiomattic / Mediyum

0 stars 0 forks source link

Mediyum

Mediyum, taking design and functionality inspiration from medium.com, is a community which allows independent recipe writers to share their recipes with others and engage in thoughtful discussion over the foods that they are passionate about.

Come and see for yourself!

Features

Technologies

Highlights

A code snippet, for the curious

This functional React component takes in the prop 'modal', which comes from the 'ui' slice of the Redux State. This prop designates which type of modal, if any, should be present on the page. The 'hideModal' prop is a function which, well, hides any present modal on dispatch! The switch statement governs which specific modal component to render on the page, and it defines classes which are interpolated into the HTML elements in the return statement so that each type of modal can have its own styling.

function Modal({modal, hideModal}) {
  if (!modal) {
    return null;
  }
  let component
  let backgroundClass
  let childClass
  switch (modal) {
    case 'Sign In':
      component = <SignInFormContainer />
      backgroundClass = 'modal-background'
      childClass = 'modal-child'
      break
    case 'Sign Up':
      component = <SignUpFormContainer />
      backgroundClass = 'modal-background'
      childClass = 'modal-child'
      break
    case 'Dropdown':
      component = <DropdownModalContainer />
      backgroundClass = 'dropdown modal-background'
      childClass = 'dropdown modal-child'
      break
    case 'Comments':
      component = <CommentsModalContainer />
      backgroundClass = 'comments modal-background'
      childClass = 'comments modal-child'
      break
    default:
      return null;
  }
  return (
    <div className={backgroundClass} onClick={hideModal}>
      <div className={childClass} onClick={e => e.stopPropagation()}>
        { component }
      </div>
    </div>
  );
}

export default Modal

If you've made it this far, I'd like to thank you so much for taking a look at my hard work! Please reach out if you'd like to learn more about how this site was developed.