Documentation
¶
Overview ¶
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
Index ¶
- Constants
- Variables
- func AppDescFromContext(ctx context.Context) string
- func AppNameFromContext(ctx context.Context) string
- func Dialog() templ.Component
- func EffectiveDarkTheme(id string) string
- func EffectiveLightTheme(id string) string
- func EffectiveTheme(id string) string
- func Layout(title string) templ.Component
- func Navbar(user *entity.User) templ.Component
- func NotFoundPage(user *entity.User) templ.Component
- func Palette() templ.Component
- func ProfileLayout(title string, active ProfileTabKey, user *entity.User) templ.Component
- func RenderNotFound(w http.ResponseWriter, r *http.Request, user *entity.User, status int)
- func ScopedSetupBanner(entry *MissingEntry, isAdmin bool) templ.Component
- func StaticHandler(prefix string, fsys fs.FS) http.Handler
- func ThemeFromContext(ctx context.Context) string
- func ThemePicker(current Theme, lightPref, darkPref string) templ.Component
- func ToolHeader(name, description, icon, key string, hasConfigs bool, isAdmin bool) templ.Component
- func UserMenu(user *entity.User) templ.Component
- func WithAppDescription(ctx context.Context, desc string) context.Context
- func WithAppName(ctx context.Context, name string) context.Context
- func WithGuestTheme(ctx context.Context, g GuestTheme) context.Context
- func WithTheme(ctx context.Context, id string) context.Context
- type GuestTheme
- type MissingEntry
- type ProfileTabKey
- type Theme
Constants ¶
const ( DefaultTheme = "github-light" DefaultLightTheme = "github-light" DefaultDarkTheme = "github-dark" )
Defaults applied when a user or guest has no stored preference, so first-time visitors land on GitHub Light with GitHub Dark as the paired dark variant instead of the device system preference.
Variables ¶
var Themes = []Theme{ {ID: "light", Label: "Light", ClassName: "theme-light", IsDark: false}, {ID: "dark", Label: "Dark", ClassName: "theme-dark", IsDark: true}, {ID: "github-light", Label: "GitHub Light", ClassName: "theme-github-light", IsDark: false}, {ID: "github-dark", Label: "GitHub Dark", ClassName: "theme-github-dark", IsDark: true}, {ID: "material-light", Label: "Material Light", ClassName: "theme-material-light", IsDark: false}, {ID: "material-dark", Label: "Material Dark", ClassName: "theme-material-dark", IsDark: true}, {ID: "solarized-light", Label: "Solarized Light", ClassName: "theme-solarized-light", IsDark: false}, {ID: "solarized-dark", Label: "Solarized Dark", ClassName: "theme-solarized-dark", IsDark: true}, {ID: "dracula", Label: "Dracula", ClassName: "theme-dracula", IsDark: true}, {ID: "nord", Label: "Nord", ClassName: "theme-nord", IsDark: true}, {ID: "gruvbox-dark", Label: "Gruvbox Dark", ClassName: "theme-gruvbox-dark", IsDark: true}, {ID: "monokai", Label: "Monokai", ClassName: "theme-monokai", IsDark: true}, }
Themes is the ordered list rendered in the theme picker. Add new themes by appending here and defining their tokens in input.css.
Functions ¶
func AppDescFromContext ¶
func AppNameFromContext ¶
AppNameFromContext returns the app name set via WithAppName, or "Wick Mini Tools" as the fallback.
func Dialog ¶ added in v0.13.0
Dialog renders the global confirm/alert modal shell mounted once per page via @Layout. JS helpers in web/public/js/dialog.js (wickConfirm / wickAlert) drive open/close + slot the title and body text. Using a single shared element keeps the modal stackable at the top of <body> so backdrop blur never gets clipped by a parent's overflow.
Why replace native confirm()/alert(): the browser dialogs render with OS chrome (white-on-black on Windows, grey-on-white on macOS, and they get blocked entirely on iOS Safari for cross-origin embeds). A custom modal lets every dialog inherit the project theme and behave consistently across pages.
func EffectiveDarkTheme ¶ added in v0.3.0
EffectiveDarkTheme returns the stored dark-mode theme id or DefaultDarkTheme when unset.
func EffectiveLightTheme ¶ added in v0.3.0
EffectiveLightTheme returns the stored light-mode theme id or DefaultLightTheme when unset.
func EffectiveTheme ¶ added in v0.3.0
EffectiveTheme returns the active theme id, falling back to DefaultTheme when unset.
func NotFoundPage ¶
NotFoundPage is shown for both 404 (missing) and 403 (forbidden) so a signed-in user cannot distinguish "tool doesn't exist" from "tool exists but I'm not allowed". The message is intentionally vague.
func Palette ¶
Palette renders the global command palette shell. Tool items are populated on first open via GET /api/tools (see web/public/js/palette.js).
func ProfileLayout ¶ added in v0.4.0
ProfileLayout is the shared chrome for every page under /profile/*. Mirrors AdminLayout: a single sticky navbar carries the logo, the "Profile" section label, the segmented tab pill group, and the theme/user controls — so children render against the full max-w-container width instead of a narrow account-style column.
func RenderNotFound ¶
RenderNotFound writes the NotFoundPage with the given status code. Use 404 for unknown paths, and 404 (not 403) for forbidden resources so the two cases are indistinguishable to the client.
func ScopedSetupBanner ¶
func ScopedSetupBanner(entry *MissingEntry, isAdmin bool) templ.Component
ScopedSetupBanner renders a single-module caution strip below the navbar when the module the user is currently viewing still has Required configs empty. nil entry suppresses the banner entirely. Admins get a Configure → link straight to the module's manager page; non-admins see a read-only nudge.
func StaticHandler ¶
StaticHandler serves files from fsys, stripping prefix, and returns 404 for directory paths so embedded asset trees don't leak via index listings.
func ThemeFromContext ¶
ThemeFromContext reads the theme id previously set via WithTheme.
func ThemePicker ¶
ThemePicker is the navbar control for switching themes. The left button is the quick toggle between Light and Dark (cycles based on the current theme's IsDark flag). The caret opens a dropdown listing every theme in Themes so the user can pick a custom palette. Posts go to /theme; the handler saves to user metadata and redirects back.
func ToolHeader ¶ added in v0.3.0
ToolHeader renders the shared per-tool top strip: icon box, name, description, and an admin-only Settings link pointing at the manager detail page. Drawn by NewToolRenderer between the setup banner and the tool body so every tool page has identical chrome without each module repeating the block. Tool bodies should omit their own <h1>/description — this is the canonical one.
func UserMenu ¶
UserMenu renders the user avatar dropdown used in all navbars. Shows avatar + dropdown (Profile, Sign out) when logged in, or a Sign in link.
func WithAppName ¶
WithAppName stores the configurable app name in ctx so templates can render it without an explicit parameter.
func WithGuestTheme ¶
func WithGuestTheme(ctx context.Context, g GuestTheme) context.Context
WithGuestTheme stores guest theme prefs in ctx (populated by Session middleware).
Types ¶
type GuestTheme ¶
GuestTheme holds the three theme preferences stored in the plain guest cookie. Current is the active theme; Light and Dark remember the last picked theme of each mode so the toggle button can cycle back to them.
func GuestThemeFromContext ¶
func GuestThemeFromContext(ctx context.Context) GuestTheme
GuestThemeFromContext returns guest theme prefs set via WithGuestTheme.
type MissingEntry ¶
type MissingEntry struct {
Scope string // "variables", "tool", "job"
Key string // owner key; "" for variables
Name string // display label
Icon string
URL string // where to go to fix
Missing []string
}
MissingEntry names a single owner (variables / tool / job) plus the config keys that are Required but empty. Collected app-wide and rendered globally by GlobalSetupBanner so operators see every incomplete module in one place — regardless of which page they're on.
type ProfileTabKey ¶ added in v0.4.0
type ProfileTabKey string
ProfileTabKey identifies which tab should render as active.
const ( ProfileTabAccount ProfileTabKey = "account" ProfileTabTokens ProfileTabKey = "tokens" ProfileTabConnections ProfileTabKey = "connections" ProfileTabMCP ProfileTabKey = "mcp" ProfileTabAgents ProfileTabKey = "agents" )
type Theme ¶
type Theme struct {
ID string // stored in user metadata
Label string // shown in UI
ClassName string // applied to <html>
IsDark bool
}
Theme represents a selectable UI theme. The ClassName is the CSS class applied to <html> that drives the color palette overrides in web/src/input.css. IsDark marks themes that should also receive the "dark" class so Tailwind's `dark:` variants activate.