-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2990 from metabrainz/stats-explanation-modal
Add a modal explaining how stats are calculated to user stats page
- Loading branch information
Showing
2 changed files
with
126 additions
and
11 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
frontend/js/src/common/stats/StatsExplanationsModal.tsx
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,104 @@ | ||
import * as React from "react"; | ||
import { get as _get } from "lodash"; | ||
import NiceModal, { useModal } from "@ebay/nice-modal-react"; | ||
|
||
/** A note about this modal: | ||
* We use Bootstrap 3 modals, which work with jQuery and data- attributes | ||
* In order to show the modal properly, including backdrop and visibility, | ||
* you'll need dataToggle="modal" and dataTarget="#StatsExplanationsModal" | ||
* on the buttons that open this modal as well as data-dismiss="modal" | ||
* on the buttons that close the modal. Modals won't work (be visible) without it | ||
* until we move to Bootstrap 5 / Bootstrap React which don't require those attributes. | ||
*/ | ||
|
||
export default NiceModal.create(() => { | ||
const modal = useModal(); | ||
|
||
const closeModal = () => { | ||
modal.hide(); | ||
document?.body?.classList?.remove("modal-open"); | ||
setTimeout(modal.remove, 200); | ||
}; | ||
|
||
return ( | ||
<div | ||
className={`modal fade ${modal.visible ? "in" : ""}`} | ||
id="StatsExplanationsModal" | ||
tabIndex={-1} | ||
role="dialog" | ||
aria-labelledby="StatsExplanationsModalLabel" | ||
data-backdrop="static" | ||
> | ||
<div className="modal-dialog" role="document"> | ||
<form className="modal-content"> | ||
<div className="modal-header"> | ||
<button | ||
type="button" | ||
className="close" | ||
data-dismiss="modal" | ||
aria-label="Close" | ||
onClick={closeModal} | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
<h4 className="modal-title" id="StatsExplanationsModalLabel"> | ||
How and when are statistics calculated? | ||
</h4> | ||
</div> | ||
<div className="modal-body"> | ||
We calculate our statistics exclusively from listens submitted | ||
directly to ListenBrainz by you, our users.{" "} | ||
<b>We do not rely on third-party statistics.</b> | ||
<br /> | ||
This applies to all our popularity, similarity, listen counts and | ||
user similarity statistics. | ||
<br /> | ||
For full transparency, all this data is{" "} | ||
<a | ||
target="_blank" | ||
href="https://metabrainz.org/datasets" | ||
rel="noreferrer" | ||
> | ||
public and available | ||
</a>{" "} | ||
for you to explore. | ||
<br /> | ||
<br /> | ||
Artist, album and track information comes from{" "} | ||
<a | ||
target="_blank" | ||
href="https://musicbrainz.org/doc/About" | ||
rel="noreferrer" | ||
> | ||
the MusicBrainz project. | ||
</a> | ||
<br /> | ||
Stats are automatically calculated at regular intervals; for more | ||
information please{" "} | ||
<a | ||
href="https://listenbrainz.readthedocs.io/en/latest/general/data-update-intervals.html" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
see this page | ||
</a> | ||
. | ||
<br /> | ||
However if you encounter an issue please | ||
<a href="mailto:[email protected]">contact us</a>. | ||
</div> | ||
<div className="modal-footer"> | ||
<button | ||
type="button" | ||
className="btn btn-default" | ||
data-dismiss="modal" | ||
onClick={closeModal} | ||
> | ||
Close | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
}); |
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