gpui-phosphor 0.1.0

An unofficial GPUI component and asset source for Phosphor Icons
Documentation
use gpui::{
    App, Application, Bounds, Context, Render, Window, WindowBounds, WindowOptions, div,
    prelude::*, px, rgb, size,
};
use gpui_phosphor::{Icon, IconName, PhosphorAssets, Weight};

struct Showcase;

impl Render for Showcase {
    fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
        div()
            .flex()
            .gap_4()
            .size_full()
            .justify_center()
            .items_center()
            .bg(rgb(0x17171b))
            .child(
                Icon::new(IconName::Heart)
                    .size(px(48.0))
                    .color(rgb(0xf472b6)),
            )
            .child(
                Icon::new(IconName::Star)
                    .size(px(48.0))
                    .color(rgb(0xfacc15)),
            )
            .child(
                Icon::new(IconName::Rocket)
                    .weight(Weight::Regular)
                    .size(px(48.0))
                    .color(rgb(0x60a5fa)),
            )
            .child(
                Icon::new(IconName::Pulse)
                    .size(px(48.0))
                    .color(rgb(0x34d399)),
            )
    }
}

fn main() {
    Application::new()
        .with_assets(PhosphorAssets)
        .run(|cx: &mut App| {
            let bounds = Bounds::centered(None, size(px(460.0), px(180.0)), cx);
            cx.open_window(
                WindowOptions {
                    window_bounds: Some(WindowBounds::Windowed(bounds)),
                    ..Default::default()
                },
                |_, cx| cx.new(|_| Showcase),
            )
            .expect("failed to open the GPUI showcase window");
            cx.activate(true);
        });
}