-
Notifications
You must be signed in to change notification settings - Fork 1
/
contrastchecker.html
30 lines (30 loc) · 1.22 KB
/
contrastchecker.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/contrastchecker/?fcolor=242424&bcolor=FCFCFC&api */ -}}
{{- $fcolor := .Get "fcolor" | string -}}
{{- $bcolor := .Get "bcolor" | string -}}
{{- with resources.GetRemote (printf "%s%s%s%s%s" "https://webaim.org/resources/contrastchecker/?fcolor=" $fcolor "&bcolor=" $bcolor "&api") -}}
{{- with .Err -}}
{{- warnf "%s" . -}}
{{- else -}}
{{- $json := unmarshal .Content -}}
<table>
<thead>
<tr>
<th>ratio</th>
<th>AA</th>
<th>AALarge</th>
<th>AAA</th>
<th>AAALarge</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ with $json.ratio }}{{ if gt . 4.5 }}✅ {{.}}{{ else }}❌ {{.}}{{ end }}{{ end }}</td>
<td>{{ with $json.AA }}{{ if eq . "pass" }}✅ {{.}}{{ else }}❌ {{.}}{{ end }}{{ end }}</td>
<td>{{ with $json.AALarge }}{{ if eq . "pass" }}✅ {{.}}{{ else }}❌ {{.}}{{ end }}{{ end }}</td>
<td>{{ with $json.AAA }}{{ if eq . "pass" }}✅ {{.}}{{ else }}❌ {{.}}{{ end }}{{ end }}</td>
<td>{{ with $json.AAALarge }}{{ if eq . "pass" }}✅ {{.}}{{ else }}❌ {{.}}{{ end }}{{ end }}</td>
</tr>
</tbody>
</table>
{{- end -}}
{{- end -}}