Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/2-REC/hugo-myportfolio-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Severin <severinderek@gmail.com>2022-02-02 11:24:29 +0300
committerDerek Severin <severinderek@gmail.com>2022-02-02 11:24:29 +0300
commita1bb569df5da58334d51942ca933b24ee904f205 (patch)
tree574bfc7a8703993f4a2149fe242dbe5c95becc57
parent6d8abb4751337c99192cdbfeea00f399be05eb6d (diff)
Fit rows + max projects params
-rw-r--r--layouts/partials/project-image.html35
-rw-r--r--layouts/partials/sections/projects.html15
-rw-r--r--static/css/theme.css16
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 }}
<div class="{{ $class }}">
{{ $path := replace .context.File.Dir "\\" "/" }}
<a href="/{{ $path }}" class="project-box project-link">
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 }}
</div>
+ <div class="row no-gutter" style="text-align: center;">
+ <a href="/{{ $path }}" >
+ More ...
+ </a>
+ </div>
</div>
</section>
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;
}