viewer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package viewer provides a library to make rendering just your component a snap so that it is easy to view visual changes quickly without loading up an entire website. As the styles are contained within the component, this should allow changes to be tested locally instead of within context of a larger page.

Usage:

var (
	port = flag.Int("port", 8080, "The port to run the server on")
)

func main() {
	// Some test data to show.
	conf := &config.VideoFiles{
		&config.VideoFile{
			Index: 0,
			Name:  "Grand Tetons",
			URL:   "https://vimeo.com/19777306",
		},
	}

	// Create component with test data.
	nav, err := nav.New("nav-component", conf, nil)
	if err != nil {
		panic(err)
	}

	// Render it to 127.0.0.1:8080
	v := viewer.New(
		*port,
		nav,
		viewer.BackgroundColor("black"),
		viewer.ServeOtherFiles("../../../", []string{".css", ".jpg", ".svg", ".png"}),
	)

	v.Run()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(v *Viewer)

Option provides an optional argument to New().

func BackgroundColor

func BackgroundColor(color string) Option

BackgroundColor changes the default background color from white to the color passed. This helps for styles utilize white and can't be seen. Does not work if UseDoc() was passed as an option.

func ServeOtherFiles

func ServeOtherFiles(from string, exts []string) Option

ServeOtherFiles looks at path "from" and serves files below that directory with the extensions in "exts". Extensions should be like ".png" or ".css".

func UseDoc

func UseDoc(doc *html.Doc) Option

UseDoc says to use this custom doc object and add the *Gear as the last element in the doc's Body.Elements list.

type Viewer

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

Viewer provides an HTTP server that will run to view an individual component without having to spin up the entire page and service. This allows debugging a component individually.

func New

func New(port int, gear *component.Gear, options ...Option) *Viewer

New constructs a new Viewer.

func (*Viewer) Run

func (v *Viewer) Run()

Run runs the viewer and will block forever.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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