diff --git a/BitBlazor.sln b/BitBlazor.sln index 6fde770..240f987 100644 --- a/BitBlazor.sln +++ b/BitBlazor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 18 -VisualStudioVersion = 18.0.11123.170 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}" EndProject @@ -36,6 +36,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "components", "components", docs\components\alert.md = docs\components\alert.md docs\components\avatar.md = docs\components\avatar.md docs\components\badge.md = docs\components\badge.md + docs\components\breadcrumb.md = docs\components\breadcrumb.md docs\components\button-badge.md = docs\components\button-badge.md docs\components\button.md = docs\components\button.md docs\components\card.md = docs\components\card.md diff --git a/docs/README.md b/docs/README.md index a209638..028988e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -37,6 +37,11 @@ Small and adaptable labels for adding information. - Support for rounded shapes - Various colors available +#### [Breadcrumb](components/breadcrumb.md) +Breadcrumb navigation component to display the current location within a hierarchy. +- Support for the customization of items and the separator +- Accessibility support + #### [Button](components/button.md) Interactive buttons with support for icons and different styles. - Solid and outline variants diff --git a/docs/components/breadcrumb.md b/docs/components/breadcrumb.md new file mode 100644 index 0000000..5c49722 --- /dev/null +++ b/docs/components/breadcrumb.md @@ -0,0 +1,153 @@ +# BitBreadcrumb + +The `BitBreadcrumb` component renders a [breadcrumb navigation](https://getbootstrap.com/docs/5.3/components/breadcrumb/) to display the user's current location within a hierarchy, supporting customization of items, separators, and accessibility features. + +## Namespace + +```csharp +BitBlazor.Components +``` + +## Description + +The Breadcrumb component provides a navigational aid that helps users understand and navigate the hierarchy of a website or application. It displays the current page's location within a navigational hierarchy and allows users to quickly move to previous levels. + +## Parameters + +| Name | Type | Required | Default | Description | +|-----------|--------------------------------------|----------|---------|-----------------------------------------------------------------------------| +| `Label` | `string?` | ✗ | `null` | The ARIA label for the breadcrumb component, improving accessibility. | +| `Items` | `IReadOnlyList` | ✓ | empty list | The collection of breadcrumb items to display. | +| `Separator` | `string?` | ✗ | `"/"` | The separator string shown between breadcrumb items. | +| `Dark` | `bool` | ✗ | `false` | Indicates if the breadcrumb is rendered on a dark background. | + +## BitBreadcrumbItem + +Each breadcrumb item is represented by a `BitBreadcrumbItem` object. Typically, this includes properties such as: + +| Property | Type | Description | +|------------|----------|---------------------------------------------| +| `Text` | `string` | The display text for the breadcrumb item. (Default empty string) | +| `Href` | `string` | The URL to navigate to when the item is clicked. (Default `"#"`, optional for the last item) | +| `Icon` | `string?` | The icon to show before the item (Optional) | + +> **Note:** The last item in the `Items` list is considered the current page and is not rendered as a link. + +## Usage Examples + +### Basic breadcrumb + +C#: +```csharp + List items = + [ + new BitBreadcrumbItem { Text = "Home", Link = "#" }, + new BitBreadcrumbItem { Text = "Category", Link = "#" }, + new BitBreadcrumbItem { Text = "Subcategory", Link = "#" }, + new BitBreadcrumbItem { Text = "Item" } + ]; +``` + +Razor: +```razor + +``` + +### Breadcrumb with custom separator + +C#: +```csharp + List items = + [ + new BitBreadcrumbItem { Text = "Home", Link = "#" }, + new BitBreadcrumbItem { Text = "Category", Link = "#" }, + new BitBreadcrumbItem { Text = "Subcategory", Link = "#" }, + new BitBreadcrumbItem { Text = "Item" } + ]; +``` + +Razor: +```razor + +``` + +### Breadcrumb with icons + +C#: +```csharp + List items = + [ + new BitBreadcrumbItem { Text = "Home", Link = "#", Icon= BitBlazor.Utilities.Icons.ItLink }, + new BitBreadcrumbItem { Text = "Category", Link = "#", Icon= BitBlazor.Utilities.Icons.ItLink }, + new BitBreadcrumbItem { Text = "Subcategory", Link = "#", Icon= BitBlazor.Utilities.Icons.ItLink }, + new BitBreadcrumbItem { Text = "Item", Icon= BitBlazor.Utilities.Icons.ItLink } + ]; +``` + +Razor: +```razor + +``` + +### Breadcrumb with dark background + +C# +```csharp + List items = + [ + new BitBreadcrumbItem { Text = "Home", Link = "#" }, + new BitBreadcrumbItem { Text = "Category", Link = "#" }, + new BitBreadcrumbItem { Text = "Subcategory", Link = "#" }, + new BitBreadcrumbItem { Text = "Item" } + ]; +``` + +Razor: +```razor + +``` + + +## Accessibility + +- The `Label` parameter sets the `aria-label` attribute for the breadcrumb navigation, enhancing accessibility for assistive technologies. + +## Generated CSS Classes + +The component generates the following CSS classes based on parameters: + +- `breadcrumb`: Base class for the breadcrumb container. +- `dark`: Added when `Dark` is `true`. +- `px-3`: Added when `Dark` is `true` for horizontal padding. + +## Generated HTML Structure + +```html + +``` + + +## Notes + +- The `Separator` parameter allows customization of the character or string used between breadcrumb items. +- When `Dark` is set to `true`, additional CSS classes are applied for better contrast on dark backgrounds. +- The last item in the `Items` list is rendered as plain text to indicate the current page. +- If `Items` is `null` or empty, the component renders nothing. \ No newline at end of file diff --git a/src/BitBlazor/Components/Breadcrumb/BitBreadcrumb.razor b/src/BitBlazor/Components/Breadcrumb/BitBreadcrumb.razor new file mode 100644 index 0000000..4bc1f04 --- /dev/null +++ b/src/BitBlazor/Components/Breadcrumb/BitBreadcrumb.razor @@ -0,0 +1,52 @@ +@namespace BitBlazor.Components + +@inherits BitComponentBase + + + + + + +@code { + + /// + /// Gets the item icon fragment, if specified. + /// + private RenderFragment BreadcrumbIconFragment(BitBreadcrumbItem item) => __builder => + { + @if (item.HasIcon()) + { + if (!Dark) + { +