-
-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): theme support to modal (#197)
* feat(component): theme support to modal * doc(component): update button color modal * refactor(component): clean up interfaces
- Loading branch information
Showing
12 changed files
with
313 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import type { FC } from 'react'; | ||
import { useState } from 'react'; | ||
import { HiOutlineExclamationCircle } from 'react-icons/hi'; | ||
|
||
import type { CodeExample } from './DemoPage'; | ||
import { DemoPage } from './DemoPage'; | ||
import type { ModalSize, ModalPlacement } from '../../lib'; | ||
import { Button, Checkbox, Label, Modal, Select, TextInput } from '../../lib'; | ||
|
||
const ModalPage: FC = () => { | ||
|
@@ -20,16 +18,18 @@ const ModalPage: FC = () => { | |
<Button onClick={() => setOpenModal('default')}>Toggle modal</Button> | ||
<Modal show={openModal === 'default'} onClose={() => setOpenModal(undefined)}> | ||
<Modal.Header>Terms of Service</Modal.Header> | ||
<Modal.Body className="space-y-6"> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
With less than a month to go before the European Union enacts new consumer privacy laws for its | ||
citizens, companies around the world are updating their terms of service agreements to comply. | ||
</p> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is | ||
meant to ensure a common set of data rights in the European Union. It requires organizations to notify | ||
users as soon as possible of high-risk data breaches that could personally affect them. | ||
</p> | ||
<Modal.Body> | ||
<div className="space-y-6"> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
With less than a month to go before the European Union enacts new consumer privacy laws for its | ||
citizens, companies around the world are updating their terms of service agreements to comply. | ||
</p> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is | ||
meant to ensure a common set of data rights in the European Union. It requires organizations to notify | ||
users as soon as possible of high-risk data breaches that could personally affect them. | ||
</p> | ||
</div> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button onClick={() => setOpenModal(undefined)}>I accept</Button> | ||
|
@@ -48,18 +48,20 @@ const ModalPage: FC = () => { | |
<Button onClick={() => setOpenModal('pop-up')}>Toggle modal</Button> | ||
<Modal show={openModal === 'pop-up'} size="md" popup onClose={() => setOpenModal(undefined)}> | ||
<Modal.Header /> | ||
<Modal.Body className="text-center"> | ||
<HiOutlineExclamationCircle className="mx-auto mb-4 h-14 w-14 text-gray-400 dark:text-gray-200" /> | ||
<h3 className="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400"> | ||
Are you sure you want to delete this product? | ||
</h3> | ||
<div className="flex justify-center gap-4"> | ||
<Button color="red" onClick={() => setOpenModal(undefined)}> | ||
{"Yes, I'm sure"} | ||
</Button> | ||
<Button color="alternative" onClick={() => setOpenModal(undefined)}> | ||
No, cancel | ||
</Button> | ||
<Modal.Body> | ||
<div className="text-center"> | ||
<HiOutlineExclamationCircle className="mx-auto mb-4 h-14 w-14 text-gray-400 dark:text-gray-200" /> | ||
<h3 className="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400"> | ||
Are you sure you want to delete this product? | ||
</h3> | ||
<div className="flex justify-center gap-4"> | ||
<Button color="failure" onClick={() => setOpenModal(undefined)}> | ||
{"Yes, I'm sure"} | ||
</Button> | ||
<Button color="alternative" onClick={() => setOpenModal(undefined)}> | ||
No, cancel | ||
</Button> | ||
</div> | ||
</div> | ||
</Modal.Body> | ||
</Modal> | ||
|
@@ -73,40 +75,42 @@ const ModalPage: FC = () => { | |
<Button onClick={() => setOpenModal('form-elements')}>Toggle modal</Button> | ||
<Modal show={openModal === 'form-elements'} size="md" popup onClose={() => setOpenModal(undefined)}> | ||
<Modal.Header /> | ||
<Modal.Body className="space-y-6 px-6 pb-4 sm:pb-6 lg:px-8 xl:pb-8"> | ||
<h3 className="text-xl font-medium text-gray-900 dark:text-white">Sign in to our platform</h3> | ||
<div> | ||
<Label className="mb-2 block" htmlFor="email"> | ||
Your email | ||
</Label> | ||
<TextInput | ||
id="email" | ||
className="dark:border-gray-500 dark:bg-gray-600" | ||
placeholder="[email protected]" | ||
required | ||
/> | ||
</div> | ||
<div> | ||
<Label className="mb-2 block" htmlFor="password"> | ||
Your password | ||
</Label> | ||
<TextInput id="password" className="dark:border-gray-500 dark:bg-gray-600" type="password" required /> | ||
</div> | ||
<div className="flex justify-between"> | ||
<div className="flex items-center gap-2"> | ||
<Checkbox id="remember" className="dark:border-gray-500 dark:bg-gray-600" /> | ||
<Label htmlFor="remember">Remember me</Label> | ||
<Modal.Body> | ||
<div className="space-y-6 px-6 pb-4 sm:pb-6 lg:px-8 xl:pb-8"> | ||
<h3 className="text-xl font-medium text-gray-900 dark:text-white">Sign in to our platform</h3> | ||
<div> | ||
<Label className="mb-2 block" htmlFor="email"> | ||
Your email | ||
</Label> | ||
<TextInput | ||
id="email" | ||
className="dark:border-gray-500 dark:bg-gray-600" | ||
placeholder="[email protected]" | ||
required | ||
/> | ||
</div> | ||
<div> | ||
<Label className="mb-2 block" htmlFor="password"> | ||
Your password | ||
</Label> | ||
<TextInput id="password" className="dark:border-gray-500 dark:bg-gray-600" type="password" required /> | ||
</div> | ||
<div className="flex justify-between"> | ||
<div className="flex items-center gap-2"> | ||
<Checkbox id="remember" className="dark:border-gray-500 dark:bg-gray-600" /> | ||
<Label htmlFor="remember">Remember me</Label> | ||
</div> | ||
<a href="/modal" className="text-sm text-blue-700 hover:underline dark:text-blue-500"> | ||
Lost Password? | ||
</a> | ||
</div> | ||
<Button className="w-full">Log in to your account</Button> | ||
<div className="text-sm font-medium text-gray-500 dark:text-gray-300"> | ||
Not registered?{' '} | ||
<a href="/modal" className="text-blue-700 hover:underline dark:text-blue-500"> | ||
Create account | ||
</a> | ||
</div> | ||
<a href="/modal" className="text-sm text-blue-700 hover:underline dark:text-blue-500"> | ||
Lost Password? | ||
</a> | ||
</div> | ||
<Button className="w-full">Log in to your account</Button> | ||
<div className="text-sm font-medium text-gray-500 dark:text-gray-300"> | ||
Not registered?{' '} | ||
<a href="/modal" className="text-blue-700 hover:underline dark:text-blue-500"> | ||
Create account | ||
</a> | ||
</div> | ||
</Modal.Body> | ||
</Modal> | ||
|
@@ -132,18 +136,20 @@ const ModalPage: FC = () => { | |
</Select> | ||
<Button onClick={() => setOpenModal('size')}>Toggle modal</Button> | ||
</div> | ||
<Modal show={openModal === 'size'} size={modalSize as ModalSize} onClose={() => setOpenModal(undefined)}> | ||
<Modal show={openModal === 'size'} size={modalSize} onClose={() => setOpenModal(undefined)}> | ||
<Modal.Header>Small modal</Modal.Header> | ||
<Modal.Body className="space-y-6 p-6"> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
With less than a month to go before the European Union enacts new consumer privacy laws for its | ||
citizens, companies around the world are updating their terms of service agreements to comply. | ||
</p> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is | ||
meant to ensure a common set of data rights in the European Union. It requires organizations to notify | ||
users as soon as possible of high-risk data breaches that could personally affect them. | ||
</p> | ||
<Modal.Body> | ||
<div className="space-y-6 p-6"> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
With less than a month to go before the European Union enacts new consumer privacy laws for its | ||
citizens, companies around the world are updating their terms of service agreements to comply. | ||
</p> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is | ||
meant to ensure a common set of data rights in the European Union. It requires organizations to notify | ||
users as soon as possible of high-risk data breaches that could personally affect them. | ||
</p> | ||
</div> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button onClick={() => setOpenModal(undefined)}>I accept</Button> | ||
|
@@ -173,22 +179,20 @@ const ModalPage: FC = () => { | |
</Select> | ||
<Button onClick={() => setOpenModal('placement')}>Toggle modal</Button> | ||
</div> | ||
<Modal | ||
show={openModal === 'placement'} | ||
placement={modalPlacement as ModalPlacement} | ||
onClose={() => setOpenModal(undefined)} | ||
> | ||
<Modal show={openModal === 'placement'} position={modalPlacement} onClose={() => setOpenModal(undefined)}> | ||
<Modal.Header>Small modal</Modal.Header> | ||
<Modal.Body className="space-y-6 p-6"> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
With less than a month to go before the European Union enacts new consumer privacy laws for its | ||
citizens, companies around the world are updating their terms of service agreements to comply. | ||
</p> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is | ||
meant to ensure a common set of data rights in the European Union. It requires organizations to notify | ||
users as soon as possible of high-risk data breaches that could personally affect them. | ||
</p> | ||
<Modal.Body> | ||
<div className="space-y-6 p-6"> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
With less than a month to go before the European Union enacts new consumer privacy laws for its | ||
citizens, companies around the world are updating their terms of service agreements to comply. | ||
</p> | ||
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400"> | ||
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is | ||
meant to ensure a common set of data rights in the European Union. It requires organizations to notify | ||
users as soon as possible of high-risk data breaches that could personally affect them. | ||
</p> | ||
</div> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button onClick={() => setOpenModal(undefined)}>I accept</Button> | ||
|
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
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
Oops, something went wrong.