Procházet zdrojové kódy

Allow changing max columns on split columns widget

Svilen Markov před 8 měsíci
rodič
revize
c3c7f8b14f

+ 1 - 0
docs/configuration.md

@@ -948,6 +948,7 @@ Example:
 ```
 ```
 
 
 ### Split Column
 ### Split Column
+<!-- TODO: update -->
 Splits a full sized column in half, allowing you to place widgets side by side. This is converted to a single column on mobile devices or if not enough width is available. Widgets are defined using a `widgets` property exactly as you would on a page column.
 Splits a full sized column in half, allowing you to place widgets side by side. This is converted to a single column on mobile devices or if not enough width is available. Widgets are defined using a `widgets` property exactly as you would on a page column.
 
 
 Example of a full page with an effective 4 column layout using two split column widgets inside of two full sized columns:
 Example of a full page with an effective 4 column layout using two split column widgets inside of two full sized columns:

+ 1 - 1
internal/assets/templates/split-column.html

@@ -3,7 +3,7 @@
 {{ define "widget-content-classes" }}widget-content-frameless{{ end }}
 {{ define "widget-content-classes" }}widget-content-frameless{{ end }}
 
 
 {{ define "widget-content" }}
 {{ define "widget-content" }}
-<div class="masonry" data-max-columns="2">
+<div class="masonry" data-max-columns="{{ .MaxColumns }}">
 {{ range .Widgets }}
 {{ range .Widgets }}
     {{ .Render }}
     {{ .Render }}
 {{ end }}
 {{ end }}

+ 5 - 0
internal/widget/split-column.go

@@ -11,6 +11,7 @@ import (
 type SplitColumn struct {
 type SplitColumn struct {
 	widgetBase          `yaml:",inline"`
 	widgetBase          `yaml:",inline"`
 	containerWidgetBase `yaml:",inline"`
 	containerWidgetBase `yaml:",inline"`
+	MaxColumns          int `yaml:"max-columns"`
 }
 }
 
 
 func (widget *SplitColumn) Initialize() error {
 func (widget *SplitColumn) Initialize() error {
@@ -22,6 +23,10 @@ func (widget *SplitColumn) Initialize() error {
 		}
 		}
 	}
 	}
 
 
+	if widget.MaxColumns < 2 {
+		widget.MaxColumns = 2
+	}
+
 	return nil
 	return nil
 }
 }