package components import ( "git.sapphic.engineer/roleypoly/v4/types" "git.sapphic.engineer/roleypoly/v4/utils" ) type RoleTemplateData struct { ID string CategoryID string Name string Selected bool Safe bool InputType InputType Colors RoleColors } type RoleColors struct { Main string Alt string } type InputType string const ( InputCheckbox InputType = "checkbox" InputRadio InputType = "radio" ) func Role(category *types.Category, role *types.Role) RoleTemplateData { inputType := InputCheckbox if category.Type == types.CategorySingle { inputType = InputRadio } colors := NewRoleColors(role.Color) return RoleTemplateData{ ID: role.ID, CategoryID: category.ID, Name: role.Name, Selected: role.Selected, InputType: inputType, Colors: colors, Safe: role.Safe, } } func NewRoleColors(roleColor uint32) RoleColors { // TODO: no color r, g, b := utils.IntToRgb(roleColor) altR, altG, altB := utils.AltColor(r, g, b) return RoleColors{ Main: utils.RgbToString(r, g, b), Alt: utils.RgbToString(altR, altG, altB), } }