|
1 | | -# Blazor.SimpleGrid |
| 1 | +# Blazor.SimpleGrid |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +A modern, lightweight Blazor component library for creating **CSS Grid Layouts**. Define complex structures directly in Razor syntax without writing manual CSS. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- Type-Safe: Use Enums for alignments and flows instead of error-prone strings. |
| 14 | +- Intuitive Areas: Define layout zones with a simple pipe syntax (header | content). |
| 15 | +- Smart Logic: Automatic prioritization of Gap over individual spacing properties. |
| 16 | +- Flexible: Full support for Attribute Splatting (CSS classes, IDs, etc.). |
| 17 | +- Lightweight: No external CSS frameworks or JavaScript dependencies required. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +1. Install the package via NuGet: |
| 24 | + `dotnet add package Blazor.SimpleGrid` |
| 25 | + |
| 26 | +2. Add the namespace to your _Imports.razor: |
| 27 | + `@using Blazor.SimpleGrid.Components` |
| 28 | + `@using Blazor.SimpleGrid.Enums` |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +### Simple 3-Column Grid |
| 35 | +```razor |
| 36 | +<SimpleGrid Columns="1fr 1fr 1fr" Gap="20px"> |
| 37 | + <SimpleGridItem>Item 1</SimpleGridItem> |
| 38 | + <SimpleGridItem>Item 2</SimpleGridItem> |
| 39 | + <SimpleGridItem>Item 3</SimpleGridItem> |
| 40 | +</SimpleGrid> |
| 41 | +``` |
| 42 | + |
| 43 | +### Complex Layout with Template Areas |
| 44 | +```razor |
| 45 | +<SimpleGrid Columns="250px 1fr" |
| 46 | + TemplateAreas="header header | sidebar content | footer footer" |
| 47 | + Gap="15px"> |
| 48 | + |
| 49 | + <SimpleGridItem Area="header">Header</SimpleGridItem> |
| 50 | + <SimpleGridItem Area="sidebar">Nav</SimpleGridItem> |
| 51 | + <SimpleGridItem Area="content">Main</SimpleGridItem> |
| 52 | + <SimpleGridItem Area="footer">Footer</SimpleGridItem> |
| 53 | +</SimpleGrid> |
| 54 | +``` |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## Configuration |
| 59 | + |
| 60 | +### SimpleGrid (Container) |
| 61 | +- Columns: string (e.g., "1fr 100px") |
| 62 | +- Rows: string (optional) |
| 63 | +- Gap: string (combined shorthand) |
| 64 | +- TemplateAreas: string (separated by |) |
| 65 | +- Horizontal: HorizontalAlignment Enum |
| 66 | +- AutoFlow: GridAutoFlow Enum |
| 67 | + |
| 68 | +### SimpleGridItem (Element) |
| 69 | +- Area: string (assigned area name) |
| 70 | +- ColumnSpan: int (span count) |
| 71 | +- RowSpan: int (span count) |
| 72 | +- Horizontal: HorizontalAlignment (Self) |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## Quality Assurance |
| 77 | + |
| 78 | +Verified by an automated test suite using bUnit and NUnit. |
| 79 | +Run tests locally with: `dotnet test` |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## License |
| 84 | + |
| 85 | +MIT License. See LICENSE file for details. |
0 commit comments