Bjarne Fyrstenborg
05/28/2024, 6:23 AMcolSpan
and rowSpan
. Furthermore we can style based on parent context by setting and attribute or class on layout block and update CSS variables as mentioned here.
https://umbraco.com/blog/deep-dive-block-grid-editor-part-3/
However if I have two columns - left area which span 6 columns and right area which span 6 columns, is there any way to know area context inside the block?
I would like to align content in block when in left area and "flip" the block content when placed in right area.Chriztian Steinmeier
05/28/2024, 6:48 AMcss
[data-col-span="6"]:has(+[data-col-span="6"]):first-child { /* left column */ }
[data-col-span="6"]+[data-col-span="6"]:last-child { /* right column */ }
(I have no idea how the markup looks, so your mileage may of course vary...)Bjarne Fyrstenborg
05/28/2024, 8:26 AMblockgridlayout.css
used in Block Grid datatype instance.
/* Left column */
.umb-block-grid__area[slot="left"] {
--umb-block-grid--areas-context-left: 0;
--umb-block-grid--areas-context-right: auto;
}
/* Right column */
.umb-block-grid__area[slot="right"] {
--umb-block-grid--areas-context-left: auto;
--umb-block-grid--areas-context-right: 0;
}
Then for styling of the specific block I have this:
margin-left: var(--umb-block-grid--areas-context-left, auto);
margin-right: var(--umb-block-grid--areas-context-right, auto);
However I think it mainly need to use the values directly.
It would be great a block also knew about the area name (it does know the column span and row span from area).Dean Leigh
05/29/2024, 2:18 PMMike Chambers
05/29/2024, 2:20 PMarea.cshtml
@* @await Html.GetBlockGridItemsHtmlAsync(Model) *@
@await Html.PartialAsync($"{BlockGridTemplateExtensions.DefaultFolder}{BlockGridTemplateExtensions.DefaultItemsTemplate}", Model, new ViewDataDictionary(ViewData) { { "area", Model.Alias }})
replacing the helper extension method.. the helper method is only really adding the default partial name... https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Web.Common/Extensions/BlockGridTemplateExtensions.cs#L107-L108
then in items.cshtml
pass the VDD on again
@await Html.PartialAsync(partialViewName, item, ViewData)
now in your blockgrid component renderer you can access ViewData["area"]
giving you the area alias in the component.Mike Chambers
05/29/2024, 2:28 PMBjarne Fyrstenborg
05/29/2024, 3:51 PMMike Chambers
05/29/2024, 4:26 PM