Skip to content

Commit

Permalink
Use box instead of button
Browse files Browse the repository at this point in the history
  • Loading branch information
pratishta committed Jul 19, 2024
1 parent 9f4f923 commit 5750a40
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
7 changes: 3 additions & 4 deletions app/components/CapitalProjectsAccordionPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, Box, Text, Flex, HStack, Heading, IconButton, Stack } from "@nycplanning/streetscape"
import { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, Box, Flex, HStack, Heading, IconButton, Stack } from "@nycplanning/streetscape"
import { Agency, CapitalProject } from "~/gen";
import { CapitalProjectsList } from "./CapitalProjectsList";
import { ChevronLeftIcon } from "@chakra-ui/icons";
import { Divider } from "@chakra-ui/react";


export interface CapitalProjectsAccordionPanelProps {
capitalProjects: Array<CapitalProject>;
Expand All @@ -28,7 +27,7 @@ export const CapitalProjectsAccordionPanel = ({
boxShadow={"0px 8px 4px 0px rgba(0, 0, 0, 0.08)"}
gap={4}
>
<Accordion allowToggle>
<Accordion defaultIndex={[0]} allowToggle>
<AccordionItem border="none">
<h2>
<AccordionButton padding="0px">
Expand Down
7 changes: 4 additions & 3 deletions app/components/CapitalProjectsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ export const CapitalProjectsList = ({
</VStack>
</Box>
</Flex>
<HStack>
<Flex paddingTop="16px" alignItems="center" justifyContent={"space-between"}>

<Pagination total={10} path={path} />
</HStack>
<Pagination total={total} path={path} />
<Button size="sm">Export Data</Button>
</Flex>

</>
);
Expand Down
21 changes: 8 additions & 13 deletions app/components/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ChevronLeftIcon, ChevronRightIcon } from "@chakra-ui/icons";
import { Flex, HStack, IconButton } from "@nycplanning/streetscape";
import { Box, Flex, HStack } from "@nycplanning/streetscape";
import { useSearchParams } from "@remix-run/react";
import { Button } from "@chakra-ui/button";
import { Link } from "@remix-run/react";
import { IconButton } from "@chakra-ui/react";

export interface PaginationProps{
total: number;
Expand All @@ -11,34 +12,28 @@ export interface PaginationProps{

export const Pagination = ({total, path}: PaginationProps) => {
const [searchParams] = useSearchParams();
console.log(searchParams);
console.log("total", total);

const limit = Number(searchParams.get("limit"));
const offset = Number(searchParams.get("offset"));

const currentPage = offset === 0 ? 1 : offset / limit + 1;
console.log(currentPage);
const canSkipBackward = offset > 0;
const canSkipForward = total === limit;
const canSkipForward = total === limit || limit === 0;

const search = `?limit=7&offset=`;
return (
<Flex
paddingTop="16px"
>
<HStack>
<HStack gap={2}>
<Link
to={{search: search + `${offset - 7}`}}
>
<IconButton disable={!canSkipBackward} size="s" aria-label="Add" icon={<ChevronLeftIcon />}/>
<Box as="button" disabled={!canSkipBackward} _disabled={{ color: 'grey' }} fontSize={"xl"}><ChevronLeftIcon /></Box>
</Link>
<Button borderRadius={0} size="sm" aria-label="Page">{currentPage}</Button>
<Box borderRadius={3} fontSize="sm" aria-label="Page">{currentPage}</Box>
<Link
to={{search: search + `${currentPage * 7}`}}
>
<IconButton disable={!canSkipBackward} size="s" aria-label="Add" icon={<ChevronRightIcon />} />
<Box as="button" disabled={!canSkipForward} _disabled={{ color: 'grey' }} fontSize={"xl"}><ChevronRightIcon /></Box>
</Link>
</HStack>
</Flex>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { CapitalProjectsList } from "~/components/CapitalProjectsList";
import { CapitalProjectsAccordionPanel } from "~/components/CapitalProjectsAccordionPanel";

export async function loader({ request, params }: LoaderFunctionArgs) {
console.log("in loader");
const url = new URL(request.url);
const path = url.pathname;
console.log("url", url);
const agenciesResponse = await findAgencies({
baseURL: `${import.meta.env.VITE_ZONING_API_URL}/api`,
});
Expand Down Expand Up @@ -49,7 +47,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {

export default function CapitalProjectsByCityCouncilDistrict() {
const {projectsByCityCouncilDistrictResponse, agencies, cityCouncilDistrictId, limit, path, offset} = useLoaderData<typeof loader>();
console.log("in return fuction", projectsByCityCouncilDistrictResponse.capitalProjects);

return (
<CapitalProjectsAccordionPanel
Expand Down

0 comments on commit 5750a40

Please sign in to comment.