mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
added searcher ui
This commit is contained in:
parent
256e78f29d
commit
62c9952866
@ -191,22 +191,113 @@ const MayLike = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default () => {
|
const SearchResultItem = (props) => {
|
||||||
return <div className="playlistExplorer">
|
return <div>
|
||||||
<RecentlyPlayed />
|
<h1>SearchResultItem</h1>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
<PlaylistsList
|
export default (props) => {
|
||||||
headerTitle="From your following artists"
|
const [searchLoading, setSearchLoading] = React.useState(false)
|
||||||
headerIcon={<Icons.MdPerson />}
|
const [searchFocused, setSearchFocused] = React.useState(false)
|
||||||
fetchMethod={FeedModel.getPlaylistsFeed}
|
const [searchValue, setSearchValue] = React.useState("")
|
||||||
/>
|
const [searchResult, setSearchResult] = React.useState([])
|
||||||
|
|
||||||
<PlaylistsList
|
const handleSearchValueChange = (e) => {
|
||||||
headerTitle="Explore from global"
|
// not allow to input space as first character
|
||||||
headerIcon={<Icons.MdExplore />}
|
if (e.target.value[0] === " ") {
|
||||||
fetchMethod={FeedModel.getGlobalMusicFeed}
|
return
|
||||||
/>
|
}
|
||||||
|
|
||||||
<MayLike />
|
setSearchValue(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const makeSearch = async (value) => {
|
||||||
|
setSearchResult([])
|
||||||
|
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
||||||
|
|
||||||
|
setSearchResult([
|
||||||
|
{
|
||||||
|
title: "test",
|
||||||
|
thumbnail: "/assets/no_song.png",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "test2",
|
||||||
|
thumbnail: "/assets/no_song.png",
|
||||||
|
}
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const timer = setTimeout(async () => {
|
||||||
|
setSearchLoading(true)
|
||||||
|
|
||||||
|
await makeSearch(searchValue)
|
||||||
|
|
||||||
|
setSearchLoading(false)
|
||||||
|
}, 400)
|
||||||
|
|
||||||
|
if (searchValue === "") {
|
||||||
|
if (typeof props.onEmpty === "function") {
|
||||||
|
//props.onEmpty()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (typeof props.onFilled === "function") {
|
||||||
|
//props.onFilled()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => clearTimeout(timer)
|
||||||
|
}, [searchValue])
|
||||||
|
|
||||||
|
return <div
|
||||||
|
className={classnames(
|
||||||
|
"musicExplorer",
|
||||||
|
{
|
||||||
|
["search-focused"]: searchFocused,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="searcher">
|
||||||
|
<antd.Input
|
||||||
|
placeholder="Search for music"
|
||||||
|
prefix={<Icons.Search />}
|
||||||
|
onFocus={() => setSearchFocused(true)}
|
||||||
|
onBlur={() => setSearchFocused(false)}
|
||||||
|
onChange={handleSearchValueChange}
|
||||||
|
value={searchValue}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="searcher_result">
|
||||||
|
{
|
||||||
|
searchLoading && <antd.Skeleton active />
|
||||||
|
}
|
||||||
|
{
|
||||||
|
searchFocused && searchValue !== "" && searchResult.length > 0 && searchResult.map((result, index) => {
|
||||||
|
return <SearchResultItem
|
||||||
|
key={index}
|
||||||
|
result={result}
|
||||||
|
/>
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="feed_main">
|
||||||
|
<RecentlyPlayed />
|
||||||
|
|
||||||
|
<PlaylistsList
|
||||||
|
headerTitle="From your following artists"
|
||||||
|
headerIcon={<Icons.MdPerson />}
|
||||||
|
fetchMethod={FeedModel.getPlaylistsFeed}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<PlaylistsList
|
||||||
|
headerTitle="Explore from global"
|
||||||
|
headerIcon={<Icons.MdExplore />}
|
||||||
|
fetchMethod={FeedModel.getGlobalMusicFeed}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
@ -1,10 +1,30 @@
|
|||||||
.playlistExplorer {
|
.musicExplorer {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
gap: 50px;
|
gap: 20px;
|
||||||
|
|
||||||
|
&.search-focused {
|
||||||
|
.feed_main {
|
||||||
|
height: 0px;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.feed_main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
gap: 50px;
|
||||||
|
|
||||||
|
transition: all 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
.playlistExplorer_section {
|
.playlistExplorer_section {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user