Skip to content

Commit c94c5c6

Browse files
v3.3.6
1 parent 5e3da85 commit c94c5c6

File tree

18 files changed

+226
-54
lines changed

18 files changed

+226
-54
lines changed

.github/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ The Umbraco v15 version of this package is [available via NuGet](https://www.nug
2222
To install the package, you can use either .NET CLI:
2323

2424
```
25-
dotnet add package Umbraco.Community.BlockPreview --version 3.3.5
25+
dotnet add package Umbraco.Community.BlockPreview --version 3.3.6
2626
```
2727

2828
or the NuGet Package Manager:
2929

3030
```
31-
Install-Package Umbraco.Community.BlockPreview -Version 3.3.5
31+
Install-Package Umbraco.Community.BlockPreview -Version 3.3.6
3232
```
3333

3434
## Setup

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.5
1+
3.3.6
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Umbraco.Cms.Core.Models.Blocks;
3+
using Umbraco.Cms.Web.Common.PublishedModels;
4+
5+
namespace Umbraco.Cms._15.x.ViewComponents
6+
{
7+
public class HeroBlockViewComponent : ViewComponent
8+
{
9+
public IViewComponentResult Invoke(BlockGridItem<HeroBlock, BlockSettings> model)
10+
{
11+
return View(model);
12+
}
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@inherits UmbracoViewPage<BlockGridItem<HeroBlock, BlockSettings>>
2+
3+
@await Html.PartialAsync("/Views/Partials/blockGrid/Components/heroBlock.cshtml", Model)

src/Umbraco.Cms.15.x/Views/Partials/blockgrid/Components/cardBlock.cshtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
@using System.Text.Json
22
@inherits UmbracoViewPage<BlockGridItem<CardBlock>>
33

4-
<pre>Block Index: @ViewData["blockIndex"]</pre>
5-
64
<div class="card @(Model.ColumnSpan == 6 ? "--medium" : null)">
75

86
<div class="card-media">

src/Umbraco.Cms.15.x/Views/Partials/blockgrid/Components/heroBlock.cshtml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
var hasBrightContrast = Model.Content.Contrast == "#ffffff";
66
}
77

8-
@* <pre>Dropdown: @Model.Content.Height</pre> *@
9-
@* <pre>Content Picker: @Model.Content.ContentPicker?.Name (@Model.Content.ContentPicker?.Url())</pre> *@
10-
<pre>MNTP: @Model.Content.Mntp?.Name() (@Model.Content.Mntp?.Id)</pre>
11-
@* <pre>MNTP: @(string.Join(", ", Model.Content.Mntp.Select(x => x.Name))) (@(string.Join(", ", Model.Content.Mntp.Select(x => x.Id))))</pre> *@
12-
@* <pre>Settings Dropdown: @Model.Settings?.Dropdown</pre> *@
13-
148
<div
159
class="hero"
1610
style="background-color:@backgroundColor"

src/Umbraco.Cms.15.x/Views/Partials/blockgrid/items.cshtml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1-
@inherits UmbracoViewPage<IEnumerable<BlockGridItem>>
1+
@inject Microsoft.AspNetCore.Mvc.ViewComponents.IViewComponentSelector Selector
2+
@inherits UmbracoViewPage<IEnumerable<BlockGridItem>>
23
@{
34
if (Model?.Any() != true) { return; }
45
}
56

67
<div class="umb-block-grid__layout-container">
78
@foreach (var item in Model)
8-
{
9-
<div
10-
class="umb-block-grid__layout-item"
11-
data-content-element-type-alias="@item.Content.ContentType.Alias"
12-
data-content-element-type-key="@item.Content.ContentType.Key"
13-
data-element-udi="@item.ContentUdi"
14-
data-col-span="@item.ColumnSpan"
15-
data-row-span="@item.RowSpan"
16-
style=" --umb-block-grid--item-column-span: @item.ColumnSpan; --umb-block-grid--item-row-span: @item.RowSpan; ">
9+
{
10+
<div class="umb-block-grid__layout-item"
11+
data-content-element-type-alias="@item.Content.ContentType.Alias"
12+
data-content-element-type-key="@item.Content.ContentType.Key"
13+
data-element-udi="@item.ContentUdi"
14+
data-col-span="@item.ColumnSpan"
15+
data-row-span="@item.RowSpan"
16+
style=" --umb-block-grid--item-column-span: @item.ColumnSpan; --umb-block-grid--item-row-span: @item.RowSpan; ">
1717
@{
18-
var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias;
19-
try
18+
var viewAlias = item.Content.ContentType.Alias.ToFirstUpper();
19+
var viewComponent = Selector.SelectComponent(viewAlias);
20+
if (viewComponent != null)
2021
{
21-
@await Html.PartialAsync(partialViewName, item)
22+
@await Component.InvokeAsync(viewComponent.TypeInfo.AsType(), item)
2223
}
23-
catch (InvalidOperationException)
24+
else
2425
{
25-
<p>
26-
<strong>Could not render component of type: @(item.Content.ContentType.Alias)</strong>
27-
<br/>
28-
This likely happened because the partial view <em>@partialViewName</em> could not be found.
29-
</p>
26+
var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias;
27+
try
28+
{
29+
@await Html.PartialAsync(partialViewName, item)
30+
}
31+
catch (InvalidOperationException)
32+
{
33+
<p>
34+
<strong>Could not render component of type: @(item.Content.ContentType.Alias)</strong>
35+
<br />
36+
This likely happened because the partial view <em>@partialViewName</em> could not be found.
37+
</p>
38+
}
3039
}
3140
}
3241
</div>

src/Umbraco.Cms.15.x/Views/Partials/blocklist/Components/heroBlock.cshtml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
var hasBrightContrast = Model.Content.Contrast == "#ffffff";
66
}
77

8-
<pre>Dropdown: @Model.Content.Height</pre>
9-
<pre>Content Picker: @Model.Content.ContentPicker?.Name (@Model.Content.ContentPicker?.Url())</pre>
10-
118
<div
129
class="hero"
1310
style="background-color:@backgroundColor"

src/Umbraco.Cms.15.x/Views/Partials/richtext/Components/heroBlock.cshtml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
var hasBrightContrast = Model.Content.Contrast == "#ffffff";
66
}
77

8-
<pre>Dropdown: @Model.Content.Height</pre>
9-
<pre>Content Picker: @Model.Content.ContentPicker?.Name (@Model.Content.ContentPicker?.Url())</pre>
10-
118
<div
129
class="hero"
1310
style="background-color:@backgroundColor"
@@ -17,7 +14,6 @@
1714
<div class="hero-background" style="background-image: url(@image.GetCropUrl(width:3840))">
1815
</div>
1916
}
20-
2117

2218
<div class="hero-content">
2319
<h1>@Model.Content.Headline</h1>

src/Umbraco.Cms.15.x/uSync/v15/Content/home.config

Lines changed: 167 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,179 @@
66
<Trashed>false</Trashed>
77
<ContentType>blockGrid</ContentType>
88
<CreateDate>2024-04-22T19:48:27</CreateDate>
9-
<NodeName Default="Home" />
9+
<NodeName Default="Home">
10+
<Name Culture="en-GB">Home</Name>
11+
<Name Culture="en-US">Home</Name>
12+
</NodeName>
1013
<SortOrder>0</SortOrder>
11-
<Published Default="true" />
14+
<Published Default="true">
15+
<Published Culture="en-GB">false</Published>
16+
<Published Culture="en-US">true</Published>
17+
</Published>
1218
<Schedule />
1319
<Template Key="09acf55b-fdd0-4cda-86fa-fa2caef695a9">BlockGrid</Template>
1420
</Info>
1521
<Properties>
1622
<content>
17-
<Value><![CDATA[{
23+
<Value Culture="en-GB"><![CDATA[{
24+
"contentData": [
25+
{
26+
"contentTypeKey": "432b58a8-01b7-47dc-8664-f72bf1045f66",
27+
"key": "cd1dc3c2-bf4f-4866-83a8-3caa87f1a38a",
28+
"udi": null,
29+
"values": [
30+
{
31+
"alias": "image",
32+
"culture": null,
33+
"editorAlias": null,
34+
"segment": null,
35+
"value": [
36+
{
37+
"key": "c134f606-d8c0-4f66-adaf-19e743d5872c",
38+
"mediaKey": "8bf1f902-53a2-498e-a48b-26e35d42df57",
39+
"mediaTypeAlias": "Image",
40+
"crops": [],
41+
"focalPoint": null
42+
}
43+
]
44+
},
45+
{
46+
"alias": "headline",
47+
"culture": null,
48+
"editorAlias": null,
49+
"segment": null,
50+
"value": "Five ways to reduce your greenhouse gas emissions"
51+
},
52+
{
53+
"alias": "backgroundColor",
54+
"culture": null,
55+
"editorAlias": null,
56+
"segment": null,
57+
"value": {
58+
"value": "062726",
59+
"label": "062726",
60+
"sortOrder": 6,
61+
"id": "7"
62+
}
63+
},
64+
{
65+
"alias": "contrast",
66+
"culture": null,
67+
"editorAlias": null,
68+
"segment": null,
69+
"value": {
70+
"label": "ffffff",
71+
"value": "#ffffff"
72+
}
73+
},
74+
{
75+
"alias": "contentPicker",
76+
"culture": null,
77+
"editorAlias": null,
78+
"segment": null,
79+
"value": "umb://document/6e2ff1f7114e484ba407918daded1aa6"
80+
},
81+
{
82+
"alias": "height",
83+
"culture": null,
84+
"editorAlias": null,
85+
"segment": null,
86+
"value": [
87+
"150"
88+
]
89+
},
90+
{
91+
"alias": "mntp",
92+
"culture": null,
93+
"editorAlias": null,
94+
"segment": null,
95+
"value": "umb://document/752e3c1cf713449aa54f10f1ab447e63"
96+
}
97+
]
98+
},
99+
{
100+
"contentTypeKey": "1d05aa7a-16bd-4f3f-b094-023fd0bf0332",
101+
"key": "5df9521b-1cc5-4077-bc69-8f7ea4e0959e",
102+
"udi": null,
103+
"values": [
104+
{
105+
"alias": "link",
106+
"culture": null,
107+
"editorAlias": null,
108+
"segment": null,
109+
"value": [
110+
{
111+
"name": "See our solutions",
112+
"target": null,
113+
"udi": "umb://document/6ac5363ad8124ce9aa893a3973426c70",
114+
"url": null,
115+
"queryString": null
116+
}
117+
]
118+
}
119+
]
120+
}
121+
],
122+
"settingsData": [
123+
{
124+
"contentTypeKey": "cb6adf93-9c01-476c-970b-7469474db5b4",
125+
"key": "aaca4393-67da-44f5-8854-e5720209d5e1",
126+
"udi": null,
127+
"values": [
128+
{
129+
"alias": "dropdown",
130+
"culture": null,
131+
"editorAlias": null,
132+
"segment": null,
133+
"value": [
134+
"100"
135+
]
136+
}
137+
]
138+
}
139+
],
140+
"expose": [
141+
{
142+
"contentKey": "cd1dc3c2-bf4f-4866-83a8-3caa87f1a38a",
143+
"culture": null,
144+
"segment": null
145+
},
146+
{
147+
"contentKey": "5df9521b-1cc5-4077-bc69-8f7ea4e0959e",
148+
"culture": null,
149+
"segment": null
150+
}
151+
],
152+
"Layout": {
153+
"Umbraco.BlockGrid": [
154+
{
155+
"areas": [
156+
{
157+
"items": [
158+
{
159+
"areas": [],
160+
"columnSpan": 6,
161+
"contentKey": "5df9521b-1cc5-4077-bc69-8f7ea4e0959e",
162+
"contentUdi": null,
163+
"rowSpan": 1,
164+
"settingsKey": null,
165+
"settingsUdi": null
166+
}
167+
],
168+
"key": "3b490f17-1471-4ac4-9434-60e676639e29"
169+
}
170+
],
171+
"columnSpan": 12,
172+
"contentKey": "cd1dc3c2-bf4f-4866-83a8-3caa87f1a38a",
173+
"contentUdi": null,
174+
"rowSpan": 1,
175+
"settingsKey": "aaca4393-67da-44f5-8854-e5720209d5e1",
176+
"settingsUdi": null
177+
}
178+
]
179+
}
180+
}]]></Value>
181+
<Value Culture="en-US"><![CDATA[{
18182
"contentData": [
19183
{
20184
"contentTypeKey": "432b58a8-01b7-47dc-8664-f72bf1045f66",

0 commit comments

Comments
 (0)