Expand description
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.
Modules§
- prelude
- Prelude for convenient imports
Structs§
- NavItem
- A navigation item in the sidebar
- Settings
- Settings for window/application
- Sidebar
Config - Configuration for the sidebar
- Sidebar
Font - Font configuration for sidebar text
- Sidebar
Section - A section in the sidebar containing navigation items
- Simple
Dark Sidebar - Simple built-in sidebar theme for dark mode
- Simple
Light Sidebar - Simple built-in sidebar theme for light mode
- Story
Meta - Metadata for a story, used for sidebar navigation and routing
- Storybook
- The main Storybook application
Enums§
- Brightness
- Brightness mode for theme switching
- Message
- Messages for the Storybook application
- Sidebar
Message - Messages from sidebar interactions
Constants§
- FALLBACK_
FONT - Built-in fallback font (Fira Sans Regular)
- FALLBACK_
FONT_ NAME - Name of the fallback font family
Traits§
- Sidebar
Theme - Minimal theme interface for icebook’s sidebar UI
- Story
- Individual story trait for single component documentation
- Story
Registry - Registry of all stories in a storybook
- Theme
Provider - Theme provider trait - implement this in your storybook consumer
Functions§
- default_
sidebar_ theme - Returns the default sidebar theme for the given brightness. Convenience function for ThemeProvider implementations that don’t need custom sidebar styling.
- default_
welcome_ view - Default welcome view when no story is selected
- run
- Run the storybook application
- run_
with_ settings - Run the storybook with custom settings