Package image

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

Package image is the full package for rendering all compatible image tags.

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 = `amp-img{max-width:var(--max-width-image);height:var(--height-image)}`

	CSSCritical = `img{max-width:var(--max-width-image);height:var(--height-image)}`

	CSSTablet     = ``

	CSSDesktop    = ``

	CSSWidescreen = ``

	CSSPrint      = ``
)

Constants for managing the package as a whole.

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

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

	// ParametersComment are the list of comment headers
	// describing inputs.
	ParametersComment = `
{{- /* .AltText           = the image alternate text                 */ -}}
{{- /* .SourceURL         = the image source URL                     */ -}}
{{- /* .Width             = explicit width setting                   */ -}}
{{- /* .Height            = explicit height setting                  */ -}}
{{- /* .SourceSet         = srcset in a single string                */ -}}
{{- /* .IsMap             = image is url mapped. either "true" or "" */ -}}
{{- /* .LoadingMode       = loading mode                             */ -}}
{{- /* .Layout            = AMP specific layout                      */ -}}
{{- /* .Class             = class tags                               */ -}}
{{- /* .Caption           = image caption                            */ -}}
`
)

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

const (
	// HTML is the vanilla HTML output type.
	HTML = `
{{- if .Caption }}<figure>{{- end }}
<img alt="{{- .AltText -}}"

	src="{{- .SourceURL -}}"
{{- if .Class }}

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

	width="{{- .Width -}}"
{{- end -}}
{{- if .Height }}

	height="{{- .Height -}}"
{{- end -}}
{{- if .SourceSet }}

	srcset="{{- .SourceSet -}}"
{{- end -}}
{{- if eq .IsMap "true" }}

	ismap
{{- end -}}
{{- if .LoadingMode }}

	loading="{{- .LoadingMode -}}"
{{- end -}}
/>

{{- if .Caption }}
<figcaption>{{- .Caption -}}</figcaption>
</figure>
{{- end }}
`

	// AMPHTML is the Accelerated Mobile Pages HTML output type.
	AMPHTML = `
{{- if .Caption }}<figure>{{- end }}
<amp-img alt="{{- .AltText -}}"

	src="{{- .SourceURL -}}"
{{- if .Class }}

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

	width="{{- .Width -}}"
{{- end -}}
{{- if .Height }}

	height="{{- .Height -}}"
{{- end -}}
{{- if .SourceSet }}

	srcset="{{- .SourceSet -}}"
{{- end -}}
{{- if .Layout }}

	layout="{{- .Layout -}}"
{{- end -}}
></amp-img>
{{- if .Caption }}
<figcaption>{{- .Caption -}}</figcaption>
</figure>
{{- end }}
`
)

Data

type Data struct {
	AltText     string
	SourceURL   string
	Width       string
	Height      string
	SourceSet   string
	IsMap       string
	LoadingMode string
	Layout      string
	Class       string
	Caption     string
}

Data is the data structure for rendering the component.