components

package
v0.3.23 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Overview

templ: version: v0.3.865

templ: version: v0.3.865

Package components provides shared components for templ templates.

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

templ: version: v0.3.865

Index

Constants

This section is empty.

Variables

View Source
var DaisyThemes = []string{
	"light",
	"dark",
	"cupcake",
	"bumblebee",
	"emerald",
	"corporate",
	"synthwave",
	"retro",
	"cyberpunk",
	"valentine",
	"halloween",
	"garden",
	"forest",
	"aqua",
	"lofi",
	"pastel",
	"fantasy",
	"wireframe",
	"black",
	"luxury",
	"dracula",
	"cmyk",
	"autumn",
	"business",
	"acid",
	"lemonade",
	"night",
	"coffee",
	"winter",
	"dim",
	"nord",
	"sunset",
	"caramellatte",
	"abyss",
	"silk",
}

Functions

func Ago added in v0.3.16

func Ago(t time.Time) templ.Component

func AssetPath

func AssetPath(ctx context.Context, path string) (string, error)

func Authenticated

func Authenticated(ctx context.Context) bool

func BareLayout

func BareLayout(props BareLayoutProps) templ.Component
func BlockLink(path templ.SafeURL) string
func Cookie(ctx context.Context, name string) string

func CopyableContent

func CopyableContent() templ.Component

func CurrentPath

func CurrentPath(ctx context.Context) string

func CurrentURL

func CurrentURL(ctx context.Context) string

func CurrentURLWithoutQuery

func CurrentURLWithoutQuery(ctx context.Context) string

func CurrentUsername

func CurrentUsername(ctx context.Context) (string, error)

func DeleteButton

func DeleteButton() templ.Component

func EditButton added in v0.3.17

func EditButton() templ.Component

func ExternalIcon added in v0.3.18

func ExternalIcon() templ.Component

func Filter added in v0.3.20

func Filter[T ~string](props FilterProps[T]) templ.Component

func Flashes

func Flashes() templ.Component

func GithubIcon added in v0.3.19

func GithubIcon() templ.Component

func GitlabIcon added in v0.3.19

func GitlabIcon() templ.Component

func Identifier

func Identifier(id resource.TfeID) templ.Component

func IsOwner

func IsOwner(ctx context.Context, organization resource.ID) bool

func IsSiteAdmin

func IsSiteAdmin(ctx context.Context) bool

func Layout

func Layout(props LayoutProps) templ.Component
func MenuItem(title string, path templ.SafeURL, matchPrefixes ...string) templ.Component

func SearchDropdown

func SearchDropdown(props SearchDropdownProps) templ.Component

func SetAllowedOrigins added in v0.3.22

func SetAllowedOrigins(origins string)

SetAllowedOrigins sets the allowed origins for inbound websocket connections. If origins is empty, all origins are allowed. Otherwise origins is expected to be a comma separated list of origins and if the origin on an inbound websocket connection does not match one of those origins then the connection is rejected.

func Strikethrough

func Strikethrough(cond bool) templ.Component

func Table added in v0.3.16

func Table[T any](populator TablePopulator[T], page *resource.Page[T], id string) templ.Component

func TokenFlashMessage

func TokenFlashMessage(w gohttp.ResponseWriter, token []byte) error

TokenFlashMessage is a helper for rendering a flash message with an authentication token.

func UnpaginatedTable added in v0.3.17

func UnpaginatedTable[T any](populator TablePopulator[T], resources []T, id string) templ.Component

Types

type BareLayoutProps

type BareLayoutProps struct {
	Title        string
	Organization resource.ID
	Menu         templ.Component
	PreContent   templ.Component
	PostContent  templ.Component
}
type Breadcrumb struct {
	Name string
	Link templ.SafeURL
}
type DropDownUIWidth string
const (
	NarrowDropDown DropDownUIWidth = "narrow"
	WideDropDown   DropDownUIWidth = "wide"
)

type FilterProps added in v0.3.20

type FilterProps[T ~string] struct {
	Title            string
	All              []T
	Selected         []T
	ParamName        string
	Visible          bool
	VisibleParamName string
	Label            func(T) templ.Component
	CheckboxClass    func(T) string
}

type LayoutProps

type LayoutProps struct {
	Title          string
	Organization   resource.ID
	Breadcrumbs    []Breadcrumb
	ContentActions templ.Component
	ContentLinks   templ.Component
	ContentMenu    templ.Component
	PreContent     templ.Component
	PostContent    templ.Component
	Menu           templ.Component
}

type SearchDropdownProps

type SearchDropdownProps struct {
	// Name to send along with value in the POST form
	Name string
	// Existing values to NOT show in the dropdown
	Existing []string
	// Available values to show in the dropdown
	Available []string
	// Action is the form action URL
	Action templ.SafeURL
	// Placeholder to show in the input element.
	Placeholder string
	// Width: "narrow" or "wide"
	Width DropDownUIWidth
}

type TablePopulator added in v0.3.16

type TablePopulator[T any] interface {
	Header() templ.Component
	Row(T) templ.Component
}

TablePopulator populates a table component with resources of type T.

type Websocket added in v0.3.23

type Websocket[Resource any] struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

Websocket is an inbound websocket connection, on which snippets of HTML are sent from the server to the client.

func NewWebsocket added in v0.3.23

func NewWebsocket[Resource any](
	logger logr.Logger,
	w http.ResponseWriter,
	r *http.Request,
	client websocketClient[Resource],
	component func(Resource) templ.Component,
) (*Websocket[Resource], error)

func (*Websocket[Resource]) Send added in v0.3.23

func (s *Websocket[Resource]) Send(id resource.TfeID) bool

Send an HTML fragment to the client rendered from a template populated with a resource corresponding to the given id. True is returned if it succeeded, otherwise it returns false, in which case the connection should be closed.

type WebsocketListHandler added in v0.3.15

type WebsocketListHandler[Resource, ResourceEvent, Options any] struct {
	logr.Logger
	Client    websocketListHandlerClient[Resource, ResourceEvent, Options]
	Populator TablePopulator[Resource]
	ID        string
}

WebsocketListHandler handles dynamically updating lists of resources via a websocket.

func (*WebsocketListHandler[Resource, ResourceEvent, Options]) Handler added in v0.3.15

func (h *WebsocketListHandler[Resource, ResourceEvent, Options]) Handler(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
Package paths are paths for use in templ templates.
Package paths are paths for use in templ templates.

Jump to

Keyboard shortcuts

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