Skip to content

Commit

Permalink
Merge pull request #709 from gethinode/validation
Browse files Browse the repository at this point in the history
Fix breakpoint-specific responsive behavior of tables
  • Loading branch information
markdumay authored Jan 6, 2024
2 parents f1598c3 + 0d2f5cc commit ed9373b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion data/structures/table.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ arguments:
class:
type: string
optional: true
comment: Class attribute of the table element, e.g. table-striped-columns w-auto.
comment: Class attribute of the table element, e.g. `table-striped-columns w-auto`.
body:
type: string
optional: false
Expand Down
16 changes: 16 additions & 0 deletions exampleSite/content/en/blog/bootstrap-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,22 @@ As an example, the following shortcode displays superscript text.
{{< /example >}}
<!-- markdownlint-enable MD037 -->

## Table

As an example, the following shortcode displays a responsive table.

<!-- markdownlint-disable MD037 -->
{{< example lang="markdown" >}}
{{</* table */>}}
| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|----|---------|---------|---------|---------|---------|---------|---------|---------|---------|
| 1. | cell | cel | cel | cel | cel | cel | cel | cel | cel |
| 2. | cell | cel | cel | cel | cel | cel | cel | cel | cel |
| 3. | cell | cel | cel | cel | cel | cel | cel | cel | cel |
{{</* /table */>}}
{{< /example >}}
<!-- markdownlint-enable MD037 -->

## Timeline

As an example, the following shortcode displays a timeline with the file `data/timeline.en.yml` as data.
Expand Down
9 changes: 9 additions & 0 deletions exampleSite/hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@
"sub",
"sup",
"svg",
"table",
"tbody",
"td",
"th",
"thead",
"time",
"title",
"tr",
"ul",
"use"
],
Expand Down Expand Up @@ -373,6 +379,8 @@
"syntax-highlight",
"tab-content",
"tab-pane",
"table",
"table-responsive",
"tag-link",
"text-bg-body",
"text-bg-body-tertiary",
Expand Down Expand Up @@ -518,6 +526,7 @@
"spinner",
"sub",
"sup",
"table",
"timeline",
"toast",
"toast-container",
Expand Down
13 changes: 9 additions & 4 deletions layouts/shortcodes/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
{{ else }}
{{ $breakpoint = .Get 0 }}
{{ end }}
{{ if eq $breakpoint "none" }}{{ $breakpoint = "" }}{{ end }}

<!-- Main code -->
{{- $input := .Inner | .Page.RenderString }}
Expand All @@ -32,6 +31,12 @@
{{- $new := printf "<table class=\"table %s\">" $class -}}
{{ $input := replace $input $old $new -}}

<div class="{{- with $breakpoint }}table-responsive table-responsive-{{ . }}{{ end -}}">
{{ $input | safeHTML }}
</div>
{{ if not $error }}
{{ if eq $breakpoint "none" }}
{{ $input | safeHTML }}
{{ else }}
<div class="table-responsive{{- with $breakpoint }}-{{ . }}{{ end -}}">
{{ $input | safeHTML }}
</div>
{{ end }}
{{ end }}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gethinode/hinode",
"version": "0.22.1",
"version": "0.22.2",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [
"hugo",
Expand Down

0 comments on commit ed9373b

Please sign in to comment.