Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Modal add #13

Closed
wants to merge 4 commits into from
Closed

Modal add #13

wants to merge 4 commits into from

Conversation

n-galrion
Copy link

Adds in basic confirm/decline modal.
image

Example of Usage:

import { Component, Solid, createSignal, Show } from "solid-js";
import { JSX } from "solid-js/jsx-runtime";
import Modal from '../../shared/Modal'
import PageHeader from '../../shared/PageHeader'
const [showModal, setShowModal] = createSignal(false)

const handleConfirm = () => {
  console.log('Modal confirmed')
}

const ModalTest = () => (
  <div>
    <button id="showModal" onClick={() => setShowModal(true)}> Show Modal </button>
    <Show when={showModal()}>
      <Modal messageHeader="Confirm Action" message="Are you sure you want to confirm this action?" confirmText="Confirm" declineText="Cancel" onConfirm={handleConfirm} />
    </Show>
  </div>
)

export default ModalTest;

@0x000011b 0x000011b self-requested a review February 12, 2023 01:29
@0x000011b 0x000011b added the enhancement New feature or request label Feb 12, 2023
Copy link
Contributor

@0x000011b 0x000011b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you! Before merging though, could you run the code style/quality enforcement tools as described in the README?

# auto-fixes any style problems
$ pnpm run style:fix

# auto-fixes any linting problems, and prints the ones that can't be auto-fixed
$ pnpm run lint:fix

# runs the TypeScript compiler so any type errors will be shown
$ pnpm run typecheck

@n-galrion
Copy link
Author

n-galrion commented Feb 12, 2023

image

The first style fix passed, but the last two failed. Unsure of what I changed that could cause this.

</div>
<div class="black mb-4 text-lg">{props.message}</div>
<div class="flex items-center justify-end">
<button

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be a case where we may need more or less buttons than two? For example, a modal with information that doesn't need a confirm/deny action.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I can also foresee situations where e.g. the button(s) should be disabled until a certain condition is met, and things of the sort.

I think the best interface for that will likely imply breaking the Modal component apart into Modal.Header, Modal.Body and Modal.Footer so we have fine-grained control of the contents in each through the children prop, but I think that can be left as a future PR if necessary.

Copy link
Contributor

@0x000011b 0x000011b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Don't worry about the linter complaining about the default export for the mock file, the mocking is being reworked in a separate PR so that point will be moot in a bit. Left some other comments below.

Comment on lines +26 to +28
<div class="fixed inset-0 transition-opacity">
<div class="absolute inset-0 bg-gray-500 opacity-75" />
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to have a different z-index? On my machine, the background actually shows in front of the modal and stops me from interacting with it:

Screen Shot 2023-02-18 at 18 54 40

</div>
<div class="black mb-4 text-lg">{props.message}</div>
<div class="flex items-center justify-end">
<button
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I can also foresee situations where e.g. the button(s) should be disabled until a certain condition is met, and things of the sort.

I think the best interface for that will likely imply breaking the Modal component apart into Modal.Header, Modal.Body and Modal.Footer so we have fine-grained control of the contents in each through the children prop, but I think that can be left as a future PR if necessary.

@0x000011b 0x000011b linked an issue Feb 18, 2023 that may be closed by this pull request
@n-galrion n-galrion closed this May 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a Modal component
3 participants