Package grid

import "gitlab.com/zoralab/bissetii/pkg/components/internal/grid"

Package grid is for rendering the grid component with various controls.

The HTML template codes are written in Go’s string format under the corresponding group. This allows one to embed the HTML codes instead of parsing it from file.

Constants

All Bissetii Compressed Compiled CSS

const (
	CSSAMP = `.row{display:flex;width:var(--grid-width);justify-content:var(--grid-justify-content);align-items:var(--grid-align-items);flex-wrap:var(--grid-flex-wrap)}.row.align-top{--grid-align-items:flex-start}.row.align-middle{--grid-align-items:center}.row.align-bottom{--grid-align-items:bottom}.row.align-baseline{--grid-align-items:baseline}.row .column{display:var(--grid-column-display);max-width:var(--grid-column-max-width);margin:var(--grid-column-margin);padding:var(--grid-column-padding);visibility:var(--grid-column-visibility);flex-grow:calc(var(--grid-column-base) * 					var(--grid-column-multiplier));flex-basis:var(--grid-column-flex-basis)}.row .column.offset{--grid-column-visibility:hidden}.row .column.grid-2x{--grid-column-multiplier:2}.row .column.grid-3x{--grid-column-multiplier:3}.row .column.grid-4x{--grid-column-multiplier:4}.row .column.grid-5x{--grid-column-multiplier:5}.row .column.grid-6x{--grid-column-multiplier:6}.row .column.grid-7x{--grid-column-multiplier:7}.row .column.grid-8x{--grid-column-multiplier:8}.row .column.grid-9x{--grid-column-multiplier:9}.row .column.grid-10x{--grid-column-multiplier:10}`

	CSSCritical = `.row{display:flex;width:var(--grid-width);justify-content:var(--grid-justify-content);align-items:var(--grid-align-items);flex-wrap:var(--grid-flex-wrap)}.row.align-top{--grid-align-items:flex-start}.row.align-middle{--grid-align-items:center}.row.align-bottom{--grid-align-items:bottom}.row.align-baseline{--grid-align-items:baseline}.row .column{display:var(--grid-column-display);max-width:var(--grid-column-max-width);margin:var(--grid-column-margin);padding:var(--grid-column-padding);visibility:var(--grid-column-visibility);flex-grow:calc(var(--grid-column-base) * 					var(--grid-column-multiplier));flex-basis:var(--grid-column-flex-basis)}.row .column.offset{--grid-column-visibility:hidden}.row .column.grid-2x{--grid-column-multiplier:2}.row .column.grid-3x{--grid-column-multiplier:3}.row .column.grid-4x{--grid-column-multiplier:4}.row .column.grid-5x{--grid-column-multiplier:5}.row .column.grid-6x{--grid-column-multiplier:6}.row .column.grid-7x{--grid-column-multiplier:7}.row .column.grid-8x{--grid-column-multiplier:8}.row .column.grid-9x{--grid-column-multiplier:9}.row .column.grid-10x{--grid-column-multiplier:10}`

	CSSTablet = ``

	CSSDesktop = ``

	CSSWidescreen = ``

	CSSPrint = `.row{break-inside:avoid}`

	CSSVariables    = ``

	CSSVariablesAMP = ``
)

Constants for managing the package as a whole.

const (
	// Name is the block name (`{{- define "this-name" -}}`).
	Name = "grid"

	// AMPName is the AMP HTML block name.
	AMPName = internal.AMPPrefix + Name

	// ParametersComment are the list of comment headers
	// describing inputs.
	ParametersComment = `
{{- /* .Type              = Grid sub-component ('row' or 'column')    */ -}}
{{- /* .Class             = Grid class attribute                      */ -}}
{{- /* .Style             = Grid style attribute                      */ -}}
{{- /* .ID                = Grid id attribute                         */ -}}
{{- /* .Content           = HTML format content for the sub-component */ -}}
`
)

Dependencies are the dependent codes for building independent template.

This is useful for rendering portable template usage like Hugo partials where they do not share a common definition source.

const (
	// DepHTML is the vanilla HTML output type.
	DepHTML = ``

	// DepAMPHTML is the Accelerated Mobile Pages HTML output
	// type.
	DepAMPHTML = ``
)

Full HTML codes for rendering templates without needing to parse file.

const (
	// HTML is the vanilla HTML output type.
	HTML = `
{{- if eq .Type "row" -}}

	<div {{ if .ID -}}id="{{- .ID -}}" {{ end -}}

	class="row{{- if .Class }} {{ .Class -}}{{- end -}}"

	{{- if .Style }} style="{{- .Style -}}"{{- end -}}

	>

		{{ .Content }}

	</div>
{{- else if eq .Type "column" -}}

	<div {{ if .ID -}}id="{{- .ID -}}" {{ end -}}

	class="column{{- if .Class }} {{ .Class -}}{{- end -}}"

	{{- if .Style }} style="{{- .Style -}}"{{- end -}}

	>

		{{ .Content }}

	</div>
{{- end -}}
`

	// AMPHTML is the Accelerated Mobile Pages HTML output type.
	AMPHTML = `
{{- if eq .Type "row" -}}

	<div {{ if .ID -}}id="{{- .ID -}}" {{ end -}}

	class="row{{- if .Class }} {{ .Class -}}{{- end -}}"

	{{- if .Style }} style="{{- .Style -}}"{{- end -}}

	>

		{{ .Content }}

	</div>
{{- else if eq .Type "column" -}}

	<div {{ if .ID -}}id="{{- .ID -}}" {{ end -}}

	class="column{{- if .Class }} {{ .Class -}}{{- end -}}"

	{{- if .Style }} style="{{- .Style -}}"{{- end -}}

	>

		{{ .Content }}

	</div>
{{- end -}}
`
)

Data

type Data struct {
	Type    string
	Class   string
	Style   string
	ID      string
	Content string
}

Data is the data structure for rendering the component.