-
Notifications
You must be signed in to change notification settings - Fork 1
/
linkcontrastchecker.html
30 lines (30 loc) · 1.11 KB
/
linkcontrastchecker.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{{- /* https://webaim.org/resources/linkcontrastchecker/?fcolor=242424&bcolor=FCFCFC&lcolor=0A802D&api */ -}}
{{- $fcolor := .Get "fcolor" | string -}}
{{- $bcolor := .Get "bcolor" | string -}}
{{- $lcolor := .Get "lcolor" | string -}}
{{- $number := 4.5 -}}
{{- with resources.GetRemote (printf "%s%s%s%s%s%s%s" "https://webaim.org/resources/linkcontrastchecker/?fcolor=" $fcolor "&bcolor=" $bcolor "&lcolor=" $lcolor "&api") -}}
{{- with .Err -}}
{{- warnf "%s" . -}}
{{- else -}}
{{- $json := unmarshal .Content -}}
<table>
<thead>
<tr>
<th></th>
<th>conformance</th>
<th>ratio</th>
</tr>
</thead>
<tbody>
{{range $index, $element := $json}}
<tr>
<td><strong>{{ $index }}</strong></td>
<td>{{ with $element.conformance }}{{ if eq . "pass" }}✅ {{.}}{{ else }}❌ {{.}}{{ end }}{{ end }}</td>
<td>{{ if eq $index "Link to Body Text" }}{{ $number = 3 }}{{ end }}{{ with $element.ratio }}{{ if gt . $number }}✅ {{.}}{{ else }}❌ {{.}}{{ end }}{{ end }}</td>
</tr>
{{ end }}
</tbody>
</table>
{{- end -}}
{{- end -}}