canvas

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

templ: version: v0.3.1001

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canvas

func Canvas(o Opts, g graph.Graph) templ.Component

Canvas is the viewport itself. Children render inside it as floating overlays (staging box, level-specific controls).

func Chrome

func Chrome(traffic bool) templ.Component

Chrome is everything the canvas needs outside the viewport: the detail drawer, the settings pane and the script that wires them. Render it once per page, after the viewport. traffic must match Opts.Traffic, the traffic toggle is hidden on levels that draw no traffic, where it would do nothing.

func ForwardFace

func ForwardFace(n graph.Node) templ.Component

ForwardFace is one live port-forward relay: who has a tunnel open (avatar badges, hover for name and server role) and on which port.

Exported because the status endpoint renders it too: these cards appear and vanish with their relay container, so the client patches them in between page loads. It asks the server for this markup rather than rebuilding it, the client-side copy this replaces drifted invisibly, since it only ran when a real tunnel was open.

func NodeFooter

func NodeFooter(n graph.Node) templ.Component

NodeFooter is a card's bottom strip: the one live line about the thing, its status light, its cron result, what it publishes. Exported because the status endpoint re-renders it on every poll: the client used to rebuild the status span and the cron line in JavaScript, a second vocabulary for the same words that nothing kept in step.

Types

type Opts

type Opts struct {
	SaveURL string // POST target for dragged positions
	WSRoom  string // live.js subscription; "" = no live updates
	CSRF    string
	Empty   string // empty-state line when the graph has no nodes
	// Traffic joins the global flow-sampler room so traffic lanes refresh on
	// every sample tick. Only levels that draw container traffic want it.
	Traffic bool
}

Opts parameterises one canvas. StatusURL is derived from SaveURL by the client (…/positions → …/status), so a level only has to name where drags go.

type StatusNode

type StatusNode struct {
	graph.Node
	HTML   string `json:"html,omitempty"`
	Class  string `json:"class,omitempty"`
	Height int    `json:"height,omitempty"`
	// Footer is the card's bottom strip re-rendered: the status light, a
	// cron's last result, the live forward count. The client swaps it in
	// whole rather than deciding what those should say.
	Footer string `json:"footer,omitempty"`
}

StatusNode is a node as the status endpoint reports it: the graph node plus, for the cards the client has to create itself, everything needed to build one, its markup, its wrapper class and its height.

func StatusNodes

func StatusNodes(ctx context.Context, nodes []graph.Node) []StatusNode

StatusNodes prepares a status payload's nodes. Only ephemeral ones carry markup: every other card already exists in the page, and the client just updates its status and position.

Jump to

Keyboard shortcuts

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