ni / nimble

The NI Nimble Design System
https://nimble.ni.dev
MIT License
32 stars 8 forks source link

Use strong typing for blazor components #751

Open rajsite opened 2 years ago

rajsite commented 2 years ago

😯 Problem to Solve

The blazor component wrappers leverage the CaptureUnmatchedValues feature to allow users to set arbitrary html attributes that are forwarded to the nimble component. For example:

<NimbleBreadcrumbItem class="my-class">Page 1</NimbleBreadcrumbItem>

However, this is untyped, lets users set arbitrary attributes, and lets users accidentally use untyped attributes instead of typed equivalents, ie:

<NimbleBreadcrumbItem href="#">Page 1</NimbleBreadcrumbItem>

instead of:

<NimbleBreadcrumbItem Href="#">Page 1</NimbleBreadcrumbItem>

Having loose typing makes it easier to accidentally break applications when refactoring / upgrading nimble.

In addition Microsoft warns about performance issues using CaptureUnmatchedValues.

A trade-off that may need to be documented is that users will not be able to leverage arbitrary data-* attributes in the strict template approach. See original discussion https://github.com/ni/nimble/pull/738#discussion_r971347578

💁 Proposed Solution

  1. Remove usage of CaptureUnmatchedValues from our blazor components
  2. Create a base class for the common shared attributes we want to enable like Class, Id, Slot, Name, etc

📋 Tasks

rajsite commented 1 year ago

Some additional discussion points: