Skip to content

Commit

Permalink
Merge branch 'develop' into tailwind/patient-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Oct 26, 2022
2 parents 957d592 + 2f09f63 commit aa96d06
Show file tree
Hide file tree
Showing 11 changed files with 640 additions and 488 deletions.
4 changes: 2 additions & 2 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const AssetsList = () => {
return (
<div className="px-6">
<PageTitle title="Assets" hideBack={true} breadcrumbs={false} />
<div className="lg:flex mt-5 space-y-2 space-x-2">
<div className="lg:flex mt-5 space-y-2">
<div className="bg-white overflow-hidden shadow rounded-lg flex-1 md:mr-2">
<div className="px-4 py-5 sm:p-6">
<dl>
Expand Down Expand Up @@ -313,7 +313,7 @@ const AssetsList = () => {
<Loading />
) : (
<>
<div className="flex space-x-2 mt-2 flex-wrap w-full col-span-3">
<div className="flex mt-2 flex-wrap w-full col-span-3">
{badge("Facility", facilityName, ["facility", "location"])}
{badge("Asset Name", qParams.search, ["search"])}
{badge("Location", locationName, ["location"])}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const InputSearchBox = (props: TextFieldPropsExtended) => {
name="search"
type="text"
{...inputProps}
className="form-input pr-8 sm:text-sm sm:leading-5"
className="form-input pr-8 sm:text-sm sm:leading-5 text-ellipsis"
/>
{searchValue ? (
<div
Expand Down
73 changes: 73 additions & 0 deletions src/Components/Common/components/AccordionV2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useState } from "react";

export default function AccordionV2(props: {
children: JSX.Element | JSX.Element[];
expandIcon?: JSX.Element;
title: JSX.Element | JSX.Element[] | string;
className?: string;
expanded?: boolean;
}) {
const [toggle, setToggle] = useState(props.expanded as boolean);
const contentEl = React.useRef<HTMLDivElement>(null);

return (
<div className={props.className}>
<div className="flex justify-between">
<button
type="button"
className="w-full grid justify-start"
onClick={() => {
setToggle((prev) => !prev);
}}
>
<>{props.title}</>
</button>
<button
type="button"
className={
toggle
? "transition-all rotate-180 duration-300 ease-in-out"
: "transition"
}
onClick={() => {
setToggle((prev) => !prev);
}}
>
{props.expandIcon ? (
props.expandIcon
) : (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={2}
stroke="currentColor"
className="w-5 h-5"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M19.5 8.25l-7.5 7.5-7.5-7.5"
/>
</svg>
)}
</button>
</div>
<div
className="transition-all ease-in-out duration-500 overflow-hidden"
ref={contentEl}
style={
toggle
? {
maxHeight: contentEl.current
? contentEl.current.scrollHeight * 2
: "0px",
}
: { maxHeight: "0px" }
}
>
{props.children}
</div>
</div>
);
}
54 changes: 54 additions & 0 deletions src/Components/Common/components/CollapseV2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, { useEffect, useState } from "react";

export default function CollapseV2(props: {
children: JSX.Element | JSX.Element[];
opened: boolean;
className?: string;
}) {
const content = React.useRef<HTMLDivElement>(null);
const [innerDivState, setInnerDivState] = useState(false);
const [outerDivState, setOuterDivState] = useState(false);

useEffect(() => {
if (props.opened) {
setOuterDivState(props.opened);
setTimeout(() => {
setInnerDivState(props.opened);
}, 1);
} else {
setInnerDivState(props.opened);
setTimeout(() => {
setOuterDivState(props.opened);
}, 300);
}
}, [props.opened]);

return (
<div
className="transition-all ease-in-out duration-300"
style={
outerDivState
? {
display: "block",
}
: { display: "none" }
}
>
<div
className={`transition-all ease-in-out duration-300 overflow-hidden ${
props.className ? props.className : ""
}`}
ref={content}
style={
innerDivState
? {
maxHeight: content.current?.scrollHeight,
}
: { maxHeight: "0px" }
}
>
{props.children}
</div>
</div>
);
}
91 changes: 36 additions & 55 deletions src/Components/Common/components/ResponsiveMedicineTables.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
Accordion,
AccordionDetails,
AccordionSummary,
} from "@material-ui/core";
import { useEffect, useState } from "react";
import AccordionV2 from "./AccordionV2";

function getWindowSize() {
const { innerWidth, innerHeight } = window;
Expand Down Expand Up @@ -67,31 +63,11 @@ export default function ResponsiveMedicineTable(props: {
) : (
<div className="rounded-md shadow-sm">
{props.list.map((med: any, index: number) => (
<Accordion elevation={0} key={index}>
<AccordionSummary
className="overflow-hidden"
expandIcon={
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={2}
stroke="currentColor"
className="w-5 h-5"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M19.5 8.25l-7.5 7.5-7.5-7.5"
/>
</svg>
}
aria-controls={`panel${index + 1}a-content`}
id={`panel${index + 1}a-header`}
>
<AccordionV2
title={
<div className="grid">
<div className="flex flex-col">
<h3 className="text-sm font-medium overflow-hidden text-ellipsis w-full">
<h3 className="text-sm font-medium overflow-hidden text-ellipsis w-full text-left">
{med[props.objectKeys[0]]}
</h3>
</div>
Expand All @@ -106,35 +82,40 @@ export default function ResponsiveMedicineTable(props: {
))}
</div>
</div>
</AccordionSummary>
<AccordionDetails className="border-t border-t-gray-400">
<div className="flex flex-col w-full">
<div className="grid grid-cols-2 gap-3 w-full">
{props.objectKeys.map((key, i) => {
if (i !== 0 && i !== props.objectKeys.length - 1)
return (
<div>
<h4 className="font-semibold text-base">
{props.theads[i]}
</h4>{" "}
<p>{med[key]}</p>
</div>
);
}
className={
props.list.length - 1 === index
? "bg-white p-5 "
: "bg-white p-5 border-b border-b-gray-400"
}
key={index}
>
<div className="flex flex-col w-full border-t border-t-gray-400 mt-3">
<div className="grid grid-cols-2 gap-3 w-full mt-3">
{props.objectKeys.map((key, i) => {
if (i !== 0 && i !== props.objectKeys.length - 1)
return (
<div>
<h4 className="font-semibold text-base">
{props.theads[i]}
</h4>{" "}
<p>{med[key]}</p>
</div>
);

if (i === props.objectKeys.length - 1)
return (
<div className="col-span-2">
<h4 className="font-semibold text-base">
{props.theads[i]}
</h4>{" "}
<p>{med[key]}</p>
</div>
);
})}
</div>
if (i === props.objectKeys.length - 1)
return (
<div className="col-span-2">
<h4 className="font-semibold text-base">
{props.theads[i]}
</h4>{" "}
<p>{med[key]}</p>
</div>
);
})}
</div>
</AccordionDetails>
</Accordion>
</div>
</AccordionV2>
))}
</div>
)}
Expand Down
9 changes: 8 additions & 1 deletion src/Components/Common/components/SelectMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Props<T> = {
selected?: T;
label?: string;
position?: string;
parentRelative?: boolean;
};

/** Deprecated. Use SelectMenuV2. */
Expand All @@ -35,7 +36,13 @@ export default function SelectMenu<T>(props: Props<T>) {
{({ open }) => (
<>
<Listbox.Label className="sr-only">{props.label}</Listbox.Label>
<div className="relative">
<div
className={
props.parentRelative || props.parentRelative === undefined
? "relative"
: ""
}
>
<Listbox.Button className="w-full flex shadow-sm rounded bg-gray-50 hover:bg-gray-200 focus:ring-primary-500 border focus:ring-1 ring-gray-400 focus:border-primary-500 border-gray-400 transition-all duration-200 ease-in-out">
<div className="relative z-0 flex w-full">
<div className="relative flex-1 flex items-center py-2 pl-3 pr-4 border border-transparent rounded-l focus:outline-none focus:z-10">
Expand Down
Loading

0 comments on commit aa96d06

Please sign in to comment.