File tree 4 files changed +30
-6
lines changed
4 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ export default function Header() {
129
129
130
130
< form className = "hidden lg:flex" >
131
131
< input
132
- className = "border-primary-light border px-2 py-1 focus:border-secondary focus:outline-none focus:transition-all "
132
+ className = "border border -primary-light px-2 py-1 focus:border-secondary focus:outline-none focus:transition-all "
133
133
type = "text"
134
134
placeholder = "Search"
135
135
/>
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import App from "./App";
4
4
import "./index.css" ;
5
5
import "react-toastify/dist/ReactToastify.css" ;
6
6
import { ToastContainer } from "react-toastify" ;
7
+ import 'react-loading-skeleton/dist/skeleton.css'
7
8
8
9
ReactDOM . createRoot ( document . getElementById ( "root" ) ) . render (
9
10
< React . StrictMode >
Original file line number Diff line number Diff line change @@ -5,18 +5,22 @@ import Slider from "react-slick";
5
5
import Products from "../pages/Products" ;
6
6
import axios from "axios" ;
7
7
import React , { useEffect , useState } from "react" ;
8
+ import Skeleton from "react-loading-skeleton" ;
8
9
9
10
export default function Home ( ) {
11
+ const [ isLoading , setIsLoading ] = useState ( true ) ;
12
+
10
13
const settings = {
11
14
dots : true ,
12
15
infinite : true ,
13
16
slidesToShow : 1 ,
14
17
slidesToScroll : 1 ,
15
- autoplay : true ,
18
+ autoplay : false ,
16
19
autoplaySpeed : 2000 ,
17
20
pauseOnHover : true ,
18
21
initialSlide : 0 ,
19
22
arrows : false ,
23
+ dots :false ,
20
24
responsive : [
21
25
{
22
26
breakpoint : 1024 ,
@@ -68,14 +72,15 @@ export default function Home() {
68
72
. then ( ( res ) => {
69
73
console . log ( res ) ;
70
74
setProducts ( res . data . data ) ;
71
- isLoading ( false ) ;
75
+ setIsLoading ( false ) ;
72
76
} )
73
77
. catch ( ( err ) => { } ) ;
74
78
} , [ ] ) ;
75
79
76
80
return (
77
81
< >
78
82
< Slider { ...settings } >
83
+ { isLoading && < Skeleton className = "h-[576px]" /> }
79
84
{ banners . map ( ( el ) => {
80
85
return (
81
86
< Banner
@@ -92,8 +97,27 @@ export default function Home() {
92
97
93
98
< div className = "container grid gap-4 py-[116px] sm:py-[130px] md:grid-cols-2 md:py-[148px] lg:grid-cols-4 lg:py-[166px] xl:py-[188px] xxl:py-[210px]" >
94
99
{ products . map ( ( el ) => {
95
- return < Products name = { el . name } price = { el . price } image = { el . image } /> ;
100
+ return (
101
+ < >
102
+ < Products
103
+ key = { el . _id }
104
+ id = { el . _id }
105
+ name = { el . name }
106
+ price = { el . price }
107
+ image = { el . image }
108
+ />
109
+ </ >
110
+ ) ;
96
111
} ) }
112
+ { isLoading && (
113
+ < >
114
+ < Skeleton className = "h-[250px]" />
115
+ < Skeleton className = "h-[250px]" />
116
+ < Skeleton className = "h-[250px]" />
117
+ < Skeleton className = "h-[250px]" />
118
+ </ >
119
+ ) }
120
+ { ! isLoading && products . length == 0 && < > no product found</ > }
97
121
</ div >
98
122
</ >
99
123
) ;
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import { FaCartPlus } from "react-icons/fa" ;
3
- import BreadCrumb from "../components/BreadCrumb" ;
4
3
5
4
export default function Products ( props ) {
6
5
return (
7
6
< >
8
- < div className = " bg-primary-light group relative shadow-[0px_0px_25px_0px_rgba(0,0,0,0.1)] " >
7
+ < div className = " group relative bg-primary-light shadow-[0px_0px_25px_0px_rgba(0,0,0,0.1)] " >
9
8
< div className = " absolute left-[11px] top-[11px] hidden h-[30px] w-[30px] items-center justify-center rounded-full border border-primary transition-all group-hover:flex" >
10
9
< FaCartPlus className = "text-primary" />
11
10
</ div >
You can’t perform that action at this time.
0 commit comments