ui

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultItemsPerPage stores the default amount of items per page
	DefaultItemsPerPage = 20

	// PageQueryKey stores the query key used to indicate the current page
	PageQueryKey = "page"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthUserView

type AuthUserView struct {
	ID    int
	Name  string
	Email string
}

type Controller

type Controller struct {
	// Container stores a services container which contains dependencies
	Container *frameworkbootstrap.Container
}

Controller provides base functionality and dependencies to controllers. The proposed pattern is to embed a Controller in each individual route struct and to use the router to inject the container so your routes have access to the services within the container

func NewController

func NewController(c *frameworkbootstrap.Container) Controller

NewController creates a new Controller

func (*Controller) Fail

func (c *Controller) Fail(err error, log string) error

Fail is a helper to fail a request by returning a 500 error and logging the error

func (*Controller) Redirect

func (c *Controller) Redirect(ctx echo.Context, route string, routeParams ...any) error

Redirect redirects to a given route name with optional route parameters.

func (*Controller) RedirectWithDetails

func (c *Controller) RedirectWithDetails(ctx echo.Context, route string, queryParams string, statusCode int, routeParams ...any) error

Redirect redirects to a given route name with optional route parameters.

func (*Controller) RenderJSON

func (c *Controller) RenderJSON(ctx echo.Context, data interface{}) error

RenderJSON renders a JSON response

func (*Controller) RenderPage

func (c *Controller) RenderPage(ctx echo.Context, page Page) error

RenderPage renders a Page as an HTTP response

func (*Controller) RenderToHTMLBlob

func (c *Controller) RenderToHTMLBlob(ctx ctx.Context, page Page) (string, error)

RenderToHTMLBlob renders a page to HTML without returning any HTTP reponse, unlike RenderPage. It is meant to generate small blobs of HTML, for example for use in SSE events.

type FormSubmission

type FormSubmission struct {
	// IsSubmitted indicates if the form has been submitted
	IsSubmitted bool

	// Errors stores a slice of error message strings keyed by form struct field name
	Errors map[string][]string
}

FormSubmission represents the state of the submission of a form, not including the form itself

func (FormSubmission) FieldHasErrors

func (f FormSubmission) FieldHasErrors(fieldName string) bool

FieldHasErrors indicates if a given field on the form has any validation errors

func (FormSubmission) FormClass

func (f FormSubmission) FormClass() string

func (FormSubmission) GetFieldErrors

func (f FormSubmission) GetFieldErrors(fieldName string) []string

GetFieldErrors gets the errors for a given field name

func (FormSubmission) GetFieldHintClass

func (f FormSubmission) GetFieldHintClass(fieldName string) string

func (FormSubmission) GetFieldInputClass

func (f FormSubmission) GetFieldInputClass(fieldName string) string

func (FormSubmission) GetFieldStatusClass

func (f FormSubmission) GetFieldStatusClass(fieldName string) string

GetFieldStatusClass returns an HTML class based on the status of the field

func (FormSubmission) HasErrors

func (f FormSubmission) HasErrors() bool

HasErrors indicates if the submission has any validation errors

func (FormSubmission) IsDone

func (f FormSubmission) IsDone() bool

IsDone indicates if the submission is considered done which is when it has been submitted and there are no errors.

func (*FormSubmission) Process

func (f *FormSubmission) Process(ctx echo.Context, form any) error

Process processes a submission for a form

func (*FormSubmission) SetFieldError

func (f *FormSubmission) SetFieldError(fieldName string, message string)

SetFieldError sets an error message for a given field name

type LayoutComponent

type LayoutComponent func(content templ.Component, page *Page) templ.Component

type Page

type Page struct {
	// Base stores app-agnostic page fields/behavior owned by framework.
	frameworkpage.Base

	// Layout stores the templ component layout base function which will be used when the page is rendered.
	Layout LayoutComponent

	// Name stores the name of the page as well as the name of the template file which will be used to render
	// the content portion of the layout template.
	// This should match a template file located within the pages directory inside the templates directory.
	// The template extension should not be included in this value.
	Name string

	IsNavBarSticky bool

	// IsFullyOnboarded indicates whether the user is fully onboarded
	IsFullyOnboarded bool

	// AuthUser stores the authenticated user
	AuthUser *AuthUserView

	// ActiveProduct stores the active product for the profile (limited to 1 for now)
	ActiveProduct domain.ProductType

	// Metatags stores metatag values
	Metatags struct {
		// Description stores the description metatag value
		Description string

		// Keywords stores the keywords metatag values
		Keywords []string
	}

	// Pager stores a pager which can be used to page lists of results
	Pager Pager

	// Bottom navbar is only shown if this is set. It allows flexibility for a native-like experience.
	ShowBottomNavbar         bool
	SelectedBottomNavbarItem domain.BottomNavbarItem
}

Page consists of all data that will be used to render a page response for a given webui. While it's not required for a controller to render a Page on a route, this is the common data object that will be passed to the templates, making it easy for all controllers to share functionality both on the back and frontend. The Page can be expanded to include anything else your app wants to support. Methods on this page also then become available in the templates, which can be more useful than the funcmap if your methods require data stored in the page, such as the appcontext.

func NewPage

func NewPage(ctx echo.Context) Page

NewPage creates and initiatizes a new Page for a given request context

func (Page) Language

func (p Page) Language() string

func (Page) StarterAlertClass

func (p Page) StarterAlertClass(variant string) string

func (Page) StarterCardClass

func (p Page) StarterCardClass() string

func (Page) StarterElevationClass

func (p Page) StarterElevationClass() string

func (Page) StarterIslandMountClass

func (p Page) StarterIslandMountClass() string

func (Page) StarterKickerClass

func (p Page) StarterKickerClass() string

func (Page) StarterLayoutContentClass

func (p Page) StarterLayoutContentClass() string

func (Page) StarterLayoutFooterClass

func (p Page) StarterLayoutFooterClass() string

func (Page) StarterLayoutHeaderClass

func (p Page) StarterLayoutHeaderClass() string

func (Page) StarterLayoutShellClass

func (p Page) StarterLayoutShellClass() string

func (Page) StarterMutedColorClass

func (p Page) StarterMutedColorClass() string

func (Page) StarterNavClass

func (p Page) StarterNavClass() string

func (Page) StarterNavItemClass

func (p Page) StarterNavItemClass(active bool) string

func (Page) StarterPageClass

func (p Page) StarterPageClass() string

func (Page) StarterPanelClass

func (p Page) StarterPanelClass() string

func (Page) StarterPrimaryActionClass

func (p Page) StarterPrimaryActionClass() string

func (Page) StarterSecondaryActionClass

func (p Page) StarterSecondaryActionClass() string

func (Page) StarterStackClass

func (p Page) StarterStackClass() string

func (Page) StarterTextClass

func (p Page) StarterTextClass() string

func (Page) StarterTitleClass

func (p Page) StarterTitleClass() string

type Pager

type Pager struct {
	// Items stores the total amount of items in the result set
	Items int

	// Page stores the current page number
	Page int

	// ItemsPerPage stores the amount of items to display per page
	ItemsPerPage int

	// Pages stores the total amount of pages in the result set
	Pages int

	// The URL to query to get more pages
	URL string
}

Pager provides a mechanism to allow a user to page results via a query parameter

func NewPager

func NewPager(ctx echo.Context, itemsPerPage int) Pager

NewPager creates a new Pager

func (*Pager) GetNextURL

func (p *Pager) GetNextURL() string

func (Pager) GetOffset

func (p Pager) GetOffset() int

GetOffset determines the offset of the results in order to get the items for the current page

func (*Pager) GetPrevURL

func (p *Pager) GetPrevURL() string

func (Pager) IsBeginning

func (p Pager) IsBeginning() bool

IsBeginning determines if the pager is at the beginning of the pages

func (Pager) IsEnd

func (p Pager) IsEnd() bool

IsEnd determines if the pager is at the end of the pages

func (*Pager) SetItems

func (p *Pager) SetItems(items int)

SetItems sets the amount of items in total for the pager and calculate the amount of total pages based off on the item per page. This should be used rather than setting either items or pages directly.

func (*Pager) SetURL

func (p *Pager) SetURL(url string)

type SemanticRecipe

type SemanticRecipe string

SemanticRecipe names a reusable UI recipe class contract.

const (
	RecipePage            SemanticRecipe = "page"
	RecipePanel           SemanticRecipe = "panel"
	RecipeTitle           SemanticRecipe = "title"
	RecipeText            SemanticRecipe = "text"
	RecipeKicker          SemanticRecipe = "kicker"
	RecipeStack           SemanticRecipe = "stack"
	RecipeMutedColor      SemanticRecipe = "muted-color"
	RecipeDangerColor     SemanticRecipe = "danger-color"
	RecipeElevationFloat  SemanticRecipe = "elevation-float"
	RecipeButtonBase      SemanticRecipe = "button-base"
	RecipeButtonPrimary   SemanticRecipe = "button-primary"
	RecipeButtonSecondary SemanticRecipe = "button-secondary"
	RecipeFieldInput      SemanticRecipe = "field-input"
	RecipeFieldHint       SemanticRecipe = "field-hint"
	RecipeFieldError      SemanticRecipe = "field-error"
	RecipeFieldSuccess    SemanticRecipe = "field-success"
	RecipeForm            SemanticRecipe = "form"
	RecipeAlert           SemanticRecipe = "alert"
	RecipeAlertInfo       SemanticRecipe = "alert-info"
	RecipeAlertSuccess    SemanticRecipe = "alert-success"
	RecipeAlertDanger     SemanticRecipe = "alert-danger"
	RecipeCard            SemanticRecipe = "card"
	RecipeNav             SemanticRecipe = "nav"
	RecipeNavItem         SemanticRecipe = "nav-item"
	RecipeNavItemActive   SemanticRecipe = "nav-item-active"
	RecipeLayoutShell     SemanticRecipe = "layout-shell"
	RecipeLayoutHeader    SemanticRecipe = "layout-header"
	RecipeLayoutContent   SemanticRecipe = "layout-content"
	RecipeLayoutFooter    SemanticRecipe = "layout-footer"
	RecipeIslandMount     SemanticRecipe = "island-mount"
)

Jump to

Keyboard shortcuts

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