Skip to content

Commit

Permalink
Merge branch 'develop' into fix-vercel-storybook-esbuild-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Jul 22, 2023
2 parents 3980d26 + d19b608 commit 442d9e4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/CAREUI/icons/CareIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect } from "react";

export interface CareIconProps {
className?: string | undefined;
onClick?: () => void;
onClick?: React.MouseEventHandler<HTMLSpanElement> | undefined;
}

/**
Expand Down
36 changes: 30 additions & 6 deletions src/Components/Common/BloodPressureFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,21 @@ export default function BloodPressureFormField(props: Props) {
labelClassName="hidden"
errorClassName="hidden"
thresholds={[
{ value: 0, label: "Low", className: "text-danger-500" },
{ value: 100, label: "Normal", className: "text-primary-500" },
{ value: 140, label: "High", className: "text-warning-500" },
{
value: 0,
label: "Low",
className: "hidden md:block text-danger-500",
},
{
value: 100,
label: "Normal",
className: "hidden md:block text-primary-500",
},
{
value: 140,
label: "High",
className: "hidden md:block text-warning-500",
},
]}
/>
<span className="text-lg font-medium text-gray-400 px-2">/</span>
Expand All @@ -69,9 +81,21 @@ export default function BloodPressureFormField(props: Props) {
labelClassName="hidden"
errorClassName="hidden"
thresholds={[
{ value: 0, label: "Low", className: "text-danger-500" },
{ value: 50, label: "Normal", className: "text-primary-500" },
{ value: 90, label: "High", className: "text-warning-500" },
{
value: 0,
label: "Low",
className: "hidden md:block text-danger-500",
},
{
value: 50,
label: "Normal",
className: "hidden md:block text-primary-500",
},
{
value: 90,
label: "High",
className: "hidden md:block text-warning-500",
},
]}
/>
</div>
Expand Down
31 changes: 18 additions & 13 deletions src/Components/Form/FormFields/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { dropdownOptionClassNames } from "../MultiSelectMenuV2";
import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";
import FormField from "./FormField";
import { classNames } from "../../../Utils/utils";
import { useTranslation } from "react-i18next";

type OptionCallback<T, R> = (option: T) => R;

Expand Down Expand Up @@ -89,6 +90,7 @@ type AutocompleteProps<T, V = T> = {
* customizability.
*/
export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
const { t } = useTranslation();
const [query, setQuery] = useState(""); // Ensure lower case
useEffect(() => {
props.onQuery?.(query);
Expand Down Expand Up @@ -160,25 +162,28 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
<Combobox.Button className="absolute inset-y-0 right-0 flex items-center pr-2">
<div className="absolute right-0 top-1 mr-2 flex h-full items-center gap-1 pb-2 text-lg text-gray-900">
<span>{value?.icon}</span>

{value && !props.isLoading && !props.required && (
<div className="tooltip">
<CareIcon
className="care-l-times-circle h-4 w-4 text-gray-800 hover:text-gray-500 transition-colors duration-200 ease-in-out"
onClick={(e) => {
e.preventDefault();
props.onChange(undefined);
}}
/>
<span className="tooltip-text tooltip-bottom -translate-x-1/2 text-xs">
{t("clear_selection")}
</span>
</div>
)}

{props.isLoading ? (
<CareIcon className="care-l-spinner animate-spin" />
) : (
<CareIcon className="care-l-angle-down" />
)}
</div>
{value && (
<div
className="absolute right-0 top-1 mr-7 flex h-full items-center gap-1 pb-2 text-lg text-gray-900 hover:text-gray-500"
onClick={(e) => {
e.preventDefault();
if (!props.required) props.onChange(undefined);
}}
>
{!props.isLoading && (
<CareIcon className="care-l-times-circle h-4 w-4" />
)}
</div>
)}
</Combobox.Button>
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/Locale/en/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,6 @@
"not_specified": "Not Specified",
"all_changes_have_been_saved": "All changes have been saved",
"no_data_found": "No data found",
"edit": "Edit"
"edit": "Edit",
"clear_selection": "Clear selection"
}

0 comments on commit 442d9e4

Please sign in to comment.