[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73BGG7TAWDSACH4MEAJQQW8":3,"skill-same:01M73BGG7TAWDSACH4MEAJQQW8":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M73BGG7TAWDSACH4MEAJQQW8","robius-widget-patterns",null,"CRITICAL: Use for Robius widget patterns. Triggers on:\napply_over, TextOrImage, modal, 可复用, 模态,\ncollapsible, drag drop, reusable widget, widget design,\npageflip, 组件设计, 组件模式","kalash33\u002Fkstack","kalash33","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F90259149?v=4","01M7365X8Q0B73NYHA730SMZWN","Kalash Poddar","01M7365X9D0JK47C3Q0YCCK9Z2",0,"MIT","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Frobius-widget-patterns\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: robius-widget-patterns\ndescription: |\n  CRITICAL: Use for Robius widget patterns. Triggers on:\n  apply_over, TextOrImage, modal, 可复用, 模态,\n  collapsible, drag drop, reusable widget, widget design,\n  pageflip, 组件设计, 组件模式\n---\n\n# Robius Widget Patterns Skill\n\nBest practices for designing reusable Makepad widgets based on Robrix and Moly codebase patterns.\n\n**Source codebases:**\n- **Robrix**: Matrix chat client - Avatar, RoomsList, RoomScreen widgets\n- **Moly**: AI chat application - Slot, ChatLine, PromptInput, AdaptiveView widgets\n\n## Triggers\n\nUse this skill when:\n- Creating reusable Makepad widgets\n- Designing widget component APIs\n- Implementing text\u002Fimage toggle patterns\n- Dynamic styling in Makepad\n- Keywords: robrix widget, makepad component, reusable widget, widget design pattern\n\n## Production Patterns\n\nFor production-ready widget patterns, see the `_base\u002F` directory:\n\n| Pattern | Description |\n|---------|-------------|\n| 01-widget-extension | Add helper methods to widget references |\n| 02-modal-overlay | Popups, dialogs using DrawList2d overlay |\n| 03-collapsible | Expandable\u002Fcollapsible sections |\n| 04-list-template | Dynamic lists with LivePtr templates |\n| 05-lru-view-cache | Memory-efficient view caching |\n| 14-callout-tooltip | Tooltips with arrow positioning |\n| 20-redraw-optimization | Efficient redraw patterns |\n| 15-dock-studio-layout | IDE-style resizable panels |\n| 16-hover-effect | Hover effects with instance variables |\n| 17-row-based-grid-layout | Dynamic grid layouts |\n| 18-drag-drop-reorder | Drag-and-drop widget reordering |\n| 19-pageflip-optimization | PageFlip 切换优化，即刻销毁\u002F缓存模式 |\n| 21-collapsible-row-portal-list | Auto-grouping consecutive items in portal lists with FoldHeader |\n| 22-dropdown-overlay | Dropdown popups using DrawList2d overlay (no layout push) |\n\n## Standard Widget Structure\n\n```rust\nuse makepad_widgets::*;\n\nlive_design! {\n    use link::theme::*;\n    use link::widgets::*;\n\n    pub MyWidget = {{MyWidget}} {\n        width: Fill, height: Fit,\n        flow: Down,\n\n        \u002F\u002F Child widgets defined in DSL\n        inner_view = \u003CView> {\n            \u002F\u002F ...\n        }\n    }\n}\n\n#[derive(Live, LiveHook, Widget)]\npub struct MyWidget {\n    #[deref] view: View,              \u002F\u002F Delegate to inner View\n\n    #[live] some_property: f64,       \u002F\u002F DSL-configurable property\n    #[live(100.0)] default_val: f64,  \u002F\u002F With default value\n\n    #[rust] internal_state: State,    \u002F\u002F Rust-only state (not in DSL)\n\n    #[animator] animator: Animator,   \u002F\u002F For animations\n}\n\nimpl Widget for MyWidget {\n    fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {\n        self.view.handle_event(cx, event, scope);\n        \u002F\u002F Custom event handling...\n    }\n\n    fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {\n        self.view.draw_walk(cx, scope, walk)\n    }\n}\n```\n\n## Text\u002FImage Toggle Pattern\n\nA common pattern for widgets that show either text or an image (like avatars):\n\n```rust\nlive_design! {\n    pub Avatar = {{Avatar}} {\n        width: 36.0, height: 36.0,\n        align: { x: 0.5, y: 0.5 }\n        flow: Overlay,  \u002F\u002F Stack views on top of each other\n\n        text_view = \u003CView> {\n            visible: true,  \u002F\u002F Default visible\n            show_bg: true,\n            draw_bg: {\n                uniform background_color: #888888\n                fn pixel(self) -> vec4 {\n                    let sdf = Sdf2d::viewport(self.pos * self.rect_size);\n                    let c = self.rect_size * 0.5;\n                    sdf.circle(c.x, c.x, c.x)\n                    sdf.fill_keep(self.background_color);\n                    return sdf.result\n                }\n            }\n            text = \u003CLabel> {\n                text: \"?\"\n            }\n        }\n\n        img_view = \u003CView> {\n            visible: false,  \u002F\u002F Hidden by default\n            img = \u003CImage> {\n                fit: Stretch,\n                width: Fill, height: Fill,\n            }\n        }\n    }\n}\n\n#[derive(LiveHook, Live, Widget)]\npub struct Avatar {\n    #[deref] view: View,\n    #[rust] info: Option\u003CUserInfo>,\n}\n\nimpl Avatar {\n    \u002F\u002F\u002F Show text content, hiding the image\n    pub fn show_text\u003CT: AsRef\u003Cstr>>(\n        &mut self,\n        cx: &mut Cx,\n        bg_color: Option\u003CVec4>,\n        info: Option\u003CAvatarTextInfo>,\n        username: T,\n    ) {\n        self.info = info.map(|i| i.into());\n\n        \u002F\u002F Get first character\n        let first_char = utils::first_letter(username.as_ref())\n            .unwrap_or(\"?\").to_uppercase();\n        self.label(ids!(text_view.text)).set_text(cx, &first_char);\n\n        \u002F\u002F Toggle visibility\n        self.view(ids!(text_view)).set_visible(cx, true);\n        self.view(ids!(img_view)).set_visible(cx, false);\n\n        \u002F\u002F Apply optional background color\n        if let Some(color) = bg_color {\n            self.view(ids!(text_view)).apply_over(cx, live! {\n                draw_bg: { background_color: (color) }\n            });\n        }\n    }\n\n    \u002F\u002F\u002F Show image content, hiding the text\n    pub fn show_image\u003CF, E>(\n        &mut self,\n        cx: &mut Cx,\n        info: Option\u003CAvatarImageInfo>,\n        image_set_fn: F,\n    ) -> Result\u003C(), E>\n    where\n        F: FnOnce(&mut Cx, ImageRef) -> Result\u003C(), E>\n    {\n        let img_ref = self.image(ids!(img_view.img));\n        let res = image_set_fn(cx, img_ref);\n\n        if res.is_ok() {\n            self.view(ids!(img_view)).set_visible(cx, true);\n            self.view(ids!(text_view)).set_visible(cx, false);\n            self.info = info.map(|i| i.into());\n        }\n        res\n    }\n\n    \u002F\u002F\u002F Check current display status\n    pub fn status(&mut self) -> DisplayStatus {\n        if self.view(ids!(img_view)).visible() {\n            DisplayStatus::Image\n        } else {\n            DisplayStatus::Text\n        }\n    }\n}\n```\n\n## Dynamic Styling with apply_over\n\nApply dynamic styles at runtime:\n\n```rust\n\u002F\u002F Apply single property\nself.view(ids!(content)).apply_over(cx, live! {\n    draw_bg: { color: #ff0000 }\n});\n\n\u002F\u002F Apply multiple properties\nself.view(ids!(message)).apply_over(cx, live! {\n    padding: { left: 20, right: 20 }\n    margin: { top: 10 }\n});\n\n\u002F\u002F Apply with variables\nlet highlight_color = if is_selected { vec4(1.0, 0.0, 0.0, 1.0) } else { vec4(0.5, 0.5, 0.5, 1.0) };\nself.view(ids!(item)).apply_over(cx, live! {\n    draw_bg: { color: (highlight_color) }\n});\n```\n\n## Widget Reference Pattern\n\nImplement `*Ref` methods for external API:\n\n```rust\nimpl AvatarRef {\n    \u002F\u002F\u002F See [`Avatar::show_text()`].\n    pub fn show_text\u003CT: AsRef\u003Cstr>>(\n        &self,\n        cx: &mut Cx,\n        bg_color: Option\u003CVec4>,\n        info: Option\u003CAvatarTextInfo>,\n        username: T,\n    ) {\n        if let Some(mut inner) = self.borrow_mut() {\n            inner.show_text(cx, bg_color, info, username);\n        }\n    }\n\n    \u002F\u002F\u002F See [`Avatar::show_image()`].\n    pub fn show_image\u003CF, E>(\n        &self,\n        cx: &mut Cx,\n        info: Option\u003CAvatarImageInfo>,\n        image_set_fn: F,\n    ) -> Result\u003C(), E>\n    where\n        F: FnOnce(&mut Cx, ImageRef) -> Result\u003C(), E>\n    {\n        if let Some(mut inner) = self.borrow_mut() {\n            inner.show_image(cx, info, image_set_fn)\n        } else {\n            Ok(())\n        }\n    }\n}\n```\n\n## Collapsible\u002FExpandable Pattern\n\n```rust\nlive_design! {\n    pub CollapsibleSection = {{CollapsibleSection}} {\n        flow: Down,\n\n        header = \u003CView> {\n            cursor: Hand,\n            icon = \u003CIcon> { }\n            title = \u003CLabel> { text: \"Section\" }\n        }\n\n        content = \u003CView> {\n            visible: false,\n            \u002F\u002F Expandable content here\n        }\n    }\n}\n\n#[derive(Live, LiveHook, Widget)]\npub struct CollapsibleSection {\n    #[deref] view: View,\n    #[rust] is_expanded: bool,\n}\n\nimpl CollapsibleSection {\n    pub fn toggle(&mut self, cx: &mut Cx) {\n        self.is_expanded = !self.is_expanded;\n        self.view(ids!(content)).set_visible(cx, self.is_expanded);\n\n        \u002F\u002F Rotate icon\n        let rotation = if self.is_expanded { 90.0 } else { 0.0 };\n        self.view(ids!(header.icon)).apply_over(cx, live! {\n            draw_icon: { rotation: (rotation) }\n        });\n\n        self.redraw(cx);\n    }\n}\n```\n\n## Loading State Pattern\n\n```rust\nlive_design! {\n    pub LoadableContent = {{LoadableContent}} {\n        flow: Overlay,\n\n        content = \u003CView> {\n            visible: true,\n            \u002F\u002F Main content\n        }\n\n        loading_overlay = \u003CView> {\n            visible: false,\n            show_bg: true,\n            draw_bg: { color: #00000088 }\n            align: { x: 0.5, y: 0.5 }\n            \u003CBouncingDots> { }\n        }\n\n        error_view = \u003CView> {\n            visible: false,\n            error_label = \u003CLabel> { }\n        }\n    }\n}\n\n#[derive(Live, LiveHook, Widget)]\npub struct LoadableContent {\n    #[deref] view: View,\n    #[rust] state: LoadingState,\n}\n\npub enum LoadingState {\n    Idle,\n    Loading,\n    Loaded,\n    Error(String),\n}\n\nimpl LoadableContent {\n    pub fn set_state(&mut self, cx: &mut Cx, state: LoadingState) {\n        self.state = state;\n        match &self.state {\n            LoadingState::Idle | LoadingState::Loaded => {\n                self.view(ids!(content)).set_visible(cx, true);\n                self.view(ids!(loading_overlay)).set_visible(cx, false);\n                self.view(ids!(error_view)).set_visible(cx, false);\n            }\n            LoadingState::Loading => {\n                self.view(ids!(content)).set_visible(cx, true);\n                self.view(ids!(loading_overlay)).set_visible(cx, true);\n                self.view(ids!(error_view)).set_visible(cx, false);\n            }\n            LoadingState::Error(msg) => {\n                self.view(ids!(content)).set_visible(cx, false);\n                self.view(ids!(loading_overlay)).set_visible(cx, false);\n                self.view(ids!(error_view)).set_visible(cx, true);\n                self.label(ids!(error_view.error_label)).set_text(cx, msg);\n            }\n        }\n        self.redraw(cx);\n    }\n}\n```\n\n## PortalList Item Pattern\n\nFor virtual list items:\n\n```rust\nlive_design! {\n    pub ItemsList = {{ItemsList}} {\n        list = \u003CPortalList> {\n            keep_invisible: false,\n            auto_tail: false,\n            width: Fill, height: Fill,\n            flow: Down,\n\n            \u002F\u002F Item templates\n            item_entry = \u003CItemEntry> {}\n            header = \u003CSectionHeader> {}\n            empty = \u003CView> {}\n        }\n    }\n}\n\nimpl Widget for ItemsList {\n    fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {\n        while let Some(item) = self.view.draw_walk(cx, scope, walk).step() {\n            if let Some(mut list) = item.as_portal_list().borrow_mut() {\n                list.set_item_range(cx, 0, self.items.len());\n\n                while let Some(item_id) = list.next_visible_item(cx) {\n                    let item = list.item(cx, item_id, live_id!(item_entry));\n                    \u002F\u002F Populate item with data\n                    self.populate_item(cx, item, &self.items[item_id]);\n                    item.draw_all(cx, scope);\n                }\n            }\n        }\n        DrawStep::done()\n    }\n}\n```\n\n## Best Practices\n\n1. **Use `#[deref]` for delegation**: Delegate to inner View for standard behavior\n2. **Separate DSL properties (`#[live]`) from Rust state (`#[rust]`)**\n3. **Implement both inner methods and `*Ref` wrappers**\n4. **Use `apply_over` for dynamic runtime styling**\n5. **Use `flow: Overlay` for toggle\u002Fswap patterns**\n6. **Use `set_visible()` to toggle between alternative views**\n7. **Always call `redraw(cx)` after state changes**\n\n## Reference Files\n\n- `references\u002Fwidget-patterns.md` - Additional widget patterns (Robrix)\n- `references\u002Fstyling-patterns.md` - Dynamic styling patterns (Robrix)\n- `references\u002Fmoly-widget-patterns.md` - Moly-specific patterns\n  - `Slot` widget for runtime content replacement\n  - `MolyRoot` conditional rendering wrapper\n  - `AdaptiveView` for responsive Mobile\u002FDesktop layouts\n  - Chat line variants (UserLine, BotLine, ErrorLine, etc.)\n  - `CommandTextInput` with action buttons\n  - Sidebar navigation with radio buttons\n","# Robius Widget Patterns Skill\n\nBest practices for designing reusable Makepad widgets based on Robrix and Moly codebase patterns.\n\n**Source codebases:**\n- **Robrix**: Matrix chat client - Avatar, RoomsList, RoomScreen widgets\n- **Moly**: AI chat application - Slot, ChatLine, PromptInput, AdaptiveView widgets\n\n## Triggers\n\nUse this skill when:\n- Creating reusable Makepad widgets\n- Designing widget component APIs\n- Implementing text\u002Fimage toggle patterns\n- Dynamic styling in Makepad\n- Keywords: robrix widget, makepad component, reusable widget, widget design pattern\n\n## Production Patterns\n\nFor production-ready widget patterns, see the `_base\u002F` directory:\n\n| Pattern | Description |\n|---------|-------------|\n| 01-widget-extension | Add helper methods to widget references |\n| 02-modal-overlay | Popups, dialogs using DrawList2d overlay |\n| 03-collapsible | Expandable\u002Fcollapsible sections |\n| 04-list-template | Dynamic lists with LivePtr templates |\n| 05-lru-view-cache | Memory-efficient view caching |\n| 14-callout-tooltip | Tooltips with arrow positioning |\n| 20-redraw-optimization | Efficient redraw patterns |\n| 15-dock-studio-layout | IDE-style resizable panels |\n| 16-hover-effect | Hover effects with instance variables |\n| 17-row-based-grid-layout | Dynamic grid layouts |\n| 18-drag-drop-reorder | Drag-and-drop widget reordering |\n| 19-pageflip-optimization | PageFlip 切换优化，即刻销毁\u002F缓存模式 |\n| 21-collapsible-row-portal-list | Auto-grouping consecutive items in portal lists with FoldHeader |\n| 22-dropdown-overlay | Dropdown popups using DrawList2d overlay (no layout push) |\n\n## Standard Widget Structure\n\n```rust\nuse makepad_widgets::*;\n\nlive_design! {\n    use link::theme::*;\n    use link::widgets::*;\n\n    pub MyWidget = {{MyWidget}} {\n        width: Fill, height: Fit,\n        flow: Down,\n\n        \u002F\u002F Child widgets defined in DSL\n        inner_view = \u003CView> {\n            \u002F\u002F ...\n        }\n    }\n}\n\n#[derive(Live, LiveHook, Widget)]\npub struct MyWidget {\n    #[deref] view: View,              \u002F\u002F Delegate to inner View\n\n    #[live] some_property: f64,       \u002F\u002F DSL-configurable property\n    #[live(100.0)] default_val: f64,  \u002F\u002F With default value\n\n    #[rust] internal_state: State,    \u002F\u002F Rust-only state (not in DSL)\n\n    #[animator] animator: Animator,   \u002F\u002F For animations\n}\n\nimpl Widget for MyWidget {\n    fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {\n        self.view.handle_event(cx, event, scope);\n        \u002F\u002F Custom event handling...\n    }\n\n    fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {\n        self.view.draw_walk(cx, scope, walk)\n    }\n}\n```\n\n## Text\u002FImage Toggle Pattern\n\nA common pattern for widgets that show either text or an image (like avatars):\n\n```rust\nlive_design! {\n    pub Avatar = {{Avatar}} {\n        width: 36.0, height: 36.0,\n        align: { x: 0.5, y: 0.5 }\n        flow: Overlay,  \u002F\u002F Stack views on top of each other\n\n        text_view = \u003CView> {\n            visible: true,  \u002F\u002F Default visible\n            show_bg: true,\n            draw_bg: {\n                uniform background_color: #888888\n                fn pixel(self) -> vec4 {\n                    let sdf = Sdf2d::viewport(self.pos * self.rect_size);\n                    let c = self.rect_size * 0.5;\n                    sdf.circle(c.x, c.x, c.x)\n                    sdf.fill_keep(self.background_color);\n                    return sdf.result\n                }\n            }\n            text = \u003CLabel> {\n                text: \"?\"\n            }\n        }\n\n        img_view = \u003CView> {\n            visible: false,  \u002F\u002F Hidden by default\n            img = \u003CImage> {\n                fit: Stretch,\n                width: Fill, height: Fill,\n            }\n        }\n    }\n}\n\n#[derive(LiveHook, Live, Widget)]\npub struct Avatar {\n    #[deref] view: View,\n    #[rust] info: Option\u003CUserInfo>,\n}\n\nimpl Avatar {\n    \u002F\u002F\u002F Show text content, hiding the image\n    pub fn show_text\u003CT: AsRef\u003Cstr>>(\n        &mut self,\n        cx: &mut Cx,\n        bg_color: Option\u003CVec4>,\n        info: Option\u003CAvatarTextInfo>,\n        username: T,\n    ) {\n        self.info = info.map(|i| i.into());\n\n        \u002F\u002F Get first character\n        let first_char = utils::first_letter(username.as_ref())\n            .unwrap_or(\"?\").to_uppercase();\n        self.label(ids!(text_view.text)).set_text(cx, &first_char);\n\n        \u002F\u002F Toggle visibility\n        self.view(ids!(text_view)).set_visible(cx, true);\n        self.view(ids!(img_view)).set_visible(cx, false);\n\n        \u002F\u002F Apply optional background color\n        if let Some(color) = bg_color {\n            self.view(ids!(text_view)).apply_over(cx, live! {\n                draw_bg: { background_color: (color) }\n            });\n        }\n    }\n\n    \u002F\u002F\u002F Show image content, hiding the text\n    pub fn show_image\u003CF, E>(\n        &mut self,\n        cx: &mut Cx,\n        info: Option\u003CAvatarImageInfo>,\n        image_set_fn: F,\n    ) -> Result\u003C(), E>\n    where\n        F: FnOnce(&mut Cx, ImageRef) -> Result\u003C(), E>\n    {\n        let img_ref = self.image(ids!(img_view.img));\n        let res = image_set_fn(cx, img_ref);\n\n        if res.is_ok() {\n            self.view(ids!(img_view)).set_visible(cx, true);\n            self.view(ids!(text_view)).set_visible(cx, false);\n            self.info = info.map(|i| i.into());\n        }\n        res\n    }\n\n    \u002F\u002F\u002F Check current display status\n    pub fn status(&mut self) -> DisplayStatus {\n        if self.view(ids!(img_view)).visible() {\n            DisplayStatus::Image\n        } else {\n            DisplayStatus::Text\n        }\n    }\n}\n```\n\n## Dynamic Styling with apply_over\n\nApply dynamic styles at runtime:\n\n```rust\n\u002F\u002F Apply single property\nself.view(ids!(content)).apply_over(cx, live! {\n    draw_bg: { color: #ff0000 }\n});\n\n\u002F\u002F Apply multiple properties\nself.view(ids!(message)).apply_over(cx, live! {\n    padding: { left: 20, right: 20 }\n    margin: { top: 10 }\n});\n\n\u002F\u002F Apply with variables\nlet highlight_color = if is_selected { vec4(1.0, 0.0, 0.0, 1.0) } else { vec4(0.5, 0.5, 0.5, 1.0) };\nself.view(ids!(item)).apply_over(cx, live! {\n    draw_bg: { color: (highlight_color) }\n});\n```\n\n## Widget Reference Pattern\n\nImplement `*Ref` methods for external API:\n\n```rust\nimpl AvatarRef {\n    \u002F\u002F\u002F See [`Avatar::show_text()`].\n    pub fn show_text\u003CT: AsRef\u003Cstr>>(\n        &self,\n        cx: &mut Cx,\n        bg_color: Option\u003CVec4>,\n        info: Option\u003CAvatarTextInfo>,\n        username: T,\n    ) {\n        if let Some(mut inner) = self.borrow_mut() {\n            inner.show_text(cx, bg_color, info, username);\n        }\n    }\n\n    \u002F\u002F\u002F See [`Avatar::show_image()`].\n    pub fn show_image\u003CF, E>(\n        &self,\n        cx: &mut Cx,\n        info: Option\u003CAvatarImageInfo>,\n        image_set_fn: F,\n    ) -> Result\u003C(), E>\n    where\n        F: FnOnce(&mut Cx, ImageRef) -> Result\u003C(), E>\n    {\n        if let Some(mut inner) = self.borrow_mut() {\n            inner.show_image(cx, info, image_set_fn)\n        } else {\n            Ok(())\n        }\n    }\n}\n```\n\n## Collapsible\u002FExpandable Pattern\n\n```rust\nlive_design! {\n    pub CollapsibleSection = {{CollapsibleSection}} {\n        flow: Down,\n\n        header = \u003CView> {\n            cursor: Hand,\n            icon = \u003CIcon> { }\n            title = \u003CLabel> { text: \"Section\" }\n        }\n\n        content = \u003CView> {\n            visible: false,\n            \u002F\u002F Expandable content here\n        }\n    }\n}\n\n#[derive(Live, LiveHook, Widget)]\npub struct CollapsibleSection {\n    #[deref] view: View,\n    #[rust] is_expanded: bool,\n}\n\nimpl CollapsibleSection {\n    pub fn toggle(&mut self, cx: &mut Cx) {\n        self.is_expanded = !self.is_expanded;\n        self.view(ids!(content)).set_visible(cx, self.is_expanded);\n\n        \u002F\u002F Rotate icon\n        let rotation = if self.is_expanded { 90.0 } else { 0.0 };\n        self.view(ids!(header.icon)).apply_over(cx, live! {\n            draw_icon: { rotation: (rotation) }\n        });\n\n        self.redraw(cx);\n    }\n}\n```\n\n## Loading State Pattern\n\n```rust\nlive_design! {\n    pub LoadableContent = {{LoadableContent}} {\n        flow: Overlay,\n\n        content = \u003CView> {\n            visible: true,\n            \u002F\u002F Main content\n        }\n\n        loading_overlay = \u003CView> {\n            visible: false,\n            show_bg: true,\n            draw_bg: { color: #00000088 }\n            align: { x: 0.5, y: 0.5 }\n            \u003CBouncingDots> { }\n        }\n\n        error_view = \u003CView> {\n            visible: false,\n            error_label = \u003CLabel> { }\n        }\n    }\n}\n\n#[derive(Live, LiveHook, Widget)]\npub struct LoadableContent {\n    #[deref] view: View,\n    #[rust] state: LoadingState,\n}\n\npub enum LoadingState {\n    Idle,\n    Loading,\n    Loaded,\n    Error(String),\n}\n\nimpl LoadableContent {\n    pub fn set_state(&mut self, cx: &mut Cx, state: LoadingState) {\n        self.state = state;\n        match &self.state {\n            LoadingState::Idle | LoadingState::Loaded => {\n                self.view(ids!(content)).set_visible(cx, true);\n                self.view(ids!(loading_overlay)).set_visible(cx, false);\n                self.view(ids!(error_view)).set_visible(cx, false);\n            }\n            LoadingState::Loading => {\n                self.view(ids!(content)).set_visible(cx, true);\n                self.view(ids!(loading_overlay)).set_visible(cx, true);\n                self.view(ids!(error_view)).set_visible(cx, false);\n            }\n            LoadingState::Error(msg) => {\n                self.view(ids!(content)).set_visible(cx, false);\n                self.view(ids!(loading_overlay)).set_visible(cx, false);\n                self.view(ids!(error_view)).set_visible(cx, true);\n                self.label(ids!(error_view.error_label)).set_text(cx, msg);\n            }\n        }\n        self.redraw(cx);\n    }\n}\n```\n\n## PortalList Item Pattern\n\nFor virtual list items:\n\n```rust\nlive_design! {\n    pub ItemsList = {{ItemsList}} {\n        list = \u003CPortalList> {\n            keep_invisible: false,\n            auto_tail: false,\n            width: Fill, height: Fill,\n            flow: Down,\n\n            \u002F\u002F Item templates\n            item_entry = \u003CItemEntry> {}\n            header = \u003CSectionHeader> {}\n            empty = \u003CView> {}\n        }\n    }\n}\n\nimpl Widget for ItemsList {\n    fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep {\n        while let Some(item) = self.view.draw_walk(cx, scope, walk).step() {\n            if let Some(mut list) = item.as_portal_list().borrow_mut() {\n                list.set_item_range(cx, 0, self.items.len());\n\n                while let Some(item_id) = list.next_visible_item(cx) {\n                    let item = list.item(cx, item_id, live_id!(item_entry));\n                    \u002F\u002F Populate item with data\n                    self.populate_item(cx, item, &self.items[item_id]);\n                    item.draw_all(cx, scope);\n                }\n            }\n        }\n        DrawStep::done()\n    }\n}\n```\n\n## Best Practices\n\n1. **Use `#[deref]` for delegation**: Delegate to inner View for standard behavior\n2. **Separate DSL properties (`#[live]`) from Rust state (`#[rust]`)**\n3. **Implement both inner methods and `*Ref` wrappers**\n4. **Use `apply_over` for dynamic runtime styling**\n5. **Use `flow: Overlay` for toggle\u002Fswap patterns**\n6. **Use `set_visible()` to toggle between alternative views**\n7. **Always call `redraw(cx)` after state changes**\n\n## Reference Files\n\n- `references\u002Fwidget-patterns.md` - Additional widget patterns (Robrix)\n- `references\u002Fstyling-patterns.md` - Dynamic styling patterns (Robrix)\n- `references\u002Fmoly-widget-patterns.md` - Moly-specific patterns\n  - `Slot` widget for runtime content replacement\n  - `MolyRoot` conditional rendering wrapper\n  - `AdaptiveView` for responsive Mobile\u002FDesktop layouts\n  - Chat line variants (UserLine, BotLine, ErrorLine, etc.)\n  - `CommandTextInput` with action buttons\n  - Sidebar navigation with radio buttons\n",{"name":5,"description":7},"main","b30820b3248f6676d5389f0ccabd4e5250c9c536","skills\u002Frobius-widget-patterns","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack","https:\u002F\u002Fgithub.com\u002Fkalash33","kalashpoddar.me","Tech-savvy Full Stack Developer 🚀 | Cybersecurity enthusiast 🔒 | Passionate about innovation and securing the digital world 🌐 | Let's code securely! 💻🔐","2026-05-20 04:11:22",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add kalash33\u002Fkstack --skill robius-widget-patterns",{"tool":38,"command":39},"bunx","bunx skills add kalash33\u002Fkstack --skill robius-widget-patterns",{"tool":41,"command":42},"pnpm","pnpm dlx skills add kalash33\u002Fkstack --skill robius-widget-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Frobius-widget-patterns\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M73CFERCR43JCAP606E41EFB","zustand-store-ts","Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state\u002Faction separation. Use when building React state management, creating global stores, or implementing reacti...","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-ts\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M73CFCMFVTAQEMTZ5HR10X8V","zoom-automation","Automate Zoom meeting creation, management, recordings, webinars, and participant tracking via Rube MCP (Composio). Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzoom-automation\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M73CFAA7EBWXJVXDQ1X555MB","zoho-crm-automation","Automate Zoho CRM tasks via Rube MCP (Composio): create\u002Fupdate records, search contacts, manage leads, and convert leads. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzoho-crm-automation\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M73CF80XCM9K81567MJ8QZFW","zod-validation-expert","Expert in Zod — TypeScript-first schema validation. Covers parsing, custom errors, refinements, type inference, and integration with React Hook Form, Next.js, and tRPC.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzod-validation-expert\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M73CF4YPMF3RA8ZJDXZSMD93","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M73CF2S25EN3XNAMKY47XHPS","zendesk-automation","Automate Zendesk tasks via Rube MCP (Composio): tickets, users, organizations, replies. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzendesk-automation\u002FSKILL.md",[],[]]