Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/BootstrapBlazor.Server/Components/Samples/ListViews.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<BodyTemplate>
<Card>
<BodyTemplate>
<img class="lv-demo-img" src="@context.ImageUrl" />
<img src="@context.ImageUrl" />
<div class="lv-demo-desc">@context.Description</div>
</BodyTemplate>
</Card>
Expand All @@ -42,7 +42,7 @@
<BodyTemplate>
<Card>
<BodyTemplate>
<img class="lv-demo-img" src="@context.ImageUrl" />
<img src="@context.ImageUrl" />
<div class="lv-demo-desc">@context.Description</div>
</BodyTemplate>
</Card>
Expand All @@ -60,7 +60,7 @@
<BodyTemplate>
<Card>
<BodyTemplate>
<img class="lv-demo-img" src="@context.ImageUrl" />
<img src="@context.ImageUrl" />
<div class="lv-demo-desc">@context.Description</div>
</BodyTemplate>
</Card>
Expand All @@ -78,7 +78,7 @@
<BodyTemplate>
<Card>
<BodyTemplate>
<img class="lv-demo-img" src="@context.ImageUrl" />
<img src="@context.ImageUrl" />
<div class="lv-demo-desc">@context.Description</div>
</BodyTemplate>
</Card>
Expand All @@ -96,7 +96,7 @@
<BodyTemplate>
<Card>
<BodyTemplate>
<img class="lv-demo-img" src="@context.ImageUrl" />
<img src="@context.ImageUrl" />
<div class="lv-demo-desc">@context.Description</div>
</BodyTemplate>
</Card>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.lv-demo-img {
width: 100%;
img {
margin-bottom: 1rem;
border-radius: var(--bs-border-radius);
}

Expand Down
43 changes: 24 additions & 19 deletions src/BootstrapBlazor/Components/ListView/ListView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
{
if (GroupName == null)
{
@RenderGroup(Rows)
foreach (var item in Rows)
{
@RenderItem(item)
}
}
else if (Collapsible)
{
Expand All @@ -32,8 +35,11 @@
{
<div @key="@key.GroupName" class="accordion-item">
<div class="accordion-header">@key.GroupName</div>
<div class="accordion-body">
@RenderGroup(key.Items)
<div class="accordion-body scroll">
@foreach (var item in key.Items)
{
@RenderItem(item)
}
</div>
</div>
}
Expand Down Expand Up @@ -65,21 +71,20 @@
</div>

@code {
RenderFragment RenderItem((object? GroupName, IOrderedEnumerable<TItem> Items) key, int index) =>
@<CollapseItem Text="@GetGroupName(key.GroupName)" IsCollapsed="IsCollapsed(index, key.GroupName)">
@RenderGroup(key.Items)
</CollapseItem>;

RenderFragment<IEnumerable<TItem>> RenderGroup => items =>
@<div class="listview-item-group">
@foreach (var item in items)
{
<div @key="item" class="listview-item" @onclick="@(e => OnClick(item))">
@if(BodyTemplate != null)
{
@BodyTemplate(item)
}
</div>
}
</div>;
RenderFragment RenderGroupItem((object? GroupName, IOrderedEnumerable<TItem> Items) key, int index) =>
@<CollapseItem Text="@GetGroupName(key.GroupName)" IsCollapsed="IsCollapsed(index, key.GroupName)">
@foreach (var item in key.Items)
{
@RenderItem(item)
}
</CollapseItem>;

RenderFragment<TItem> RenderItem => item =>
@<div @key="item" class="listview-item" @onclick="@(e => OnClick(item))">
@if(BodyTemplate != null)
{
@BodyTemplate(item)
}
</div>;
}
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/ListView/ListView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private RenderFragment RenderCollapsibleItems(Func<TItem, object?> groupFunc) =>
foreach (var key in GetGroupItems(groupFunc))
{
var i = index++;
builder.AddContent(i, RenderItem(key, i));
builder.AddContent(i, RenderGroupItem(key, i));
}
};

Expand Down
33 changes: 25 additions & 8 deletions src/BootstrapBlazor/Components/ListView/ListView.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
--bb-lv-item-border-hover-color: #{$bb-lv-item-border-hover-color};
--bb-lv-item-shadow: #{$bb-lv-item-shadow};
--bb-lv-body-padding: #{$bb-lv-body-padding};
--bb-lv-body-item-gap: #{$bb-lv-body-item-gap};
--bb-lv-body-item-margin: #{$bb-lv-body-item-margin};
--bb-lv-footer-padding: #{$bb-lv-footer-padding};
border: 1px solid var(--bb-lv-border-color);
border-radius: var(--bs-border-radius);
Expand All @@ -29,17 +29,24 @@
.listview .listview-body {
padding: var(--bb-lv-body-padding);
position: relative;
overflow: auto;
display: flex;
flex-flow: row wrap;
flex: 1;
min-height: 0;
align-content: flex-start;
height: 1%;
min-height: 0;
}

.listview .listview-body.is-group {
padding: 0;
}

.listview .listview-body .listview-item {
margin: var(--bb-lv-body-item-margin);
}

.listview .listview-body .listview-item .card {
box-shadow: var(--bb-lv-item-shadow);
transition: var(--bb-lv-item-trans);
}

Expand All @@ -48,11 +55,15 @@
border: 1px solid var(--bb-lv-item-border-hover-color);
}

.listview .listview-item-group {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: var(--bb-lv-body-item-gap);
align-items: start;
.listview .listview-body .listview-item .card {
box-shadow: var(--bb-lv-item-shadow);
}

.listview .listview-body .listview-item-group {
flex-basis: 100%;
margin: 1rem 0;
font-weight: bold;
position: relative;
}

.listview .listview-body .accordion {
Expand All @@ -71,9 +82,15 @@
}

.listview .listview-body .accordion-body {
display: flex;
flex-wrap: wrap;
padding: var(--bb-lv-body-padding);
}

.listview .listview-body .accordion-item {
width: 100%;
}

.listview .listview-body .accordion-item:last-child .accordion-header {
border-bottom: 1px solid var(--bb-lv-border-color);
}
Expand Down
6 changes: 3 additions & 3 deletions src/BootstrapBlazor/wwwroot/scss/theme/bootstrapblazor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ $bb-lv-border-color: var(--bs-border-color);
$bb-lv-item-trans: border .3s linear;
$bb-lv-item-border-hover-color: #409eff;
$bb-lv-item-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
$bb-lv-body-padding: 0.5rem;
$bb-lv-body-item-gap: 0.5rem;
$bb-lv-footer-padding: 0.5rem;
$bb-lv-body-padding: 1rem 0 0 1rem;
$bb-lv-body-item-margin: 0 1rem 1rem 0;
$bb-lv-footer-padding: 1rem;

// Logout
$bb-logout-avatar-width: 42px;
Expand Down