Skip to content

Commit

Permalink
Merge branch 'feature/guides' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sho-87 committed Mar 4, 2020
2 parents dcb986e + 7e015a5 commit ea38363
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 67 deletions.
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rok-talents",
"title": "RoK Talents",
"version": "1.1.1",
"version": "1.2.0",
"dataVersion": 1,
"description": "Rise of Kingdoms talent builder",
"homepage": "http://www.roktalents.com",
Expand All @@ -16,7 +16,13 @@
"url": "http://www.simonho.ca"
},
"contributors": [
"Sara Ahmadian"
{
"name": "Sara Ahmadian"
},
{
"name": "rok.guide",
"url": "https://rok.guide"
}
],
"repository": {
"type": "git",
Expand Down
Binary file added public/images/guide-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class App extends Component {
this.state = this.getEmptyState();
treeData = loadTreeData(dataVersion);
this.updateURL('clear');
ReactGA.event({
category: 'Load',
action: 'New'
});
break;
case 5: // complete url
let [urlDataVersion, comID, red, yellow, blue] = urlParams;
Expand Down Expand Up @@ -155,8 +159,18 @@ class App extends Component {
this.state = this.getEmptyState();
treeData = loadTreeData(dataVersion);
this.updateURL('clear');
ReactGA.event({
category: 'Load',
action: 'Error',
label: this.props.url
});
} else {
this.updateURL('update');
ReactGA.event({
category: 'Load',
action: 'Existing',
label: this.props.url
});
}
break;
default:
Expand All @@ -166,6 +180,11 @@ class App extends Component {
this.state = this.getEmptyState();
treeData = loadTreeData(dataVersion);
this.updateURL('clear');
ReactGA.event({
category: 'Load',
action: 'Error',
label: this.props.url
});
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/Modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ export class AboutModal extends Component {
}));
}

getContributors() {
let contributorsList = contributors.map((c, i) => [
i > 0 && ', ',
<a href={c.url} target="_blank" rel="noopener noreferrer">
{c.name}
</a>
]);

return contributorsList;
}

showDonate() {
ReactGA.event({
category: 'App',
Expand Down Expand Up @@ -161,7 +172,7 @@ export class AboutModal extends Component {
</div>
<div>
<span className="about-label">Contributors:</span>{' '}
{contributors.join(', ')}
{this.getContributors()}
</div>
{/* <div>
<span className="about-label">Code:</span>{' '}
Expand Down
4 changes: 2 additions & 2 deletions src/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class NavBar extends Component {

render() {
return (
<React.Fragment>
<>
<AboutModal
ref={component => (this.aboutModalRef = component)}
toggleTour={this.props.toggleTour}
Expand Down Expand Up @@ -158,7 +158,7 @@ class NavBar extends Component {
/>
</Nav>
</Navbar>
</React.Fragment>
</>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/NavBarSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class NavBarSettings extends Component {
</div>

{process.env.NODE_ENV === 'development' && (
<React.Fragment>
<>
<Dropdown.Divider />
<Dropdown.Header>Dev Mode</Dropdown.Header>
<Form.Check
Expand All @@ -145,7 +145,7 @@ class NavBarSettings extends Component {
checked={this.props.isShownTalentID}
onChange={e => this.props.toggleTalentID()}
/>
</React.Fragment>
</>
)}
</Form.Group>
</Form>
Expand Down
45 changes: 36 additions & 9 deletions src/SummaryPanel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';

import { GeneralTooltip } from './Tooltips';
import Commanders from './data/commanders.json';
import './styles/SummaryPanel.css';

Expand All @@ -10,17 +10,21 @@ import './styles/SummaryPanel.css';
* @extends {Component}
*/
class SummaryPanel extends Component {
render() {
getHeader() {
return (
<div id="summary-panel" className="info-box">
{this.props.commander && (
<img
src={`${process.env.PUBLIC_URL}/images/commanders/${this.props.commander}.png`}
alt={this.props.commander}
></img>
<>
<span>{this.props.commander}</span>
{Commanders[this.props.commander].guide && (
<GuideIcon commander={this.props.commander} />
)}
</>
);
}

<h1>{this.props.commander ? this.props.commander : 'Summary'}</h1>
render() {
return (
<div id="summary-panel" className="info-box">
<h1>{this.props.commander ? this.getHeader() : 'Summary'}</h1>
<h3>
{this.props.commander && Commanders[this.props.commander].title}
</h3>
Expand All @@ -34,4 +38,27 @@ class SummaryPanel extends Component {
}
}

/**
* Icon for commander guides
*
* @returns {DOMElement} Icon linking to the external commander guide
*/
function GuideIcon(props) {
return (
<GeneralTooltip tooltip="Commander guide">
<a
href={Commanders[props.commander].guide}
target="_blank"
rel="noopener noreferrer"
>
<img
className="summary-panel-guide-icon"
src={`${process.env.PUBLIC_URL}/images/guide-icon.png`}
alt={`${props.commander} guide`}
></img>
</a>
</GeneralTooltip>
);
}

export default SummaryPanel;
49 changes: 32 additions & 17 deletions src/Tooltips.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React from 'react';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Tooltip from 'react-bootstrap/Tooltip';
import { faQuestionCircle } from '@fortawesome/free-solid-svg-icons';
Expand All @@ -9,22 +9,37 @@ import './styles/Tooltips.css';
/**
* Tooltip showing a hoverable 'help' tooltip
*
* @class HelpTooltip
* @extends {Component}
* @returns {Tooltip} Tooltip
*/
export class HelpTooltip extends Component {
render() {
return (
<OverlayTrigger
placement="top"
flip={true}
trigger={['hover', 'click']}
overlay={<Tooltip className="help-text">{this.props.tooltip}</Tooltip>}
>
<FontAwesomeIcon icon={faQuestionCircle} className="help-icon" />
</OverlayTrigger>
);
}
export function HelpTooltip(props) {
return (
<OverlayTrigger
placement="top"
flip={true}
trigger={['hover', 'click']}
overlay={<Tooltip className="help-text">{props.tooltip}</Tooltip>}
>
<FontAwesomeIcon icon={faQuestionCircle} className="help-icon" />
</OverlayTrigger>
);
}

export default { HelpTooltip };
/**
* General tooltip component
*
* @returns {Tooltip} Tooltip
*/
export function GeneralTooltip(props) {
return (
<OverlayTrigger
placement="top"
flip={true}
trigger={['hover', 'click']}
overlay={<Tooltip className="help-text">{props.tooltip}</Tooltip>}
>
{props.children}
</OverlayTrigger>
);
}

export default { HelpTooltip, GeneralTooltip };
6 changes: 4 additions & 2 deletions src/data/commanders.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
"tier": "Legendary",
"red": "Leadership",
"yellow": "Peacekeeping",
"blue": "Support"
"blue": "Support",
"guide": "https://rok.guide/aethelflaed/"
},
"Richard I": {
"id": "2",
"title": "The Lion Heart",
"tier": "Legendary",
"red": "Infantry",
"yellow": "Garrison",
"blue": "Defense"
"blue": "Defense",
"guide": "https://rok.guide/commanders/richard-i/"
},
"Yi Seong-Gye": {
"id": "3",
Expand Down
13 changes: 5 additions & 8 deletions src/styles/SummaryPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@
flex-grow: 2;
}

#summary-panel img {
position: absolute;
height: auto;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
opacity: 0.2;
filter: blur(8px);
.summary-panel-guide-icon {
height: 0.4em;
width: auto;
margin-left: 0.4em;
vertical-align: baseline;
}

#summary-panel-summary p {
Expand Down
24 changes: 0 additions & 24 deletions src/styles/fonts.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ h3 {
.node-tooltip-increase {
font-size: 0.8em;
}

#summary-panel img {
width: 180%;
}
}

@media (max-height: 599px) and (orientation: landscape) {
Expand Down Expand Up @@ -168,10 +164,6 @@ h3 {
.node-tooltip-increase {
font-size: 0.6em;
}

#summary-panel img {
width: 300%;
}
}

/* Tablet */
Expand Down Expand Up @@ -215,10 +207,6 @@ h3 {
.node-tooltip-increase {
font-size: 1.6em;
}

#summary-panel img {
width: 150%;
}
}

@media (min-width: 900px) and (orientation: landscape) {
Expand Down Expand Up @@ -277,10 +265,6 @@ h3 {
.node-tooltip-increase {
font-size: 1.2em;
}

#summary-panel img {
width: 200%;
}
}

/* Desktop */
Expand Down Expand Up @@ -324,10 +308,6 @@ h3 {
.node-tooltip-increase {
font-size: 2em;
}

#summary-panel img {
width: 190%;
}
}

@media (min-width: 1280px) and (orientation: landscape) {
Expand Down Expand Up @@ -386,8 +366,4 @@ h3 {
.node-tooltip-increase {
font-size: 1.6em;
}

#summary-panel img {
width: 190%;
}
}

0 comments on commit ea38363

Please sign in to comment.