forked from AdventOfJavaScript/2023-12-00__starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from camer0nluo/wishlist
feature: add edit event title name and modal
- Loading branch information
Showing
5 changed files
with
162 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Pass props to your component by passing an `args` object to your story | ||
// | ||
// ```tsx | ||
// export const Primary: Story = { | ||
// args: { | ||
// propName: propValue | ||
// } | ||
// } | ||
// ``` | ||
// | ||
// See https://storybook.js.org/docs/react/writing-stories/args. | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import ModalPopup from './ModalPopup' | ||
|
||
const meta: Meta<typeof ModalPopup> = { | ||
component: ModalPopup, | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof ModalPopup> | ||
|
||
export const Primary: Story = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { render } from '@redwoodjs/testing/web' | ||
|
||
import ModalPopup from './ModalPopup' | ||
|
||
// Improve this test with help from the Redwood Testing Doc: | ||
// https://redwoodjs.com/docs/testing#testing-components | ||
|
||
describe('ModalPopup', () => { | ||
it('renders successfully', () => { | ||
expect(() => { | ||
render(<ModalPopup />) | ||
}).not.toThrow() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const ModalPopup = ({ | ||
setShowModal, | ||
title, | ||
message, | ||
inputElement, | ||
confirm, | ||
}) => { | ||
return ( | ||
<div | ||
className="relative z-10" | ||
aria-labelledby="modal-title" | ||
role="dialog" | ||
aria-modal="true" | ||
> | ||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div> | ||
|
||
<div className="fixed inset-0 z-10 w-screen overflow-y-auto"> | ||
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0"> | ||
<div className="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg"> | ||
<div className="bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4"> | ||
<div className="sm:flex sm:items-start"> | ||
<div className="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10"> | ||
<svg | ||
className="h-6 w-6 text-green-600" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
strokeWidth="1.5" | ||
stroke="currentColor" | ||
aria-hidden="true" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" | ||
/> | ||
</svg> | ||
</div> | ||
<div className="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left"> | ||
<h3 | ||
className="text-base font-semibold leading-6 text-gray-900" | ||
id="modal-title" | ||
> | ||
{title} | ||
</h3> | ||
<div className="mt-2"> | ||
<p className="text-sm text-gray-500">{message}</p> | ||
{inputElement} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6"> | ||
<button | ||
type="button" | ||
onClick={confirm} | ||
className="inline-flex w-full justify-center rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-500 sm:ml-3 sm:w-auto" | ||
> | ||
Confirm | ||
</button> | ||
<button | ||
type="button" | ||
className="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto" | ||
onClick={() => setShowModal(false)} | ||
> | ||
Cancel | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ModalPopup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters