-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ListItem to allow filtering
- Loading branch information
1 parent
4011075
commit e615f29
Showing
24 changed files
with
271 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# testing | ||
/coverage | ||
/metrics | ||
# *.spec.* | ||
|
||
# next.js | ||
/.next/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
type ReactElement = import("react").ReactElement | ||
|
||
interface ActionButton<Item> { | ||
onClick: (() => void | Promise<void>) | ((item: Item) => void | Promise<void>) | ||
onClick: (item: Item) => void | Promise<void> | ||
label?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
import { ReactElement } from "react" | ||
import { StackProps, VStack } from "@chakra-ui/react" | ||
import { Fade, List, ListItem, ListProps } from "@chakra-ui/react" | ||
|
||
import { ListItemProps } from "@components/ListItem" | ||
import { ListItemSkeleton } from "@components/ListItem/LIstItemSkeleton" | ||
import { ItemProps } from "@components/ListItem" | ||
import { ListItemSkeleton } from "@components/ListItem/ListItemSkeleton" | ||
|
||
interface ListProps<Data> extends StackProps { | ||
interface ListViewProps<Data> extends ListProps { | ||
items: Data[] | undefined | ||
render: (item: Data) => ReactElement<ItemProps<Data>> | ||
isLoading: boolean | ||
children: | ||
| ReactElement<ListItemProps<Data>> | ||
| ReactElement<ListItemProps<Data>>[] | ||
| undefined | ||
} | ||
|
||
export const List = <Data,>({ | ||
children, | ||
export const ListView = <Data,>({ | ||
items, | ||
render, | ||
isLoading, | ||
...props | ||
}: ListProps<Data>) => { | ||
}: ListViewProps<Data>) => { | ||
return ( | ||
<VStack align="stretch" spacing={6} {...props}> | ||
{children} | ||
{isLoading && <ListItemSkeleton />} | ||
</VStack> | ||
<List spacing={6} {...props}> | ||
{items?.map((item, key) => ( | ||
<Fade in key={key}> | ||
<ListItem>{render(item)}</ListItem> | ||
</Fade> | ||
))} | ||
|
||
{isLoading && | ||
Array.from({ length: 4 }, (_, key) => <ListItemSkeleton key={key} />)} | ||
</List> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Fade, Flex, HStack, Skeleton, VStack } from "@chakra-ui/react" | ||
|
||
export const ListItemSkeleton = () => ( | ||
<Fade in data-testid="list-item-skeleton"> | ||
<Flex | ||
w="100%" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
pb={2} | ||
bg="white" | ||
borderRadius="md" | ||
padding={4} | ||
boxShadow="medium" | ||
height="92px" | ||
> | ||
<VStack spacing={2} alignItems="start"> | ||
<Skeleton height="24px" w={175} /> | ||
<Skeleton height="16px" w={280} /> | ||
</VStack> | ||
<HStack spacing={4} alignSelf="end"> | ||
<Skeleton height="40px" width="40px" alignSelf="end" /> | ||
<Skeleton height="40px" width="40px" alignSelf="end" /> | ||
<Skeleton height="40px" width="40px" alignSelf="end" /> | ||
</HStack> | ||
</Flex> | ||
</Fade> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.