MCPcopy Create free account
hub / github.com/cogentcore/core / makeBlock

Function makeBlock

docs/docs.go:175–214  ·  view source on GitHub ↗
(title, text string, graphic func(w *T), url ...string)

Source from the content-addressed store, hash-verified

173var home *core.Frame
174
175func makeBlock[T tree.NodeValue](title, text string, graphic func(w *T), url ...string) {
176 if len(url) > 0 {
177 title = `<a href="` + url[0] + `">` + title + `</a>`
178 }
179 tree.AddChildAt(home, title, func(w *core.Frame) {
180 w.Styler(func(s *styles.Style) {
181 s.Gap.Set(units.Em(1))
182 s.Grow.Set(1, 0)
183 if home.SizeClass() == core.SizeCompact {
184 s.Direction = styles.Column
185 }
186 })
187 w.Maker(func(p *tree.Plan) {
188 graphicFirst := w.IndexInParent()%2 != 0 && w.SizeClass() != core.SizeCompact
189 if graphicFirst {
190 tree.Add(p, graphic)
191 }
192 tree.Add(p, func(w *core.Frame) {
193 w.Styler(func(s *styles.Style) {
194 s.Direction = styles.Column
195 s.Text.Align = styles.Start
196 s.Grow.Set(1, 1)
197 })
198 tree.AddChild(w, func(w *core.Text) {
199 w.SetType(core.TextHeadlineLarge).SetText(title)
200 w.Styler(func(s *styles.Style) {
201 s.Font.Weight = styles.WeightBold
202 s.Color = colors.Scheme.Primary.Base
203 })
204 })
205 tree.AddChild(w, func(w *core.Text) {
206 w.SetType(core.TextTitleLarge).SetText(text)
207 })
208 })
209 if !graphicFirst {
210 tree.Add(p, graphic)
211 }
212 })
213 })
214}
215
216func homePage(ctx *htmlcore.Context) bool {
217 home = core.NewFrame(ctx.BlockParent)

Callers 1

homePageFunction · 0.85

Calls 11

AddChildAtFunction · 0.92
EmFunction · 0.92
AddFunction · 0.92
AddChildFunction · 0.92
StylerMethod · 0.80
SizeClassMethod · 0.80
MakerMethod · 0.80
IndexInParentMethod · 0.80
SetMethod · 0.65
SetTextMethod · 0.45
SetTypeMethod · 0.45

Tested by

no test coverage detected