Skip to content

Commit

Permalink
feat: add progress bars (#1013)
Browse files Browse the repository at this point in the history
* feat: add progress bars

* fix: tweak the values
  • Loading branch information
hugomrdias committed Jul 24, 2020
1 parent 1e7598b commit f2f5f65
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

.Dashboard-section {
max-width:250px;
// max-width:250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
Expand Down
1 change: 1 addition & 0 deletions content/intro/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ over time, without requiring further interaction from the original parties
(such as the clients who requested the data storage).

## Spec Status Overview
{{<dashboard-progress>}}

{{<dashboard-table>}}
55 changes: 55 additions & 0 deletions layouts/shortcodes/dashboard-progress.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{- with .Site.GetPage "/" -}}
{{- $level := 0 -}}
{{- template "dashboard-progress" (dict "Site" $.Site "level" $level) -}}
{{- end -}}

<!-- Children Template -->
{{ define "dashboard-progress" }}
{{- $count := .level -}}
{{- $countWeight:= 0 -}}
{{- $stable := 0 -}}
{{- $stableWeight := 0 -}}
{{- $pages := where .Site.AllPages "Params.bookhidden" "ne" true -}}
{{- $pages2 := where $pages "Params.dashboardhidden" "ne" true -}}
{{- $pages3 := where $pages2 "Kind" "in" (slice "section" "page") -}}
{{- $pages4 := where $pages3 "Language.Lang" "eq" "en" -}}
{{- range sort $pages4 "Weight" "asc" -}}
{{- if .Params.dashboardState -}}
{{- $count = add $count 1 -}}
{{- $countWeight = add $countWeight (mul 1 (float .Params.dashboardWeight)) -}}
{{- if eq .Params.dashboardState "stable" -}}
{{- $stable = add $stable 1 -}}
{{- $stableWeight = add $stableWeight (mul 1 (float .Params.dashboardWeight)) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $perc := lang.NumFmt 2 (div (float (mul $stable 100)) (float $count)) -}}
{{- $perc2 := lang.NumFmt 2 (div (mul $stableWeight 100) $countWeight) -}}

<h3>Progress</h3>
<div class="meter">
<span style="width: {{$perc}}%">{{$perc}}%</span>
</div>
<h3>Consequence</h3>
<div class="meter">
<span style="width: {{$perc2}}%">{{$perc2}}%</span>
</div>
<style>
.meter {
height: 20px; /* Can be anything */
position: relative;
background: #555;
border-radius: 4px;
color: white;
}
.meter > span {
display: block;
height: 100%;
line-height: 20px;
text-align: right;
border-radius: 4px;
background-color: #0090ff;
overflow: hidden;
}
</style>
{{ end }}

0 comments on commit f2f5f65

Please sign in to comment.