-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ameen Azeez <[email protected]>
- Loading branch information
Showing
26 changed files
with
5,642 additions
and
3,311 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ | |
"react-scripts": "5.0.1", | ||
"tailwindcss": "^3.1.3" | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
import React from "react"; | ||
import classNames from "classnames"; | ||
|
||
const Button = ({ children, disabled, onClick }) => { | ||
return ( | ||
<button | ||
onClick={onClick} | ||
disabled={disabled} | ||
className={classNames( | ||
"py-2 leading-6 px-4 text-sm rounded-md disabled:opacity-75 bg-primary-200 text-gray-50" | ||
)} | ||
> | ||
{children} | ||
</button> | ||
); | ||
}; | ||
|
||
export default Button; |
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
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,20 @@ | ||
import React from "react"; | ||
import className from "classnames"; | ||
|
||
const PillFilter = ({ text, onClick, selected }) => { | ||
return ( | ||
<div | ||
onClick={() => onClick()} | ||
className={className( | ||
"block w-min py-2 px-3 max-w-[15rem] cursor-pointer hover:bg-gray-600 hover:text-gray-50 border-2 truncate mr-3 my-1 text-xs leading-3 rounded-xl", | ||
{ "bg-gray-600 font-semibold text-gray-50 border-gray-600": selected }, | ||
{ "bg-gray-50 font-medium text-gray-600 border-gray-400": !selected } | ||
|
||
)} | ||
> | ||
<span>{text}</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PillFilter; |
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,67 @@ | ||
import React, { useRef, useState } from "react"; | ||
|
||
import PillFilter from "../PillFilter"; | ||
import className from "classnames"; | ||
|
||
const useIsOverflow = (ref, callback) => { | ||
const [isOverflow, setIsOverflow] = React.useState(undefined); | ||
|
||
React.useLayoutEffect(() => { | ||
const { current } = ref; | ||
const trigger = () => { | ||
const hasOverflow = current.scrollHeight > current.clientHeight; | ||
setIsOverflow(hasOverflow); | ||
if (callback) callback(hasOverflow); | ||
}; | ||
if (current) { | ||
trigger(); | ||
} | ||
}, [callback, ref]); | ||
|
||
return isOverflow; | ||
}; | ||
|
||
export function PillFilterList({ x, onAdd, onRemove, values }) { | ||
const [isOverflow, setIsOverflow] = useState(false); | ||
const [selectedShowMore, setSelectedShowMore] = useState(false); | ||
const [selected, setSelected] = useState(values); | ||
|
||
const containerRef = useRef(null); | ||
|
||
useIsOverflow(containerRef, (overflow) => setIsOverflow(overflow)); | ||
|
||
return ( | ||
<> | ||
<div | ||
ref={containerRef} | ||
className={className("flex flex-wrap", { | ||
"max-h-[5rem] overflow-hidden": !selectedShowMore, | ||
})} | ||
> | ||
{x.map((x) => ( | ||
<PillFilter | ||
text={x} | ||
selected={selected.includes(x)} | ||
onClick={() => { | ||
if (selected.includes(x)) { | ||
onRemove(x) | ||
setSelected([...selected.filter((val) => val !== x)]); | ||
} else { | ||
onAdd(x) | ||
setSelected([...selected, x]); | ||
} | ||
}} | ||
/> | ||
))} | ||
</div> | ||
<div> | ||
{isOverflow && ( | ||
<PillFilter | ||
onClick={() => setSelectedShowMore(true)} | ||
text={"Show More"} | ||
/> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} |
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.