content/static: module and package page title badges
Adds badges to unit page for packages and modules.
A unit that contains both a module and package
will show both badges.
https://drive.google.com/file/d/1aXb3xGUw6fHDegdw5F_sK_Xb2N_qYjkp/view
Change-Id: I5c72694970633e84da68d6a248eb9052d6d83a17
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/257200
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/content/static/css/unit_header.css b/content/static/css/unit_header.css
index 795b18d..5547b78 100644
--- a/content/static/css/unit_header.css
+++ b/content/static/css/unit_header.css
@@ -125,3 +125,13 @@
.UnitHeader-backLink img {
margin-right: 0.5rem;
}
+.UnitHeader-moduleBadge,
+.UnitHeader-packageBadge {
+ border: 1px solid var(--gray-4);
+ border-radius: 0.125rem;
+ font-size: 0.6875rem;
+ height: 1rem;
+ padding: 0.1rem 0.25rem;
+ vertical-align: middle;
+ width: 3.25rem;
+}
diff --git a/content/static/html/helpers/_unit_header.tmpl b/content/static/html/helpers/_unit_header.tmpl
index 7bcf7b2..7350471 100644
--- a/content/static/html/helpers/_unit_header.tmpl
+++ b/content/static/html/helpers/_unit_header.tmpl
@@ -17,7 +17,15 @@
<span class="UnitHeader-breadcrumbItem">{{.Current}}</span>
{{end}}
</div>
- <h1 class="UnitHeader-title">{{.Title}}</h1>
+ <h1 class="UnitHeader-title">
+ {{.Title}}
+ {{if .Unit.IsModule}}
+ <span class="UnitHeader-moduleBadge">module</span>
+ {{end}}
+ {{if .Unit.IsPackage}}
+ <span class="UnitHeader-packageBadge">package</span>
+ {{end}}
+ </h1>
<div class="UnitHeader-versionBanner $$GODISCOVERY_LATESTMAJORCLASS$$">
<img height="19px" width="16px" class="UnitHeader-detailIcon" src="/static/img/pkg-icon-info_19x16.svg">
<span>