@@ -12,18 +12,17 @@ import {
1212} from "@utils/languageUtils" ;
1313import { slugify } from "@utils/slugify" ;
1414
15- import { LeftAngleArrowIcon } from "./Icons" ;
1615import SnippetModal from "./SnippetModal" ;
1716
1817const SnippetList = ( ) => {
1918 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
20- const shouldReduceMotion = useReducedMotion ( ) ;
21-
19+ const { fetchedSnippets, loading } = useSnippets ( ) ;
2220 const { language, subLanguage, snippet, setSnippet } = useAppContext ( ) ;
23- const { fetchedSnippets } = useSnippets ( ) ;
2421
2522 const [ isModalOpen , setIsModalOpen ] = useState < boolean > ( false ) ;
2623
24+ const shouldReduceMotion = useReducedMotion ( ) ;
25+
2726 const handleOpenModal = ( selected : SnippetType ) => ( ) => {
2827 setIsModalOpen ( true ) ;
2928 setSnippet ( selected ) ;
@@ -56,18 +55,29 @@ const SnippetList = () => {
5655 // eslint-disable-next-line react-hooks/exhaustive-deps
5756 } , [ fetchedSnippets , searchParams ] ) ;
5857
59- if ( ! fetchedSnippets ) {
60- return (
61- < div >
62- < LeftAngleArrowIcon />
63- </ div >
64- ) ;
65- }
58+ if ( loading ) return null ;
6659
6760 return (
6861 < >
69- < motion . ul role = "list" className = "snippets" >
62+ < motion . ul
63+ role = "list"
64+ className = { `snippets ${ fetchedSnippets && fetchedSnippets . length === 0 ? "data-empty" : "" } ` }
65+ >
7066 < 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+
7181 { fetchedSnippets . map ( ( snippet , idx ) => {
7282 const uniqueId = `${ language . name } -${ snippet . title } -${ idx } ` ;
7383 return (
0 commit comments