Media Object

The b.Media constructor creates a media.

ChildAction
b.OnMedia(...any)Apply children to the <article class="media"> element
b.OnContent(...any)Apply children to the <div class="media-content"> element
b.MediaLeft(...any)Apply children to the <div class="media-left"> element
b.MediaRight(...any)Apply children to the <div class="media-right"> element
e.ElementAdd element the <div class="media-content"> element
gomponents.Nodeof type gomponents.AttributeTypeApply attribute to the <article class="media"> element
gomponents.Nodeof type gomponents.ElementTypeApply child to the <div class="media-content"> element
Anything elseApply child to the <article class="media"> element

Each of the left, content and right parts is only included if it has content.

Bulma examples

Example
Code
b.Media(
	b.MediaLeft(
		html.Figure,
		b.ImageImg(
			"https://bulma.io/assets/images/placeholders/128x128.png",
			html.P, b.ImgSq64,
		),
	),
	b.Content(
		e.P(
			e.Strong("John Smith"), " ", e.Small("@johnsmith"), " ", e.Small("31m"),
			e.Br(),
			"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ornare magna eros, eu pellentesque tortor vestibulum ut. Maecenas non massa sem. Etiam finibus odio quis feugiat facilisis.",
		),
		b.Level(
			b.Mobile,
			b.LevelLeft(
				e.A(fa.Icon(fa.Solid, "reply", b.Small)),
				e.A(fa.Icon(fa.Solid, "retweet", b.Small)),
				e.A(fa.Icon(fa.Solid, "heart", b.Small)),
			),
		),
	),
	b.MediaRight(b.Delete()),
)
ResultHTML

John Smith @johnsmith 31m
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ornare magna eros, eu pellentesque tortor vestibulum ut. Maecenas non massa sem. Etiam finibus odio quis feugiat facilisis.

Example
Code
b.Media(
	b.MediaLeft(
		html.Figure,
		b.ImageImg(
			"https://bulma.io/assets/images/placeholders/128x128.png",
			e.P, b.ImgSq64,
		),
	),
	b.Field(
		b.Control(
			b.Textarea(
				e.Placeholder("Add a comment..."),
			),
		),
	),
	b.Level(
		b.LevelLeft(
			b.LevelItem(
				b.ButtonA(b.Info, "Submit"),
			),
		),
		b.LevelRight(
			b.Checkbox("Press enter to submit"),
		),
	),
)
ResultHTML

Nesting

Example
Code
b.Media(
	b.MediaLeft(
		html.Figure,
		b.ImageImg(
			"https://bulma.io/assets/images/placeholders/128x128.png",
			html.P, b.ImgSq64,
		),
	),
	b.Content(
		e.P(
			e.Strong("Barbara Middleton"),
			e.Br(),
			"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis porta eros lacus, nec ultricies elit blandit non. Suspendisse pellentesque mauris sit amet dolor blandit rutrum. Nunc in tempus turpis.",
			e.Br(),
			e.Small(e.A("Like"), " · ", e.A("Reply"), " · 3 hrs"),
		),
	),
	b.Media(
		b.MediaLeft(
			html.Figure,
			b.ImageImg(
				"https://bulma.io/assets/images/placeholders/96x96.png",
				html.P, b.ImgSq48,
			),
		),
		b.Content(
			e.P(
				e.Strong("Sean Brown"),
				e.Br(),
				"Donec sollicitudin urna eget eros malesuada sagittis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam blandit nisl a nulla sagittis, a lobortis leo feugiat.",
				e.Br(),
				e.Small(e.A("Like"), " · ", e.A("Reply"), " · 2 hrs"),
			),
		),
		b.Media("Vivamus quis semper metus, non tincidunt dolor. Vivamus in mi eu lorem cursus ullamcorper sit amet nec massa."),
		b.Media("Morbi vitae diam et purus tincidunt porttitor vel vitae augue. Praesent malesuada metus sed pharetra euismod. Cras tellus odio, tincidunt iaculis diam non, porta aliquet tortor."),
	),
	b.Media(
		b.MediaLeft(
			html.Figure,
			b.ImageImg(
				"https://bulma.io/assets/images/placeholders/96x96.png",
				html.P, b.ImgSq48,
			),
		),
		b.Content(
			e.P(
				e.Strong("Kayli Eunice"),
				e.Br(),
				"Sed convallis scelerisque mauris, non pulvinar nunc mattis vel. Maecenas varius felis sit amet magna vestibulum euismod malesuada cursus libero. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus lacinia non nisl id feugiat.",
				e.Br(),
				e.Small(e.A("Like"), " · ", e.A("Reply"), " · 2 hrs"),
			),
		),
	),
),
b.Media(
	b.MediaLeft(
		html.Figure,
		b.ImageImg(
			"https://bulma.io/assets/images/placeholders/128x128.png",
			html.P, b.ImgSq64,
		),
	),
	b.Field(b.Control(
		b.Textarea(
			e.Placeholder("Add a comment..."),
		),
	)),
	b.Field(b.Control(
		b.Button("Post comment"),
	)),
)
ResultHTML

Barbara Middleton
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis porta eros lacus, nec ultricies elit blandit non. Suspendisse pellentesque mauris sit amet dolor blandit rutrum. Nunc in tempus turpis.
Like · Reply · 3 hrs

Sean Brown
Donec sollicitudin urna eget eros malesuada sagittis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam blandit nisl a nulla sagittis, a lobortis leo feugiat.
Like · Reply · 2 hrs

Vivamus quis semper metus, non tincidunt dolor. Vivamus in mi eu lorem cursus ullamcorper sit amet nec massa.
Morbi vitae diam et purus tincidunt porttitor vel vitae augue. Praesent malesuada metus sed pharetra euismod. Cras tellus odio, tincidunt iaculis diam non, porta aliquet tortor.

Kayli Eunice
Sed convallis scelerisque mauris, non pulvinar nunc mattis vel. Maecenas varius felis sit amet magna vestibulum euismod malesuada cursus libero. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus lacinia non nisl id feugiat.
Like · Reply · 2 hrs