Merge pull request #21097 from dvdksn/tbl-styles

hugo: update table styles
This commit is contained in:
David Karlsson 2024-10-24 15:10:43 +02:00 committed by GitHub
commit 6d320898d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 131 additions and 92 deletions

View File

@ -73,10 +73,5 @@
@apply text-lg; @apply text-lg;
line-height: 1.75; line-height: 1.75;
} }
table {
display: block;
overflow-x: auto;
max-width: 100%;
}
} }
} }

View File

@ -413,6 +413,7 @@
"outline-none", "outline-none",
"overflow-clip", "overflow-clip",
"overflow-hidden", "overflow-hidden",
"overflow-x-auto",
"overflow-x-hidden", "overflow-x-hidden",
"overflow-y-auto", "overflow-y-auto",
"p-1", "p-1",

View File

@ -0,0 +1,39 @@
<div class="overflow-x-auto">
<table
{{- range $k, $v := .Attributes }}
{{- if $v }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}>
<thead class="bg-gray-light-100 dark:bg-gray-dark-200">
{{- range .THead }}
<tr>
{{- range . }}
<th class="p-2"
{{- with .Alignment }}
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
{{- end -}}
>
{{- .Text -}}
</th>
{{- end }}
</tr>
{{- end }}
</thead>
<tbody>
{{- range .TBody }}
<tr>
{{- range . }}
<td class="p-2"
{{- with .Alignment }}
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
{{- end -}}
>
{{- .Text -}}
</td>
{{- end }}
</tr>
{{- end }}
</tbody>
</table>
</div>

View File

@ -11,38 +11,40 @@
<article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert"> <article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert">
{{ partial "breadcrumbs.html" . }} {{ partial "breadcrumbs.html" . }}
<h1 class="scroll-mt-36">{{ .Title }}</h1> <h1 class="scroll-mt-36">{{ .Title }}</h1>
<table> <div class="overflow-x-auto">
<tbody> <table>
{{ with $data.short }} <tbody>
<tr> {{ with $data.short }}
<th class="text-left w-32">Description</th> <tr>
<td>{{ . }}</th> <th class="text-left w-32">Description</th>
</tr> <td>{{ . }}</th>
{{ end }} </tr>
{{ with $data.usage }} {{ end }}
<tr> {{ with $data.usage }}
<th class="text-left w-32">Usage</th> <tr>
<td><code>{{ . }}</code></td> <th class="text-left w-32">Usage</th>
</tr> <td><code>{{ . }}</code></td>
{{ end }} </tr>
{{ with $data.aliases }} {{ end }}
{{ $aliases := strings.Replace . (fmt.Printf "%s, " page.Title) "" }} {{ with $data.aliases }}
<tr> {{ $aliases := strings.Replace . (fmt.Printf "%s, " page.Title) "" }}
<th class="text-left w-32 flex items-center gap-2"> <tr>
<span>Aliases</span> <th class="text-left w-32 flex items-center gap-2">
{{ partialCached "tooltip.html" "An alias is a short or memorable alternative for a longer command." "cli-alias" }} <span>Aliases</span>
</th> {{ partialCached "tooltip.html" "An alias is a short or memorable alternative for a longer command." "cli-alias" }}
<td> </th>
<div class="flex gap-3"> <td>
{{ range (strings.Split $aliases ", ") }} <div class="flex gap-3">
<code>{{ . }}</code> {{ range (strings.Split $aliases ", ") }}
{{ end }} <code>{{ . }}</code>
</div> {{ end }}
</td> </div>
</tr> </td>
{{ end }} </tr>
</tbody> {{ end }}
</table> </tbody>
</table>
</div>
{{ .Content }} {{ .Content }}
{{ if $data.deprecated }} {{ if $data.deprecated }}
{{ markdownify ` {{ markdownify `
@ -96,62 +98,64 @@ can be removed entirely in a future release.
{{ $heading := dict "level" 2 "text" "Options" }} {{ $heading := dict "level" 2 "text" "Options" }}
{{ partialCached "heading.html" $heading "cli-options" }} {{ partialCached "heading.html" $heading "cli-options" }}
{{ $.Scratch.Add "headings" $heading }} {{ $.Scratch.Add "headings" $heading }}
<table> <div class="overflow-x-auto">
<thead> <table>
<tr> <thead class="bg-gray-light-100 dark:bg-gray-dark-200">
<th>Option</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{{ range . }}
<tr> <tr>
{{ $short := .shorthand }} <th class="p-2">Option</th>
{{ $long := .option }} <th class="p-2">Default</th>
<td> <th class="p-2">Description</th>
{{ with .details_url }}
<a class="link" href="{{ . }}">
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
</a>
{{ else }}
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
{{ end }}
</td>
{{ $skipDefault := `[],map[],false,0,0s,default,'',""` }}
<td>
{{ with .default_value }}
{{ cond (in $skipDefault .) "" (printf "<code>%s</code>" . | safeHTML) }}
{{ end }}
</td>
<td>
{{ with .min_api_version }}
{{ partialCached "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) "api" . }}
{{ end }}
{{ with .deprecated }}
{{ partialCached "components/badge.html" (dict "color" "red" "content" "Deprecated") "deprecated" }}
{{ end }}
{{ with .experimental }}
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") "exp" }}
{{ end }}
{{ with .experimentalcli }}
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") "exp-cli" }}
{{ end }}
{{ with .kubernetes }}
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Kubernetes") "k8s" }}
{{ end }}
{{ with .swarm }}
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Swarm") "swarm" }}
{{ end }}
{{ if .description }}
{{/* replace newlines in long desc with break tags */}}
{{ markdownify (strings.Replace .description "\n" "<br>") }}
{{ end }}
</td>
</tr> </tr>
{{ end }} </thead>
</tbody> <tbody>
</table> {{ range . }}
<tr class="p-2">
{{ $short := .shorthand }}
{{ $long := .option }}
<td>
{{ with .details_url }}
<a class="link" href="{{ . }}">
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
</a>
{{ else }}
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
{{ end }}
</td>
{{ $skipDefault := `[],map[],false,0,0s,default,'',""` }}
<td>
{{ with .default_value }}
{{ cond (in $skipDefault .) "" (printf "<code>%s</code>" . | safeHTML) }}
{{ end }}
</td>
<td>
{{ with .min_api_version }}
{{ partialCached "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) "api" . }}
{{ end }}
{{ with .deprecated }}
{{ partialCached "components/badge.html" (dict "color" "red" "content" "Deprecated") "deprecated" }}
{{ end }}
{{ with .experimental }}
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") "exp" }}
{{ end }}
{{ with .experimentalcli }}
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") "exp-cli" }}
{{ end }}
{{ with .kubernetes }}
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Kubernetes") "k8s" }}
{{ end }}
{{ with .swarm }}
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Swarm") "swarm" }}
{{ end }}
{{ if .description }}
{{/* replace newlines in long desc with break tags */}}
{{ markdownify (strings.Replace .description "\n" "<br>") }}
{{ end }}
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ with $data.examples }} {{ with $data.examples }}

View File

@ -39,7 +39,7 @@ module.exports = {
"--tw-prose-invert-hr": theme("colors.divider.dark"), "--tw-prose-invert-hr": theme("colors.divider.dark"),
"--tw-prose-invert-captions": theme("colors.gray.dark.600"), "--tw-prose-invert-captions": theme("colors.gray.dark.600"),
"--tw-prose-invert-th-borders": theme("colors.gray.dark.200"), "--tw-prose-invert-th-borders": theme("colors.gray.dark.200"),
"--tw-prose-invert-td-borders": theme("colors.gray.dark.200"), "--tw-prose-invert-td-borders": theme("colors.gray.dark.300"),
}, },
}, },
}), }),