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
50 lines
1.2 KiB
Rust
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()
|
|
}
|
|
}
|