core

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2022 License: MIT Imports: 13 Imported by: 3

README

Go Reference GitHub go.mod Go version GitHub release (latest by date) Go Report Card Actions Status

HomeDashboard Renderer Core Components

Contains core components and basic renderers for HomeDashboard UIs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSource

type DataSource interface {

	// Latest willreturn latest element for given datasource.
	Latest(core.DataSource) (proto.Message, error)

	// All returns a list of available events for passed datasource.
	All(core.DataSource) ([]proto.Message, error)

	// Observe returns a channels to listen for new events.
	// You can pass a filter to listen for events from specific datasource, only.
	// Datasource will not block if channel capacity is reached. Events will be skipped!
	Observe(*[]core.DataSource) <-chan proto.Message
}

DataSource is used to get data for templates.

type FileTemplate

type FileTemplate struct {
	// contains filtered or unexported fields
}

FileTemplate used to generate content based on file templates.

func (*FileTemplate) RenderWith

func (fileTemplate *FileTemplate) RenderWith(data interface{}) (string, error)

type Point

type Point struct {
	X, Y int
}

Point is used to define a position based on y/> coordinates.

type Renderer added in v1.0.1

type Renderer interface {

	// Size returns height and width a rendered element uses.
	Size() Size

	// Content returns rendered elements.
	Content() (string, error)

	// ObserveDataSource will start listen for new events provided by used datasource to get updated data for rendering.
	// Uses passed context to wait for cancelations.
	ObserveDataSource(context.Context)
}

Renderer generates content based on templates and event data.

type Size

type Size struct {
	Height, Width int
}

Size a canvas uses in a template.

type Spacing added in v1.0.3

type Spacing struct {
	Top, Right, Bottom, Left int
}

Spacing defines top, left right and bottom distance to other elements.

type Template

type Template interface {

	// Render generated content based on a template with given values.
	RenderWith(interface{}) (string, error)
}

Template renders content.

func NewFileTemplate

func NewFileTemplate(filename string) Template

NewFileTemplate returns a new template for given file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL