1
- /* global CMS, createClass */
1
+ /* global CMS, createClass, window */
2
+
3
+ import slugify from '@sindresorhus/slugify' ;
4
+
5
+ const successCriteria = window . successCriteria ;
6
+
7
+ CMS . registerPreviewStyle ( '/assets/styles/cms.css' ) ;
8
+ CMS . registerPreviewStyle ( '/assets/styles/main.css' ) ;
2
9
CMS . registerPreviewStyle ( '/assets/styles/report.css' ) ;
3
10
4
11
const IssuePreview = createClass ( {
@@ -14,7 +21,12 @@ const IssuePreview = createClass({
14
21
< dl >
15
22
< div >
16
23
< dt > WCAG Criteria: </ dt >
17
- < dd > { entry . getIn ( [ 'data' , 'sc' ] ) } </ dd >
24
+ < dd > { entry . getIn ( [ 'data' , 'sc' ] ) . map ( sc => (
25
+ < a class = 'wcag-link' href = { `https://www.w3.org/WAI/WCAG22/quickref/#${ successCriteria [ sc ] . id } ` } rel = 'external' >
26
+ { sc } < span class = 'external' > (external link)</ span >
27
+ < svg aria-hidden = 'true' role = 'presentation' focusable = 'false' xmlns = 'http://www.w3.org/2000/svg' fill = 'none' viewBox = '0 0 24 24' height = '14' width = '16' > < path xmlns = 'http://www.w3.org/2000/svg' fill-rule = 'evenodd' clip-rule = 'evenodd' d = 'M14 5C13.4477 5 13 4.55228 13 4C13 3.44772 13.4477 3 14 3H20C20.2652 3 20.5196 3.10536 20.7071 3.29289C20.8946 3.48043 21 3.73478 21 4L21 10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10L19 6.41422L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L17.5858 5H14ZM3 7C3 5.89543 3.89543 5 5 5H10C10.5523 5 11 5.44772 11 6C11 6.55228 10.5523 7 10 7H5V19H17V14C17 13.4477 17.4477 13 18 13C18.5523 13 19 13.4477 19 14V19C19 20.1046 18.1046 21 17 21H5C3.89543 21 3 20.1046 3 19V7Z' fill = 'currentColor' > </ path > </ svg >
28
+ </ a >
29
+ ) ) } </ dd >
18
30
</ div >
19
31
{ entry . getIn ( [ 'data' , 'severity' ] ) === 'High' ? (
20
32
< div >
@@ -26,7 +38,10 @@ const IssuePreview = createClass({
26
38
) }
27
39
< div >
28
40
< dt > Sample: </ dt >
29
- < dd > { entry . getIn ( [ 'data' , 'sample' ] ) } </ dd >
41
+ < dd > { entry . getIn ( [ 'data' , 'sample' ] ) === 'all'
42
+ ? 'All pages' : (
43
+ < a href = { `/#${ slugify ( entry . getIn ( [ 'data' , 'sample' ] ) ) } ` } > { entry . getIn ( [ 'data' , 'sample' ] ) } </ a >
44
+ ) } </ dd >
30
45
</ div >
31
46
</ dl >
32
47
</ div >
@@ -36,3 +51,78 @@ const IssuePreview = createClass({
36
51
} ) ;
37
52
38
53
CMS . registerPreviewTemplate ( 'issue' , IssuePreview ) ;
54
+
55
+ const ReportPreview = createClass ( {
56
+ render ( ) {
57
+ const entry = this . props . entry ;
58
+ return (
59
+ < >
60
+ < section id = 'start' >
61
+ < h1 > Accessibility Conformance Report for { entry . getIn ( [ 'data' , 'title' ] ) } </ h1 >
62
+ < dl >
63
+ < dt > Evaluated by</ dt >
64
+ < dd > { entry . getIn ( [ 'data' , 'evaluators' ] ) . join ( ', ' ) } </ dd >
65
+ < dt > Commissioned by</ dt >
66
+ < dd > { entry . getIn ( [ 'data' , 'commissioner' ] ) } </ dd >
67
+ < dt > Target</ dt >
68
+ < dd > WCAG { entry . getIn ( [ 'data' , 'targetWcagVersion' ] ) } , Level { entry . getIn ( [ 'data' , 'targetLevel' ] ) } </ dd >
69
+ < dt > Date</ dt >
70
+ < dd > { new Intl . DateTimeFormat ( 'en-CA' , { dateStyle : 'long' } ) . format ( entry . getIn ( [ 'data' , 'date' ] ) ) } </ dd >
71
+ < dt > Special requirements</ dt >
72
+ < dd > { entry . getIn ( [ 'data' , 'specialRequirements' ] ) } </ dd >
73
+ </ dl >
74
+ </ section >
75
+ < section id = 'executive-summary' >
76
+ < h2 > Executive summary</ h2 >
77
+ { this . props . widgetFor ( 'body' ) }
78
+ </ section >
79
+ < section id = 'scope' >
80
+ < h2 > Scope</ h2 >
81
+ < h3 > Pages</ h3 >
82
+ < p > Scope:</ p >
83
+ < ul >
84
+ { this . props . widgetsFor ( 'scope' ) . map ( ( scope , index ) => (
85
+ < li key = { index } >
86
+ < a href = { scope . getIn ( [ 'data' , 'url' ] ) } rel = 'external' >
87
+ { scope . getIn ( [ 'data' , 'title' ] ) } < span class = 'external' > (external link)</ span >
88
+ < svg aria-hidden = 'true' role = 'presentation' focusable = 'false' xmlns = 'http://www.w3.org/2000/svg' fill = 'none' viewBox = '0 0 24 24' height = '14' width = '16' > < path xmlns = 'http://www.w3.org/2000/svg' fill-rule = 'evenodd' clip-rule = 'evenodd' d = 'M14 5C13.4477 5 13 4.55228 13 4C13 3.44772 13.4477 3 14 3H20C20.2652 3 20.5196 3.10536 20.7071 3.29289C20.8946 3.48043 21 3.73478 21 4L21 10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10L19 6.41422L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L17.5858 5H14ZM3 7C3 5.89543 3.89543 5 5 5H10C10.5523 5 11 5.44772 11 6C11 6.55228 10.5523 7 10 7H5V19H17V14C17 13.4477 17.4477 13 18 13C18.5523 13 19 13.4477 19 14V19C19 20.1046 18.1046 21 17 21H5C3.89543 21 3 20.1046 3 19V7Z' fill = 'currentColor' > </ path > </ svg >
89
+ </ a > { scope . getIn ( [ 'data' , 'description' ] ) ? (
90
+ < p > { scope . getIn ( [ 'data' , 'description' ] ) } </ p >
91
+ ) : '' }
92
+ </ li >
93
+ ) ) }
94
+ </ ul >
95
+ < p > Not in scope:</ p >
96
+ < ul >
97
+ { this . props . widgetsFor ( 'outOfScope' ) . map ( ( outOfScope , index ) => (
98
+ < li key = { index } >
99
+ < a href = { outOfScope . getIn ( [ 'data' , 'url' ] ) } rel = 'external' >
100
+ { outOfScope . getIn ( [ 'data' , 'title' ] ) } < span class = 'external' > (external link)</ span >
101
+ < svg aria-hidden = 'true' role = 'presentation' focusable = 'false' xmlns = 'http://www.w3.org/2000/svg' fill = 'none' viewBox = '0 0 24 24' height = '14' width = '16' > < path xmlns = 'http://www.w3.org/2000/svg' fill-rule = 'evenodd' clip-rule = 'evenodd' d = 'M14 5C13.4477 5 13 4.55228 13 4C13 3.44772 13.4477 3 14 3H20C20.2652 3 20.5196 3.10536 20.7071 3.29289C20.8946 3.48043 21 3.73478 21 4L21 10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10L19 6.41422L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L17.5858 5H14ZM3 7C3 5.89543 3.89543 5 5 5H10C10.5523 5 11 5.44772 11 6C11 6.55228 10.5523 7 10 7H5V19H17V14C17 13.4477 17.4477 13 18 13C18.5523 13 19 13.4477 19 14V19C19 20.1046 18.1046 21 17 21H5C3.89543 21 3 20.1046 3 19V7Z' fill = 'currentColor' > </ path > </ svg >
102
+ </ a > { outOfScope . getIn ( [ 'data' , 'description' ] ) ? (
103
+ < p > { outOfScope . getIn ( [ 'data' , 'description' ] ) } </ p >
104
+ ) : '' }
105
+ </ li >
106
+ ) ) }
107
+ </ ul >
108
+ < h3 > Tools used</ h3 >
109
+ < p > In conducting this audit, the following tools were used:</ p >
110
+ < ul >
111
+ { this . props . widgetsFor ( 'tools' ) . map ( ( tool , index ) => (
112
+ < li key = { index } > { tool . getIn ( [ 'data' , 'name' ] ) } { tool . getIn ( [ 'data' , 'version' ] ) ? ` ${ tool . getIn ( [ 'data' , 'version' ] ) } ` : '' } </ li >
113
+ ) ) }
114
+ </ ul >
115
+ < h3 > Technologies used</ h3 >
116
+ < p > The audited web page relies on the following technologies:</ p >
117
+ < ul >
118
+ { entry . getIn ( [ 'data' , 'technologies' ] ) . map ( ( technology , index ) => (
119
+ < li key = { index } > { technology } </ li >
120
+ ) ) }
121
+ </ ul >
122
+ </ section >
123
+ </ >
124
+ ) ;
125
+ } ,
126
+ } ) ;
127
+
128
+ CMS . registerPreviewTemplate ( 'report' , ReportPreview ) ;
0 commit comments