Skip to content

Commit

Permalink
fix: Filters overflow & Responsiveness issues (#566)
Browse files Browse the repository at this point in the history
* fix(web): fix filters elements overflow & responsiveness

* chore(web): update changeset

* web(refactor): reduce block number/slot date range width in big screens
  • Loading branch information
xFJA authored Sep 21, 2024
1 parent bbf5111 commit e6d78aa
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-taxis-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blobscan/web": patch
---

Fixed overflow style and responsiveness issues in Filters.
2 changes: 1 addition & 1 deletion apps/web/src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const Dropdown: React.FC<DropdownProps> = function ({
<ListboxButton
className={`relative h-9 ${
width ?? DEFAULT_WIDTH
} flex cursor-pointer items-center justify-between rounded-lg border border-transparent bg-controlBackground-light pl-2 pr-12 text-left text-sm shadow-md hover:border hover:border-controlBorderHighlight-light focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white active:border-controlBorderHighlight-dark ui-open:border-controlActive-light dark:bg-controlBackground-dark dark:hover:border-controlBorderHighlight-dark dark:ui-open:border-controlActive-dark`}
} flex cursor-pointer items-center justify-between rounded-lg border border-transparent bg-controlBackground-light pl-2 pr-8 text-left text-sm shadow-md hover:border hover:border-controlBorderHighlight-light focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white active:border-controlBorderHighlight-dark ui-open:border-controlActive-light dark:bg-controlBackground-dark dark:hover:border-controlBorderHighlight-dark dark:ui-open:border-controlActive-dark`}
>
<div className="truncate align-middle">
{selected ? (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Filters/RollupFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const RollupFilter: FC<RollupFilterProps> = function ({
options={ROLLUP_OPTIONS}
onChange={onChange}
placeholder="Rollup"
width="w-full"
width="sm:w-[130px] w-full md:max-lg:w-full"
clearable
/>
);
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/components/Filters/TimestampFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ import cn from "classnames";
import type { DatepickerType } from "react-tailwindcss-datepicker";
import Datepicker from "react-tailwindcss-datepicker";

import { useBreakpoint } from "~/hooks/useBreakpoint";

type TimestampFilterProps = Pick<DatepickerType, "value" | "onChange">;

export const TimestampFilter: FC<TimestampFilterProps> = function ({
value,
onChange,
}) {
const isValueSet = value?.startDate || value?.endDate;
const breakpoint = useBreakpoint();
const shouldShowPlaceholder = breakpoint !== "md";

return (
<Datepicker
primaryColor="purple"
value={value}
onChange={onChange}
inputClassName={cn(
"h-9 w-full pl-2 pr-12",
"h-9 w-full xl:w-[222px] md:max-lg:w-[44px] pl-2 pr-8",
"text-left text-sm placeholder:text-sm",
"cursor-pointer",
"rounded-lg border border-transparent shadow-md",
Expand All @@ -38,7 +42,7 @@ export const TimestampFilter: FC<TimestampFilterProps> = function ({
"relative",
"[&>div>div]:dark:bg-controlBackground-dark [&>div>div]:border-controlBorder-light [&>div>div]:dark:border-transparent"
)}
placeholder="Start date - End date"
placeholder={shouldShowPlaceholder ? "Start date - End date" : ""}
/>
);
};
65 changes: 35 additions & 30 deletions apps/web/src/components/Filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,36 +194,38 @@ export const Filters: FC = function () {
}, [queryParams]);

return (
<Card>
<Card compact>
<div className="flex flex-col justify-between gap-4 lg:flex-row lg:gap-0">
<div className="flex w-full flex-col items-center gap-2 md:flex-row">
<SortToggle
type={filters.sort}
onChange={(newSort) => {
dispatch({ type: "UPDATE", payload: { sort: newSort } });
}}
/>
<div className="w-full md:w-40">
<RollupFilter
selected={filters.rollup}
onChange={(newRollup) =>
dispatch({ type: "UPDATE", payload: { rollup: newRollup } })
}
/>
</div>
<div className="w-full md:w-64">
<TimestampFilter
value={filters.timestampRange}
onChange={(newTimestampRange) =>
dispatch({
type: "UPDATE",
payload: { timestampRange: newTimestampRange },
})
}
<div className="flex w-full flex-col items-center gap-2 md:flex-row lg:max-xl:gap-1">
<div className="flex w-full flex-row gap-2 xl:w-auto">
<SortToggle
type={filters.sort}
onChange={(newSort) => {
dispatch({ type: "UPDATE", payload: { sort: newSort } });
}}
/>
<div className="w-full sm:w-[130px] md:max-lg:w-full">
<RollupFilter
selected={filters.rollup}
onChange={(newRollup) =>
dispatch({ type: "UPDATE", payload: { rollup: newRollup } })
}
/>
</div>
<div className="w-full md:max-lg:w-[44px] lg:w-[222px]">
<TimestampFilter
value={filters.timestampRange}
onChange={(newTimestampRange) =>
dispatch({
type: "UPDATE",
payload: { timestampRange: newTimestampRange },
})
}
/>
</div>
</div>
<div className="flex gap-2">
<div className="w-full md:w-52">
<div className="w-full md:w-52 lg:max-xl:w-[12rem]">
<BlockNumberFilter
range={filters.blockNumberRange}
onChange={(newBlockNumberRange) =>
Expand All @@ -234,7 +236,7 @@ export const Filters: FC = function () {
}
/>
</div>
<div className="w-full md:w-52">
<div className="w-full md:w-52 lg:max-xl:w-44">
<SlotFilter
range={filters.slotRange}
onChange={(newSlotRange) =>
Expand All @@ -247,16 +249,19 @@ export const Filters: FC = function () {
</div>
</div>
</div>
<div className="flex flex-col gap-2 md:flex-row">
<div className="flex flex-col gap-1 md:flex-row lg:ml-2">
<Button
className="w-full lg:w-auto"
className="w-full lg:w-auto lg:px-3 xl:px-6"
variant="outline"
onClick={() => dispatch({ type: "CLEAR" })}
disabled={disableClear}
>
Clear
</Button>
<Button className="w-full lg:w-auto" onClick={handleFilter}>
<Button
className="w-full lg:w-auto lg:px-3 xl:px-6"
onClick={handleFilter}
>
Filter
</Button>
</div>
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/PaginatedTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const PaginatedTable: FC<PaginatedTableProps> = function ({
</div>
}
emptyState={DEFAULT_TABLE_EMPTY_STATE}
compact
>
<div className="flex flex-col gap-6">
<Table
Expand Down

0 comments on commit e6d78aa

Please sign in to comment.