github.com/kotovmak/go-admin@v1.1.1/template/components/box.go (about) 1 package components 2 3 import ( 4 "fmt" 5 "html/template" 6 7 "github.com/kotovmak/go-admin/template/types" 8 ) 9 10 type BoxAttribute struct { 11 Name string 12 Header template.HTML 13 Body template.HTML 14 Footer template.HTML 15 Title template.HTML 16 Theme string 17 HeadBorder string 18 Attr template.HTMLAttr 19 HeadColor string 20 SecondHeaderClass string 21 SecondHeader template.HTML 22 SecondHeadBorder string 23 SecondHeadColor string 24 Style template.HTMLAttr 25 Padding string 26 types.Attribute 27 } 28 29 func (compo *BoxAttribute) SetTheme(value string) types.BoxAttribute { 30 compo.Theme = value 31 return compo 32 } 33 34 func (compo *BoxAttribute) SetHeader(value template.HTML) types.BoxAttribute { 35 compo.Header = value 36 return compo 37 } 38 39 func (compo *BoxAttribute) SetBody(value template.HTML) types.BoxAttribute { 40 compo.Body = value 41 return compo 42 } 43 44 func (compo *BoxAttribute) SetStyle(value template.HTMLAttr) types.BoxAttribute { 45 compo.Style = value 46 return compo 47 } 48 49 func (compo *BoxAttribute) SetAttr(attr template.HTMLAttr) types.BoxAttribute { 50 compo.Attr = attr 51 return compo 52 } 53 54 func (compo *BoxAttribute) SetIframeStyle(iframe bool) types.BoxAttribute { 55 if iframe { 56 compo.Attr = `style="border-radius: 0px;box-shadow:none;border-top:none;margin-bottom: 0px;"` 57 } 58 return compo 59 } 60 61 func (compo *BoxAttribute) SetFooter(value template.HTML) types.BoxAttribute { 62 compo.Footer = value 63 return compo 64 } 65 66 func (compo *BoxAttribute) SetTitle(value template.HTML) types.BoxAttribute { 67 compo.Title = value 68 return compo 69 } 70 71 func (compo *BoxAttribute) SetHeadColor(value string) types.BoxAttribute { 72 compo.HeadColor = value 73 return compo 74 } 75 76 func (compo *BoxAttribute) WithHeadBorder() types.BoxAttribute { 77 compo.HeadBorder = "with-border" 78 return compo 79 } 80 81 func (compo *BoxAttribute) SetSecondHeader(value template.HTML) types.BoxAttribute { 82 compo.SecondHeader = value 83 return compo 84 } 85 86 func (compo *BoxAttribute) SetSecondHeadColor(value string) types.BoxAttribute { 87 compo.SecondHeadColor = value 88 return compo 89 } 90 91 func (compo *BoxAttribute) SetSecondHeaderClass(value string) types.BoxAttribute { 92 compo.SecondHeaderClass = value 93 return compo 94 } 95 96 func (compo *BoxAttribute) SetNoPadding() types.BoxAttribute { 97 compo.Padding = "padding:0;" 98 return compo 99 } 100 101 func (compo *BoxAttribute) WithSecondHeadBorder() types.BoxAttribute { 102 compo.SecondHeadBorder = "with-border" 103 return compo 104 } 105 106 func (compo *BoxAttribute) GetContent() template.HTML { 107 108 if compo.Style == "" { 109 compo.Style = template.HTMLAttr(fmt.Sprintf(`style="%s"`, compo.Padding)) 110 } else { 111 compo.Style = template.HTMLAttr(fmt.Sprintf(`style="%s"`, string(compo.Style)+compo.Padding)) 112 } 113 114 return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "box") 115 }