@@ -5,22 +5,16 @@ import { useAppContext } from "@contexts/AppContext";
5
5
import { useSnippets } from "@hooks/useSnippets" ;
6
6
import { SnippetType } from "@types" ;
7
7
8
- import { LeftAngleArrowIcon } from "./Icons" ;
9
8
import SnippetModal from "./SnippetModal" ;
10
9
11
10
const SnippetList = ( ) => {
12
11
const { language, snippet, setSnippet } = useAppContext ( ) ;
13
- const { fetchedSnippets } = useSnippets ( ) ;
12
+ const { fetchedSnippets, loading } = useSnippets ( ) ;
14
13
const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
15
14
16
15
const shouldReduceMotion = useReducedMotion ( ) ;
17
16
18
- if ( ! fetchedSnippets )
19
- return (
20
- < div >
21
- < LeftAngleArrowIcon />
22
- </ div >
23
- ) ;
17
+ if ( loading ) return null ;
24
18
25
19
const handleOpenModal = ( activeSnippet : SnippetType ) => {
26
20
setIsModalOpen ( true ) ;
@@ -34,9 +28,25 @@ const SnippetList = () => {
34
28
35
29
return (
36
30
< >
37
- < motion . ul role = "list" className = "snippets" >
31
+ < motion . ul
32
+ role = "list"
33
+ className = { `snippets ${ fetchedSnippets && fetchedSnippets . length === 0 ? "data-empty" : "" } ` }
34
+ >
38
35
< 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 ) => {
40
50
const uniqueId = `${ language . name } -${ snippet . title } ` ;
41
51
return (
42
52
< motion . li
0 commit comments