@ministryofjustice/hmpps-arns-frontend-components-lib 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
{% set showScore = params.showScore if params.showScore else false %}
|
|
31
31
|
|
|
32
32
|
{% if latestAssessment is defined %}
|
|
33
|
-
<div class="
|
|
33
|
+
<div class="{% if params.classes %}{{ params.classes }}{% endif %}">
|
|
34
34
|
{% for key, predictor in latestAssessment %}
|
|
35
35
|
{% if key == params.predictor %}
|
|
36
36
|
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<span class="predictor-badge__score">{{ predictor.score }}%</span>
|
|
53
53
|
{% endif %}
|
|
54
54
|
|
|
55
|
-
{% if predictor.staticOrDynamic %}
|
|
55
|
+
{% if predictor.staticOrDynamic is defined %}
|
|
56
56
|
<span class="predictor-badge__static_or_dynamic">{{ predictor.staticOrDynamic }}</span>
|
|
57
57
|
{% endif %}
|
|
58
58
|
</div>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
$very-high-score-colour: #942514;
|
|
2
|
+
$very-high-score-colour--light: #ffac9f;
|
|
3
|
+
$very-high-score-colour__text: #711a0d;
|
|
4
|
+
$high-score-colour: #d4351c;
|
|
5
|
+
$high-score-colour--light: #f6d7d2;
|
|
6
|
+
$high-score-colour__text: #942514;
|
|
7
|
+
$medium-score-colour: #f47738;
|
|
8
|
+
$medium-score-colour--light: #f9e8bd;
|
|
9
|
+
$medium-score-colour__text: #a34e00;
|
|
10
|
+
$low-score-colour: #85994b;
|
|
11
|
+
$low-score-colour--light: #dee9bd;
|
|
12
|
+
$low-score-colour__text: #485b10;
|
|
13
|
+
|
|
14
|
+
@mixin expanded-predictor-badge-base($primary-colour, $secondary-colour, $text-colour) {
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
outline: 2px solid $primary-colour;
|
|
18
|
+
width: 259px;
|
|
19
|
+
|
|
20
|
+
& .predictor-badge__type {
|
|
21
|
+
@include govuk-font(19, "bold");
|
|
22
|
+
color: govuk-colour("black");
|
|
23
|
+
|
|
24
|
+
padding: 10px 10px 2px 10px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
& .predictor-badge__stats {
|
|
28
|
+
padding: 2px 10px 2px 10px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
& .predictor-badge__level {
|
|
32
|
+
@include govuk-font(19, "bold");
|
|
33
|
+
color: $text-colour;
|
|
34
|
+
|
|
35
|
+
padding: 0px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
& .predictor-badge__score {
|
|
39
|
+
@include govuk-font(19, "bold");
|
|
40
|
+
color: govuk-colour("black");
|
|
41
|
+
|
|
42
|
+
background-color: $secondary-colour;
|
|
43
|
+
|
|
44
|
+
padding: 2px 4px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
& .predictor-badge__static_or_dynamic {
|
|
48
|
+
@include govuk-font(19, "regular");
|
|
49
|
+
color: #282D30;
|
|
50
|
+
|
|
51
|
+
background-color: #E5E6E7;
|
|
52
|
+
|
|
53
|
+
padding: 2px 4px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
& .predictor-badge__wrapped_static_or_dynamic {
|
|
57
|
+
display: inline-block;
|
|
58
|
+
margin-top: 3px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
& .predictor-badge__last_updated {
|
|
62
|
+
@include govuk-font(16, "regular");
|
|
63
|
+
color: #6E777A;
|
|
64
|
+
|
|
65
|
+
padding: 2px 10px 10px 10px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.expanded-predictor-badge--very-high {
|
|
70
|
+
@include expanded-predictor-badge-base(
|
|
71
|
+
$very-high-score-colour,
|
|
72
|
+
$very-high-score-colour--light,
|
|
73
|
+
$very-high-score-colour__text
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.expanded-predictor-badge--high {
|
|
78
|
+
@include expanded-predictor-badge-base($high-score-colour, $high-score-colour--light, $high-score-colour__text);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.expanded-predictor-badge--medium {
|
|
82
|
+
@include expanded-predictor-badge-base($medium-score-colour, $medium-score-colour--light, $medium-score-colour__text);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.expanded-predictor-badge--low {
|
|
86
|
+
@include expanded-predictor-badge-base($low-score-colour, $low-score-colour--light, $low-score-colour__text);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.expanded-predictor-badge__fixed-width {
|
|
90
|
+
width: 259px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.expanded-predictor-badge__dynamic {
|
|
94
|
+
width: 100%;
|
|
95
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{#
|
|
2
|
+
ARNS Expanded Predictor Badge Component
|
|
3
|
+
|
|
4
|
+
@name expandedPredictorBadge
|
|
5
|
+
|
|
6
|
+
@description Displays specified risk predictor score badges in an expanded format.
|
|
7
|
+
It uses the latest assessment from the provided data set.
|
|
8
|
+
|
|
9
|
+
@example
|
|
10
|
+
In route handler:
|
|
11
|
+
const riskData = await arnsComponents.getRiskData(token, 'crn', 'X123456')
|
|
12
|
+
res.render('page', { riskData })
|
|
13
|
+
|
|
14
|
+
In template:
|
|
15
|
+
{% from "components/expanded-badge/macro.njk" import expandedPredictorBadge %}
|
|
16
|
+
{{ expandedPredictorBadge({
|
|
17
|
+
data: riskData,
|
|
18
|
+
predictor: "allReoffendingPredictor",
|
|
19
|
+
showScore: true,
|
|
20
|
+
fixedWidth: true,
|
|
21
|
+
classes: "class-name-here"
|
|
22
|
+
}) }}
|
|
23
|
+
|
|
24
|
+
@param {object} params
|
|
25
|
+
@param {RiskData} params.data - Risk data object from ArnsComponents.getRiskData() containing an 'assessments' array
|
|
26
|
+
@param {string} params.predictor - The name of the specific predictor to display
|
|
27
|
+
@param {boolean} [params.showScore=false] - If true, displays the percentage score
|
|
28
|
+
@param {boolean} [params.fixedWidth=true] - If true or undefined, displays the expanded predictor badge in a fixed width format
|
|
29
|
+
@param {string} [params.classes] - Optional CSS utility classes to apply to the container
|
|
30
|
+
#}
|
|
31
|
+
{% set latestAssessment = params.data.assessments | first if params.data.assessments else null %}
|
|
32
|
+
{% set showScore = params.showScore if params.showScore else false %}
|
|
33
|
+
|
|
34
|
+
{% if latestAssessment is defined %}
|
|
35
|
+
<div class="{% if params.classes %}{{ params.classes }}{% endif %}">
|
|
36
|
+
|
|
37
|
+
{% for key, predictor in latestAssessment %}
|
|
38
|
+
{% if key == params.predictor %}
|
|
39
|
+
|
|
40
|
+
{% set badgeClass = '' %}
|
|
41
|
+
{% switch predictor.band %}
|
|
42
|
+
{% case 'VERY_HIGH' %}
|
|
43
|
+
{% set badgeClass = 'expanded-predictor-badge--very-high' %}
|
|
44
|
+
{% case 'HIGH' %}
|
|
45
|
+
{% set badgeClass = 'expanded-predictor-badge--high' %}
|
|
46
|
+
{% case 'MEDIUM' %}
|
|
47
|
+
{% set badgeClass = 'expanded-predictor-badge--medium' %}
|
|
48
|
+
{% case 'LOW' %}
|
|
49
|
+
{% set badgeClass = 'expanded-predictor-badge--low' %}
|
|
50
|
+
{% endswitch %}
|
|
51
|
+
|
|
52
|
+
{% set staticOrDynamicClass = 'predictor-badge__static_or_dynamic' %}
|
|
53
|
+
{% if showScore and predictor.band in ['VERY HIGH', 'MEDIUM'] and predictor.staticOrDynamic === 'DYNAMIC' %}
|
|
54
|
+
{% set staticOrDynamicClass = staticOrDynamicClass + ' predictor-badge__wrapped_static_or_dynamic' %}
|
|
55
|
+
{% endif %}
|
|
56
|
+
|
|
57
|
+
{% if params.fixedWidth or params.fixedWidth is undefined %}
|
|
58
|
+
{% set badgeWidthClass = 'expanded-predictor-badge__fixed-width' %}
|
|
59
|
+
{% else %}
|
|
60
|
+
{% set badgeWidthClass = 'expanded-predictor-badge__dynamic' %}
|
|
61
|
+
{% endif %}
|
|
62
|
+
|
|
63
|
+
<div class="{{ badgeClass }} {{ badgeWidthClass }}">
|
|
64
|
+
<span
|
|
65
|
+
class="predictor-badge__type">{{ predictor.name }}</span>
|
|
66
|
+
|
|
67
|
+
<div class="predictor-badge__stats">
|
|
68
|
+
<span class="predictor-badge__level">{{ predictor.band }}</span>
|
|
69
|
+
|
|
70
|
+
{% if showScore and predictor.score is defined %}
|
|
71
|
+
<span class="predictor-badge__score">{{ predictor.score }}%</span>
|
|
72
|
+
{% endif %}
|
|
73
|
+
|
|
74
|
+
{% if predictor.staticOrDynamic is defined %}
|
|
75
|
+
<span class="{{ staticOrDynamicClass }}">{{ predictor.staticOrDynamic }}</span>
|
|
76
|
+
{% endif %}
|
|
77
|
+
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<span class="predictor-badge__last_updated">Last updated: {{ predictor.completedDate }}</span>
|
|
81
|
+
|
|
82
|
+
</div>
|
|
83
|
+
{% endif %}
|
|
84
|
+
{% endfor %}
|
|
85
|
+
{% endif %}
|
|
86
|
+
</div>
|
|
87
|
+
{% endif %}
|
package/package.json
CHANGED