-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(myLibrary): new "My Library" section
- Loading branch information
Showing
5 changed files
with
157 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { createUseStyles } from 'react-jss'; | ||
import renderIcons from '../../../helpers/renderIcons'; | ||
|
||
const useStyle = createUseStyles({ | ||
wrapper: { | ||
alignItems: 'center', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
height: '100vh', | ||
fontSize: 'smaller', | ||
padding: '0 5rem', | ||
}, | ||
}); | ||
|
||
const Empty = () => { | ||
const classes = useStyle(); | ||
return ( | ||
<div className={classes.wrapper}> | ||
{renderIcons({ name: 'Download', height: '50px', width: '50px' })} | ||
<p>It's empty in here..</p> | ||
<p>To sync your osu! library go to the Settings section and register you song folder</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Empty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { createUseStyles } from 'react-jss'; | ||
import TextInput from '../../common/TextInput'; | ||
|
||
const useStyle = createUseStyles({}); | ||
|
||
const Header = ({ setFilter, unplayedCount, overallDration, beatmapSetCount }) => { | ||
const classes = useStyle(); | ||
const handleInput = e => { | ||
setFilter(e.target.value); | ||
}; | ||
console.log({ unplayedCount, overallDration, beatmapSetCount }); | ||
return ( | ||
<div className={classes.wrapper}> | ||
{beatmapSetCount} | ||
{unplayedCount} | ||
{overallDration} | ||
<TextInput onChange={handleInput} placeHolder="id, artist, title, creator" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { FixedSizeList as List } from 'react-window'; | ||
import config from '../../../shared/config'; | ||
import { useDownloadHistory } from '../../Providers/HistoryProvider'; | ||
import BeatmapListItem from '../Packs/BeatmapPackDetail/Item'; | ||
import Empty from './components/Empty'; | ||
import Header from './components/Header'; | ||
|
||
const MyLibrary = ({ setHeaderContent, windowSize }) => { | ||
const listWidth = windowSize.width - config.display.sidePanelCompactedLength; | ||
const listHeight = windowSize.height; | ||
|
||
const [filter, setFilter] = useState(''); | ||
const { history, stats } = useDownloadHistory(); | ||
let historyItems = Object.values(history); | ||
useEffect(() => { | ||
setHeaderContent( | ||
<Header | ||
setFilter={setFilter} | ||
unplayedCount={stats.overallUnplayedCount} | ||
overallDration={stats.overallDuration} | ||
beatmapSetCount={historyItems.length} | ||
/>, | ||
); | ||
return () => setHeaderContent(null); | ||
}); | ||
|
||
if (filter) { | ||
const lowerCase = filter.toLowerCase(); | ||
historyItems = historyItems.filter(historyItem => | ||
[historyItem.id, historyItem.title, historyItem.artist, historyItem.creator].some( | ||
property => | ||
property && | ||
String(property) | ||
.toLowerCase() | ||
.includes(lowerCase), | ||
), | ||
); | ||
} | ||
|
||
const itemCount = historyItems.length; | ||
return ( | ||
<div className="menuContainer Downloads" style={{ transition: 'background 0ms', overflow: 'hidden' }}> | ||
{itemCount ? ( | ||
<List | ||
height={listHeight} | ||
itemCount={itemCount} | ||
itemSize={50} | ||
width={listWidth} | ||
itemData={{ items: historyItems, itemMode: 'library' }} | ||
> | ||
{BeatmapListItem} | ||
</List> | ||
) : ( | ||
<Empty /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
const mapStateToProps = ({ app }) => ({ | ||
windowSize: app.window, | ||
}); | ||
export default connect(mapStateToProps)(MyLibrary); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters