Files
oak-gpui/crates/collab_ui/src/face_pile.rs
T
Marshall Bowers 8871fec2a8 Adjust names of negated style methods (#11453)
This PR adjusts the names of the negated style methods by moving the
`neg_` to after the property name instead of before.

This will help keep related style methods grouped together in
completions.

It also makes it a bit clearer that the negation applies to the value.

### Before

```rs
div()
    .neg_mx_1()
    .neg_mt_2()
```

### After

```rs
div()
    .mx_neg_1()
    .mt_neg_2()
```

Release Notes:

- N/A
2024-05-06 13:56:25 -04:00

50 lines
1.2 KiB
Rust

use gpui::AnyElement;
use smallvec::SmallVec;
use ui::prelude::*;
#[derive(IntoElement)]
pub struct FacePile {
base: Div,
faces: SmallVec<[AnyElement; 2]>,
}
impl FacePile {
pub fn empty() -> Self {
Self::new(SmallVec::new())
}
pub fn new(faces: SmallVec<[AnyElement; 2]>) -> Self {
Self { base: div(), faces }
}
}
impl RenderOnce for FacePile {
fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
// Lay the faces out in reverse so they overlap in the desired order (left to right, front to back)
self.base
.flex()
.flex_row_reverse()
.items_center()
.justify_start()
.children(
self.faces
.into_iter()
.enumerate()
.rev()
.map(|(ix, player)| div().when(ix > 0, |div| div.ml_neg_1()).child(player)),
)
}
}
impl ParentElement for FacePile {
fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
self.faces.extend(elements);
}
}
impl Styled for FacePile {
fn style(&mut self) -> &mut gpui::StyleRefinement {
self.base.style()
}
}