menu

package module
v0.0.0-...-7afa3fa Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 3 Imported by: 0

README

menu

A menu structure for general purpose

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMenu

type BaseMenu struct {
	MenuID      string         // ID of the menu
	HasChildren bool           // Shortcut to find out if the menu has children
	Text        string         // Text of the menu
	TextClass   string         // Text style of the menu via CSS class
	Icon        string         // Icon of the menu
	Link        string         // Link of the menu
	LinkClass   string         // Style of the link via CSS class
	OnClick     string         // Onclick event
	Visible     bool           // Indicates if the menu is visible or not
	Visibility  VisibilityType // Visibility of the menu when logged in, logged out or both
	Ordinal     int            // Order of the menu
	Children    []Menu         // Children of the current menu
	Headers     []Header       // Header of the current menu
}

BaseMenu - base menu struct (Not rendered)

type Header struct {
	Text       string // Header text
	Subscripts []Menu // Lists the menus that are under this header
}

Header is a header for the menu

func (*Header) Sorted

func (h *Header) Sorted() []Menu
type MainMenu struct {
	BaseMenu
}

MainMenu is a menu that cannot have links This is often used as the header menus

func (mm *MainMenu) AddHeader(header *Header) (*Header, error)

AddHeader add headers to the menu

func (mm *MainMenu) AddMenu(menu *Menu) *Menu

AddMenu add a sub menu to a main menu

type Menu struct {
	BaseMenu
	HeaderSubscription string
}

Menu is a common menu that can be rendered

func (m *Menu) AddHeader(header *Header) (*Header, error)

AddHeader add headers to the menu

type RootMenu

type RootMenu struct {
	Children    []MainMenu
	Initialized bool
	Logged      bool
}

RootMenu is the root of the menus (not rendered)

func (*RootMenu) Add

func (rm *RootMenu) Add(menu *MainMenu) *MainMenu

Add - adds a main menu to the root menu

func (*RootMenu) Evaluate

func (rm *RootMenu) Evaluate()

Evaluate evaluates various properties set before being assigned to the template

type VisibilityType

type VisibilityType int

VisibilityType - the type of visibility

const (
	// BOTH - visible on both logged or logged status
	BOTH VisibilityType = 0
	// NOTLOGGED - visible when the status is not logged
	NOTLOGGED VisibilityType = 1
	// LOGGED - visible when the status is logged
	LOGGED VisibilityType = 2
)

Jump to

Keyboard shortcuts

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