Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Score Rendering improvements #713

Merged
merged 10 commits into from
Jun 3, 2019
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;
}