icebook 1.2.0

Generic component storybook framework for Iced applications - compiles to WASM
Documentation

icebook - A theme-agnostic storybook for Iced components

Overview

icebook provides a framework for building component storybooks with Iced. It's designed to be generic over your theme system - bring your own themes by implementing the ThemeProvider trait.

Quick Start

use icebook::prelude::*;

// Define your theme provider
struct MyThemeProvider;

impl ThemeProvider for MyThemeProvider {
    type Theme = MyTheme;

    fn get_theme(brightness: Brightness) -> &'static Self::Theme {
        // Return your theme based on brightness
    }

    fn get_sidebar_theme(brightness: Brightness) -> &'static dyn SidebarTheme {
        // Return sidebar theming (can use defaults)
        icebook::default_sidebar_theme(brightness)
    }
}

// Define your story registry
#[derive(Default)]
struct MyStories { /* ... */ }

impl StoryRegistry for MyStories {
    type Message = MyMessage;
    type Provider = MyThemeProvider;

    fn stories() -> Vec<StoryMeta> { /* ... */ }
    fn view(&self, story_id: &str, theme: &Self::Theme) -> Element<Self::Message> { /* ... */ }
    // ...
}

// Run the storybook
fn main() -> iced::Result {
    icebook::run::<MyStories>()
}

Architecture

  • StoryRegistry: Trait that your storybook must implement. Provides story metadata and rendering functions.
  • ThemeProvider: Trait that supplies themes. Your registry specifies which provider to use.
  • SidebarTheme: Minimal theme trait for the sidebar UI. Default implementations provided.
  • Storybook: The main application shell that displays stories.