Skip to content

Commit

Permalink
Merge pull request #713 from WebYourMind/webyourmind/issue-652
Browse files Browse the repository at this point in the history
Score Rendering improvements
  • Loading branch information
geneh authored Jun 3, 2019
2 parents 5f42cb6 + b684f53 commit 7904df8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
31 changes: 28 additions & 3 deletions src/components/Navigation/Ui/ScoreRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ScoreRenderer extends Component {
return (
<p style={{ color }}>
{label}: {score[name]}
{this.renderUnit()}
</p>
)
}
Expand All @@ -71,28 +72,52 @@ class ScoreRenderer extends Component {

<h2>Licensed</h2>
{this.renderScores(licensedScore, licensedToolScore)}
{this.renderScoreInfo()}
</div>
)
} else {
return <div className="ScoreRenderer">{this.renderScores(get(domain, 'score'), get(domain, 'toolScore'))}</div>
return (
<div className="ScoreRenderer">
{this.renderScores(get(domain, 'score'), get(domain, 'toolScore'))} {this.renderScoreInfo()}
</div>
)
}
}

renderScores(effective, tools) {
return (
<div className="ScoreRenderer__domain">
<div className="ScoreRenderer__domain__section">
<h2>{`Effective: ${isNumber(effective.total) ? effective.total : effective}`}</h2>
<h2>
{`Effective: ${isNumber(effective.total) ? effective.total : effective}`}
{this.renderUnit()}
</h2>
{this.renderScore(effective)}
</div>
<div className="ScoreRenderer__domain__section">
<h2>{`Tools: ${isNumber(tools.total) ? tools.total : tools}`}</h2>
<h2>
{`Tools: ${isNumber(tools.total) ? tools.total : tools}`}
{this.renderUnit()}
</h2>
{this.renderScore(tools)}
</div>
</div>
)
}

renderUnit = () => <span>/100</span>

renderScoreInfo = () => (
<div className="ScoreInfo">
<a
href="https://github.com/clearlydefined/license-score/blob/master/ClearlyLicensedMetrics.md#clearlylicensed-scoring-formula"
target="_blank"
>
Scoring Formula
</a>
</div>
)

render() {
const { domain, scores } = this.props
if (!domain && !scores) return null
Expand Down
8 changes: 6 additions & 2 deletions src/components/Navigation/Ui/__tests__/ScoreRenderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ describe('ScoreRenderer', () => {
expect(resultScores).toEqual(
<div className="ScoreRenderer__domain">
<div className="ScoreRenderer__domain__section">
<h2>Effective: 0</h2>
<h2>
Effective: 0<span>/100</span>
</h2>
{instance.renderScore(licensedScore)}
</div>
<div className="ScoreRenderer__domain__section">
<h2>Tools: 0</h2>
<h2>
Tools: 0<span>/100</span>
</h2>
{instance.renderScore(licensedToolScore)}
</div>
</div>
Expand Down
17 changes: 15 additions & 2 deletions src/styles/_ScoreRenderer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
color: white;
font-size: 16px;
}
.ScoreInfo {
font-size: 12px;
text-decoration: underline;
width: 100%;
text-align: right;
a {
color: white;
}
}
.ScoreRenderer__domain {
display: flex;
width: 300px;
width: 400px;
}
.ScoreRenderer__domain__section {
padding: 10px;
Expand All @@ -18,7 +27,11 @@
padding: 0;
}
}
.unit {
font-size: 12px;
}
}
.ant-tooltip-inner {
width: 300px !important;
background-color: rgba(0, 0, 0, 0.9);
width: 400px !important;
}

0 comments on commit 7904df8

Please # to comment.