diff --git a/src/components/Themes/BackgroundTheme.js b/src/components/Themes/BackgroundTheme.js
index 22b76ec..70dca69 100644
--- a/src/components/Themes/BackgroundTheme.js
+++ b/src/components/Themes/BackgroundTheme.js
@@ -1,83 +1,24 @@
-import React, { useState, useEffect, useContext } from 'react';
-import unsplash from "../../utils/unsplashConfig";
+import React, { useContext } from 'react';
import { ImgContext } from '../../utils/ImgContext';
+import UnsplashSearch from '../UnsplashSearch';
const BackgroundTheme = ({ config }) => {
- const { title, author, font, icon, customIcon, platform, bgColor } = config;
-
- // const [image, setImage] = useState({})
-
- const [imageList, setImageList] = useState([]);
- const [searchText, setSearchText] = useState('dev');
-
+ const { title, author, font, icon, customIcon, bgColor } = config;
const { unsplashImage, setUnsplashImage } = useContext(ImgContext);
- const searchImages = () => {
-
- unsplash.search
- .getPhotos({
- query: searchText,
- page: 1,
- per_page: 30,
- // orientation:'portrait'
-
-
- })
- .then(response => {
- // console.log(response.response.results);
- setImageList(response.response.results)
- });
- }
-
- useEffect(() => {
-
- unsplash.search
- .getPhotos({
- query: 'setup',
- page: 1,
- per_page: 30
-
- })
- .then(response => {
- // console.log(response.response.results);
- setImageList(response.response.results)
- });
- }, [])
-
- const selectImage = (image) => {
- setUnsplashImage({
- url: image.urls.regular,
- name: image.user.name,
- avatar: image.user.profile_image.small,
- profile: `${image.user.links.html}?utm_source=https://coverview.vercel.app&utm_medium=referral`,
- downloadLink: image.links.download_location
-
- })
-
-
- }
-
- const handleSearchSubmit = (e) => {
- e.preventDefault();
- searchImages(searchText);
-
- }
-
return (
-
+
-
-
-
+
-
{unsplashImage ?
@@ -131,37 +72,8 @@ const BackgroundTheme = ({ config }) => {
:
-
-
Click on any image to select
-
-
-
-
-
-
- {
- imageList.map(image => {
- return

selectImage(image)
- }
- />
- })
- }
-
}
diff --git a/src/components/UnsplashSearch.js b/src/components/UnsplashSearch.js
new file mode 100644
index 0000000..5d62ff3
--- /dev/null
+++ b/src/components/UnsplashSearch.js
@@ -0,0 +1,107 @@
+import React, { useState, useEffect, useContext } from 'react';
+import unsplash from '../utils/unsplashConfig';
+import { ImgContext } from '../utils/ImgContext';
+
+const UnsplashSearch = () => {
+
+ const [imageList, setImageList] = useState([]);
+ const [searchText, setSearchText] = useState('setup');
+ const { unsplashImage, setUnsplashImage } = useContext(ImgContext);
+
+
+ const searchImages = () => {
+
+ unsplash.search
+ .getPhotos({
+ query: searchText,
+ page: 1,
+ per_page: 30,
+ // orientation:'portrait'
+
+
+ })
+ .then(response => {
+ // console.log(response.response.results);
+ setImageList(response.response.results)
+ });
+ }
+
+
+ const selectImage = (image) => {
+ setUnsplashImage({
+ url: image.urls.regular,
+ name: image.user.name,
+ avatar: image.user.profile_image.small,
+ profile: `${image.user.links.html}?utm_source=https://coverview.vercel.app&utm_medium=referral`,
+ downloadLink: image.links.download_location
+
+ })
+
+
+ }
+
+ const handleSearchSubmit = (e) => {
+ e.preventDefault();
+ searchImages(searchText);
+
+ }
+
+ useEffect(() => {
+
+ unsplash.search
+ .getPhotos({
+ query: 'setup',
+ page: 1,
+ per_page: 30
+
+ })
+ .then(response => {
+ // console.log(response.response.results);
+ setImageList(response.response.results)
+ });
+ }, [])
+
+ return (
+
+
+
+
+
+
+
+ {
+ imageList.map(image => {
+ return
+
Click to Select
+

selectImage(image)
+ }
+ className="rounded-lg object-cover h-44 w-full"
+ />
+
+ })
+ }
+
+
+
+ );
+}
+
+export default UnsplashSearch;
\ No newline at end of file