blob: 8368eecf5b1e6388aaf760ac671738912374b24b [file] [log] [blame]
<!--
Copyright 2020 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
{{/* . is internal/frontend.UnitPage */}}
{{define "unit_header"}}
<header class="js-unitHeader UnitHeader{{if eq .SelectedTab.Name ""}} UnitHeader--full UnitHeader--main{{if .Unit.IsPackage}}--package{{end}}{{end}}" aria-label="{{if eq .PageType "std"}}module{{else}}{{.PageType}}{{end}} {{.Title}} information" role="complementary">
<div class="js-headerSentinel"></div>
{{template "unit_header_banners" .}}
{{template "unit_header_breadcrumbs" .}}
{{template "unit_header_content" .}}
</header>
{{end}}
{{define "unit_header_breadcrumbs"}}
<div class="UnitHeader-breadcrumbs" data-test-id="UnitHeader-breadcrumb">
<div class="Site-margin">
{{with .Breadcrumb}}
{{range .Links}}
<span class="UnitHeader-breadcrumbItem" data-test-id="UnitHeader-breadcrumbItem">
<a data-gtmc="breadcrumbs link" href="{{.Href}}">{{.Body}}</a>
</span>
{{end}}
<span class="UnitHeader-breadcrumbItem">
<span data-test-id="UnitHeader-breadcrumbCurrent">{{.Current}}</span>
{{if .CopyData}}
<button class="CopyToClipboardButton js-copyToClipboard"
title="Copy path to clipboard.&#10;&#10;{{.CopyData}}"
data-to-copy="{{.CopyData}}"
data-gtmc="breadcrumbs button" aria-label="Copy to Clipboard">
<img class="CopyToClipboardButton-image" src="/static/legacy/img/copy-click.svg" alt="">
</button>
{{end}}
</span>
{{end}}
</div>
</div>
{{end}}
{{define "unit_header_content"}}
<div class="UnitHeader-content">
<div class="Site-margin">
{{template "unit_header_title" .}}
{{with .Breadcrumb}}
{{if .CopyData}}
<button class="CopyToClipboardButton js-copyToClipboard"
title="Copy path to clipboard.&#10;&#10;{{.CopyData}}"
data-to-copy="{{.CopyData}}"
data-gtmc="title button"
aria-label="Copy to Clipboard"
tabindex="-1">
<img class="CopyToClipboardButton-image" src="/static/legacy/img/copy-click.svg" alt="">
</button>
{{end}}
{{end}}
<div style="flex-grow: 1;"></div>
<div class="UnitHeader-details">
{{if (eq .SelectedTab.Name "")}}
{{template "detail_item_version" .}}
{{template "detail_item_commit_time" .}}
{{template "detail_item_licenses" .}}
{{if .Unit.IsPackage}}
{{template "detail_item_imports" .}}
{{template "detail_item_importedby" .}}
{{end}}
{{else}}
{{template "detail_page_nav" .}}
{{end}}
</div>
{{template "detail_items_overflow" .}}
</div>
</div>
{{end}}
{{define "unit_header_title"}}
<div class="UnitHeader-title">
<div class="UnitHeader-logo">
<a href="https://go.dev/" tabindex="-1" data-gtmc="header link" aria-label="Link to Go Homepage">
<img height="72px" width="72px" class="UnitHeader-logo" src="/static/legacy/img/go-logo-blue.svg" alt="Go">
</a>
</div>
<h1 data-test-id="UnitHeader-title">{{.Title}}</h1>
{{range .PageLabels}}
<span class="UnitHeader-badge">{{.}}</span>
{{end}}
</div>
{{end}}
{{define "detail_item_version"}}
<span class="UnitHeader-detailItem" data-test-id="UnitHeader-version">
<a href="?tab=versions" aria-label="Go to Versions" data-gtmc="header link"><span class="UnitHeader-detailItemSubtle">Version: </span>{{.DisplayVersion}}</a>
<!-- Do not reformat the data attributes of the following div: the server uses a regexp to extract them. -->
<div class="DetailsHeader-badge {{.LatestMinorClass}}"
data-test-id="UnitHeader-minorVersionBanner"
data-version="{{.LinkVersion}}"
data-mpath="{{.Unit.ModulePath}}"
data-ppath="{{.Unit.Path}}"
data-pagetype="{{.PageType}}">
<span class="DetailsHeader-span--latest">Latest</span>
<span class="DetailsHeader-span--notAtLatest">
Latest
{{template "severity_toggletip" "This package is not in the latest version of its module."}}
</span>
<a href="{{.LatestURL}}" aria-label="Go to Latest Version" data-gtmc="header link">Go to latest</a>
</div>
</span>
{{end}}
{{define "detail_item_commit_time"}}
<span class="UnitHeader-detailItem" data-test-id="UnitHeader-commitTime">
Published: {{.Details.CommitTime}}
</span>
{{end}}
{{define "detail_item_licenses"}}
<span class="UnitHeader-detailItem" data-test-id="UnitHeader-licenses">
License:{{" "}}
{{- if .Details.Licenses -}}
{{- if .Unit.IsRedistributable -}}
<a href="{{$.URLPath}}?tab=licenses" data-test-id="UnitHeader-license"
aria-label="Go to Licenses" data-gtmc="header link">
{{- range $i, $e := .Details.Licenses -}}
{{if $i}}, {{end}}{{$e.Type}}
{{- end -}}
</a>
{{else}}
<span>
{{- range $i, $e := .Details.Licenses -}}
{{if $i}}, {{end}} {{$e.Type}}
{{- end -}}
</span>
<a href="/license-policy" class="Disclaimer-link"
aria-label="Go to License Policy" data-gtmc="info link">
<em>not legal advice</em>
</a>
{{end}}
{{else}}
<span>None detected</span>
<a href="/license-policy" class="Disclaimer-link"
aria-label="Go to License Policy" data-gtmc="info link">
<em>not legal advice</em>
</a>
{{end}}
</span>
{{end}}
{{define "detail_item_imports"}}
<span class="UnitHeader-detailItem" data-test-id="UnitHeader-imports">
<a href="{{$.URLPath}}?tab=imports" aria-label="Go to Imports"
data-gtmc="header link">
<span class="UnitHeader-detailItemSubtle">Imports: </span>{{.Details.NumImports}}
</a>
</span>
{{end}}
{{define "detail_item_importedby"}}
<span class="UnitHeader-detailItem" data-test-id="UnitHeader-importedby">
<a href="{{$.URLPath}}?tab=importedby" aria-label="Go to Imported By"
data-gtmc="header link">
<span class="UnitHeader-detailItemSubtle">Imported by: </span>{{.Details.ImportedByCount}}
</a>
</span>
{{end}}
{{define "detail_items_overflow"}}
<div class="UnitHeader-overflowContainer">
<svg class="UnitHeader-overflowImage" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
</svg>
<select class="UnitHeader-overflowSelect js-overflowSelect" tabindex="-1">
<option>Main</option>
<option value="{{$.URLPath}}?tab=versions">
Versions
</option>
<option value="{{$.URLPath}}?tab=licenses">
Licenses
</option>
{{if .Unit.IsPackage}}
<option value="{{$.URLPath}}?tab=imports">
Imports
</option>
<option value="{{$.URLPath}}?tab=importedby">
Imported By
</option>
{{end}}
</select>
</div>
{{end}}
{{define "detail_page_nav"}}
<span class="UnitHeader-detailItem">
<!-- Do not reformat the data attributes of the following div: the server uses a regexp to extract them. -->
<div style="display: none;" class="DetailsHeader-badge {{.LatestMinorClass}}"
data-version="{{.LinkVersion}}" data-mpath="{{.Unit.ModulePath}}" data-ppath="{{.Unit.Path}}" data-pagetype="{{.PageType}}">
</div>
<a class="UnitHeader-backLink" href="{{.URLPath}}" data-gtmc="header link">
<img height="16px" width="16px" src="/static/legacy/img/pkg-icon-arrowLeft_16x16.svg" alt=""> Go to main page
</a>
</span>
{{end}}
{{define "unit_header_banners"}}
<div class="UnitHeader-banners">
{{with .RedirectedFromPath}}
<div class="UnitHeader-banner UnitHeader-banner--redirected">
<span class="Site-margin UnitHeader-bannerContent">
<img height="19px" width="16px" class="UnitHeader-banner-icon" src="/static/legacy/img/pkg-icon-info_19x16.svg" alt="">
<span>
Redirected from <span data-test-id="redirected-banner-text">{{.}}</span>.
</span>
</span>
</div>
{{end}}
{{if .Unit.Deprecated}}
<div class="UnitHeader-banner UnitHeader-banner--deprecated">
<span class="Site-margin UnitHeader-bannerContent">
<strong>Deprecated</strong>
{{with .Unit.DeprecationComment}}
<strong>:</strong>&nbsp;{{.}}
{{end}}
</span>
</div>
{{end}}
{{if .Unit.Retracted}}
<div class="UnitHeader-banner UnitHeader-banner--retracted">
<span class="Site-margin UnitHeader-bannerContent">
<strong>Retracted</strong>
{{with .Unit.RetractionRationale}}
<strong>:</strong>&nbsp;{{.}}
{{end}}
</span>
</div>
{{end}}
{{if .LatestMajorVersion}}
<div class="UnitHeader-banner UnitHeader-banner--majorVersion" data-test-id="UnitHeader-majorVersionBanner">
<span class="Site-margin UnitHeader-bannerContent">
<img height="19px" width="16px" class="UnitHeader-banner-icon" src="/static/legacy/img/pkg-icon-info_19x16.svg" alt="">
<span>
The highest tagged major version is
<a href="/{{.LatestMajorVersionURL}}" data-gtmc="banner link" aria-label="Go to Latest Major Version">
{{.LatestMajorVersion}}
</a>.
</span>
</span>
</div>
{{end}}
</div>
{{end}}
{{define "severity_toggletip"}}
<span class="UnitMetaDetails-toggletip">
<button type="button" data-gtmc="toggle tip button"
aria-label="More Info" data-toggletip-content="{{.}}">
<img src="/static/legacy/img/severity.svg" alt="" height="14" width="15">
</button>
<span role="status"></span>
</span>
{{end}}