webamp/js/components/MainWindow/MainVolume.js
2017-07-15 10:32:09 -07:00

22 lines
508 B
JavaScript

import React from "react";
import { connect } from "react-redux";
import Volume from "../Volume";
const MainVolume = props => {
const { volume } = props;
const percent = volume / 100;
const sprite = Math.round(percent * 28);
const offset = (sprite - 1) * 15;
const style = {
backgroundPosition: `0 -${offset}px`
};
return <Volume style={style} id="volume" />;
};
const mapStateToProps = state => ({
volume: state.media.volume
});
export default connect(mapStateToProps)(MainVolume);