From a1bb569df5da58334d51942ca933b24ee904f205 Mon Sep 17 00:00:00 2001 From: Derek Severin Date: Wed, 2 Feb 2022 15:24:29 +0700 Subject: Fit rows + max projects params --- layouts/partials/project-image.html | 35 +++++++++++++++++++++++---------- layouts/partials/sections/projects.html | 15 ++++++++++++-- static/css/theme.css | 16 +++++++++++++++ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/layouts/partials/project-image.html b/layouts/partials/project-image.html index 9995503..d0d7a1e 100644 --- a/layouts/partials/project-image.html +++ b/layouts/partials/project-image.html @@ -1,22 +1,37 @@ {{/* Get the number of columns from config */}} -{{ $col_lg := "col-lg-2" }} -{{ $col_sm := "col-sm-3" }} -{{ $col_xs := "col-xs-6" }} +{{ $nb_col_lg := 6 }} +{{ $nb_col_sm := 4 }} +{{ $nb_col_xs := 2 }} {{ with .data }} {{ with .nb_columns }} - {{ $nb_cols := div 12 (int .) }} - {{ $col_lg = print "col-lg-" $nb_cols }} + {{ $nb_col_lg = int . }} {{ end }} {{ with .nb_columns_small }} - {{ $nb_cols := div 12 (int .) }} - {{ $col_sm = print "col-sm-" $nb_cols }} + {{ $nb_col_sm = int . }} {{ end }} {{ with .nb_columns_xsmall }} - {{ $nb_cols := div 12 (int .) }} - {{ $col_xs = print "col-xs-" $nb_cols }} + {{ $nb_col_xs = int . }} {{ end }} {{ end }} -{{ $class := print $col_lg " " $col_sm " " $col_xs }} +{{ $col_lg := print "col-lg-" (div 12 (int $nb_col_lg)) }} +{{ $col_sm := print "col-sm-" (div 12 (int $nb_col_sm)) }} +{{ $col_xs := print "col-xs-" (div 12 (int $nb_col_xs)) }} +{{ $class_hide := "" }} +{{ if .fit }} + {{ $nb_rows := int (div .nb $nb_col_lg) }} + {{ if and (ge .nb $nb_col_lg) (gt .index (mul $nb_rows $nb_col_lg)) }} + {{ $class_hide = print $class_hide " hide_lg" }} + {{ end }} + {{ $nb_rows = int (div .nb $nb_col_sm) }} + {{ if and (ge .nb $nb_col_sm) (gt .index (mul $nb_rows $nb_col_sm)) }} + {{ $class_hide = print $class_hide " hide_sm" }} + {{ end }} + {{ $nb_rows = int (div .nb $nb_col_xs) }} + {{ if and (ge .nb $nb_col_xs) (gt .index (mul $nb_rows $nb_col_xs)) }} + {{ $class_hide = print $class_hide " hide_xs" }} + {{ end }} +{{ end }} +{{ $class := print $col_lg " " $col_sm " " $col_xs $class_hide }}
{{ $path := replace .context.File.Dir "\\" "/" }} diff --git a/layouts/partials/sections/projects.html b/layouts/partials/sections/projects.html index e619fd9..d3c410d 100644 --- a/layouts/partials/sections/projects.html +++ b/layouts/partials/sections/projects.html @@ -11,11 +11,22 @@ {{ if .Sections }} {{/* Sort the list */}} {{ partial "utils/ordered-list.html" (dict "list" .Sections "params" .Params "scratch" .Scratch) }} - {{ range (.Scratch.Get "list") }} - {{ partial "project-image.html" (dict "context" . "data" $params.home) }} + {{ $projects := .Scratch.Get "list" }} + {{ $max := len $projects }} + {{ if and $params.max_projects (lt $params.max_projects $max) }} + {{ $max = $params.max_projects }} + {{ end }} + {{ range seq $max }} + {{ $project := index $projects (sub . 1) }} + {{ partial "project-image.html" (dict "context" $project "data" $params.home "fit" $params.fit_rows "nb" $max "index" .) }} {{ end }} {{ .Scratch.Delete "list" }} {{ end }}
+
+ + More ... + +
diff --git a/static/css/theme.css b/static/css/theme.css index bef760c..59902bc 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -1173,6 +1173,22 @@ min-height: 300px; width: 100%; } +@media (max-width:768px) { + .hide_xs { + display: none; + } +} +@media (min-width:768px) and (max-width:1200px) { + .hide_sm { + display: none; + } +} +@media (min-width:1200px) { + .hide_lg { + display: none; + } +} + .projects-link .row { margin: 0px; } -- cgit v1.2.3