diff --git a/ui/messagebox.go b/ui/messagebox.go new file mode 100644 index 0000000..684f948 --- /dev/null +++ b/ui/messagebox.go @@ -0,0 +1,62 @@ +/* + * Amsterdam Web Communities System + * Copyright (c) 2025-2026 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +// Package ui holds the support for the Amsterdam user interface, wrapping Echo and Jet templates. +package ui + +import ( + _ "embed" + + "gopkg.in/yaml.v3" +) + +// MBoxWarningLine defines a single warning line in a message box. +type MBoxWarningLine struct { + Text string `yaml:"text"` + Bold bool `yaml:"bold"` +} + +// MBoxButton defines a single button on a message box. +type MBoxButton struct { + Id string `yaml:"id"` + Link string `yaml:"link"` + Confirm bool `yaml:"confirm"` + Tone string `yaml:"tone"` + Icon string `yaml:"icon"` + Text string `yaml:"text"` +} + +// MessageBoxDefinition defines a single message box resource. +type MessageBoxDefinition struct { + Id string `yaml:"id"` + Title string `yaml:"title"` + Tone string `yaml:"tone"` + Destructive bool `yaml:"destructive"` + Message string `yaml:"message"` + WarningIcon string `yaml:"warningIcon"` + WarningLines []MBoxWarningLine `yaml:"warningLines"` + Buttons []MBoxButton `yaml:"buttons"` +} + +// MessageBoxDefs is the top-level structure for defining message boxes. +type MessageBoxDefs struct { + D []MessageBoxDefinition `yaml:"messagedefs"` +} + +//go:embed messagedefs.yaml +var initMessageData []byte + +// messageBoxDefs is the master repository for message box data. +var messageBoxDefs MessageBoxDefs + +// init loads and binds the message box definitions. +func init() { + if err := yaml.Unmarshal(initMessageData, &messageBoxDefs); err != nil { + panic(err) // can't happen + } +} diff --git a/ui/messagedefs.yaml b/ui/messagedefs.yaml new file mode 100644 index 0000000..f06cd75 --- /dev/null +++ b/ui/messagedefs.yaml @@ -0,0 +1,33 @@ +# +# Amsterdam Web Communities System +# Copyright (c) 2025-2026 Erbosoft Metaverse Design Solutions, All Rights Reserved +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# +messagedefs: + - id: "nuke" + title: "Nuke Message" + tone: "red" + destructive: true + message: "You are about to nuke a message!" + warningIcon: "💣" + warningLines: + - text: "Warning: This action cannot be undone!" + bold: true + - text: "Nuking this message will permanently delete it from the system." + bold: false + buttons: + - id: "yes" + link: "placeholder" + confirm: true + tone: "red" + icon: "✓" + text: "Yes, Nuke It" + - id: "no" + link: "placeholder" + confirm: false + tone: "green" + icon: "✗" + text: "No, Cancel" diff --git a/ui/views/messagebox.jet b/ui/views/messagebox.jet new file mode 100644 index 0000000..527628c --- /dev/null +++ b/ui/views/messagebox.jet @@ -0,0 +1,66 @@ +{* + * Amsterdam Web Communities System + * Copyright (c) 2025-2026 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + *} +
+ +
+
+ +
+

+ {{ if destructive }}span class="text-3xl">⚠️{{ end }} + {{ amsterdam_pageTitle }} + {{ if destructive }}⚠️{{ end }} +

+
+ + +
+
+

+ {{ message }} + {* You are about to nuke message <Playground.129.16>, + originally composed by <erbo>! *} +

+ {{ if destructive }} +

Are you sure you want to do this?

+ {{ end }} +
+ + {{ if useWarning }} + +
+
+ {{ warningIcon }} +
+ {{ range i, line := warningLines }} + {{ if line.Bold }} +

{{ line.Text }}

+ {{ else }} +

{{ line.Text }}

+ {{ end }} + {{ end }} +
+
+
+ {{ end }} + + +
+ {{ range i, bt := buttons }} + + {{ bt.Icon }} + {{ bt.Text }} + + {{ end }} +
+
+
+
+