ui
crate docs & spring cleaning (#18768)
Similar to https://github.com/zed-industries/zed/pull/18690 & https://github.com/zed-industries/zed/pull/18695, this PR enables required docs for `ui` and does some cleanup. Changes: - Enables the `deny(missing_docs)` crate-wide. - Adds `allow(missing_docs)` on many modules until folks pick them up to document them - Documents some modules (all in `ui/src/styles`) - Crate root-level organization: Traits move to `traits`, other misc organization - Cleaned out a bunch of unused code. Note: I'd like to remove `utils/format_distance` but the assistant panel uses it. To move it over to use the `time_format` crate we may need to update it to use `time` instead of `chrono`. Needs more investigation. Release Notes: - N/A
This commit is contained in:
parent
c9bee9f81f
commit
8376dd2011
66 changed files with 405 additions and 364 deletions
|
@ -1,8 +1,9 @@
|
|||
#![allow(missing_docs)]
|
||||
use gpui::{relative, CursorStyle, DefiniteLength, MouseButton};
|
||||
use gpui::{transparent_black, AnyElement, AnyView, ClickEvent, Hsla, Rems};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{prelude::*, Elevation, ElevationIndex, Spacing};
|
||||
use crate::{prelude::*, ElevationIndex, Spacing};
|
||||
|
||||
/// A trait for buttons that can be Selected. Enables setting the [`ButtonStyle`] of a button when it is selected.
|
||||
pub trait SelectableButton: Selectable {
|
||||
|
@ -145,20 +146,12 @@ pub(crate) struct ButtonLikeStyles {
|
|||
pub icon_color: Hsla,
|
||||
}
|
||||
|
||||
fn element_bg_from_elevation(elevation: Option<Elevation>, cx: &mut WindowContext) -> Hsla {
|
||||
fn element_bg_from_elevation(elevation: Option<ElevationIndex>, cx: &mut WindowContext) -> Hsla {
|
||||
match elevation {
|
||||
Some(Elevation::ElevationIndex(ElevationIndex::Background)) => {
|
||||
cx.theme().colors().element_background
|
||||
}
|
||||
Some(Elevation::ElevationIndex(ElevationIndex::ElevatedSurface)) => {
|
||||
cx.theme().colors().surface_background
|
||||
}
|
||||
Some(Elevation::ElevationIndex(ElevationIndex::Surface)) => {
|
||||
cx.theme().colors().elevated_surface_background
|
||||
}
|
||||
Some(Elevation::ElevationIndex(ElevationIndex::ModalSurface)) => {
|
||||
cx.theme().colors().background
|
||||
}
|
||||
Some(ElevationIndex::Background) => cx.theme().colors().element_background,
|
||||
Some(ElevationIndex::ElevatedSurface) => cx.theme().colors().surface_background,
|
||||
Some(ElevationIndex::Surface) => cx.theme().colors().elevated_surface_background,
|
||||
Some(ElevationIndex::ModalSurface) => cx.theme().colors().background,
|
||||
_ => cx.theme().colors().element_background,
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +159,7 @@ fn element_bg_from_elevation(elevation: Option<Elevation>, cx: &mut WindowContex
|
|||
impl ButtonStyle {
|
||||
pub(crate) fn enabled(
|
||||
self,
|
||||
elevation: Option<Elevation>,
|
||||
elevation: Option<ElevationIndex>,
|
||||
cx: &mut WindowContext,
|
||||
) -> ButtonLikeStyles {
|
||||
let filled_background = element_bg_from_elevation(elevation, cx);
|
||||
|
@ -196,7 +189,7 @@ impl ButtonStyle {
|
|||
|
||||
pub(crate) fn hovered(
|
||||
self,
|
||||
elevation: Option<Elevation>,
|
||||
elevation: Option<ElevationIndex>,
|
||||
cx: &mut WindowContext,
|
||||
) -> ButtonLikeStyles {
|
||||
let mut filled_background = element_bg_from_elevation(elevation, cx);
|
||||
|
@ -281,7 +274,7 @@ impl ButtonStyle {
|
|||
#[allow(unused)]
|
||||
pub(crate) fn disabled(
|
||||
self,
|
||||
elevation: Option<Elevation>,
|
||||
elevation: Option<ElevationIndex>,
|
||||
cx: &mut WindowContext,
|
||||
) -> ButtonLikeStyles {
|
||||
element_bg_from_elevation(elevation, cx).fade_out(0.82);
|
||||
|
@ -348,7 +341,7 @@ pub struct ButtonLike {
|
|||
pub(super) selected_style: Option<ButtonStyle>,
|
||||
pub(super) width: Option<DefiniteLength>,
|
||||
pub(super) height: Option<DefiniteLength>,
|
||||
pub(super) layer: Option<Elevation>,
|
||||
pub(super) layer: Option<ElevationIndex>,
|
||||
size: ButtonSize,
|
||||
rounding: Option<ButtonLikeRounding>,
|
||||
tooltip: Option<Box<dyn Fn(&mut WindowContext) -> AnyView>>,
|
||||
|
@ -463,7 +456,7 @@ impl ButtonCommon for ButtonLike {
|
|||
}
|
||||
|
||||
fn layer(mut self, elevation: ElevationIndex) -> Self {
|
||||
self.layer = Some(elevation.into());
|
||||
self.layer = Some(elevation);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue