diff --git a/app/components/ConfirmationModal.tsx b/app/components/ConfirmationModal.tsx new file mode 100644 index 0000000000..abcdd1040a --- /dev/null +++ b/app/components/ConfirmationModal.tsx @@ -0,0 +1,89 @@ +import { Dialog, Transition } from "@headlessui/react"; +import { Button } from "~/components/Button"; +import { Fragment } from "react"; + +interface Props { + text: string; + title: string; + open: boolean; + onClose: () => void; + onOk?: () => void; + okText?: string; + okColor?: string; + onCancel?: () => void; + cancelText?: string; +} + +export const ConfirmationModal = ({ + text, + title, + open, + onClose, + onOk, + okText = "OK", + okColor = "bg-brand-success", + onCancel, + cancelText = "Cancel", +}: Props) => { + return ( + + + +
+ +
+ + + + {title} + + +
{text}
+ +
+ {!!onCancel && ( + + )} + {!!onOk && ( + + )} +
+
+
+
+
+
+ ); +}; diff --git a/app/components/ItemPicker.tsx b/app/components/ItemPicker.tsx index 90eae68411..a0949916ec 100644 --- a/app/components/ItemPicker.tsx +++ b/app/components/ItemPicker.tsx @@ -1,16 +1,31 @@ +import { twMerge } from "tailwind-merge"; import { H4 } from "."; + interface ItemPickerProps extends React.ImgHTMLAttributes { label: string + selected: boolean; + onSelected : (val:string)=>void; } export const ItemPicker = ({ label, + selected = false, + onSelected, ...imgProps }:ItemPickerProps) => { + + const handleSelected = ()=>{ + onSelected(label); + }; + return ( -
+
+

{label}

) diff --git a/app/components/LoadingDots.tsx b/app/components/LoadingDots.tsx new file mode 100644 index 0000000000..4d622587ba --- /dev/null +++ b/app/components/LoadingDots.tsx @@ -0,0 +1,71 @@ +import { useState, useEffect } from 'react'; +import { twMerge } from 'tailwind-merge'; + +interface LoadingDotsProps { + className?: string; + show?: boolean; + transition?: boolean; + transitionDuration?: number; +}; + +interface LoadingDotsInnerProps { + className?: string; + show?: boolean; + transition?: boolean; + transitionDuration?: number; + children: React.ReactNode; +}; + +export const LoadingDotsTyping = (props: LoadingDotsProps)=>{ + return ( + +
+
+ ) +} +export const LoadingDotsBricks = (props: LoadingDotsProps)=>{ + return ( + +
+
+ ) +} + +function LoadingDots({ + className, + show=true, + transition = false, + transitionDuration = 1000, + children, +}: LoadingDotsInnerProps){ + const [state, setState] = useState<'loading'|'loaded'|'completed'>('loading'); + const transitionClasses = + (transition ? `transition-opacity duration-${transitionDuration} `: "") + + (state === 'loading' ? 'opacity-100' : 'opacity-0'); + + const classNames = twMerge("w-full h-full flex justify-center items-center bg-ui-background ",transitionClasses, className); + useEffect(()=>{ + if(!show){ + if(transition){ + setState((curr)=>{ + if (curr === 'loading') return 'loaded' + else return curr; + }); + setTimeout(()=>setState('completed'), 2000); + } else { + setState('completed'); + } + } + }, [show, transition]); + + if(state!== 'completed'){ + return( +
+ {children} +
+ ); + }else{ + return null; + } +}; + diff --git a/app/components/Textarea.tsx b/app/components/Textarea.tsx index f9ca528ab9..3b069b39ee 100644 --- a/app/components/Textarea.tsx +++ b/app/components/Textarea.tsx @@ -7,11 +7,18 @@ export const Textarea = ({ }:TextareaHTMLAttributes) => { return(