Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show wip and reliable in progress bar #1137

Merged
merged 1 commit into from Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions assets/plugins/_meter.scss
@@ -0,0 +1,17 @@
.meter {
height: 24px; /* Can be anything */
background: #EBEBEB;
border-radius: 4px;
color: #222;
border-radius: 4px;
overflow: hidden;
}
.meter > .bar {
display: inline-block;
height: 100%;
line-height: 24px;
text-align: right;
font-size: 12px;
padding-right: 1em;
vertical-align: top;
}
46 changes: 20 additions & 26 deletions layouts/shortcodes/dashboard-progress.html
Expand Up @@ -6,45 +6,39 @@
<!-- Children Template -->
{{ define "dashboard-progress" }}
{{- $count := .level -}}
{{- $countWeight:= 0 -}}
{{- $stable := 0 -}}
{{- $stableWeight := 0 -}}
{{- $reliable := 0 -}}
{{- $wip := 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 -}}
{{- if eq .Params.dashboardState "reliable" -}}
{{- $reliable = add $reliable 1 -}}
{{- end -}}
{{- if eq .Params.dashboardState "wip" -}}
{{- $wip = add $wip 1 -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $perc := lang.NumFmt 0 (div (float (mul $stable 100)) (float $count)) -}}
{{- $perc2 := lang.NumFmt 0 (div (mul $stableWeight 100) $countWeight) -}}

{{- $total := (add $stable (add $reliable $wip)) }}
{{- $usable := add $stable $reliable }}
{{- $stablePercent := lang.NumFmt 0 (div (float (mul $stable 100)) (float $count)) -}}
{{- $reliablePercent := lang.NumFmt 0 (div (float (mul $reliable 100)) (float $count)) -}}
{{- $wipPercent := lang.NumFmt 0 (div (float (mul $wip 100)) (float $count)) -}}
{{- $totalPercent := lang.NumFmt 0 (div (float (mul $total 100)) (float $count)) -}}
{{- $usablePercent := lang.NumFmt 0 (div (float (mul $usable 100)) (float $count)) -}}
<div class="meter">
<span style="width: {{$perc}}%">{{$perc}}%</span>
<span class="bar bg-wip" style="width: {{ $wipPercent }}%">WIP <strong>{{$wipPercent}}%</strong>
</span><span class="bar bg-reliable" style="width: {{ $reliablePercent }}%">Reliable <strong>{{$reliablePercent}}%</strong>
</span><span class="bar bg-stable" style="width: {{ $stablePercent }}%">Stable <strong>{{$stablePercent}}%</strong>
</span>
{{/* <span> total {{$totalPercent}}%</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 }}