(title, text string, graphic func(w *T), url ...string)
| 173 | var home *core.Frame |
| 174 | |
| 175 | func 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 | |
| 216 | func homePage(ctx *htmlcore.Context) bool { |
| 217 | home = core.NewFrame(ctx.BlockParent) |
no test coverage detected