bitplatform Toolkit

repository·develop·Indexed 23 days ago

https://github.com/bitfoundation/bitplatform

A specialized toolkit for Blazor developers featuring high-performance UI components (bit BlazorUI), PWA capabilities via Bswup, C# access to Browser APIs through Butil, and offline data management using Besql (EF Core and SQLite in-browser). The toolkit also includes Bit.Bmotion for Blazor-native animations and Bit.BlazorES2019 for older browser compatibility.

Tokens
40.4K
Snippets
99
Records
183
Agent score
79%

What's inside bitplatform

  1. Overview of bit BlazorUI

    develop

    bit BlazorUI is a native, high-performance UI library for Blazor developed in C#. It is designed to be lightweight and independent of external JavaScript frameworks.

    Key Features:

    • Blazor Native: Built specifically for Blazor, ensuring a consistent development experience.
    • Universal Support: Works with Server, WASM, and Hybrid interactive modes.
    • High Performance: Optimized for low load times and fast rendering.
    • Open Source: Free to use and open for community contributions.
  2. Overview of bit Code Analyzers

    develop
    bit Code Analyzers are tools designed to enforce best practices within the bit platform ecosystem. They function by scanning source code to warn developers when patterns deviate from established standards—for example, recommending the use of DateTimeOffset instead of DateTime to ensure better temporal precision and consistency.
  3. Overview of bit Boilerplate

    develop
    bit Boilerplate is a free, open-source, full-stack, and cross-platform project template designed for C# and Blazor developers. It provides a battle-tested foundation for building modern web applications, cross-platform native apps, and cloud-ready systems. The template is highly modular, allowing developers to selectively choose features during project creation to match specific requirements.
  4. Overview of the bitplatform toolkit

    develop

    bitplatform is a comprehensive toolkit for Blazor development designed to provide high performance and a rich component library. The platform consists of several specialized tools:

    • bit BlazorUI components: A UI toolkit featuring over 80 components with support for both Dark and Light themes, optimized for a compact size (under 400 KB).
    • Bswup: A tool that implements Progressive Web App (PWA) capabilities using the .NET 8 structure, utilizing pre-rendering techniques to provide an experience similar to GitHub or Reddit.
    • Butil: A library that provides essential Browser APIs directly in C#, allowing developers to interact with browser functionality without writing JavaScript.
    • Besql: A solution for building offline web applications by incorporating Entity Framework Core and SQLite directly within the browser, enabling data saving and later synchronization.
    • Bit Boilerplate Project Template: A comprehensive template that integrates all the above tools along with ASP.NET Core Identity, multilingual support, and the ability to develop unified Web, Android, iOS, Windows, and macOS applications from a single codebase.
  5. Key features of bit Boilerplate

    develop

    bit Boilerplate includes a wide range of production-ready features:

    Web & Native Capabilities

    • Modern Web Apps: Supports SEO-friendly Blazor WebAssembly with pre-rendering, Admin Panels with real-time dashboards, and offline-capable PWAs.
    • Cross-Platform Native Apps: Uses .NET MAUI Blazor Hybrid to generate Android, iOS, Windows, and macOS applications from a single codebase.

    Data & Infrastructure

    • Client-Side Offline Database: Uses Entity Framework Core + SQLite on the client side with cross-platform data synchronization.
    • Advanced Caching: Supports In-memory, Redis, Hybrid (memory + Redis), Output, CDN Edge (Cloudflare), and Browser/Client device caching.
    • Storage: Flexible file storage options including Local, S3, and Azure Blob Storage.
    • Database Support: Entity Framework Core with support for SQL Server, PostgreSQL, MySQL, and SQLite.

    Security, AI, & Observability

    • Identity & Security: Includes Passwordless authentication, Two-factor authentication (2FA), and Single Sign-On (SSO).
    • GenAI & RAG: Built-in AI Chatbot integration and vectorized database search using embeddings.
    • Observability: Integrated with OpenTelemetry (tracing/metrics), Sentry (error tracking), and Azure Application Insights.
    • Localization: Multi-language support with built-in RTL (Right-to-Left) and LTR (Left-to-Right) layout capabilities.

    Modern Tech Stack

    • Core: ASP.NET Core 10, C# 14, and .NET Aspire.
    • CI/CD: Pre-configured pipelines for GitHub Actions and Azure DevOps.
  6. Check Platform Support and Capabilities

    develop

    Bit.Bmotion behavior varies depending on the Blazor hosting model:

    • Blazor WebAssembly: Fully supported. Compositor-eligible animations (tweens/springs on transform/opacity) run on the browser's Web Animations API off the main thread. Other features run via the C# rAF engine.
    • Blazor Server: The compositor path works for transform/opacity. However, features requiring a per-frame loop (inertia, color/dimension interpolation, keyframes, drag, motion values) degrade to instant state changes.
    • Server-side Prerendering: Components render initial styles; animations start once the circuit is interactive.

    To detect capabilities programmatically, inject BmotionCapabilities and check Caps.SupportsFrameLoop (false on Server) or Caps.SupportsCompositor (always true).

  7. Implement navigation guards and lifecycle hooks in bit Brouter

    develop

    bit Brouter provides several mechanisms to control navigation flow and component lifecycles:

    • Async Guard: Use Guard to allow/cancel/redirect navigation via BrouterNavigationContext.
    • LeaveGuard (Per-route): Runs when a route is being deactivated (e.g., for "unsaved changes" prompts). It runs from leaf to root.
    • Component-level Navigation Lock: Implement OnDeactivating or OnRenavigating on the routed component to veto navigation. This is useful for handling parameter changes on the same route.
    • External-navigation confirmation: Use o.ConfirmExternalNavigation or brouter.SetConfirmExternalNavigationAsync(...) to trigger the browser's beforeunload dialog.

    Route Lifecycle Hooks

    Components can implement IBrouterRoute or derive from BrouterRouteBase to receive these callbacks:

    • OnActivated
    • OnDeactivated
    • OnRenavigated (includes OnRenavigating for locking navigation)
  8. How Bit.Bmotion's hybrid engine works

    develop

    Bit.Bmotion uses a hybrid engine to balance performance and capability:

    1. Compositor-eligible animations: Tweens and zero-velocity springs targeting transform or opacity are pre-sampled in C# and handed to the browser's Web Animations API. These run off the main thread with zero per-frame interop.
    2. C# rAF engine: All other animations (inertia, color/dimension interpolation, keyframe arrays, drag, motion values) run on the C# RequestAnimationFrame (rAF) engine.

    Runtime Behavior:

    • Blazor WebAssembly: Full support for all features.
    • Blazor Server: Compositor-eligible animations play normally via async interop. Features requiring the per-frame loop (inertia, color interpolation, etc.) degrade to instant state changes.
  9. Manage reactive motion values

    develop

    Motion values are a reactive value graph that can be bound to elements. They allow for high-performance updates that flush to the DOM every frame without triggering Blazor re-renders.

    • Creation: Use Bm.Value(initialValue) to create a reactive value.
    • Transformations: Use .Transform() to map ranges or derive new values (e.g., mapping [0, 200] to [0, 360]).
    • Binding to Elements:
      • Use Values for standard properties: <Bmotion Values='new() { ["x"] = _x }'>.
      • Use StringValues for CSS properties requiring strings: <Bmotion StringValues='new() { ["filter"] = _filter }'>.
    • Templates: Use Bm.Template to compose motion values into CSS strings (e.g., blur(10px)).
    // Create and manipulate values
    var x = Bm.Value(0.0);
    x.SetSync(100);
    var angle = x.Transform([0, 200], [0, 360]);
    
    // Create a CSS template
    var blur = Bm.Value(0.0);
    var filter = Bm.Template(() => $"blur({blur.Value}px)", blur);
    <Bmotion Values='new() { ["x"] = _x, ["rotate"] = _angle }'>
        <div />
    </Bmotion>
  10. Bind route and query parameters in Brouter

    develop

    Brouter binds route segments and query values to component properties using standard Blazor attributes.

    Rules for binding:

    1. Route Segments: Bind to [Parameter] properties by name.
    2. Query Values: Bind to properties decorated with both [Parameter] and [SupplyParameterFromQuery].
      • Note: A [SupplyParameterFromQuery] property without [Parameter] is handled by the framework's supplier, which Blazor forbids setting explicitly. For Brouter, always pair these two attributes.
    3. Supported Types: The framework supplier supports string, numerics, bool, Guid, DateTime/DateOnly/TimeOnly, and nullables or arrays of these.
    4. Custom Types: For types outside the supported set (like enums), use Brouter's opt-in [BrouterQuery] attribute instead.