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

[BSv5] Adapt cardpane shortcode #1376

Merged
merged 2 commits into from
May 4, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ For a list of issues targeted for the next release, see the [23Q1][] milestone.
- `blocks/section`: **default** and accepted values of the `type` argument
have changed! For details see [blocks/section] ([#1472]).

- **[Adaptation of shortcodes for diplay of cards (#1376)][1376]:
- shortcode `cardpane`: renamed CSS class `td-card-deck` to `td-card-group`.
- shortcode `card`, `card-code`: markup of inner content (html/markdown)
now depends on the syntax of the calling shortcode, not on extension
of page file any more [#906][906].
- shortcode `card-code` is now deprecated, use shortcode `card` with named
parameter `code=true` instead.

**Other changes**:

- Non-breaking changes that result from the Bootstrap v5 upgrade:
Expand Down
3 changes: 2 additions & 1 deletion assets/scss/shortcodes/cards-pane.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.td-card-deck.card-deck {
.td-card-group.card-group {
@extend .td-max-width-on-larger-screens;
}

Expand All @@ -8,6 +8,7 @@

.highlight {
border: none;
margin: 0;
}
}

Expand Down
28 changes: 12 additions & 16 deletions layouts/shortcodes/card-code.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<div class="td-card card">
{{ $lang := "" }}
{{ with $.Get "lang" }}
{{ $lang = $.Get "lang" }}
{{ end }}
{{ $highlight := "" }}
{{ with $.Get "highlight" }}
{{ $highlight = $.Get "highlight" }}
{{ end }}
{{- with $.Get "header" -}}
{{ warnf `shortcode 'card-code' is deprecated: use shortcode 'card' with named parameter 'code=true' instead.` -}}
{{ $lang := default "" ($.Get "lang") -}}
deining marked this conversation as resolved.
Show resolved Hide resolved
{{ $highlight := default "" ($.Get "highlight") -}}

<div class="td-card card border me-4">
deining marked this conversation as resolved.
Show resolved Hide resolved
{{ with $.Get "header" -}}
<div class="card-header bg-white">
{{- $.Get "header" | markdownify -}}
{{ . | markdownify -}}
</div>
{{end}}
<div class="card-body code p-l0 m-0">
{{ with $.Inner }}
{{- highlight $.Inner $lang $highlight -}}
{{ end }}
{{ end -}}
<div class="card-body code p-0 m-0">
{{ with $.Inner -}}
{{ highlight . $lang $highlight -}}
{{ end -}}
</div>
</div>
76 changes: 37 additions & 39 deletions layouts/shortcodes/card.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
<div class="td-card card mb-4">
{{ with $.Get "header" }}
<div class="card-header">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "header" | markdownify }}
{{ else }}
{{ $.Get "header" | htmlUnescape | safeHTML }}
{{ end }}
{{/* Check parameter type */ -}}
{{ $code := false -}}
{{ with .Get "code" -}}
{{ $type := printf "%T" . -}}
{{ if ne $type "bool" -}}
{{ errorf `shortcode 'card': boolean value expected for parameter 'code', but got %s` $type -}}
{{ else }}
{{ $code = . -}}
{{ end -}}
{{ end -}}

{{ $lang := default "" (.Get "lang") -}}
{{ $highlight := default "" (.Get "highlight") -}}

<div class="td-card card border me-4">
deining marked this conversation as resolved.
Show resolved Hide resolved
{{ with $.Get "header" -}}
<div class="card-header{{- cond $code " bg-white" "" -}}">
deining marked this conversation as resolved.
Show resolved Hide resolved
{{ . | markdownify }}
</div>
{{ end }}
<div class="card-body">
{{ with $.Get "title" }}
{{ end -}}
<div class="card-body{{- cond $code " code p-0 m-0" "" -}}">
{{ with $.Get "title" -}}
<h5 class="card-title">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "title" | markdownify }}
{{ else }}
{{ $.Get "title" | htmlUnescape | safeHTML }}
{{ end }}
{{ . | markdownify -}}
</h5>
{{ end }}
{{ with $.Get "subtitle" }}
<h6 class="card-title mb-2 text-muted">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "subtitle" | markdownify }}
{{ else }}
{{ $.Get "subtitle" | htmlUnescape | safeHTML }}
{{ end }}
{{ end -}}
{{ with $.Get "subtitle" -}}
<h6 class="card-title ms-2 text-muted">
{{ . | markdownify -}}
</h6>
{{ end }}
{{ with $.Inner }}
{{ end -}}
{{ with $.Inner -}}
{{ if $code -}}
{{ highlight . $lang $highlight -}}
{{ else -}}
<p class="card-text">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Inner | markdownify }}
{{ else }}
{{ $.Inner | htmlUnescape | safeHTML }}
{{ end }}
{{ . -}}
</p>
{{ end }}
{{ end -}}
{{ end -}}
</div>
{{ with $.Get "footer" }}
{{ with $.Get "footer" -}}
<div class="card-footer">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "footer" | markdownify }}
{{ else }}
{{ $.Get "footer" | htmlUnescape | safeHTML }}
{{ end }}
{{ . | markdownify -}}
</div>
{{ end }}
{{ end -}}
</div>
4 changes: 2 additions & 2 deletions layouts/shortcodes/cardpane.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="td-card-deck card-deck mb-4">
<div class="td-card-group card-group p-0 mb-4">
{{- .Inner -}}
</div>
</div>
Loading