Rename package from ui to gpui-component (#606)

## 🚨Break Change

Update dependencies from `ui` to `gpui-component`.
This commit is contained in:
Floyd Wang 2025-02-06 17:21:46 +08:00 committed by GitHub
parent e423497da6
commit abb3de013e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 118 additions and 116 deletions

View file

@ -5,15 +5,17 @@ default-members = ["crates/story"]
resolver = "2" resolver = "2"
[workspace.dependencies] [workspace.dependencies]
anyhow = "1" gpui-component = { path = "crates/ui" }
story = { path = "crates/story" }
gpui = { git = "https://github.com/huacnlee/zed.git", branch = "webview" } gpui = { git = "https://github.com/huacnlee/zed.git", branch = "webview" }
anyhow = "1"
log = "0.4" log = "0.4"
rust-embed = "8.5.0"
serde = "1.0.203" serde = "1.0.203"
serde_json = "1" serde_json = "1"
smallvec = "1" smallvec = "1"
rust-embed = "8.5.0"
story = { path = "crates/story" }
ui = { package = "gpui-component", path = "crates/ui" }
windows = { version = "0.58.0", features = [ windows = { version = "0.58.0", features = [
"Wdk", "Wdk",
"Wdk_System", "Wdk_System",

View file

@ -58,7 +58,7 @@ And GPUI Component depends on `gpui` by special version (It keep updated to upst
```toml ```toml
gpui = { git = "https://github.com/huacnlee/zed.git", branch = "export-platform-window" } gpui = { git = "https://github.com/huacnlee/zed.git", branch = "export-platform-window" }
ui = { git = "https://github.com/longbridge/gpui-component.git" } gpui-component = { git = "https://github.com/longbridge/gpui-component.git" }
``` ```
More usage can be found in [story](https://github.com/longbridge/gpui-component/tree/main/crates/story) directory. More usage can be found in [story](https://github.com/longbridge/gpui-component/tree/main/crates/story) directory.

View file

@ -1,22 +1,22 @@
[package] [package]
name = "story"
version = "0.1.0"
edition = "2021" edition = "2021"
name = "story"
publish = false publish = false
version = "0.1.0"
[dependencies] [dependencies]
ui.workspace = true anyhow.workspace = true
gpui.workspace = true
fake = { version = "2.10.0", features = ["dummy"] }
charts-rs = "0.3" charts-rs = "0.3"
regex = "1"
chrono = "0.4" chrono = "0.4"
fake = { version = "2.10.0", features = ["dummy"] }
gpui.workspace = true
gpui-component.workspace = true
rand = "0.8"
regex = "1"
rust-embed.workspace = true
serde = "1" serde = "1"
serde_json = "1" serde_json = "1"
unindent = "0.2.3" unindent = "0.2.3"
anyhow.workspace = true
rust-embed.workspace = true
rand = "0.8"
[lints] [lints]
workspace = true workspace = true

View file

@ -2,7 +2,7 @@ use gpui::{
App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement as _, App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement as _,
Render, Styled as _, Window, Render, Styled as _, Window,
}; };
use ui::{ use gpui_component::{
accordion::Accordion, accordion::Accordion,
button::{Button, ButtonGroup}, button::{Button, ButtonGroup},
checkbox::Checkbox, checkbox::Checkbox,

View file

@ -3,11 +3,12 @@ use gpui::{
Focusable, InteractiveElement, IntoElement, ParentElement as _, Render, Styled as _, Window, Focusable, InteractiveElement, IntoElement, ParentElement as _, Render, Styled as _, Window,
}; };
use ui::{ use gpui_component::{
black,
button::{Button, ButtonCustomVariant, ButtonGroup, ButtonVariants as _, DropdownButton}, button::{Button, ButtonCustomVariant, ButtonGroup, ButtonVariants as _, DropdownButton},
checkbox::Checkbox, checkbox::Checkbox,
h_flex, v_flex, ActiveTheme, Disableable as _, Icon, IconName, Selectable as _, Sizable as _, green_500, green_600, green_800, green_900, green_950, h_flex, v_flex, white, ActiveTheme,
Theme, Disableable as _, Icon, IconName, Selectable as _, Sizable as _, Theme,
}; };
use crate::section; use crate::section;
@ -209,29 +210,29 @@ impl Render for ButtonStory {
.custom( .custom(
ButtonCustomVariant::new(cx) ButtonCustomVariant::new(cx)
.color(if cx.theme().mode.is_dark() { .color(if cx.theme().mode.is_dark() {
ui::green_900() green_900()
} else { } else {
ui::green_500() green_500()
}) })
.foreground(if cx.theme().mode.is_dark() { .foreground(if cx.theme().mode.is_dark() {
ui::white() white()
} else { } else {
ui::black() black()
}) })
.border(if cx.theme().mode.is_dark() { .border(if cx.theme().mode.is_dark() {
ui::green_800() green_800()
} else { } else {
ui::green_600() green_600()
}) })
.hover(if cx.theme().mode.is_dark() { .hover(if cx.theme().mode.is_dark() {
ui::green_800() green_800()
} else { } else {
ui::green_500() green_500()
}) })
.active(if cx.theme().mode.is_dark() { .active(if cx.theme().mode.is_dark() {
ui::green_950() green_950()
} else { } else {
ui::green_600() green_600()
}), }),
) )
.label("Custom Button") .label("Custom Button")

View file

@ -3,7 +3,7 @@ use gpui::{
px, App, AppContext, Context, Entity, Focusable, IntoElement, ParentElement as _, Render, px, App, AppContext, Context, Entity, Focusable, IntoElement, ParentElement as _, Render,
Styled as _, Window, Styled as _, Window,
}; };
use ui::{ use gpui_component::{
button::Button, button::Button,
date_picker::{DatePicker, DatePickerEvent, DateRangePreset}, date_picker::{DatePicker, DatePickerEvent, DateRangePreset},
v_flex, Sizable as _, Size, v_flex, Sizable as _, Size,

View file

@ -3,7 +3,7 @@ use gpui::{
KeyBinding, ParentElement, Render, SharedString, Styled, Window, KeyBinding, ParentElement, Render, SharedString, Styled, Window,
}; };
use ui::{ use gpui_component::{
checkbox::Checkbox, checkbox::Checkbox,
dropdown::{Dropdown, DropdownEvent, DropdownItem, SearchableVec}, dropdown::{Dropdown, DropdownEvent, DropdownItem, SearchableVec},
h_flex, v_flex, ActiveTheme, FocusableCycle, IconName, Sizable, h_flex, v_flex, ActiveTheme, FocusableCycle, IconName, Sizable,

View file

@ -2,7 +2,7 @@ use gpui::{
actions, div, prelude::FluentBuilder as _, App, AppContext, Axis, Context, Entity, Focusable, actions, div, prelude::FluentBuilder as _, App, AppContext, Axis, Context, Entity, Focusable,
InteractiveElement, IntoElement, ParentElement as _, Render, Styled, Window, InteractiveElement, IntoElement, ParentElement as _, Render, Styled, Window,
}; };
use ui::{ use gpui_component::{
button::{Button, ButtonGroup}, button::{Button, ButtonGroup},
checkbox::Checkbox, checkbox::Checkbox,
date_picker::DatePicker, date_picker::DatePicker,

View file

@ -2,10 +2,10 @@ use gpui::{
px, rems, App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement, px, rems, App, AppContext, Context, Entity, FocusHandle, Focusable, IntoElement, ParentElement,
Render, Styled, Window, Render, Styled, Window,
}; };
use ui::{ use gpui_component::{
button::{Button, ButtonVariant, ButtonVariants}, button::{Button, ButtonVariant, ButtonVariants},
dock::PanelControl, dock::PanelControl,
h_flex, v_flex, ActiveTheme as _, Icon, IconName, gray_500, green_500, h_flex, red_500, v_flex, ActiveTheme as _, Icon, IconName,
}; };
pub struct IconStory { pub struct IconStory {
@ -53,25 +53,17 @@ impl Render for IconStory {
.child( .child(
Icon::new(IconName::Maximize) Icon::new(IconName::Maximize)
.size_6() .size_6()
.text_color(ui::green_500()), .text_color(green_500()),
) )
.child(Icon::new(IconName::Maximize).size(px(55.))) .child(Icon::new(IconName::Maximize).size(px(55.)))
.child( .child(
Button::new("like1") Button::new("like1")
.icon( .icon(Icon::new(IconName::Heart).text_color(gray_500()).size_6())
Icon::new(IconName::Heart)
.text_color(ui::gray_500())
.size_6(),
)
.with_variant(ButtonVariant::Ghost), .with_variant(ButtonVariant::Ghost),
) )
.child( .child(
Button::new("like2") Button::new("like2")
.icon( .icon(Icon::new(IconName::HeartOff).text_color(red_500()).size_6())
Icon::new(IconName::HeartOff)
.text_color(ui::red_500())
.size_6(),
)
.with_variant(ButtonVariant::Ghost), .with_variant(ButtonVariant::Ghost),
) )
.child( .child(

View file

@ -1,7 +1,7 @@
use gpui::{ use gpui::{
px, App, AppContext, Entity, FocusHandle, Focusable, ParentElement as _, Render, Styled, Window, px, App, AppContext, Entity, FocusHandle, Focusable, ParentElement as _, Render, Styled, Window,
}; };
use ui::{dock::PanelControl, h_flex, v_flex, SvgImg}; use gpui_component::{dock::PanelControl, h_flex, v_flex, SvgImg};
const GOOGLE_LOGO: &str = include_str!("./fixtures/google.svg"); const GOOGLE_LOGO: &str = include_str!("./fixtures/google.svg");
const PIE_JSON: &str = include_str!("./fixtures/pie.json"); const PIE_JSON: &str = include_str!("./fixtures/pie.json");

View file

@ -6,11 +6,11 @@ use gpui::{
use regex::Regex; use regex::Regex;
use crate::section; use crate::section;
use ui::{ use gpui_component::{
button::{Button, ButtonVariant, ButtonVariants as _}, button::{Button, ButtonVariant, ButtonVariants as _},
checkbox::Checkbox, checkbox::Checkbox,
h_flex, h_flex,
input::{InputEvent, NumberInput, NumberInputEvent, OtpInput, TextInput}, input::{InputEvent, NumberInput, NumberInputEvent, OtpInput, StepAction, TextInput},
v_flex, FocusableCycle, IconName, Sizable, v_flex, FocusableCycle, IconName, Sizable,
}; };
@ -269,13 +269,13 @@ impl InputStory {
InputEvent::Blur => println!("Blur"), InputEvent::Blur => println!("Blur"),
}, },
NumberInputEvent::Step(step_action) => match step_action { NumberInputEvent::Step(step_action) => match step_action {
ui::input::StepAction::Decrement => { StepAction::Decrement => {
self.number_input1_value = self.number_input1_value - 1; self.number_input1_value = self.number_input1_value - 1;
self.number_input1.update(cx, |input, cx| { self.number_input1.update(cx, |input, cx| {
input.set_value(self.number_input1_value.to_string(), window, cx); input.set_value(self.number_input1_value.to_string(), window, cx);
}); });
} }
ui::input::StepAction::Increment => { StepAction::Increment => {
self.number_input1_value = self.number_input1_value + 1; self.number_input1_value = self.number_input1_value + 1;
self.number_input1.update(cx, |input, cx| { self.number_input1.update(cx, |input, cx| {
input.set_value(self.number_input1_value.to_string(), window, cx); input.set_value(self.number_input1_value.to_string(), window, cx);
@ -300,7 +300,7 @@ impl InputStory {
InputEvent::Blur => println!("Blur"), InputEvent::Blur => println!("Blur"),
}, },
NumberInputEvent::Step(step_action) => match step_action { NumberInputEvent::Step(step_action) => match step_action {
ui::input::StepAction::Decrement => { StepAction::Decrement => {
if self.number_input2_value.le(&0) { if self.number_input2_value.le(&0) {
return; return;
} }
@ -310,7 +310,7 @@ impl InputStory {
input.set_value(self.number_input2_value.to_string(), window, cx); input.set_value(self.number_input2_value.to_string(), window, cx);
}); });
} }
ui::input::StepAction::Increment => { StepAction::Increment => {
self.number_input2_value = self.number_input2_value + 1; self.number_input2_value = self.number_input2_value + 1;
self.number_input2.update(cx, |input, cx| { self.number_input2.update(cx, |input, cx| {
input.set_value(self.number_input2_value.to_string(), window, cx); input.set_value(self.number_input2_value.to_string(), window, cx);

View file

@ -53,7 +53,7 @@ pub use title_bar::AppTitleBar;
pub use tooltip_story::TooltipStory; pub use tooltip_story::TooltipStory;
pub use webview_story::WebViewStory; pub use webview_story::WebViewStory;
use ui::{ use gpui_component::{
button::Button, button::Button,
divider::Divider, divider::Divider,
dock::{register_panel, Panel, PanelControl, PanelEvent, PanelInfo, PanelState, TitleStyle}, dock::{register_panel, Panel, PanelControl, PanelEvent, PanelInfo, PanelState, TitleStyle},
@ -188,7 +188,7 @@ impl Render for StoryRoot {
impl Global for AppState {} impl Global for AppState {}
pub fn init(cx: &mut App) { pub fn init(cx: &mut App) {
ui::init(cx); gpui_component::init(cx);
AppState::init(cx); AppState::init(cx);
input_story::init(cx); input_story::init(cx);
dropdown_story::init(cx); dropdown_story::init(cx);
@ -229,7 +229,7 @@ pub fn init(cx: &mut App) {
actions!(story, [ShowPanelInfo]); actions!(story, [ShowPanelInfo]);
pub fn section(title: impl IntoElement, cx: &App) -> Div { pub fn section(title: impl IntoElement, cx: &App) -> Div {
use ui::ActiveTheme; use gpui_component::ActiveTheme;
let theme = cx.theme(); let theme = cx.theme();
h_flex() h_flex()

View file

@ -8,7 +8,7 @@ use gpui::{
Subscription, Task, Timer, Window, Subscription, Task, Timer, Window,
}; };
use ui::{ use gpui_component::{
button::Button, button::Button,
checkbox::Checkbox, checkbox::Checkbox,
h_flex, hsl, h_flex, hsl,

View file

@ -1,5 +1,11 @@
use anyhow::{Context as _, Result}; use anyhow::{Context as _, Result};
use gpui::*; use gpui::*;
use gpui_component::{
button::{Button, ButtonVariants as _},
dock::{DockArea, DockAreaState, DockEvent, DockItem, DockPlacement},
popup_menu::PopupMenuExt,
IconName, Root, Sizable, Theme, TitleBar,
};
use serde::Deserialize; use serde::Deserialize;
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
use story::{ use story::{
@ -8,12 +14,6 @@ use story::{
ProgressStory, Quit, ResizableStory, ScrollableStory, SidebarStory, StoryContainer, ProgressStory, Quit, ResizableStory, ScrollableStory, SidebarStory, StoryContainer,
SwitchStory, TableStory, TextStory, TooltipStory, SwitchStory, TableStory, TextStory, TooltipStory,
}; };
use ui::{
button::{Button, ButtonVariants as _},
dock::{DockArea, DockAreaState, DockEvent, DockItem, DockPlacement},
popup_menu::PopupMenuExt,
IconName, Root, Sizable, Theme, TitleBar,
};
#[derive(Clone, PartialEq, Eq, Deserialize)] #[derive(Clone, PartialEq, Eq, Deserialize)]
pub struct AddPanel(DockPlacement); pub struct AddPanel(DockPlacement);
@ -33,7 +33,7 @@ pub fn init(cx: &mut App) {
cx.on_action(|_action: &Open, _cx: &mut App| {}); cx.on_action(|_action: &Open, _cx: &mut App| {});
ui::init(cx); gpui_component::init(cx);
story::init(cx); story::init(cx);
} }
@ -506,7 +506,7 @@ impl Render for StoryWorkspace {
} }
fn main() { fn main() {
use ui::input::{Copy, Cut, Paste, Redo, Undo}; use gpui_component::input::{Copy, Cut, Paste, Redo, Undo};
let app = Application::new().with_assets(Assets); let app = Application::new().with_assets(Assets);

View file

@ -7,7 +7,7 @@ use gpui::{
Task, Timer, WeakEntity, Window, Task, Timer, WeakEntity, Window,
}; };
use ui::{ use gpui_component::{
button::{Button, ButtonVariant, ButtonVariants as _}, button::{Button, ButtonVariant, ButtonVariants as _},
checkbox::Checkbox, checkbox::Checkbox,
date_picker::DatePicker, date_picker::DatePicker,
@ -19,7 +19,7 @@ use ui::{
notification::{Notification, NotificationType}, notification::{Notification, NotificationType},
v_flex, v_flex,
webview::WebView, webview::WebView,
ActiveTheme as _, ContextModal as _, Icon, IconName, Placement, wry, ActiveTheme as _, ContextModal as _, Icon, IconName, Placement,
}; };
actions!(modal_story, [TestAction]); actions!(modal_story, [TestAction]);
@ -76,7 +76,7 @@ impl ListDelegate for ListItemDeletegate {
if let Some(item) = self.matches.get(ix) { if let Some(item) = self.matches.get(ix) {
let list_item = ListItem::new(("item", ix)) let list_item = ListItem::new(("item", ix))
.check_icon(ui::IconName::Check) .check_icon(IconName::Check)
.confirmed(confirmed) .confirmed(confirmed)
.selected(selected) .selected(selected)
.py_1() .py_1()
@ -523,7 +523,7 @@ impl Render for ModalStory {
.child(Button::new("webview").label("Open WebView").on_click( .child(Button::new("webview").label("Open WebView").on_click(
cx.listener(|_, _, window, cx| { cx.listener(|_, _, window, cx| {
let webview = cx.new(|cx| { let webview = cx.new(|cx| {
let webview = ui::wry::WebViewBuilder::new() let webview = wry::WebViewBuilder::new()
.build_as_child(&window.raw_window_handle()) .build_as_child(&window.raw_window_handle())
.unwrap(); .unwrap();

View file

@ -3,8 +3,7 @@ use gpui::{
Element, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, Element, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement,
KeyBinding, MouseButton, ParentElement as _, Render, SharedString, Styled as _, Window, KeyBinding, MouseButton, ParentElement as _, Render, SharedString, Styled as _, Window,
}; };
use serde::Deserialize; use gpui_component::{
use ui::{
button::{Button, ButtonVariants as _}, button::{Button, ButtonVariants as _},
context_menu::ContextMenuExt, context_menu::ContextMenuExt,
divider::Divider, divider::Divider,
@ -15,6 +14,7 @@ use ui::{
switch::Switch, switch::Switch,
v_flex, ActiveTheme as _, ContextModal, IconName, Sizable, v_flex, ActiveTheme as _, ContextModal, IconName, Sizable,
}; };
use serde::Deserialize;
#[derive(Clone, PartialEq, Deserialize)] #[derive(Clone, PartialEq, Deserialize)]
struct Info(usize); struct Info(usize);

View file

@ -2,11 +2,12 @@ use gpui::{
div, hsla, px, App, AppContext, Context, Entity, Focusable, Hsla, IntoElement, ParentElement, div, hsla, px, App, AppContext, Context, Entity, Focusable, Hsla, IntoElement, ParentElement,
Render, SharedString, Styled, Subscription, Window, Render, SharedString, Styled, Subscription, Window,
}; };
use ui::{ use gpui_component::{
blue_500,
button::Button, button::Button,
clipboard::Clipboard, clipboard::Clipboard,
divider::Divider, divider::Divider,
h_flex, gray_300, h_flex,
indicator::Indicator, indicator::Indicator,
progress::Progress, progress::Progress,
skeleton::Skeleton, skeleton::Skeleton,
@ -204,7 +205,7 @@ impl Render for ProgressStory {
Indicator::new() Indicator::new()
.large() .large()
.icon(IconName::LoaderCircle) .icon(IconName::LoaderCircle)
.color(ui::blue_500()), .color(blue_500()),
) )
.child(Indicator::new().with_size(px(64.))), .child(Indicator::new().with_size(px(64.))),
) )
@ -212,7 +213,7 @@ impl Render for ProgressStory {
Divider::horizontal() Divider::horizontal()
.mt_10() .mt_10()
.label("Slider") .label("Slider")
.color(ui::gray_300()), .color(gray_300()),
) )
.child(self.slider1.clone()) .child(self.slider1.clone())
.child(format!("Slider 1: {}", self.slider1_value)) .child(format!("Slider 1: {}", self.slider1_value))

View file

@ -2,10 +2,9 @@ use gpui::{
div, px, AnyElement, App, AppContext, Context, Entity, Focusable, IntoElement, div, px, AnyElement, App, AppContext, Context, Entity, Focusable, IntoElement,
ParentElement as _, Render, SharedString, Styled, Window, ParentElement as _, Render, SharedString, Styled, Window,
}; };
use ui::ActiveTheme; use gpui_component::{
use ui::{
resizable::{h_resizable, resizable_panel, v_resizable, ResizablePanelGroup}, resizable::{h_resizable, resizable_panel, v_resizable, ResizablePanelGroup},
v_flex, v_flex, ActiveTheme,
}; };
pub struct ResizableStory { pub struct ResizableStory {

View file

@ -5,12 +5,14 @@ use gpui::{
div, px, size, App, AppContext, Context, Entity, Focusable, InteractiveElement, IntoElement, div, px, size, App, AppContext, Context, Entity, Focusable, InteractiveElement, IntoElement,
ParentElement, Pixels, Render, ScrollHandle, SharedString, Size, Styled, Window, ParentElement, Pixels, Render, ScrollHandle, SharedString, Size, Styled, Window,
}; };
use ui::button::Button; use gpui_component::{
use ui::divider::Divider; button::Button,
use ui::label::Label; divider::Divider,
use ui::scroll::{Scrollbar, ScrollbarAxis, ScrollbarState}; gray_100, gray_800, h_flex,
use ui::ActiveTheme; label::Label,
use ui::{h_flex, v_flex, v_virtual_list, StyledExt as _}; scroll::{Scrollbar, ScrollbarAxis, ScrollbarState},
v_flex, v_virtual_list, ActiveTheme as _, StyledExt as _,
};
pub struct ScrollableStory { pub struct ScrollableStory {
focus_handle: gpui::FocusHandle, focus_handle: gpui::FocusHandle,
@ -212,9 +214,9 @@ impl Render for ScrollableStory {
.bg( .bg(
if cx.theme().mode.is_dark() if cx.theme().mode.is_dark()
{ {
ui::gray_800() gray_800()
} else { } else {
ui::gray_100() gray_100()
}, },
) )
.child(if i == 0 { .child(if i == 0 {

View file

@ -3,8 +3,8 @@ use gpui::{
Context, Entity, Focusable, ParentElement, Render, SharedString, Styled, Window, Context, Entity, Focusable, ParentElement, Render, SharedString, Styled, Window,
}; };
use serde::Deserialize; use gpui_component::{
use ui::{ blue_500,
breadcrumb::{Breadcrumb, BreadcrumbItem}, breadcrumb::{Breadcrumb, BreadcrumbItem},
divider::Divider, divider::Divider,
h_flex, h_flex,
@ -12,8 +12,9 @@ use ui::{
sidebar::{ sidebar::{
Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarMenu, SidebarToggleButton, Sidebar, SidebarFooter, SidebarGroup, SidebarHeader, SidebarMenu, SidebarToggleButton,
}, },
v_flex, ActiveTheme, Collapsible, Icon, IconName, v_flex, white, ActiveTheme, Collapsible, Icon, IconName,
}; };
use serde::Deserialize;
#[derive(Clone, PartialEq, Eq, Deserialize)] #[derive(Clone, PartialEq, Eq, Deserialize)]
pub struct SelectCompany(SharedString); pub struct SelectCompany(SharedString);
@ -216,8 +217,8 @@ impl Render for SidebarStory {
.items_center() .items_center()
.justify_center() .justify_center()
.rounded(cx.theme().radius) .rounded(cx.theme().radius)
.bg(ui::blue_500()) .bg(blue_500())
.text_color(ui::white()) .text_color(white())
.size_8() .size_8()
.flex_shrink_0() .flex_shrink_0()
.child(Icon::new(IconName::GalleryVerticalEnd).size_4()) .child(Icon::new(IconName::GalleryVerticalEnd).size_4())

View file

@ -3,7 +3,7 @@ use gpui::{
SharedString, Styled, Window, SharedString, Styled, Window,
}; };
use ui::{ use gpui_component::{
checkbox::Checkbox, checkbox::Checkbox,
h_flex, h_flex,
label::Label, label::Label,

View file

@ -9,18 +9,19 @@ use gpui::{
Context, Edges, Entity, Focusable, InteractiveElement, IntoElement, ParentElement, Pixels, Context, Edges, Entity, Focusable, InteractiveElement, IntoElement, ParentElement, Pixels,
Render, SharedString, Styled, Timer, Window, Render, SharedString, Styled, Timer, Window,
}; };
use serde::Deserialize; use gpui_component::{
use ui::{
button::Button, button::Button,
checkbox::Checkbox, checkbox::Checkbox,
h_flex, green, h_flex,
indicator::Indicator, indicator::Indicator,
input::{InputEvent, TextInput}, input::{InputEvent, TextInput},
label::Label, label::Label,
popup_menu::{PopupMenu, PopupMenuExt}, popup_menu::{PopupMenu, PopupMenuExt},
table::{ColFixed, ColSort, Table, TableDelegate, TableEvent}, red,
table::{self, ColFixed, ColSort, Table, TableDelegate, TableEvent},
v_flex, ActiveTheme as _, Selectable, Sizable as _, Size, StyleSized as _, v_flex, ActiveTheme as _, Selectable, Sizable as _, Size, StyleSized as _,
}; };
use serde::Deserialize;
#[derive(Clone, PartialEq, Eq, Deserialize)] #[derive(Clone, PartialEq, Eq, Deserialize)]
struct ChangeSize(Size); struct ChangeSize(Size);
@ -274,11 +275,11 @@ impl StockTableDelegate {
let right_num = ((val - val.floor()) * 1000.).floor() as i32; let right_num = ((val - val.floor()) * 1000.).floor() as i32;
let this = if right_num % 3 == 0 { let this = if right_num % 3 == 0 {
this.text_color(ui::red(fg_scale)) this.text_color(red(fg_scale))
.bg(ui::red(bg_scale).opacity(opacity)) .bg(red(bg_scale).opacity(opacity))
} else if right_num % 3 == 1 { } else if right_num % 3 == 1 {
this.text_color(ui::green(fg_scale)) this.text_color(green(fg_scale))
.bg(ui::green(bg_scale).opacity(opacity)) .bg(green(bg_scale).opacity(opacity))
} else { } else {
this this
}; };
@ -322,7 +323,7 @@ impl TableDelegate for StockTableDelegate {
} }
} }
fn col_fixed(&self, col_ix: usize, _: &App) -> Option<ui::table::ColFixed> { fn col_fixed(&self, col_ix: usize, _: &App) -> Option<table::ColFixed> {
if !self.fixed_cols { if !self.fixed_cols {
return None; return None;
} }

View file

@ -3,14 +3,15 @@ use gpui::{
SharedString, Styled, Window, SharedString, Styled, Window,
}; };
use ui::{ use gpui_component::{
button::{Button, ButtonVariant, ButtonVariants as _}, button::{Button, ButtonVariant, ButtonVariants as _},
clipboard::Clipboard, clipboard::Clipboard,
h_flex, h_flex,
label::Label, label::Label,
link::Link, link::Link,
red_500,
tag::Tag, tag::Tag,
v_flex, IconName, Sizable, StyledExt, v_flex, yellow_500, yellow_800, IconName, Sizable, StyledExt,
}; };
use crate::section; use crate::section;
@ -71,7 +72,7 @@ impl Render for TextStory {
.child(Label::new("Text align center").text_center()) .child(Label::new("Text align center").text_center())
.child(Label::new("Text align right").text_right()), .child(Label::new("Text align right").text_right()),
) )
.child(Label::new("Color Label").text_color(ui::red_500())) .child(Label::new("Color Label").text_color(red_500()))
.child( .child(
Label::new("Font Size Label") Label::new("Font Size Label")
.text_size(px(20.)) .text_size(px(20.))
@ -104,8 +105,8 @@ impl Render for TextStory {
.child( .child(
Link::new("link2") Link::new("link2")
.href("https://github.com") .href("https://github.com")
.text_color(ui::red_500()) .text_color(red_500())
.text_decoration_color(ui::red_500()) .text_decoration_color(red_500())
.child("Red Link"), .child("Red Link"),
) )
.child( .child(
@ -199,7 +200,7 @@ impl Render for TextStory {
.child(Tag::outline().small().child("Outline")) .child(Tag::outline().small().child("Outline"))
.child(Tag::danger().small().child("danger")) .child(Tag::danger().small().child("danger"))
.child( .child(
Tag::custom(ui::yellow_500(), ui::yellow_800(), ui::yellow_500()) Tag::custom(yellow_500(), yellow_800(), yellow_500())
.small() .small()
.child("Custom"), .child("Custom"),
), ),
@ -212,7 +213,7 @@ impl Render for TextStory {
.child(Tag::outline().child("Outline")) .child(Tag::outline().child("Outline"))
.child(Tag::danger().child("danger")) .child(Tag::danger().child("danger"))
.child( .child(
Tag::custom(ui::yellow_500(), ui::yellow_800(), ui::yellow_500()) Tag::custom(yellow_500(), yellow_800(), yellow_500())
.child("Custom"), .child("Custom"),
), ),
), ),

View file

@ -5,13 +5,15 @@ use gpui::{
Entity, FocusHandle, Hsla, InteractiveElement as _, IntoElement, MouseButton, Entity, FocusHandle, Hsla, InteractiveElement as _, IntoElement, MouseButton,
ParentElement as _, Render, SharedString, Styled as _, Subscription, Window, ParentElement as _, Render, SharedString, Styled as _, Subscription, Window,
}; };
use ui::{ use gpui_component::{
badge::Badge, badge::Badge,
button::{Button, ButtonVariants as _}, button::{Button, ButtonVariants as _},
color_picker::{ColorPicker, ColorPickerEvent}, color_picker::{ColorPicker, ColorPickerEvent},
locale,
popup_menu::PopupMenuExt as _, popup_menu::PopupMenuExt as _,
scroll::ScrollbarShow, scroll::ScrollbarShow,
ActiveTheme as _, ContextModal as _, IconName, Sizable as _, Theme, TitleBar, set_locale, ActiveTheme as _, ContextModal as _, IconName, Sizable as _, Theme, ThemeMode,
TitleBar,
}; };
use crate::{SelectFont, SelectLocale, SelectRadius, SelectScrollbarShow}; use crate::{SelectFont, SelectLocale, SelectRadius, SelectScrollbarShow};
@ -90,8 +92,8 @@ impl AppTitleBar {
fn change_color_mode(&mut self, _: &ClickEvent, window: &mut Window, cx: &mut Context<Self>) { fn change_color_mode(&mut self, _: &ClickEvent, window: &mut Window, cx: &mut Context<Self>) {
let mode = match cx.theme().mode.is_dark() { let mode = match cx.theme().mode.is_dark() {
true => ui::ThemeMode::Light, true => ThemeMode::Light,
false => ui::ThemeMode::Dark, false => ThemeMode::Dark,
}; };
Theme::change(mode, None, cx); Theme::change(mode, None, cx);
@ -174,7 +176,7 @@ impl LocaleSelector {
window: &mut Window, window: &mut Window,
_: &mut Context<Self>, _: &mut Context<Self>,
) { ) {
ui::set_locale(&locale.0); set_locale(&locale.0);
window.refresh(); window.refresh();
} }
} }
@ -182,7 +184,7 @@ impl LocaleSelector {
impl Render for LocaleSelector { impl Render for LocaleSelector {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let focus_handle = self.focus_handle.clone(); let focus_handle = self.focus_handle.clone();
let locale = ui::locale().to_string(); let locale = locale().to_string();
div() div()
.id("locale-selector") .id("locale-selector")

View file

@ -3,7 +3,7 @@ use gpui::{
ParentElement, Render, StatefulInteractiveElement, Styled, Window, ParentElement, Render, StatefulInteractiveElement, Styled, Window,
}; };
use ui::{ use gpui_component::{
button::{Button, ButtonVariant, ButtonVariants}, button::{Button, ButtonVariant, ButtonVariants},
checkbox::Checkbox, checkbox::Checkbox,
dock::PanelControl, dock::PanelControl,

View file

@ -2,12 +2,12 @@ use gpui::{
div, App, AppContext, ClickEvent, Context, Entity, FocusHandle, Focusable, IntoElement, div, App, AppContext, ClickEvent, Context, Entity, FocusHandle, Focusable, IntoElement,
ParentElement as _, Render, Styled as _, Window, ParentElement as _, Render, Styled as _, Window,
}; };
use ui::{ use gpui_component::{
h_flex, h_flex,
input::{InputEvent, TextInput}, input::{InputEvent, TextInput},
v_flex, v_flex,
webview::WebView, webview::WebView,
ActiveTheme, wry, ActiveTheme,
}; };
pub struct WebViewStory { pub struct WebViewStory {
@ -31,7 +31,7 @@ impl WebViewStory {
let focus_handle = cx.focus_handle(); let focus_handle = cx.focus_handle();
let webview = cx.new(|cx| { let webview = cx.new(|cx| {
let webview = ui::wry::WebViewBuilder::new() let webview = wry::WebViewBuilder::new()
.build_as_child(&window.raw_window_handle()) .build_as_child(&window.raw_window_handle())
.unwrap(); .unwrap();
WebView::new(webview, window, cx) WebView::new(webview, window, cx)