-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathgrid.html
More file actions
39 lines (39 loc) · 1.6 KB
/
grid.html
File metadata and controls
39 lines (39 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{{- $outline := default "false" .outline -}}
{{- $columns := default "auto" .columns -}}
{{- $gutter := default "2" .gutter -}}
{{- $items := .items -}}
{{- if eq $outline "true" -}}
{{- $outline = "sd-border-1" -}}
{{- end -}}
<div class="sd-container-fluid sd-mb-4 {{ $outline | safeHTMLAttr }}">
{{- if eq $columns "auto"}}
<div class="sd-row sd-row-cols-auto sd-row-cols-xs-auto sd-row-cols-sm-auto sd-row-cols-md-auto sd-row-cols-lg-auto">
{{- else }}
{{- $columns := split $columns " " }}
{{- $xs := index $columns 0 }}
{{- $sm := index $columns 1 }}
{{- $md := index $columns 2 }}
{{- $lg := index $columns 3 }}
{{- $gutterParts := split $gutter " " -}}
{{- $gXs := index $gutterParts 0 -}}
{{- $gSm := $gXs -}}
{{- $gMd := $gXs -}}
{{- $gLg := $gXs -}}
{{- if and (gt (len $gutterParts) 1) (ne (len $gutterParts) 4) -}}
{{- errorf "grid gutter must be either 1 or 4 values (but got %d): %q" (len $gutterParts) $gutter -}}
{{- else if eq (len $gutterParts) 4 -}}
{{- $gSm = index $gutterParts 1 -}}
{{- $gMd = index $gutterParts 2 -}}
{{- $gLg = index $gutterParts 3 -}}
{{- end -}}
<div class="sd-row sd-row-cols-{{ $xs }} sd-row-cols-xs-{{ $xs }} sd-row-cols-sm-{{ $sm }} sd-row-cols-md-{{ $md }} sd-row-cols-lg-{{ $lg }} sd-g-{{ $gXs }} sd-g-xs-{{ $gXs }} sd-g-sm-{{ $gSm }} sd-g-md-{{ $gMd }} sd-g-lg-{{ $gLg }}">
{{- end }}
{{- range $key, $item := $items -}}
{{- if eq $item.type "card" }}
{{- partial "_elements/card.html" (dict "grid_item_card" true "card" $item) -}}
{{- else }}
{{- partial "_elements/item.html" $item -}}
{{- end }}
{{- end }}
</div>
</div>