Git Product home page Git Product logo

challenge-dialog-design-system's Introduction

Show Modal Dialogs 💬

Este proyecto consta de mostrar modales de dialogo basado en componentes de React JS.

image

API/Component

HomePage/index.tsx

<main>
    <div className="container-btns">
        {
            buttons.map( ({ icon, label }) => (
                <ButtonDialog
                    key={icon}
                    onClick={() => handleOpenModal(icon)}
                    label={label}
                    icon={icon}
                />
            ))
        }
    </div>

    {
        isOpenModal && <ModalDialog {...{ handleCloseModal, isOpenModal, type }} />
    }
</main>

En el componente HomePage contiene los botones para desplegar los modales de dialogo.
El arreglo de "buttons" consiste en varios objetos con la como el siguiente:

   const buttons: Pick<PropsButton, 'icon' | 'label'>[] = [
       {
           icon: 'warning',
           label: 'Warning Dialog'
       },
       {
           icon: 'error',
           label: 'Error Dialog'
       },
       {
           icon: 'success',
           label: 'Success Dialog'
       }
   ]

Y para cada botón, hay un modal que se idenfica mediante el valor de la propiedad "icono" de la constante "buttons".


components/ModalDialog/Modal.tsx

export const Modal = (props: PropsModal) => {

    const { isOpenModal, handleCloseModal } = props;

    return (
        <dialog 
            open={isOpenModal} 
            className='modal-overlay' 
            onClick={handleCloseModal}
        >
            <div 
                className='modal-container' 
                onClick={handleStopPropagation}
            >
                { showModalDetails(props) }
                
                <ButtonCloseModal handleCloseModal={handleCloseModal} />
            </div>
        </dialog>
    )
}

utils/showModalDetails.tsx

export const showModalDetails = (props: PropsModal) => {

    const selectedModal = {
        "warning": <WarningModal {...props} />,
        "success": <SuccessModal {...props} />,
        "error": <ErrorModal {...props} />
    }

    return selectedModal[props.type!]
}

Installation

  1. Clone the repository (you need to have Git installed).
    git clone https://github.com/Franklin361/challenge-dialog-design-system.git
  1. Install dependencies of the project.
    npm install
  1. Run the project.
    npm run dev

Note: For running the tests, use the following command

    npm run test

Demo

Demo de la aplicación

License

Inlcuir la licéncia y el link a esta MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.