toaster

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOC_TOP_LEFT      ToastLocation = "top-left"
	LOC_TOP_CENTER    ToastLocation = "top-center"
	LOC_TOP_RIGHT     ToastLocation = "top-right" // default
	LOC_BOTTOM_LEFT   ToastLocation = "bottom-left"
	LOC_BOTTOM_CENTER ToastLocation = "bottom-center"
	LOC_BOTTOM_RIGHT  ToastLocation = "bottom-right"

	TYPE_SUCCESS ToastType = "success"
	TYPE_WARNING ToastType = "warning"
	TYPE_ERROR   ToastType = "error"
	TYPE_INFO    ToastType = "info"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	DB                  *sqlx.DB
	ToastTemplate       string
	HyperscriptTemplate string
}

func ConnectDB

func ConnectDB(driverName string, dataSourceName string) (*DB, error)

func (DB) CreateSchema

func (db DB) CreateSchema() error

func (*DB) Delete

func (db *DB) Delete(key string) error

func (*DB) Get

func (db *DB) Get(key string) (*Toast, error)

func (DB) GetHyperTempl added in v0.1.3

func (db DB) GetHyperTempl() string

func (DB) GetToastTempl added in v0.1.3

func (db DB) GetToastTempl() string

func (DB) New added in v0.1.4

func (db DB) New(msg string) *Toast

func (*DB) Save added in v0.1.4

func (db *DB) Save(toast *Toast) (string, error)

func (*DB) SetHyperTempl added in v0.1.3

func (db *DB) SetHyperTempl(tmpl string)

func (*DB) SetToastTempl added in v0.1.3

func (db *DB) SetToastTempl(tmpl string)

type MapStore

type MapStore struct {
	Messages            map[string]*Toast
	ToastTemplate       string
	HyperscriptTemplate string
}

func CreateMapStore

func CreateMapStore() *MapStore

func (*MapStore) Delete

func (ms *MapStore) Delete(key string) error

func (MapStore) Get

func (ms MapStore) Get(key string) (*Toast, error)

func (MapStore) GetHyperTempl added in v0.1.2

func (ms MapStore) GetHyperTempl() string

func (MapStore) GetToastTempl

func (ms MapStore) GetToastTempl() string

func (MapStore) New added in v0.1.4

func (ms MapStore) New(msg string) *Toast

func (*MapStore) Save added in v0.1.4

func (ms *MapStore) Save(toast *Toast) (string, error)

func (*MapStore) SetHyperTempl added in v0.1.2

func (ms *MapStore) SetHyperTempl(tmpl string)

func (*MapStore) SetToastTempl

func (ms *MapStore) SetToastTempl(tmpl string)

type Store

type Store interface {
	New(string) *Toast
	Save(*Toast) (string, error)
	Get(string) (*Toast, error)
	Delete(string) error
	GetToastTempl() string
	SetToastTempl(string)
	GetHyperTempl() string
	SetHyperTempl(string)
}

type Toast

type Toast struct {
	ID                  string        `json:"id" db:"id"`
	Title               string        `json:"title,omitempty" db:"title"`
	Message             string        `json:"message,omitempty" db:"message"`
	Location            ToastLocation `json:"location,omitempty" db:"location"`
	Icon                bool          `json:"icon" db:"icon"`
	Dismissable         bool          `json:"dismissable" db:"dismissable"`
	Type                ToastType     `json:"type,omitempty" db:"msg_type"`
	CreatedAt           time.Time     `json:"created_at" db:"-"`
	CreatedAtStr        string        `json:"-" db:"created_at"`
	ToastTemplate       string        `json:"-" db:"-"`
	HyperscriptTemplate string        `json:"-" db:"-"`
}

func (Toast) Render

func (t Toast) Render() string

func (Toast) RenderHyperscript

func (t Toast) RenderHyperscript() string

func (*Toast) SetDismissable

func (t *Toast) SetDismissable(dis bool) *Toast

func (*Toast) SetErrMessage

func (t *Toast) SetErrMessage(msg error) *Toast

func (*Toast) SetLocation

func (t *Toast) SetLocation(loc ToastLocation) *Toast

func (*Toast) SetMessage

func (t *Toast) SetMessage(msg string) *Toast

func (*Toast) SetTitle

func (t *Toast) SetTitle(title string) *Toast

func (*Toast) SetType

func (t *Toast) SetType(tp ToastType) *Toast

func (*Toast) ShowIcon

func (t *Toast) ShowIcon(icn bool) *Toast

type ToastLocation

type ToastLocation string

type ToastType

type ToastType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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