-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Changed order of Graphs * Moved Graphs to their own container * Allow you to add an optional profile name * Started work on PDF generation * draft PDF * Move from react-pdf -> jspdf * Cleanup * More cleanup * Table bg fix * Fix graph legends breaking in dark mode pdf export * Change pdf table head color * Clean up App Bar * Cleanup * Disable pdf button if no units * Add Reddit button to footer * Add beta tag for PDF * Better contrast * Bump package.json version
- Loading branch information
Showing
48 changed files
with
1,277 additions
and
292 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { MenuItem } from '@material-ui/core'; | ||
import { Delete } from '@material-ui/icons'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
menuItemIcon: { | ||
marginRight: theme.spacing(1), | ||
}, | ||
item: { | ||
color: theme.palette.getContrastText(theme.palette.background.paper), | ||
}, | ||
link: { | ||
color: theme.palette.getContrastText(theme.palette.background.paper), | ||
textDecoration: 'none', | ||
}, | ||
})); | ||
|
||
const ClearUnitsItem = ({ onClick }) => { | ||
const classes = useStyles(); | ||
|
||
const handleClick = () => { | ||
onClick(); | ||
}; | ||
|
||
return ( | ||
<Link onClick={handleClick} to="/units/confirm" className={classes.link}> | ||
<MenuItem className={classes.item}> | ||
<Delete className={classes.menuItemIcon} /> | ||
Clear All Units | ||
</MenuItem> | ||
</Link> | ||
); | ||
}; | ||
|
||
ClearUnitsItem.propTypes = { | ||
/** A callback function to call when the menu item is clicked */ | ||
onClick: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default ClearUnitsItem; |
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,76 @@ | ||
import React, { useCallback } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { MenuItem } from '@material-ui/core'; | ||
import { ImportExport } from '@material-ui/icons'; | ||
import { addUnit } from 'actions/units.action'; | ||
import { connect } from 'react-redux'; | ||
import { addNotification } from 'actions/notifications.action'; | ||
import Uploader from 'components/Uploader'; | ||
import { addUnitEnabled } from 'utils/unitHelpers'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
menu: {}, | ||
icon: { | ||
color: theme.palette.primary.contrastText, | ||
}, | ||
caption: { | ||
paddingBottom: theme.spacing(1), | ||
}, | ||
menuItemIcon: { | ||
marginRight: theme.spacing(1), | ||
}, | ||
})); | ||
|
||
|
||
const ImportUnitItem = ({ | ||
// eslint-disable-next-line no-unused-vars | ||
numUnits, onClick, addNotification, addUnit, | ||
}) => { | ||
const classes = useStyles(); | ||
|
||
/** Is the upload menu item disabled or not */ | ||
const isUploadDisabled = !addUnitEnabled(); | ||
|
||
/** The function to call when a file upload happens. | ||
* In this case that would be importing the uploaded unit data | ||
* @param {object} data the JSON from the uploaded unit | ||
* */ | ||
const onUnitUpload = useCallback((data) => { | ||
if (data && data.name && data.weapon_profiles) { | ||
onClick(); | ||
addNotification({ message: 'Successfully imported unit', variant: 'success' }); | ||
addUnit(data.name, data.weapon_profiles); | ||
} | ||
}, [addNotification, addUnit, onClick]); | ||
|
||
return ( | ||
<Uploader | ||
onUpload={onUnitUpload} | ||
disabled={isUploadDisabled} | ||
component={( | ||
<MenuItem disabled={isUploadDisabled}> | ||
<ImportExport className={classes.menuItemIcon} /> | ||
Import Unit | ||
</MenuItem> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
ImportUnitItem.propTypes = { | ||
/** The current number of units. Used to ensure that the item is disabled when limit is reached */ | ||
numUnits: PropTypes.number.isRequired, | ||
/** A callback function to call when the menu item is clicked */ | ||
onClick: PropTypes.func.isRequired, | ||
/** A function to call to add a notification to the stack */ | ||
addNotification: PropTypes.func.isRequired, | ||
/** A function to call to add a new unit */ | ||
addUnit: PropTypes.func.isRequired, | ||
}; | ||
|
||
const mapStateToProps = (state) => ({ | ||
numUnits: state.units.length, | ||
}); | ||
|
||
export default connect(mapStateToProps, { addNotification, addUnit })(ImportUnitItem); |
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,55 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { MenuItem } from '@material-ui/core'; | ||
import { GetApp } from '@material-ui/icons'; | ||
import { Link } from 'react-router-dom'; | ||
import BetaTag from 'components/BetaTag'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
menuItemIcon: { | ||
marginRight: theme.spacing(1), | ||
}, | ||
item: { | ||
color: theme.palette.getContrastText(theme.palette.background.paper), | ||
}, | ||
link: { | ||
color: theme.palette.getContrastText(theme.palette.background.paper), | ||
textDecoration: 'none', | ||
}, | ||
})); | ||
|
||
const PdfDownloadItem = ({ onClick, numUnits }) => { | ||
const classes = useStyles(); | ||
|
||
const handleClick = () => { | ||
onClick(); | ||
}; | ||
|
||
const disabled = numUnits <= 0; | ||
|
||
return ( | ||
// eslint-disable-next-line jsx-a11y/anchor-is-valid | ||
<Link onClick={handleClick} to={disabled ? '' : '/pdf'} className={classes.link}> | ||
<MenuItem className={classes.item} disabled={disabled}> | ||
<GetApp className={classes.menuItemIcon} /> | ||
Download PDF | ||
<BetaTag /> | ||
</MenuItem> | ||
</Link> | ||
); | ||
}; | ||
|
||
PdfDownloadItem.propTypes = { | ||
/** A callback function to call when the menu item is clicked */ | ||
onClick: PropTypes.func.isRequired, | ||
/** The current number of units. Used to disable the button */ | ||
numUnits: PropTypes.number.isRequired, | ||
}; | ||
|
||
const mapStateToProps = (state) => ({ | ||
numUnits: state.units.length, | ||
}); | ||
|
||
export default connect(mapStateToProps)(PdfDownloadItem); |
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,38 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { MenuItem, Typography } from '@material-ui/core'; | ||
import { BrightnessMedium } from '@material-ui/icons'; | ||
import { toggleDarkMode } from 'actions/config.action'; | ||
import { connect } from 'react-redux'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
menuItemIcon: { | ||
marginRight: theme.spacing(1), | ||
}, | ||
})); | ||
|
||
const ToggleDarkModeItem = ({ onClick, toggleDarkMode }) => { | ||
const classes = useStyles(); | ||
|
||
const handleClick = () => { | ||
onClick(); | ||
toggleDarkMode(); | ||
}; | ||
|
||
return ( | ||
<MenuItem onClick={handleClick}> | ||
<BrightnessMedium className={classes.menuItemIcon} /> | ||
<span>Toggle Dark Mode </span> | ||
</MenuItem> | ||
); | ||
}; | ||
|
||
ToggleDarkModeItem.propTypes = { | ||
/** A callback function to call when the menu item is clicked */ | ||
onClick: PropTypes.func.isRequired, | ||
/** A function to call to toggle dark/light themes */ | ||
toggleDarkMode: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default connect(null, { toggleDarkMode })(ToggleDarkModeItem); |
Oops, something went wrong.