|
9 | 9 | https://github.com/CloudCannon/bookshop/blob/main/guides/hugo.adoc#passing-data-to-bookshop-components |
10 | 10 | */}} |
11 | 11 |
|
12 | | -{{ define "_partials/inline/testimonial-carousel.html" }} |
13 | | - {{ $carousel := .carousel }} |
14 | | - {{ $testimonials := .testimonials }} |
15 | | - {{ $card := .card }} |
16 | | - {{ $padding := .padding }} |
17 | | - {{ $colGrid := .colGrid }} |
18 | | - {{ $iconStyle := index . "icon-style" }} |
19 | | - |
20 | | - {{ if and $carousel (gt (len $testimonials) 1) }} |
21 | | - {{ $id := printf "testimonial-carousel-%s" (md5 (delimit (slice . now) "-")) }} |
22 | | - <div id="{{ $id }}" class="carousel slide"> |
23 | | - <div class="carousel-indicators"> |
24 | | - {{ range $index, $item := $testimonials }} |
25 | | - <button type="button" |
26 | | - data-bs-target="#{{ $id }}" |
27 | | - data-bs-slide-to="{{ $index }}" |
28 | | - {{ if eq $index 0 }}class="active" aria-current="true"{{ end }} |
29 | | - aria-label="Slide 1"> |
30 | | - </button> |
31 | | - {{ end }} |
32 | | - </div> |
33 | | - <div class="carousel-inner"> |
34 | | - {{ range $index, $item := $testimonials }} |
35 | | - <div class="carousel-item{{ if eq $index 0 }} active{{ end }}"> |
36 | | - {{ $cardStyle := partial "utilities/GetBackgroundStyle" (dict "background" $card) }} |
37 | | - {{ $cardStyle = print $cardStyle " testimonial-carousel-item" }} |
38 | | - |
39 | | - {{ partial "assets/testimonial.html" (dict |
40 | | - "page" page |
41 | | - "content" $item.content |
42 | | - "logo" $item.logo |
43 | | - "icon" $item.icon |
44 | | - "icon-style" $iconStyle |
45 | | - "scale" $item.scale |
46 | | - "contact" (cond ($item.client | not | not) $item.client.contact "") |
47 | | - "role" (cond ($item.client | not | not) $item.client.role "") |
48 | | - "image" (cond ($item.client | not | not) $item.client.image "") |
49 | | - "url" (cond ($item.client | not | not) $item.client.url "") |
50 | | - "link" $item.link |
51 | | - "show-controls" true |
52 | | - "padding" $padding.x |
53 | | - "class" $cardStyle |
54 | | - )}} |
55 | | - </div> |
56 | | - {{ end}} |
57 | | - </div> |
58 | | - <button class="carousel-control-prev" type="button" data-bs-target="#{{ $id }}" data-bs-slide="prev"> |
59 | | - {{ partial "assets/icon.html" (dict "icon" "fas chevron-left fa-2xl") }} |
60 | | - <span class="visually-hidden">{{ T "testimonialPrevious" }}</span> |
61 | | - </button> |
62 | | - <button class="carousel-control-next" type="button" data-bs-target="#{{ $id }}" data-bs-slide="next"> |
63 | | - {{ partial "assets/icon.html" (dict "icon" "fas chevron-right fa-2xl") }} |
64 | | - <span class="visually-hidden">{{ T "testimonialNext" }}</span> |
65 | | - </button> |
66 | | - </div> |
67 | | - {{ else }} |
68 | | - <div class="testimonial-grid container p-0"> |
69 | | - <div class="row {{ $colGrid }} g-3"> |
70 | | - {{ range $testimonials }} |
71 | | - <div class="col"> |
72 | | - {{ partial "assets/testimonial.html" (dict |
73 | | - "page" page |
74 | | - "content" .content |
75 | | - "logo" .logo |
76 | | - "icon" .icon |
77 | | - "icon-style" $iconStyle |
78 | | - "scale" .scale |
79 | | - "contact" (cond (.client | not | not) .client.contact "") |
80 | | - "role" (cond (.client | not | not) .client.role "") |
81 | | - "image" (cond (.client | not | not) .client.image "") |
82 | | - "url" (cond (.client | not | not) .client.url "") |
83 | | - "link" .link |
84 | | - "padding" $padding.x |
85 | | - "class" (partial "utilities/GetBackgroundStyle" (dict "background" $card)) |
86 | | - )}} |
87 | | - </div> |
88 | | - {{ end}} |
89 | | - </div> |
90 | | - </div> |
91 | | - {{ end }} |
92 | | -{{ end }} |
93 | | - |
94 | | -{{/* Initialize global arguments */}} |
95 | | -{{- $style := partial "utilities/GetBackgroundStyle" (dict "background" .background) -}} |
96 | | -{{- $breakpoint := partial "utilities/GetBreakpoint.html" -}} |
97 | | -{{- $padding := partial "utilities/GetPadding.html" -}} |
98 | | - |
99 | 12 | {{/* Main code */}} |
100 | | -{{ $colGrid := printf "row-cols-%d" (.cols | default 1) }} |
101 | | -{{- if eq .cols 1 }} |
102 | | - {{ $colGrid = "row-cols-1" -}} |
103 | | -{{- else if eq .cols 2 }} |
104 | | - {{ $colGrid = printf "row-cols-1 row-cols-%s-2" $breakpoint.next }} |
105 | | -{{- else if eq .cols 3 }} |
106 | | - {{ $colGrid = printf "row-cols-1 row-cols-%s-3" $breakpoint.next }} |
107 | | -{{- else if eq .cols 4 }} |
108 | | - {{ $colGrid = printf "row-cols-1 row-cols-%s-2 row-cols-%s-4" $breakpoint.current $breakpoint.next }} |
109 | | -{{- else if eq .cols 5 }} |
110 | | - {{ $colGrid = printf "row-cols-1 row-cols-%s-3 row-cols-%s-5" $breakpoint.current $breakpoint.next }} |
111 | | -{{ end -}} |
112 | | - |
113 | | -{{ $raw := partial "inline/testimonial-carousel.html" (dict |
| 13 | +{{ $raw := partial "assets/testimonial-carousel.html" (dict |
114 | 14 | "carousel" .carousel |
115 | 15 | "testimonials" .testimonials |
116 | 16 | "card" .card |
117 | | - "padding" .padding |
118 | | - "colGrid" $colGrid |
| 17 | + "cols" .cols |
119 | 18 | "icon-style" (or .icon_style (index . "icon-style")) |
120 | 19 | ) }} |
121 | 20 |
|
|
0 commit comments