use crate::section; use gpui::{ App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement as _, Render, Styled, Window, img, }; use gpui_component::{dock::PanelControl, v_flex}; pub struct ImageStory { focus_handle: gpui::FocusHandle, } impl super::Story for ImageStory { fn title() -> &'static str { "Image" } fn description() -> &'static str { "Image and SVG image supported." } fn new_view(window: &mut Window, cx: &mut App) -> Entity { Self::view(window, cx) } fn zoomable() -> Option { Some(PanelControl::Toolbar) } } impl ImageStory { pub fn new(_: &mut Window, cx: &mut App) -> Self { Self { focus_handle: cx.focus_handle(), } } pub fn view(window: &mut Window, cx: &mut App) -> Entity { cx.new(|cx| Self::new(window, cx)) } } impl Focusable for ImageStory { fn focus_handle(&self, _: &App) -> FocusHandle { self.focus_handle.clone() } } impl Render for ImageStory { fn render(&mut self, _: &mut Window, _: &mut Context) -> impl IntoElement { v_flex().gap_4().size_full().child( section("SVG from URL") .child(img("https://pub.lbkrs.com/files/202503/vEnnmgUM6bo362ya/sdk.svg").h_24()), ) } }