feat: add clipboard button component
This commit is contained in:
@@ -12,6 +12,7 @@ use gpui_native_core::avatar::Avatar;
|
||||
use gpui_native_core::badge::{Badge, BadgeVariant};
|
||||
use gpui_native_core::button::{Button, ButtonVariant};
|
||||
use gpui_native_core::checkbox::Checkbox;
|
||||
use gpui_native_core::clipboard::ClipboardButton;
|
||||
use gpui_native_core::combobox::{Combobox, ComboboxOption, ComboboxState};
|
||||
use gpui_native_core::command_palette::{Command, CommandPalette, CommandPaletteState};
|
||||
use gpui_native_core::common::{Sizable as _, Size, h_flex, v_flex};
|
||||
@@ -72,6 +73,7 @@ const CATALOG: &[(&str, &[(&str, &str)])] = &[
|
||||
("segmented", "Segmented"),
|
||||
("select", "Select"),
|
||||
("link", "Link"),
|
||||
("clipboard", "Clipboard"),
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -496,6 +498,12 @@ impl Gallery {
|
||||
}),
|
||||
cx,
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("clipboard", "Clipboard", |_, cx| {
|
||||
cx.new(|_| ClipboardDemo).into()
|
||||
}),
|
||||
cx,
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("badge", "Badge", |_, cx| cx.new(|_| BadgeDemo).into()),
|
||||
cx,
|
||||
@@ -1624,6 +1632,41 @@ impl Render for LinkDemo {
|
||||
}
|
||||
}
|
||||
|
||||
struct ClipboardDemo;
|
||||
|
||||
impl Render for ClipboardDemo {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let colors = cx.theme().colors;
|
||||
|
||||
ScrollArea::new("clipboard-demo")
|
||||
.size_full()
|
||||
.p_4()
|
||||
.child(demo_section(
|
||||
"sizes",
|
||||
colors,
|
||||
h_flex()
|
||||
.flex_wrap()
|
||||
.gap_3()
|
||||
.child(ClipboardButton::new("clipboard-small", "gpui-native-kit").small())
|
||||
.child(ClipboardButton::new("clipboard-medium", "gpui-native-kit"))
|
||||
.child(ClipboardButton::new("clipboard-large", "gpui-native-kit").large()),
|
||||
))
|
||||
.child(demo_section(
|
||||
"states",
|
||||
colors,
|
||||
h_flex()
|
||||
.flex_wrap()
|
||||
.gap_3()
|
||||
.child(
|
||||
ClipboardButton::new("clipboard-url", "https://example.com/repo.git")
|
||||
.tooltip(Tooltip::text("Copy repository URL"))
|
||||
.accessibility_label("Copy repository URL"),
|
||||
)
|
||||
.child(ClipboardButton::new("clipboard-disabled", "drift").disabled(true)),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
struct BadgeDemo;
|
||||
|
||||
impl Render for BadgeDemo {
|
||||
|
||||
Reference in New Issue
Block a user