@@ -12,18 +12,17 @@ import {
12
12
} from "@utils/languageUtils" ;
13
13
import { slugify } from "@utils/slugify" ;
14
14
15
- import { LeftAngleArrowIcon } from "./Icons" ;
16
15
import SnippetModal from "./SnippetModal" ;
17
16
18
17
const SnippetList = ( ) => {
19
18
const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
20
- const shouldReduceMotion = useReducedMotion ( ) ;
21
-
19
+ const { fetchedSnippets, loading } = useSnippets ( ) ;
22
20
const { language, subLanguage, snippet, setSnippet } = useAppContext ( ) ;
23
- const { fetchedSnippets } = useSnippets ( ) ;
24
21
25
22
const [ isModalOpen , setIsModalOpen ] = useState < boolean > ( false ) ;
26
23
24
+ const shouldReduceMotion = useReducedMotion ( ) ;
25
+
27
26
const handleOpenModal = ( selected : SnippetType ) => ( ) => {
28
27
setIsModalOpen ( true ) ;
29
28
setSnippet ( selected ) ;
@@ -56,18 +55,29 @@ const SnippetList = () => {
56
55
// eslint-disable-next-line react-hooks/exhaustive-deps
57
56
} , [ fetchedSnippets , searchParams ] ) ;
58
57
59
- if ( ! fetchedSnippets ) {
60
- return (
61
- < div >
62
- < LeftAngleArrowIcon />
63
- </ div >
64
- ) ;
65
- }
58
+ if ( loading ) return null ;
66
59
67
60
return (
68
61
< >
69
- < motion . ul role = "list" className = "snippets" >
62
+ < motion . ul
63
+ role = "list"
64
+ className = { `snippets ${ fetchedSnippets && fetchedSnippets . length === 0 ? "data-empty" : "" } ` }
65
+ >
70
66
< AnimatePresence mode = "popLayout" >
67
+ { fetchedSnippets && fetchedSnippets . length === 0 && (
68
+ < div className = "category-no-snippets-found" >
69
+ < p > No snippets found for this category. Why not add one? 🚀</ p >
70
+ < a
71
+ href = "https://github.com/dostonnabotov/quicksnip/blob/main/CONTRIBUTING.md"
72
+ target = "_blank"
73
+ rel = "noopener noreferrer"
74
+ className = "styled-link"
75
+ >
76
+ Add your own snippet
77
+ </ a >
78
+ </ div >
79
+ ) }
80
+
71
81
{ fetchedSnippets . map ( ( snippet , idx ) => {
72
82
const uniqueId = `${ language . name } -${ snippet . title } -${ idx } ` ;
73
83
return (
0 commit comments