Skip to content

Commit

Permalink
[TM-1476] [TM-13476] add tree species iu
Browse files Browse the repository at this point in the history
  • Loading branch information
dottyy committed Dec 4, 2024
1 parent a95a159 commit 09750be
Show file tree
Hide file tree
Showing 11 changed files with 309 additions and 58 deletions.
9 changes: 9 additions & 0 deletions src/assets/icons/add-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/assets/icons/edit-ta.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/assets/icons/new-tag-tree-species.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/icons/non-scientific name.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/assets/icons/trash-ta.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Popover, Transition } from "@headlessui/react";
import { useT } from "@transifex/react";
import classNames from "classnames";
import { ChangeEvent, forwardRef, Fragment, Ref, useState } from "react";
import { Else, If, Then } from "react-if";

Expand All @@ -11,11 +12,16 @@ import Input, { InputProps } from "../Input/Input";
export interface AutoCompleteInputProps extends InputProps {
onSearch: (query: string) => Promise<string[]>;
disableAutoComplete?: boolean;
classNameMenu?: string;
onSelected?: (item: string) => void;
}

//TODO: Bugfix: Users can enter space in this input
const AutoCompleteInput = forwardRef(
({ onSearch, disableAutoComplete, ...inputProps }: AutoCompleteInputProps, ref?: Ref<HTMLInputElement>) => {
(
{ onSearch, disableAutoComplete, classNameMenu, onSelected, ...inputProps }: AutoCompleteInputProps,
ref?: Ref<HTMLInputElement>
) => {
const t = useT();
const [list, setList] = useState<string[]>([]);
const [loading, setLoading] = useState(false);
Expand All @@ -27,6 +33,8 @@ const AutoCompleteInput = forwardRef(
inputProps.onChange?.({ target: { name: inputProps.name, value: item } } as ChangeEvent<HTMLInputElement>);
}

onSelected?.(item);

setList([]);
};

Expand Down Expand Up @@ -63,7 +71,10 @@ const AutoCompleteInput = forwardRef(
leaveFrom="transform scale-100 opacity-100"
leaveTo="transform scale-95 opacity-0"
>
<Popover.Panel as="div" className="border-light mt-2 max-h-[230px] overflow-auto rounded-lg">
<Popover.Panel
as="div"
className={classNames("border-light mt-2 max-h-[230px] overflow-auto rounded-lg", classNameMenu)}
>
<If condition={loading}>
<Then>
<Text variant="text-body-600" className="p-3">
Expand Down
7 changes: 6 additions & 1 deletion src/components/elements/Inputs/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface InputProps
extends InputWrapperProps,
Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "type" | "form"> {
name: string;
variant?: "secondary" | "default" | "login" | "signup" | "monitored";
variant?: "secondary" | "default" | "login" | "signup" | "monitored" | "treePlanted";
formHook?: UseFormReturn<any>;
clearable?: boolean;
iconButtonProps?: IconButtonProps;
Expand Down Expand Up @@ -112,6 +112,11 @@ const Input = forwardRef(
true,
"pl-4": inputProps.type === "number",
"border-neutral-300": !error
},
treePlanted: {
"py-[7.5px] py-1.5 !w-[100px] text-center border border-blueCustom-700 rounded hover:border-primary hover:shadow-blue-border opacity-60 outline-none text-14-light !font-primary":
true,
"text-center": inputProps.type === "number"
}
};

Expand Down
Loading

0 comments on commit 09750be

Please sign in to comment.