|
| 1 | +import { |
| 2 | + component$, |
| 3 | + useSignal, |
| 4 | + type QwikIntrinsicElements, |
| 5 | + useStyles$, |
| 6 | +} from '@builder.io/qwik'; |
| 7 | +import { Modal, ModalContent, ModalFooter, ModalHeader } from '@qwik-ui/headless'; |
| 8 | +// import styles from './animation.css?inline'; |
| 9 | + |
| 10 | +export default component$(() => { |
| 11 | + const showSig = useSignal(false); |
| 12 | + useStyles$(` |
| 13 | + .my-transition::backdrop { |
| 14 | + background: rgba(0,0,0,0.5); |
| 15 | + } |
| 16 | +
|
| 17 | + .my-transition, .my-transition::backdrop { |
| 18 | + opacity: 0; |
| 19 | + transition: opacity 500ms ease; |
| 20 | + } |
| 21 | +
|
| 22 | + .my-transition.modal-showing, .my-transition.modal-showing::backdrop { |
| 23 | + opacity: 1; |
| 24 | + } |
| 25 | + |
| 26 | + .my-transition.modal-closing, .my-transition.modal-closing::backdrop { |
| 27 | + opacity: 0; |
| 28 | + } |
| 29 | + `); |
| 30 | + |
| 31 | + return ( |
| 32 | + <> |
| 33 | + <button |
| 34 | + onClick$={() => { |
| 35 | + showSig.value = true; |
| 36 | + }} |
| 37 | + class="rounded-md border-2 border-slate-300 bg-slate-700 px-3 py-2 text-white" |
| 38 | + > |
| 39 | + Open Modal |
| 40 | + </button> |
| 41 | + <Modal |
| 42 | + bind:show={showSig} |
| 43 | + class="my-transition shadow-dark-medium max-w-[25rem] rounded-md bg-white p-[28px] text-slate-950" |
| 44 | + > |
| 45 | + <ModalHeader> |
| 46 | + <h2 class="text-lg font-bold">Edit Profile</h2> |
| 47 | + </ModalHeader> |
| 48 | + <ModalContent class="mb-2 py-4"> |
| 49 | + <p class="mb-4 leading-5"> |
| 50 | + You can update your profile here. Hit the save button when finished. |
| 51 | + </p> |
| 52 | + <fieldset class="mb-1 flex items-baseline justify-between"> |
| 53 | + <label for="name">Name</label> |
| 54 | + <input |
| 55 | + class="mt-2 rounded-sm px-4 py-[10px] text-white" |
| 56 | + id="name" |
| 57 | + type="text" |
| 58 | + placeholder="John Doe" |
| 59 | + /> |
| 60 | + </fieldset> |
| 61 | + <fieldset class="flex items-baseline justify-between"> |
| 62 | + <label for="email">Email</label> |
| 63 | + <input |
| 64 | + class="mt-2 rounded-sm px-4 py-3 text-white" |
| 65 | + id="email" |
| 66 | + type="text" |
| 67 | + placeholder="johndoe@gmail.com" |
| 68 | + /> |
| 69 | + </fieldset> |
| 70 | + </ModalContent> |
| 71 | + <ModalFooter class="flex justify-end gap-4"> |
| 72 | + <button |
| 73 | + class="rounded-sm border border-none bg-slate-200 px-4 py-[10px] text-slate-600 outline-none focus-visible:outline-slate-700" |
| 74 | + onClick$={() => (showSig.value = false)} |
| 75 | + > |
| 76 | + Cancel |
| 77 | + </button> |
| 78 | + <button |
| 79 | + class="rounded-sm border border-none bg-green-200 px-4 py-[10px] text-green-900 outline-none focus-visible:outline-green-700" |
| 80 | + onClick$={() => (showSig.value = false)} |
| 81 | + > |
| 82 | + Save Changes |
| 83 | + </button> |
| 84 | + </ModalFooter> |
| 85 | + <button |
| 86 | + onClick$={() => (showSig.value = false)} |
| 87 | + class="absolute right-6 top-[26px]" |
| 88 | + > |
| 89 | + <CloseIcon class="h-8 w-8" /> |
| 90 | + </button> |
| 91 | + </Modal> |
| 92 | + </> |
| 93 | + ); |
| 94 | +}); |
| 95 | + |
| 96 | +export function CloseIcon(props: QwikIntrinsicElements['svg'], key: string) { |
| 97 | + return ( |
| 98 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props} key={key}> |
| 99 | + <path |
| 100 | + fill="020617" |
| 101 | + d="m12 13.4l2.9 2.9q.275.275.7.275t.7-.275q.275-.275.275-.7t-.275-.7L13.4 12l2.9-2.9q.275-.275.275-.7t-.275-.7q-.275-.275-.7-.275t-.7.275L12 10.6L9.1 7.7q-.275-.275-.7-.275t-.7.275q-.275.275-.275.7t.275.7l2.9 2.9l-2.9 2.9q-.275.275-.275.7t.275.7q.275.275.7.275t.7-.275l2.9-2.9Zm0 8.6q-2.075 0-3.9-.788t-3.175-2.137q-1.35-1.35-2.137-3.175T2 12q0-2.075.788-3.9t2.137-3.175q1.35-1.35 3.175-2.137T12 2q2.075 0 3.9.788t3.175 2.137q1.35 1.35 2.138 3.175T22 12q0 2.075-.788 3.9t-2.137 3.175q-1.35 1.35-3.175 2.138T12 22Zm0-2q3.35 0 5.675-2.325T20 12q0-3.35-2.325-5.675T12 4Q8.65 4 6.325 6.325T4 12q0 3.35 2.325 5.675T12 20Zm0-8Z" |
| 102 | + ></path> |
| 103 | + </svg> |
| 104 | + ); |
| 105 | +} |
0 commit comments