#63 cleanup and assertions

This commit is contained in:
Mikayla Fischler
2022-06-11 17:06:32 -04:00
parent 4488a0594f
commit 89437b2be9
12 changed files with 46 additions and 23 deletions

View File

@@ -12,11 +12,15 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field height? integer parent height if omitted
---@field fg_bg cpair foreground/background colors
---@field fg_bg? cpair foreground/background colors
-- new switch button (latch high/low)
---@param args switch_button_args
local function switch_button(args)
assert(type(args.text) == "string", "graphics.elements.button_switch: text is a required field")
assert(type(args.callback) == "function", "graphics.elements.button_switch: callback is a required field")
assert(type(args.active_fg_bg) == "table", "graphics.elements.button_switch: active_fg_bg is a required field")
-- button state (convert nil to false if missing)
local state = args.default or false