@@ -5,22 +5,16 @@ import { useAppContext } from "@contexts/AppContext";
55import { useSnippets } from "@hooks/useSnippets" ;
66import { SnippetType } from "@types" ;
77
8- import { LeftAngleArrowIcon } from "./Icons" ;
98import SnippetModal from "./SnippetModal" ;
109
1110const SnippetList = ( ) => {
1211 const { language, snippet, setSnippet } = useAppContext ( ) ;
13- const { fetchedSnippets } = useSnippets ( ) ;
12+ const { fetchedSnippets, loading } = useSnippets ( ) ;
1413 const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
1514
1615 const shouldReduceMotion = useReducedMotion ( ) ;
1716
18- if ( ! fetchedSnippets )
19- return (
20- < div >
21- < LeftAngleArrowIcon />
22- </ div >
23- ) ;
17+ if ( loading ) return null ;
2418
2519 const handleOpenModal = ( activeSnippet : SnippetType ) => {
2620 setIsModalOpen ( true ) ;
@@ -34,9 +28,25 @@ const SnippetList = () => {
3428
3529 return (
3630 < >
37- < motion . ul role = "list" className = "snippets" >
31+ < motion . ul
32+ role = "list"
33+ className = { `snippets ${ fetchedSnippets && fetchedSnippets . length === 0 ? "data-empty" : "" } ` }
34+ >
3835 < AnimatePresence mode = "popLayout" >
39- { fetchedSnippets . map ( ( snippet , idx ) => {
36+ { fetchedSnippets && fetchedSnippets . length === 0 && (
37+ < div className = "category-no-snippets-found" >
38+ < p > No snippets found for this category. Why not add one? 🚀</ p >
39+ < a
40+ href = "https://github.com/dostonnabotov/quicksnip/blob/main/CONTRIBUTING.md"
41+ target = "_blank"
42+ rel = "noopener noreferrer"
43+ className = "styled-link"
44+ >
45+ Add your own snippet
46+ </ a >
47+ </ div >
48+ ) }
49+ { fetchedSnippets ?. map ( ( snippet , idx ) => {
4050 const uniqueId = `${ language . name } -${ snippet . title } ` ;
4151 return (
4252 < motion . li
0 commit comments