Categorygithub.com/gowasm/vecty
modulepackage
0.0.1
Repository: https://github.com/gowasm/vecty.git
Documentation: pkg.go.dev

# README

Vecty is a React-like library for GopherJS so that you can do frontend development in Go instead of writing JavaScript/HTML/CSS.

Build Status GoDoc codecov

Features

  • Share frontend and backend code.
  • Write everything in Go -- not JS/HTML/CSS!
  • XSS protection: unsafe HTML must be explicitly denoted as such.
  • Reusability: share components by making Go packages that others can import!

Goals

  • Simplicity
    • Keep things as simple as possible to understand for newcomers.
    • Designed from the ground up to be easily mastered (like Go)!
  • Performance
    • As efficient as possible, make it clear what each operation in your webpage will do.
    • Same performance as just using plain JS/HTML/CSS.
  • Composability
    • Nest components to form your entire user interface, seperate them logically as you would any normal Go package.

Current Status

Vecty is currently considered to be an experimental work-in-progress.

  • APIs will change.
  • The scope of Vecty is only ~80% defined currently.
  • There are a number of important open issues.

For a list of projects currently using Vecty, see the doc/projects-using-vecty.md file.

Community

Changelog

See the doc/CHANGELOG.md file.

# Packages

Package elem defines markup to create DOM elements.
Package event defines markup to bind DOM events.
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddStylesheet adds an external stylesheet to the document.
Attribute returns an Applyer which applies the given attribute to an element.
Class returns an Applyer which applies the provided classes.
Data returns an Applyer which applies the given data attribute.
If returns nil if cond is false, otherwise it returns the given children.
Key returns an Applyer that uniquely identifies the HTML element amongst its siblings.
Markup wraps a list of Applyer which is individually applied to an HTML element or text node.
MarkupIf returns nil if cond is false, otherwise it returns the given markup.
Namespace is Applyer which sets the namespace URI to associate with the created element.
Property returns an Applyer which applies the given JavaScript property to an HTML element or text node.
RenderBody renders the given component as the document body.
Rerender causes the body of the given Component (i.e.
SetTitle sets the title of the document.
Style returns an Applyer which applies the given CSS style.
Tag returns an HTML element with the given tag name.
Text returns a TextNode with the given literal text.
UnsafeHTML is Applyer which unsafely sets the inner HTML of an HTML element.
Value Returns the js value of a type.

# Structs

Core implements the Context method of the Component interface, and is the core/central struct which all Component implementations should embed.
Event represents a DOM event.
EventListener is markup that specifies a callback function to be invoked when the named DOM event is fired.
HTML represents some form of HTML: an element with a specific tag, or some literal text (a TextNode).
KeyedList is produced by calling List.WithKey.
MarkupList represents a list of Applyer which is individually applied to an HTML element or text node.

# Interfaces

Applyer represents some type of markup (a style, property, data, etc) which can be applied to a given HTML element or text node.
Component represents a single visual component within an application.
ComponentOrHTML represents one of: Component *HTML List KeyedList nil An unexported method on this interface ensures at compile time that the underlying value must be one of these types.
Copier is an optional interface that a Component can implement in order to copy itself.
Keyer is an optional interface that a Component can implement in order to uniquely identify the component amongst its siblings.
MarkupOrChild represents one of: Component *HTML List KeyedList nil MarkupList An unexported method on this interface ensures at compile time that the underlying value must be one of these types.
Mounter is an optional interface that a Component can implement in order to receive component mount events.
RenderSkipper is an optional interface that Component's can implement in order to short-circuit the reconciliation of a Component's rendered body.
Unmounter is an optional interface that a Component can implement in order to receive component unmount events.

# Type aliases

ClassMap is markup that specifies classes to be applied to an element if their boolean value are true.
List represents a list of components or HTML.