Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

larger pair selector text #161

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test("connects to AlphaDEX", async ({ page }) => {
);

// A pair should appear in the pair selector
await expect(page.locator("#pair-selector")).toHaveText(/.*\/.*/);
await expect(page.locator("#pair-selector-text")).toHaveText(/^.* - .*$/);
});

// TODO: after MVP
Expand Down
23 changes: 15 additions & 8 deletions src/app/components/PairSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { useAppSelector, useAppDispatch } from "../hooks";
import { selectPairAddress } from "../redux/pairSelectorSlice";

function displayName(name?: string) {
return name?.replace("/", " - ");
}

export function PairSelector() {
const pairSelector = useAppSelector((state) => state.pairSelector);
const dispatch = useAppDispatch();
const selectPair = (pairAddress: string) => {
dispatch(selectPairAddress(pairAddress));
};

return (
<div className="dropdown dropdown-start w-full" id="pair-selector">
<label tabIndex={0} className="justify-between btn btn-block font-bold">
<span>{pairSelector.name || "Loading"}</span>
<div className="dropdown w-full">
<label
tabIndex={0}
className="justify-between btn btn-block px-8 text-xl font-bold"
>
<span id="pair-selector-text">
{displayName(pairSelector.name) || "Loading"}
</span>
<span className="float-right">
<svg
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -25,18 +35,15 @@ export function PairSelector() {
</label>
<ul
tabIndex={0}
className="dropdown-content z-[1] menu bg-base-200 shadow rounded-box w-full !my-0 !px-0"
className="dropdown-content z-[1] menu bg-base-200 shadow rounded-box w-full !my-0 !p-0"
>
<li className="text-xs text-left uppercase text-secondary-content !pl-4 ">
Select a pair of tokens:
</li>
{pairSelector.pairsList.map((pair, index) => (
<li className="font-bold !pl-0" key={index}>
<button
className="justify-between"
onClick={() => selectPair(pair.address)}
>
{pair.name}
{displayName(pair.name)}
<span>+</span>
</button>
</li>
Expand Down