All Projects → EngstromJimmy → Blazm.components

EngstromJimmy / Blazm.components

A few useful and awesome components for Blazor. Blazor + awesome (azm)=Blazm (Blossom)

Projects that are alternatives of or similar to Blazm.components

Bojler
Bojler is an email framework
Stars: ✭ 885 (+2951.72%)
Mutual labels:  grid, scss
Griddd
A dead simple, customisable, flexbox-based griddd
Stars: ✭ 108 (+272.41%)
Mutual labels:  grid, scss
Interior
Design system for the modern web.
Stars: ✭ 77 (+165.52%)
Mutual labels:  grid, scss
Baseguide
Lightweight and robust CSS framework for prototyping and production code.
Stars: ✭ 127 (+337.93%)
Mutual labels:  grid, scss
Blueprint Css
📘 Blueprint CSS is a modern responsive CSS layout library & grid built on top of CSS Grid and Flexbox.
Stars: ✭ 233 (+703.45%)
Mutual labels:  grid, scss
Lemonade
simple flexible grid
Stars: ✭ 457 (+1475.86%)
Mutual labels:  grid, scss
Gridlex
Just a CSS Flexbox Grid System
Stars: ✭ 1,328 (+4479.31%)
Mutual labels:  grid, scss
Flexible Grid
Flexible grid layouts to get you familiar with building within the flexible grid system.(HTML, CSS, SASS, SCSS)
Stars: ✭ 154 (+431.03%)
Mutual labels:  grid, scss
Iota
A responsive micro-framework for the grid spec powered by CSS custom properties.
Stars: ✭ 189 (+551.72%)
Mutual labels:  grid, scss
Blazortable
Blazor Table Component with Sorting, Paging and Filtering
Stars: ✭ 249 (+758.62%)
Mutual labels:  nuget, grid
Neat
Neat is maintained by the thoughtbot design team. It is funded by thoughtbot, inc. and the names and logos for thoughtbot are trademarks of thoughtbot, inc.
Stars: ✭ 4,506 (+15437.93%)
Mutual labels:  grid, scss
Swiftui Grid
🚀 SwiftUI Grid layout with custom styles
Stars: ✭ 872 (+2906.9%)
Mutual labels:  grid
Font Awesome Animation
Simple animations using FontAwesome and some CSS3.
Stars: ✭ 856 (+2851.72%)
Mutual labels:  scss
Core
A canvas-based super high performant grid renderer API
Stars: ✭ 857 (+2855.17%)
Mutual labels:  grid
Sierra
Sierra SCSS library
Stars: ✭ 852 (+2837.93%)
Mutual labels:  scss
React Redux Saga Starter
Basic, Opinionated starter kit for React+Redux+Redux Saga with support for SCSS CSS Modules, Storybook, JEST testing, and ESLint
Stars: ✭ 12 (-58.62%)
Mutual labels:  scss
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+24375.86%)
Mutual labels:  nuget
Gridiron
Feature-Packed React Grid Framework
Stars: ✭ 8 (-72.41%)
Mutual labels:  grid
Gulp Frontnote
スタイルガイドジェネレーターFrontNoteのGulpプラグイン
Stars: ✭ 7 (-75.86%)
Mutual labels:  scss
Mozilla Iot.github.io
Mozilla IoT Website
Stars: ✭ 21 (-27.59%)
Mutual labels:  scss

How to use Blazm

I promised myself that I wouldn't build another component library. But for different reasons I had to build a Grid component (and some other components), and why not share that with others? So here it is, my component library.

The company me and my wife run is called Azm Dev (Awesome dev). Blazor + Azm == Blazm and it will make you site blazm (blossom). I know.. I like puns.

Blazm

Components

BlazmGrid

Forecast sample using Blazm

<BlazmGrid Data="forecasts" PageSize="10" Sortable="true" SortField="@nameof(WeatherForecast.Date)">
    <GridColumns>
        <GridColumn Field="@nameof(WeatherForecast.Date)" Format="{0:d}"  Priority="3"/>
        <GridColumn Field="@nameof(WeatherForecast.TemperatureC)" HighlightSign="true" Priority="1" Class="alignRight" />
        <GridColumn Field="@nameof(WeatherForecast.TemperatureF)" Priority="2" Class="alignRight"/>
        <GridColumn Field="@nameof(WeatherForecast.Summary)"  Priority="0"/>
    </GridColumns>
</BlazmGrid>

Sponsors

Thanks you to much to my sponsors!

Telerik UI for Blazor – Increase productivity and cut cost in half! Use the Telerik truly native Blazor UI components to cover any app scenario. Give it a try.

How to get started

Prerequisites

At this point the library is using Bootstrap.
This might change in the future but for now you will need Bootstrap.
It is also using FontAwesome so make sure you reference that as well.

In Startup.cs

  1. Add services.AddBlazm();
    This adds the necessary things for the grid to be responsive.

In your .Razor file

  1. Add using Blazm.Components
  2. Add your grid
<BlazmGrid Data="TestData" PageSize="10">
    <GridColumns>
        <GridColumn Field="@nameof(TestClass.String)" Title="A string from property"></GridColumn>
        <GridColumn Field="@nameof(TestClass.Double)"></GridColumn>
        <GridColumn Field="@nameof(TestClass.Date)"></GridColumn>
    </GridColumns>
</BlazmGrid>

Add Script and Styles

In Pages/_Host.cshtml

  1. Inside the head tag add <link href="_content/Blazm.Components/css/styles.min.css" rel="stylesheet" />
  2. After the script tag (towards the bottom of the page) referring to blazor.server.js. Add
<script src="_content/BlazorPro.BlazorSize/blazorSize.min.js"></script>

In program.cs

  1. Add webBuilder.UseStaticWebAssets();

Grid Features

Paging

By specifying a number in the PageSize property the grid will add next and previous buttons and page the data.

Sorting

To sort the grid use SortField="@nameof(TestClass.Double)" to sort your grid. If you want to enable the user to sort the grid use Sortable="true". Set the default sort direction by setting the SortDirection parameter

This works with grouped lists as well. To sort the grouping you can use GroupSortField="@nameof(TestClass.Double)"

Checkboxes

Use ShowCheckbox="true" to show checkboxes on every row. Use @bind-SelectedData="SelectedTestData" to get the selected items.

Grouping

To add grouping set the data as usual (without grouping) and set the GroupBy-parameter.

GroupBy="d=>d.Group"

Group header

If you group your grid you can add a group header. It will add a table row with the content in the template. Context is the group key.

<GroupHeader>
    <h5>@context</h5>
<GroupHeader>

Footer

Footers are available in grouped segments and for the whole table. In the GroupFooterTemplate the context-variable is a List containing all the data in that group.

<GroupFooterTemplate>
    var h = context as List<TestClass>;
    @h.Sum(r => r.Double).ToString("N0")
</GroupFooterTemplate>

Will sum all the Double-field in that group.

FooterTemplate will get a List containing all the rows in the table.

<FooterTemplate>
    var h = context as List<TestClass>;
    @h.Sum(r => r.Double).ToString("N0")
</FooterTemplate>

Will sum ALL the double-fields in the entire table.

<GridColumn Field="@nameof(TestClass.Double)" Format="{0:N2}">
    <GroupFooterTemplate>
        @{
            var h = context as List<TestClass>;
            @h.Sum(r => r.Double).ToString("N0")
        }
    </GroupFooterTemplate>
    <FooterTemplate>
        @{
            var h = context as List<TestClass>;
            @h.Sum(r => r.Double).ToString("N0")
        }
    </FooterTemplate>
</GridColumn>

Empty Grid Template

By supplying an EmptyGridTemplate you can specify if there should be any text shown it the grid is empty.

<EmptyGridTemplate>
    No data found
</EmptyGridTemplate>

Null Grid Template

By supplying an NullGridTemplate you can specify if there should be any text shown it the grid has no data (typically while you load data).

<NullGridTemplate>
    Loading....
</NullGridTemplate>

Column features

Column header

The title of the column can be specified by using the title property but can also be specified using the Display-attribute

public class TestClass
{
    public string String { get; set; }
    [Display(Name = "Comes from attribute")]
    public double Double { get; set; }
    public DateTime Date { get; set; }
}

Format

To format the data, use the Format-property.

<GridColumn Field="@nameof(TestClass.Double)" Format="{0:N2}"></GridColumn>

Style

There are two ways of styling content. Class will set the class attribute on the header and data. HeaderClass will set the class attribute on the header. DataClass will set the class attribute on the data. If you want to align both data and header to the right add the class property.

<GridColumn  ... Class="alignRight" ... />

HighlightSign

To highlight the sign on a column set the HighlightSign to true. This will set the class .negative if the value is negative. It will set the class .positive if the value is positive and leave it alone of the value is zero. Use ValueNegativeClass and ValuePositiveClass to specify the classes used (if you want to).

Priority (Responsive)

By adding Priority to the columns the grid will become responsive and hide columns in the order of priority. Priority 0 is the highest priority which means the column will always be visible. It uses BlazorPro.BlazorSize by Ed Charbeneau to detect resize on the client. If a column is hidden, an icon will appear and the row will become expandable (to show the removed columns). The icon is customizable using ExpandTemplate and CollapseTemplate

Command columns

To add a column that is not connected to any field (like command buttons for example) just add a GridColumn without the Field-property.

<GridColumn>
    <Template>
        @{
            var item = context as WeatherForecast;
        }
        <button class="btn btn-danger" @onclick="@(async () => { await Delete(item); })"><i class="far fa-trash-alt"></i></button>
    </Template>
</GridColumn>

Export to Excel

The build-in support for exporting data to Excel will not us templated columns (it will render the value not the template). All columns will be exported by default. Add Exportable=false to exclude columns from the export.

<button class="btn btn-success" @onclick="@(async ()=> { await MyGrid.ExportDataAsync("Weather.xlsx","Export","yyyy-mm-dd"); })">Export data to Excel</button>
    
<BlazmGrid @ref="MyGrid" .......>
//Code removed for brevity

and in the code section add

private BlazmGrid<WeatherForecast> MyGrid;

WeatherForecast is the type of data you have in the grid.

Auto generate columns

If you want to auto generate columns you can do that by setting AutoGenerateColumns="true" The grid will then create columns for all the properties on your data object.

<BlazmGrid Data="forecasts" AutoGenerateColumns="true">
</BlazmGrid>

dynamic

You can use dynamic (ExpandoObject) with the grid. If you for example have a DataTable, convert it to dynamic and it will work with the grid.

DetailTemplate

By adding a DetailTemplate you can show details about the row. The details will show up as a row beneath the original row. The context is the row data of the row you expand.

<DetailTemplate>
    Details! @context.Summary
</DetailTemplate>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].