-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix nested routes rerender * Add list component
- Loading branch information
1 parent
bbde8e8
commit 0b4826f
Showing
15 changed files
with
197 additions
and
104 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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { List } from './list'; | ||
|
||
export { List }; |
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,30 @@ | ||
.list { | ||
display: grid; | ||
gap: 32px 16px; | ||
} | ||
|
||
.notFound { | ||
margin: 0 auto; | ||
padding: 100px; | ||
|
||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
gap: 16px; | ||
|
||
text-align: center; | ||
|
||
.heading { | ||
font-size: 32px; | ||
font-weight: 600; | ||
line-height: 35px; | ||
letter-spacing: 0.01em; | ||
} | ||
|
||
.text { | ||
font-size: 16px; | ||
font-weight: 500; | ||
line-height: 24px; | ||
color: rgba(#000, 0.7); | ||
} | ||
} |
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,34 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import styles from './list.module.scss'; | ||
import NotFoundSVG from './not-found.svg?react'; | ||
|
||
type Props<T> = { | ||
items: T[] | undefined; | ||
itemsPerRow: number; | ||
emptyText: string; | ||
renderItem: (item: T, index: number) => ReactNode; | ||
}; | ||
|
||
function List<T>({ items, itemsPerRow, emptyText, renderItem }: Props<T>) { | ||
if (!items) return null; | ||
|
||
const renderItems = () => items?.map((item, index) => renderItem(item, index)); | ||
|
||
return items.length ? ( | ||
<ul className={styles.list} style={{ gridTemplateColumns: `repeat(${itemsPerRow}, 1fr)` }}> | ||
{renderItems()} | ||
</ul> | ||
) : ( | ||
<div className={styles.notFound}> | ||
<NotFoundSVG /> | ||
|
||
<h3 className={styles.heading}>Oops, Nothing Found!</h3> | ||
<p className={styles.text}> | ||
Looks like we're on a wild goose chase! {emptyText} to have them displayed here. | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
export { List }; |
File renamed without changes
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,4 +1,5 @@ | ||
import { GridSize } from './components'; | ||
import { GRID_SIZE } from './consts'; | ||
import { useGridSize } from './hooks'; | ||
|
||
export { GridSize, useGridSize }; | ||
export { GridSize, GRID_SIZE, useGridSize }; |
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,15 @@ | ||
import { useMarketplaceMessage, useCollectionMessage, useApprovedMessage } from './api'; | ||
import { useChangeEffect } from './use-change-effect'; | ||
import { useIsOwner } from './use-is-owner'; | ||
import { useLoading } from './use-loading'; | ||
import { useModal } from './use-modal'; | ||
|
||
export { useMarketplaceMessage, useCollectionMessage, useApprovedMessage, useModal, useIsOwner, useLoading }; | ||
export { | ||
useMarketplaceMessage, | ||
useCollectionMessage, | ||
useApprovedMessage, | ||
useModal, | ||
useIsOwner, | ||
useLoading, | ||
useChangeEffect, | ||
}; |
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,21 @@ | ||
import { EffectCallback, DependencyList, useRef, useEffect } from 'react'; | ||
|
||
function useChangeEffect(callback: EffectCallback, dependencies?: DependencyList) { | ||
const mounted = useRef(false); | ||
|
||
useEffect( | ||
() => () => { | ||
mounted.current = false; | ||
}, | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
if (mounted.current) return callback(); | ||
|
||
mounted.current = true; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, dependencies); | ||
} | ||
|
||
export { useChangeEffect }; |
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
Oops, something went wrong.