Skip to content

Commit

Permalink
styling updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Oct 24, 2023
1 parent 3f73fbe commit 8d656ba
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/app/components/PairSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,37 +91,42 @@ export function PairSelector() {
};
const options = pairSelector.pairsList;
const id = "pairOption";
const selectedVal = pairSelector.pairsList[0]
let selectedVal = pairSelector.pairsList[0]
? pairSelector.pairsList[0].name
: "Loading";
const handleChange = (val) => {
console.log(val);
selectPair(val);
};

const [query, setQuery] = useState("");
const [isOpen, setIsOpen] = useState(false);
const [isOpen, setIsOpen] = useState(true);

const inputRef = useRef(null);

const dropdownRef = useRef(null);
/*
useEffect(() => {
document.addEventListener("click", toggle);
return () => document.removeEventListener("click", toggle);
}, []);

*/
const selectOption = (option) => {
setQuery(() => "");
handleChange(option["address"]);
console.log(option);

Check warning on line 115 in src/app/components/PairSelector.tsx

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
selectedVal = option["name"];
setIsOpen((isOpen) => !isOpen);
};

function toggle(e) {
console.log(inputRef.current);

Check warning on line 121 in src/app/components/PairSelector.tsx

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
setIsOpen(e && e.target === inputRef.current);
}

const getDisplayValue = () => {
if (query) return query;
if (selectedVal) return selectedVal;
console.log("query %s", query);

Check warning on line 126 in src/app/components/PairSelector.tsx

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
console.log("sel %s", selectedVal);

Check warning on line 127 in src/app/components/PairSelector.tsx

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
if (query) return displayName(query);
if (selectedVal) return displayName(selectedVal);

return "";
};
Expand All @@ -134,9 +139,9 @@ export function PairSelector() {

return (
<div className="w-full">
<div className="dropdown dropdown-end">
<label className="justify-between btn btn-block px-8 text-xl font-bold">
<div className="selected-value">
<div className="dropdown dropdown-end w-full">
<label className="btn btn-block text-xl font-bold no-animation">
<div className="flex justify-between selected-value w-full">
<input
ref={inputRef}
type="text"
Expand All @@ -147,8 +152,9 @@ export function PairSelector() {
handleChange(null);
}}
onClick={toggle}
className="flex-initial !bg-transparent"
/>
<span className="float-right">
<span className="flex-none order-last pt-2">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
Expand All @@ -162,9 +168,10 @@ export function PairSelector() {
</div>
</label>
<ul
ref={dropdownRef}
tabIndex={0}
className={
`options ${isOpen ? "" : ""}` +
`options ${isOpen ? "" : "hidden"}` +
" dropdown-content z-[1] menu bg-base-200 shadow rounded-box w-full !my-0 !p-0"
}
>
Expand All @@ -177,11 +184,12 @@ export function PairSelector() {
" font-bold !pl-0"
}
key={`${id}-${index}`}
value={option["name"]}
>
<button>
{displayName(option["name"])}
<span>+</span>
</button>
<div className="flex justify-between">
<span className="flex-1">{displayName(option["name"])}</span>
<span className="flex-none">+</span>
</div>
</li>
);
})}
Expand Down

0 comments on commit 8d656ba

Please sign in to comment.