From 46f26b7774678b9c65535629fd5ddd7bd36f1dbc Mon Sep 17 00:00:00 2001 From: Vishal Singh Date: Sun, 1 Nov 2020 12:17:32 +0530 Subject: [PATCH] modified search page and fixed dropdown ans siderbar playlist --- src/app/App.jsx | 7 ++- src/components/Pages/Home.jsx | 23 ++++++++-- src/components/Pages/Search.jsx | 41 +++++++++++------ src/components/Pages/css/Search.scss | 46 ++++++++++++++++++- .../assets/scss/FooterSelectMusic.scss | 2 +- .../fragment/DropDownLanguageList.jsx | 9 +--- src/components/fragment/FooterSelectMusic.jsx | 2 +- src/components/fragment/Navigation.jsx | 3 +- src/components/fragment/SearchBar.jsx | 2 +- src/components/fragment/SideBar.jsx | 6 +-- 10 files changed, 104 insertions(+), 37 deletions(-) diff --git a/src/app/App.jsx b/src/app/App.jsx index 22a5b88..d513088 100644 --- a/src/app/App.jsx +++ b/src/app/App.jsx @@ -14,9 +14,12 @@ const App = () => { const dispatch = useDispatch(); useEffect(()=>{ - if (language === null){ + if (language === null || language.includes("any")){ dispatch(setPlaylist(musicDB)) - }else { + } + else if (language.includes('hindi')){ + alert("No hindi tracks available") + } else { let x = musicDB.filter((item)=>( item.lang && language.includes(item.lang.toLowerCase()) )) diff --git a/src/components/Pages/Home.jsx b/src/components/Pages/Home.jsx index 911880d..7254bc6 100644 --- a/src/components/Pages/Home.jsx +++ b/src/components/Pages/Home.jsx @@ -14,6 +14,7 @@ import FooterSelectMusic from "../fragment/FooterSelectMusic"; import CurrentPlayingLarge from "../fragment/CurrentPlayingLarge"; import Search from "./Search"; import Explore from "./Explore"; +import About from "./About"; function getCurrPage(pathName) { switch (pathName) { @@ -27,6 +28,8 @@ function getCurrPage(pathName) { return case "/home/add": return + case "/home/about": + return default: return null } @@ -37,6 +40,13 @@ function Home() { const [screenSize, setScreenSize] = useState(undefined); const [currMusic, setCurrMusic] = useState(null); + const [Page,setCurrPage] = useState(); + + let pathname = window.location.pathname; + useEffect(()=>{ + setCurrPage(getCurrPage(pathname)) + }, [pathname]); + window.addEventListener("resize", handleResize); function handleResize() { @@ -49,8 +59,7 @@ function Home() { }); const useStyle = useContext(ThemeContext); - let pathname = window.location.pathname; - const {playing,bannerOpen} = useSelector(state => state.musicReducer); + const {playing, bannerOpen} = useSelector(state => state.musicReducer); useEffect(() => { @@ -70,20 +79,24 @@ function Home() {
{ - getCurrPage(pathname) + Page }
{ bannerOpen - && + &&
} { - currMusic ? : + currMusic + ? + + : + } { screenSize <= 970 && diff --git a/src/components/Pages/Search.jsx b/src/components/Pages/Search.jsx index 8322437..89ee3ea 100644 --- a/src/components/Pages/Search.jsx +++ b/src/components/Pages/Search.jsx @@ -3,7 +3,10 @@ import './css/Search.scss'; import Container from "../fragment/Container"; import {useSelector} from "react-redux"; import MusicCard from "../fragment/MusicCard"; - +import SearchMusic from "../assets/img/searchMusic.svg"; +import SearchMusicMp3 from "../assets/img/searchMusicMp3.svg"; +import SearchMusicDisc from "../assets/img/searchMusicDisc.svg"; +import ArrowUp from '../assets/img/left.svg'; const Search = () => { const {playlists, search} = useSelector(state => state.musicReducer); const [searchResult, setSearchResult] = useState([]); @@ -21,19 +24,31 @@ const Search = () => { return ( { - search === "" - && -
-

Type in search box to search an item

-
+ (search === "" || search === null) + ? +
+
+ search-music-icon + search-music-icon + search-music-icon + +
+
+ : +
+ { + searchResult.length === 0 + ? +
+ No result found. +
+ : + searchResult.map((item) => ( + + )) + } +
} -
- { - searchResult.map((item) => ( - - )) - } -
); } diff --git a/src/components/Pages/css/Search.scss b/src/components/Pages/css/Search.scss index 8314689..39d577b 100644 --- a/src/components/Pages/css/Search.scss +++ b/src/components/Pages/css/Search.scss @@ -1,5 +1,49 @@ +.Search{ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + position: relative; + .Search-img{ + img{ + width: 240px; + position: absolute; + top: 50%; + left: 50%; + transform: translateX(-50%) translateY(-50%); + } + .Rotate-img{ + animation-name: spin; + animation-duration: 5s; + animation-iteration-count: infinite; + animation-timing-function: linear; + transform: translateX(-50%) translateY(-50%) rotate(0deg); + } + .Arrow{ + top: 15%; + left: 60%; + transform: translateX(-60%) translateY(-50%) rotate(70deg) ; + width: 100px; + } + @keyframes spin { + from { + transform: translateX(-50%) translateY(-50%) rotate(0deg); + } + to { + transform: translateX(-50%) translateY(-50%) rotate(360deg); + } + } + } + h3{ + position: absolute; + top: 15%; + left: 0; + width: 100%; + text-align: center; + transform: translateY(-15%); + } +} .Search-result{ display: flex; flex-wrap: wrap; - justify-content: space-evenly; } \ No newline at end of file diff --git a/src/components/assets/scss/FooterSelectMusic.scss b/src/components/assets/scss/FooterSelectMusic.scss index 5e82778..adb8379 100644 --- a/src/components/assets/scss/FooterSelectMusic.scss +++ b/src/components/assets/scss/FooterSelectMusic.scss @@ -2,7 +2,7 @@ width: 100%; height: 10vh; a{ - color: #e0e0e0; + color: #444; text-align: center; letter-spacing: 5px; text-transform: uppercase; diff --git a/src/components/fragment/DropDownLanguageList.jsx b/src/components/fragment/DropDownLanguageList.jsx index d8622bb..c3e5957 100644 --- a/src/components/fragment/DropDownLanguageList.jsx +++ b/src/components/fragment/DropDownLanguageList.jsx @@ -12,18 +12,14 @@ const DropDownLanguageList = () => { const useStyle = useContext(ThemeContext); const listOfLanguage = [ + "Any", "Hindi", "English", - "Punjabi", - "Tamil", - "Telugu" ]; const [selectedList,setSelectedList] = useState({ + "Any":false, "Hindi": false, "English": false, - "Punjabi": false, - "Tamil": false, - "Telugu": false }); const handleSelected = (val,selected) => { setSelectedList(prevState => { @@ -47,7 +43,6 @@ const DropDownLanguageList = () => { return(
-

What music do you like?

Pick the language you want to listen to

diff --git a/src/components/fragment/FooterSelectMusic.jsx b/src/components/fragment/FooterSelectMusic.jsx index 231cd3f..461e851 100644 --- a/src/components/fragment/FooterSelectMusic.jsx +++ b/src/components/fragment/FooterSelectMusic.jsx @@ -7,7 +7,7 @@ function FooterSelectMusic() { const useStyle = useContext(ThemeContext); return ( -
+
Select a music to continue diff --git a/src/components/fragment/Navigation.jsx b/src/components/fragment/Navigation.jsx index 4ea5714..93add9d 100644 --- a/src/components/fragment/Navigation.jsx +++ b/src/components/fragment/Navigation.jsx @@ -37,8 +37,7 @@ function Navigation() {
- - {/**/} + {/**/}
diff --git a/src/components/fragment/SearchBar.jsx b/src/components/fragment/SearchBar.jsx index be38270..3e9c5ce 100644 --- a/src/components/fragment/SearchBar.jsx +++ b/src/components/fragment/SearchBar.jsx @@ -26,7 +26,7 @@ const SearchBar = () => { const searchLink = useRef(); const handleSearch = (e) => { e.preventDefault(); - dispatch(setSearch(searchQuery)); + dispatch(setSearch(searchQuery.toLowerCase())); if (searchQuery !== "") searchLink.current.click(); }; diff --git a/src/components/fragment/SideBar.jsx b/src/components/fragment/SideBar.jsx index 25dbdf1..3994719 100644 --- a/src/components/fragment/SideBar.jsx +++ b/src/components/fragment/SideBar.jsx @@ -27,10 +27,8 @@ function SideBar() { */}

- - - - + +
);