remove unused

This commit is contained in:
Nate Butler
2024-12-10 19:12:30 -05:00
parent 0c8bb20424
commit 8dddbf31bf

View File

@@ -2,20 +2,10 @@
//!
//! A view for exploring Zed components.
#![allow(unused, dead_code)]
use component_system::{get_all_component_previews, ComponentPreview as _};
use gpui::{
actions, hsla, Action, AnyElement, AppContext, EventEmitter, FocusHandle, FocusableView, Hsla,
};
use gpui::{prelude::*, AppContext, EventEmitter, FocusHandle, FocusableView};
use strum::IntoEnumIterator;
use ui::{
element_cell, prelude::*, string_cell, utils::calculate_contrast_ratio, AudioStatus,
Availability, Avatar, AvatarAudioStatusIndicator, AvatarAvailabilityIndicator, ButtonLike,
Checkbox, CheckboxWithLabel, ContentGroup, DecoratedIcon, ElevationIndex, Facepile,
IconDecoration, Indicator, Table, TintColor, Tooltip,
};
actions!(component_preview, []);
use ui::{prelude::*, Avatar, TintColor};
use workspace::{item::ItemEvent, Item, Workspace, WorkspaceId};
@@ -29,23 +19,6 @@ pub fn init(cx: &mut AppContext) {
.detach();
}
// pub fn show_component_preview(
// app_state: Arc<AppState>,
// cx: &mut AppContext,
// ) -> Task<anyhow::Result<()>> {
// open_new(Default::default(), app_state, cx, |workspace, cx| {
// workspace.toggle_dock(DockPosition::Left, cx);
// let welcome_page = WelcomePage::new(workspace, cx);
// workspace.add_item_to_center(Box::new(welcome_page.clone()), cx);
// cx.focus_view(&welcome_page);
// cx.notify();
// db::write_and_log(cx, || {
// KEY_VALUE_STORE.write_kvp(FIRST_OPEN.to_string(), "false".to_string())
// });
// })
// }
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, strum::EnumIter)]
enum ComponentPreviewPage {
Overview,
@@ -94,7 +67,7 @@ impl FocusableView for ComponentPreview {
impl Item for ComponentPreview {
type Event = ItemEvent;
fn tab_content_text(&self, cx: &WindowContext) -> Option<SharedString> {
fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {
Some("Component Preview".into())
}
@@ -122,13 +95,7 @@ impl Item for ComponentPreview {
}
}
const AVATAR_URL: &str = "https://avatars.githubusercontent.com/u/1714999?v=4";
impl ComponentPreview {
fn preview_bg(cx: &WindowContext) -> Hsla {
cx.theme().colors().editor_background
}
fn render_overview_page(&self, cx: &ViewContext<Self>) -> impl IntoElement {
let all_previews = get_all_component_previews();
@@ -144,9 +111,10 @@ impl ComponentPreview {
.gap_4()
.child(Headline::new(preview_name).size(HeadlineSize::Small))
.child(
// TODO: We should get preview functions from all_previews,
// not just strings so we don't have to do this match
div().id(id).child(match preview_name {
"Avatar" => Avatar::preview(cx),
// Add other component preview matches here
_ => div()
.child(format!("Preview not implemented for {}", preview_name))
.into_any_element(),
@@ -161,7 +129,7 @@ impl ComponentPreview {
.items_center()
.gap_4()
.py_2()
.bg(Self::preview_bg(cx))
.bg(cx.theme().colors().editor_background)
.children(ComponentPreviewPage::iter().map(|p| {
Button::new(ElementId::Name(p.name().into()), p.name())
.on_click(cx.listener(move |this, _, cx| {
@@ -185,7 +153,7 @@ impl Render for ComponentPreview {
.max_h_full()
.track_focus(&self.focus_handle)
.px_2()
.bg(Self::preview_bg(cx))
.bg(cx.theme().colors().editor_background)
.child(self.render_page_nav(cx))
.child(self.view(self.current_page, cx))
}