adabraka-ui

repository·main·Indexed 19 days ago

https://github.com/augani/adabraka-ui

A professional, GPU-accelerated UI component library for the GPUI framework, inspired by shadcn/ui. It provides over 85 accessible components for building high-performance desktop applications in Rust. Features include a semantic color token system for light and dark modes, layout utilities (VStack, HStack, Grid), a flexible icon system, and a Styled trait for component customization. Requires the Rust nightly toolchain.

Tokens
16.7K
Snippets
50
Records
68
Agent score
62%

What's inside adabraka-ui

  1. Overview of adabraka-ui components and systems

    main

    adabraka-ui is a comprehensive UI framework built on top of GPUI. It provides a wide array of pre-built components, animation systems, and theming capabilities designed to minimize direct dependency on GPUI.

    Core Systems

    • Components: Over 80+ components covering Input, Display, Navigation, Overlays, Layout, Media, and Charts.
    • Animation System: Includes 20+ easing functions (e.g., quad, cubic, spring), a spring physics engine, ScrollPhysics (momentum + overscroll bounce), and AnimatedInteraction for state blending (hover/press/focus). It also supports gesture detection (swipe, long-press, pan, tap).
    • Theme System: 18 pre-built themes (e.g., light, dark, dracula, nord, tokyo_night, catppuccin) using design tokens for colors, radii, shadows, and fonts.
    • Infrastructure: Features a responsive breakpoints system, virtual lists (uniform and variable height), keyboard navigation, a Builder pattern API, and a Styled trait available on all components.
  2. Micro-interaction Components Roadmap

    main

    Small, high-polish interaction components:

    • CopyButton: A button that performs clipboard writes and provides animated checkmark feedback.
    • SkeletonLoader: A wrapper that renders shimmer placeholders matching the dimensions of its children during loading.
    • MagneticButton: A button that subtly shifts toward the cursor using spring-animated offsets.
    • TiltCard: A card that simulates a 3D tilt effect based on cursor position using shadow displacement.
    • ExpandableCard: A card that animates from its source position to a larger target size.
    • FloatingActionButton: A circular button that expands into a radial or vertical list of actions (speed dial).
    • Confetti: A celebration particle burst triggered by specific events.
  3. Media & Canvas Components Roadmap

    main

    Components for handling media and low-level drawing:

    • Canvas: A direct GPUI painting surface that allows users to provide a paint callback for arbitrary Path and Quad drawing.
    • SVGRenderer: A parser and renderer for SVG path data using GPUI Path.
    • QRCode: A generator that renders QR codes as a grid of colored quads.
    • Waveform: Audio waveform visualization using vertical bars or continuous paths.
    • CropArea: An image cropping tool with draggable selection rectangles and aspect ratio constraints.
  4. Developer Experience and API Patterns in adabraka-ui

    main

    adabraka-ui is built to provide a familiar developer experience (DX) for web developers, specifically those accustomed to the React and shadcn ecosystems, while providing Rust-level safety.

    Core Patterns

    • Familiar Component Vocabulary: Uses standard names like Button, Input, Select, Dialog, Sheet, Toast, and DataGrid.
    • Builder Pattern: Employs a shadcn-style builder pattern for component configuration.
    • Type Safety: Leverages Rust for compile-time guarantees, preventing common runtime errors like null pointer crashes or undefined property access.
    • Theme Tokens: Uses theme tokens for consistent visual styling.

    Component Ecosystem

    The library aims for a total of 128+ components across several categories, including Animation & Motion, Visual Effects, Typography, Data Visualization, Media & Canvas, and Layout Animation.

  5. Use the Theme system and semantic tokens

    main

    adabraka-ui uses a semantic color token system to manage light and dark modes.

    1. Initialization: Call install_theme(cx, Theme::dark()) or Theme::light() during app startup.
    2. Accessing Tokens: Use use_theme() within your render method to access the current theme's tokens.

    Available Semantic Tokens:

    • Backgrounds: background, card, popover, muted
    • Foregrounds: foreground, card_foreground, popover_foreground, muted_foreground
    • Interactive: primary, primary_foreground, secondary, secondary_foreground, accent, accent_foreground, destructive, destructive_foreground
    • UI Elements: border, input, ring
    • Sizing/Typography: radius_sm, radius_md, radius_lg, font_family, font_mono
    use adabraka_ui::theme::{install_theme, Theme, use_theme};
    
    // In your app initialization
    install_theme(cx, Theme::dark()); // or Theme::light()
    
    // In your render method
    fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        let theme = use_theme();
    
        div()
            .bg(theme.tokens.background)
            .text_color(theme.tokens.foreground)
            .child("Themed content")
    }
  6. Understand the adabraka-ui value proposition vs Electron

    main

    adabraka-ui is designed as a high-performance alternative to Electron for building native desktop applications. While Electron relies on a browser engine (Chromium) and Node.js, adabraka-ui targets native performance with GPU-accelerated rendering and a significantly smaller footprint.

    Key Performance Advantages

    • Memory Usage: 50-100MB compared to Electron's 300-800MB.
    • Startup Speed: Instant cold starts (< 200ms) vs Electron's 2-5 second boot.
    • Rendering: Guaranteed 60fps with GPU-accelerated rendering, avoiding garbage collection pauses, layout thrashing, or style recalculation.
    • Latency: Sub-millisecond input latency via native event handling (bypassing the JS event loop).
    • Binary Size: Ship a 10-20MB single binary instead of a 200MB+ Electron installer.

    Target Use Cases

    • Creative Tools: Photo editors, design tools, and DAWs requiring low input latency.
    • Real-time Dashboards: High-frequency data visualization (financial terminals, monitoring systems).
    • Developer Tools: Code editors and database browsers with high responsiveness.
    • Communication Apps: Chat and collaboration tools requiring smooth animations and glassmorphic effects.
    • Enterprise Apps: Data-heavy UIs (CRMs, ERPs) with large data grids (100k+ rows).
  7. Layout Animation Components Roadmap

    main

    Advanced layout and transition components:

    • LayoutTransition: Automatically animates position and size changes of children between renders by snapshotting bounds.
    • SharedElementTransition: Implements 'hero animations' where elements appear to fly between different views.
    • AnimatedCollapsible: An enhanced Collapsible component that smoothly animates height changes.
    • AnimatedSwitch: Animates transitions between content regions using slide, scale, or morph modes.
    • Dock: A macOS-style dock with magnification effects based on cursor proximity.
    • ViewRouter: A view stack manager with push/pop semantics and animated transitions.
    • PageTransition: Configurable enter/exit animation presets (slide, fade, scale) for the ViewRouter.
    • SegmentedNavigation: An animated sliding highlight for active segments in navigation bars.
    • DrawerNavigation: A gesture-driven side drawer with animated sliding and backdrop dimming.
  8. Animation & Motion Components Roadmap

    main

    The roadmap outlines several upcoming motion-based components for adabraka-ui. Key foundational components include:

    • AnimatedPresence: Manages mount/unmount animations by delaying DOM removal until exit animations complete.
    • AnimatedList: Automatically animates item insertion, removal, and reordering using key-based diffing.
    • AnimatedCounter: Provides animated number displays with digit tweening or rolling transitions.
    • Shimmer: An animated gradient sweep overlay used for loading states.
    • AnimatedProgress: An enhanced ProgressBar with animated fill transitions and optional shimmer.
    • Marquee: Auto-scrolling content with configurable speed and seamless looping.
    • TypeWriter: Character-by-character text reveal with configurable speed and cursor blinking.
    • NumberTicker: A slot-machine style digit roller.
    • ParticleEmitter: A lightweight particle system for effects like confetti or snow.
    • PulseIndicator: A pulsing dot or ring for live status indicators.
  9. Typography & Text Components Roadmap

    main

    Upcoming text-focused components include:

    • AnimatedText: Per-character stagger animations (fade-in, slide-up, etc.).
    • TextReveal: Word-by-word or line-by-line text reveal using content masking.
    • TextHighlight: An animated background highlight sweep that moves across inline text.
    • CodeBlock: Syntax-highlighted code display with line numbers, language badges, and copy buttons.
    • KBD: Styled badges for displaying keyboard shortcuts.
  10. Planned GPUI Extensions for Visual Effects

    main

    The adabraka-ui roadmap includes several planned extensions to the underlying GPUI framework to enable advanced visual capabilities. These extensions are categorized by priority (P0-P2) and include:

    • Element Transforms (P0): Enables rotate(), scale(), skewX(), skewY(), translate(), and transform_origin() on quad elements via the Styled trait.
    • Gradients (P1): Support for Multi-stop Linear Gradients (up to 8 stops), Radial Gradients (including elliptical), and Conic Gradients.
    • Blur & Opacity (P1): Per-element Gaussian blur (.blur(radius)), backdrop blur (.backdrop_blur(radius)), and per-element opacity.
    • Advanced Compositing (P2): Support for various BlendModes such as Multiply, Screen, Overlay, SoftLight, Difference, and Exclusion.
  11. How to use ScrollContainer and ScrollHandle

    main

    The ScrollContainer provides auto-managed scrolling. You can use it for vertical, horizontal, or both directions. For programmatic control (like scrolling to a specific item or bottom), use a ScrollHandle and register it with .track_scroll(&handle).

    Key Methods for ScrollHandle:

    • scroll_to_bottom(): Scrolls to the end of the container.
    • set_offset(point): Sets a specific scroll position.
    • scroll_to_item(index): Scrolls to a specific child index.
    • top_item() / bottom_item(): Returns the index of the currently visible items.
    // Simple vertical scroll
    ScrollContainer::vertical()
        .h(px(400.0))
        .child(long_content())
    
    // With programmatic control
    let scroll_handle = ScrollHandle::new();
    ScrollContainer::vertical()
        .track_scroll(&scroll_handle)
        .child(content())
    
    // Later: scroll programmatically
    scroll_handle.scroll_to_bottom();
    scroll_handle.set_offset(point(px(0.0), px(100.0)));
  12. Data Visualization Components Roadmap

    main

    Planned components for representing data visually:

    • AreaChart: Line charts with filled areas and gradient fades.
    • DonutChart: A PieChart variant with an inner radius cutout and center labels.
    • RadarChart: Spider/radar charts using polygon shapes via GPUI Path.
    • Heatmap: A grid of colored cells with value-to-color mapping.
    • Gauge: Semicircular or circular gauges with animated needles or arcs.
    • TreeMap: Hierarchical data visualization using nested rectangles via a squarified algorithm.