config: dialog,packages,lua (5 files)

This commit is contained in:
Richard Ward
2025-12-31 12:16:06 +00:00
parent 1a6accf258
commit faefd4d1a2
5 changed files with 357 additions and 1 deletions

View File

@@ -0,0 +1,70 @@
-- admin_dialog: Action Dialog Component
-- Multi-purpose dialog for admin actions with custom buttons
local M = {}
function M.render(context)
local dialog = context.dialog or {
title = "Admin Action",
message = "Select an action to perform",
actions = {
{ text = "Approve", action = "admin.action.approve", variant = "primary" },
{ text = "Reject", action = "admin.action.reject", variant = "danger" },
{ text = "Review Later", action = "admin.action.defer", variant = "secondary" }
}
}
local actionButtons = {}
for _, actionDef in ipairs(dialog.actions) do
local buttonClass = "button admin_dialog_button_" .. (actionDef.variant or "default")
table.insert(actionButtons, {
type = "button",
className = buttonClass,
text = actionDef.text,
action = actionDef.action,
data = actionDef.data
})
end
return {
type = "div",
className = "admin_dialog_overlay",
children = {
{
type = "div",
className = "card admin_dialog",
children = {
{
type = "div",
className = "admin_dialog_header",
children = {
{
type = "h3",
className = "admin_dialog_title",
text = dialog.title
}
}
},
{
type = "div",
className = "admin_dialog_body",
children = {
{
type = "p",
className = "admin_dialog_message",
text = dialog.message
}
}
},
{
type = "div",
className = "admin_dialog_footer admin_dialog_footer_multi",
children = actionButtons
}
}
}
}
}
end
return M

View File

@@ -0,0 +1,71 @@
-- admin_dialog: Confirmation Dialog Component
-- Standard confirmation dialog for admin actions
local M = {}
function M.render(context)
local dialog = context.dialog or {
title = "Confirm Action",
message = "Are you sure you want to proceed?",
confirmText = "Confirm",
cancelText = "Cancel",
variant = "warning"
}
local variantClass = "admin_dialog_" .. (dialog.variant or "default")
return {
type = "div",
className = "admin_dialog_overlay",
children = {
{
type = "div",
className = "card admin_dialog " .. variantClass,
children = {
{
type = "div",
className = "admin_dialog_header",
children = {
{
type = "h3",
className = "admin_dialog_title",
text = dialog.title
}
}
},
{
type = "div",
className = "admin_dialog_body",
children = {
{
type = "p",
className = "admin_dialog_message",
text = dialog.message
}
}
},
{
type = "div",
className = "admin_dialog_footer",
children = {
{
type = "button",
className = "button admin_dialog_button_cancel",
text = dialog.cancelText,
action = "admin.dialog.cancel"
},
{
type = "button",
className = "button admin_dialog_button_confirm",
text = dialog.confirmText,
action = "admin.dialog.confirm"
}
}
}
}
}
}
}
end
return M

View File

@@ -0,0 +1,89 @@
-- admin_dialog: Delete Confirmation Dialog Component
-- Specialized dialog for destructive delete actions
local M = {}
function M.render(context)
local item = context.item or {
type = "item",
name = "Unknown Item"
}
return {
type = "div",
className = "admin_dialog_overlay",
children = {
{
type = "div",
className = "card admin_dialog admin_dialog_danger",
children = {
{
type = "div",
className = "admin_dialog_header",
children = {
{
type = "h3",
className = "admin_dialog_title",
text = "⚠️ Confirm Delete"
}
}
},
{
type = "div",
className = "admin_dialog_body",
children = {
{
type = "p",
className = "admin_dialog_message",
text = "You are about to permanently delete:"
},
{
type = "div",
className = "admin_dialog_item_info",
children = {
{
type = "strong",
text = item.name
},
{
type = "p",
className = "admin_dialog_warning",
text = "This action cannot be undone!"
}
}
},
{
type = "input",
className = "input admin_dialog_confirm_input",
name = "confirmText",
placeholder = "Type 'DELETE' to confirm",
required = true
}
}
},
{
type = "div",
className = "admin_dialog_footer",
children = {
{
type = "button",
className = "button admin_dialog_button_cancel",
text = "Cancel",
action = "admin.dialog.cancel"
},
{
type = "button",
className = "button admin_dialog_button_danger",
text = "Delete Permanently",
action = "admin.dialog.delete",
data = { itemId = item.id, itemType = item.type }
}
}
}
}
}
}
}
end
return M

View File

@@ -14,6 +14,11 @@
"lua_test"
],
"exports": {
"scripts": [
"confirm_dialog",
"delete_confirm",
"action_dialog"
],
"components": []
},
"tests": {
@@ -42,6 +47,19 @@
"styles": "seed/styles.json"
},
"storybook": {
"stories": []
"stories": [
{
"name": "Confirm Dialog",
"render": "confirm_dialog"
},
{
"name": "Delete Confirmation",
"render": "delete_confirm"
},
{
"name": "Action Dialog",
"render": "action_dialog"
}
]
}
}

View File

@@ -0,0 +1,108 @@
-- stream_cast: Stream Schedule Component
-- Manage streaming schedule and upcoming broadcasts
local M = {}
function M.render(context)
local schedules = context.schedules or {
{ id = 1, title = "Morning Gaming Session", date = "2025-01-02", time = "09:00", duration = "3h", recurring = true },
{ id = 2, title = "Tutorial Series Ep. 5", date = "2025-01-03", time = "14:00", duration = "2h", recurring = false },
{ id = 3, title = "Community Q&A", date = "2025-01-04", time = "18:00", duration = "1h", recurring = true },
{ id = 4, title = "Special Event Stream", date = "2025-01-05", time = "20:00", duration = "4h", recurring = false }
}
local user = context.user or {}
local canManageSchedule = user.level and user.level >= 3
local scheduleItems = {}
for _, schedule in ipairs(schedules) do
table.insert(scheduleItems, {
type = "div",
className = "card stream_cast_schedule_item",
children = {
{
type = "div",
className = "stream_cast_schedule_header",
children = {
{
type = "h4",
className = "stream_cast_schedule_title",
text = schedule.title
},
{
type = "span",
className = "stream_cast_schedule_badge",
text = schedule.recurring and "♻️ Recurring" or "📅 One-time"
}
}
},
{
type = "div",
className = "stream_cast_schedule_details",
children = {
{
type = "span",
text = "📆 " .. schedule.date
},
{
type = "span",
text = "🕐 " .. schedule.time
},
{
type = "span",
text = "⏱️ " .. schedule.duration
}
}
},
{
type = "div",
className = "stream_cast_schedule_actions",
children = {
{
type = "button",
className = "button stream_cast_button_small",
text = "Edit",
action = "stream.schedule.edit",
data = { scheduleId = schedule.id },
disabled = not canManageSchedule
},
{
type = "button",
className = "button stream_cast_button_small",
text = "Delete",
action = "stream.schedule.delete",
data = { scheduleId = schedule.id },
disabled = not canManageSchedule
}
}
}
}
})
end
return {
type = "div",
className = "stream_cast_schedule",
children = {
{
type = "h2",
className = "stream_cast_heading",
text = "Stream Schedule"
},
{
type = "div",
className = "stream_cast_schedule_list",
children = scheduleItems
},
{
type = "button",
className = "button stream_cast_button_primary",
text = "+ Add Stream",
action = "stream.schedule.create",
disabled = not canManageSchedule
}
}
}
end
return M