Skip to content

Commit a8044d5

Browse files
authored
Fixed partially styled call-outs (#297)
* Callouts: Fixed partially styled call-outs * Callouts: Refactored inline param to be sideline param instead
1 parent f2b8ec5 commit a8044d5

File tree

15 files changed

+54
-54
lines changed

15 files changed

+54
-54
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{<banner "caution" "Under development">}}
2+
<br>
3+
This product on our example site is under development and changes are being added frequently.
4+
<br>
5+
Please reach out to <strong>#friends-of-the-docs</strong> on Slack to ask questions.
6+
{{</banner>}}

exampleSite/content/test-product/_index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ description: Test pages for nginx-hugo-theme
33
title: Test pages
44
weight: 100
55
nd-landing-page: true
6+
cascade:
7+
nd-banner:
8+
enabled: true
9+
start-date: 2025-01-01
10+
md: /_banners/test-product-intro.md
611
---
712
{{<card-layout>}}
813
{{<card-section showAsCards="true">}}

exampleSite/content/test-product/call-out/call-out-param-types.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ The callout shortcode aims to support both, but **not** in the same shortcode in
1313
## The two callouts below using **unnamed** params
1414

1515
{{<call-out "" "Custom title" "fa fa-check-circle" "true">}}
16-
This callout uses the icon check-circle. **This should be an inline callout.**
16+
This callout uses the icon check-circle. **This should be an sideline callout.**
1717
{{</call-out>}}
1818

1919
{{<call-out "" "Custom title" "fa fa-check-circle" "false">}}
20-
This callout uses the icon check-circle. **This should be an sideline callout.**
20+
This callout uses the icon check-circle. **This should be an inline callout.**
2121
{{</call-out>}}
2222

2323
## The two callouts below using **named** params
2424
This should work exactly the same as the two callouts above
2525

26-
{{<call-out title="Custom title" icon="fa fa-check-circle" inline="true">}}
27-
This callout uses the icon check-circle. **This should be an inline callout.**
26+
{{<call-out title="Custom title" icon="fa fa-check-circle" sideline="true">}}
27+
This callout uses the icon check-circle. **This should be an sideline callout.**
2828
{{</call-out>}}
2929

30-
{{<call-out title="Custom title" icon="fa fa-check-circle" inline="asdas">}}
30+
{{<call-out title="Custom title" icon="fa fa-check-circle" sideline="true">}}
3131
This callout uses the icon check-circle. **This should be an sideline callout.**
3232
{{</call-out>}}

exampleSite/content/test-product/call-out/call-out-side.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ This assumes the callout text is shorter than the text in the callout.
4646
If the text in the paragraph is shorter than the callout, it's likely
4747
the content needs to be re-written.
4848

49-
{{<call-out "tip inline-callout" "Tip for Automated Reporting" >}}
49+
{{<call-out "tip" "Tip for Automated Reporting" >}}
5050
I am some call out text. Look at me go!
5151
{{</call-out>}}

layouts/partials/callout.html

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
{{ $class := .class | default "" }}
33
{{ $title := .title | default "" }}
44
{{ $icon := .icon | default "" }}
5-
{{ $inlineParam := .inline | default "false" | lower }}
5+
{{ $sidelineParam := .sideline | default "false" | lower }}
66

7-
{{ if not (in (slice "true" "false") $inlineParam) }}
8-
{{ errorf "Invalid parameter 'inline'='%s' passed to blockquote partial from '%s'. Allowed values: true, false" $inlineParam .Page.Path }}
7+
{{ if not (in (slice "true" "false") $sidelineParam) }}
8+
{{ errorf "Invalid parameter 'sideline'='%s' passed to blockquote partial from '%s'. Allowed values: true, false" $sidelineParam .Page.Path }}
99
{{ end }}
1010

1111
{{/* Figure out inline/side and set class accordingly */}}
12-
{{ $inline := eq $inlineParam "true" }}
12+
{{ $sideline := eq $sidelineParam "true" }}
1313
{{ $sideOption := "side-callout" }}
1414
{{ $inlineOption := "inline-callout" }}
1515

16-
{{ if $inline }}
16+
{{ if $sideline }}
1717
{{ $class = printf "%s %s" $class $sideOption }}
1818
{{ else }}
1919
{{ $class = printf "%s %s" $class $inlineOption }}
@@ -34,31 +34,30 @@
3434

3535

3636
{{/* Render a different block, if "loud" callouts are used */}}
37+
{{ $type := (index (split $class " ") 0) | strings.FirstUpper }}
3738
{{ $specialTitles := slice "Caution" "Warning" "Deprecated" "Important" }}
3839
{{ $specialTitleIcons := dict
3940
"Caution" "alert-triangle"
4041
"Warning" "alert-octagon"
4142
"Deprecated" "alert-octagon"
4243
"Important" "arrow-right-circle"
4344
}}
44-
{{ $icon := index $specialTitleIcons $title | default "" }}
45+
{{ $icon := index $specialTitleIcons $type | default "" }}
4546

46-
{{ $isSpecialTitle := in $specialTitles $title }}
47+
{{ $isSpecialTitle := in $specialTitles $type }}
4748
{{ if $isSpecialTitle }}
48-
{{/* Loud callouts */}}
49+
{{/* Loud callouts */}}
50+
<blockquote class="{{ $class }}" data-mf="true" style="display: none;">
4951
<div>
50-
<blockquote class="{{ $class }}" data-mf="true" style="display: none;">
51-
<div>
52-
<div class="call-out-type">
53-
{{ partial "feather" (dict "context" . "icon" $icon) .}}
54-
{{ $title }}
55-
</div>
56-
<div class="callout-content">
57-
{{ .content | markdownify }}
58-
</div>
52+
<div class="call-out-type">
53+
{{ partial "feather" (dict "context" . "icon" $icon) .}}
54+
{{ $title }}
5955
</div>
60-
</blockquote>
61-
</div>
56+
<div class="callout-content">
57+
{{ .content | markdownify }}
58+
</div>
59+
</div>
60+
</blockquote>
6261

6362
{{ else }}
6463

layouts/shortcodes/banner.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{{- $type := .Get 0 | default (.Get "type") | default "" -}}
22
{{- $title := .Get 1 | default (.Get "title") | default "" -}}
33
{{ partial "callout.html" (dict
4-
"class" $type
4+
"class" (printf "%s %s" $type "call-out")
55
"title" $title
66
"icon" "fa-solid fa-triangle-exclamation"
7-
"inline" true
7+
"sideline" true
8+
"type" ($type | strings.FirstUpper)
89
"content" .Inner
910
) }}

layouts/shortcodes/before-you-begin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"class" "tip"
33
"title" "Before you begin:"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}
88
{{ warnf "'<before-you-begin></before-you-begin>' is being deprecated. Use generic 'call-out' shortcode instead."}}

layouts/shortcodes/call-out.html

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{{/*
22

33
Usage:
4-
{{<call-out title="Custom title" icon="fa fa-check-circle" inline="true">}}
5-
This callout uses the icon check-circle. **This should be an inline callout.**
4+
{{<call-out title="Custom title" icon="fa fa-check-circle" sideline="true">}}
5+
This callout uses the icon check-circle. **This should be an sideline callout.**
66
{{</call-out>}}
77

88
Backwards compatibility usage:
99
{{<call-out "warning" "Custom title" "fa fa-check-circle" "true">}}
10-
This callout uses the icon check-circle. **This should be an inline callout.**
10+
This callout uses the icon check-circle. **This should be an sideline callout.**
1111
{{</call-out>}}
1212

1313
Depends on `callout.html` partial.
@@ -19,27 +19,16 @@
1919
{{ $icon := .Get 2 | default (.Get "icon") | default "" }}
2020

2121
{{/* Handle different versions of booleans */}}
22-
{{ $inlineParam := (.Get 3) | default (.Get "inline") | default "false" | lower }}
22+
{{ $sidelineParam := (.Get 3) | default (.Get "sideline") | default "false" | lower }}
2323
{{- /* Validate the parameter strictly */ -}}
24-
{{ if not (in (slice "true" "false") $inlineParam) }}
25-
{{ warnf "The '<call-out>' Shortcode parameter 'inline' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $inlineParam}}
26-
{{ end }}
27-
28-
{{ $inline := eq $inlineParam "true" }}
29-
30-
{{ $sideOption := "side-callout" }}
31-
{{ $inlineOption := "inline-callout" }}
32-
33-
{{ if $inline }}
34-
{{ $class = printf "%s %s" $class $inlineOption }}
35-
{{ else }}
36-
{{ $class = printf "%s %s" $class $sideOption }}
24+
{{ if not (in (slice "true" "false") $sidelineParam) }}
25+
{{ warnf "The '<call-out>' Shortcode parameter 'sideline' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $sidelineParam}}
3726
{{ end }}
3827

3928
{{ partial "callout.html" (dict
40-
"class" $class
29+
"class" (printf "%s %s" $class "call-out")
4130
"title" $title
4231
"icon" $icon
43-
"inline" $inline
32+
"sideline" $sidelineParam
4433
"content" .Inner
4534
) }}

layouts/shortcodes/caution.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"class" "caution call-out"
33
"title" "Caution"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}

layouts/shortcodes/deprecated.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"class" "warning call-out"
33
"title" "Deprecated"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}

layouts/shortcodes/important.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"class" "important call-out"
33
"title" "Important"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}

layouts/shortcodes/note.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"class" "note"
33
"title" "Note:"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}
88
{{ warnf "'<note></note>' is being deprecated. Use generic 'call-out' shortcode instead."}}

layouts/shortcodes/see-also.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"class" "tip"
33
"title" "See Also:"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}
88
{{ warnf "'<see-also></see-also>' is being deprecated. Use generic 'call-out' shortcode instead."}}

layouts/shortcodes/tip.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"class" "tip"
33
"title" "Tip:"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}
88
{{ warnf "'<tip></tip>' is being deprecated. Use generic 'call-out' shortcode instead."}}

layouts/shortcodes/warning.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"class" "warning call-out"
33
"title" "Warning"
44
"icon" ""
5-
"inline" "false"
5+
"sideline" "false"
66
"content" .Inner
77
) }}

0 commit comments

Comments
 (0)