Make border methods always require an explicit width (#11450)

This PR makes the `border` methods require an explicit width instead of
defaulting to 1px.

This breaks convention with Tailwind, but it makes GPUI more consistent
with itself. We already have an edge case where the parameterized method
had to be named `border_width`, since `border` was taken up by an alias
for the 1px variant.

### Before

```rs
div()
    .border()
    .border_t()
    .border_r()
    .border_b()
    .border_l()
    .border_width(px(7.))
```

### After

```rs
div()
    .border_1()
    .border_t_1()
    .border_r_1()
    .border_b_1()
    .border_l_1()
    .border(px(7.))
```

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-05-06 13:22:47 -04:00 committed by GitHub
parent f99b24acca
commit f658af5903
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 49 additions and 55 deletions

View file

@ -115,7 +115,7 @@ impl RenderOnce for Avatar {
div
})
.when_some(self.border_color, |this, color| {
this.border_width(border_width).border_color(color)
this.border(border_width).border_color(color)
})
.child(
self.image

View file

@ -95,7 +95,7 @@ impl RenderOnce for Checkbox {
.size(crate::styles::custom_spacing(cx, 16.))
.rounded_sm()
.bg(bg_color)
.border()
.border_1()
.border_color(border_color)
.when(!self.disabled, |this| {
this.group_hover(group_id.clone(), |el| {

View file

@ -88,7 +88,7 @@ impl RenderOnce for CollapsibleContainer {
.relative()
.rounded_md()
.bg(styles.background_color)
.border()
.border_1()
.border_color(styles.border_color)
.text_color(styles.text_color)
.overflow_hidden()
@ -97,7 +97,7 @@ impl RenderOnce for CollapsibleContainer {
.overflow_hidden()
.w_full()
.group("toggleable_container_header")
.border_b()
.border_b_1()
.border_color(if self.toggle {
styles.border_color
} else {

View file

@ -393,7 +393,7 @@ impl RenderOnce for IconWithIndicator {
.absolute()
.w_2()
.h_2()
.border()
.border_1()
.border_color(indicator_border_color)
.rounded_full()
.neg_bottom_0p5()

View file

@ -161,7 +161,7 @@ impl RenderOnce for ListItem {
this
// TODO: Add focus state
// .when(self.state == InteractionState::Focused, |this| {
// this.border()
// this.border_1()
// .border_color(cx.theme().colors().border_focused)
// })
.hover(|style| style.bg(cx.theme().colors().ghost_element_hover))
@ -186,7 +186,7 @@ impl RenderOnce for ListItem {
this
// TODO: Add focus state
// .when(self.state == InteractionState::Focused, |this| {
// this.border()
// this.border_1()
// .border_color(cx.theme().colors().border_focused)
// })
.hover(|style| style.bg(cx.theme().colors().ghost_element_hover))

View file

@ -16,7 +16,7 @@ impl Render for CheckboxStory {
.p_2()
.gap_2()
.rounded_md()
.border()
.border_1()
.border_color(cx.theme().colors().border)
.child(Checkbox::new("checkbox-enabled", Selection::Unselected))
.child(Checkbox::new(
@ -31,7 +31,7 @@ impl Render for CheckboxStory {
.p_2()
.gap_2()
.rounded_md()
.border()
.border_1()
.border_color(cx.theme().colors().border)
.child(Checkbox::new("checkbox-disabled", Selection::Unselected).disabled(true))
.child(

View file

@ -124,21 +124,21 @@ impl RenderOnce for Tab {
.map(|this| match self.position {
TabPosition::First => {
if self.selected {
this.pl_px().border_r().pb_px()
this.pl_px().border_r_1().pb_px()
} else {
this.pl_px().pr_px().border_b()
this.pl_px().pr_px().border_b_1()
}
}
TabPosition::Last => {
if self.selected {
this.border_l().border_r().pb_px()
this.border_l_1().border_r_1().pb_px()
} else {
this.pr_px().pl_px().border_b().border_r()
this.pr_px().pl_px().border_b_1().border_r_1()
}
}
TabPosition::Middle(Ordering::Equal) => this.border_l().border_r().pb_px(),
TabPosition::Middle(Ordering::Less) => this.border_l().pr_px().border_b(),
TabPosition::Middle(Ordering::Greater) => this.border_r().pl_px().border_b(),
TabPosition::Middle(Ordering::Equal) => this.border_l_1().border_r_1().pb_px(),
TabPosition::Middle(Ordering::Less) => this.border_l_1().pr_px().border_b_1(),
TabPosition::Middle(Ordering::Greater) => this.border_r_1().pl_px().border_b_1(),
})
.cursor_pointer()
.child(

View file

@ -108,8 +108,8 @@ impl RenderOnce for TabBar {
.flex_none()
.gap(Spacing::Small.rems(cx))
.px(Spacing::Medium.rems(cx))
.border_b()
.border_r()
.border_b_1()
.border_r_1()
.border_color(cx.theme().colors().border)
.children(self.start_children),
)
@ -126,7 +126,7 @@ impl RenderOnce for TabBar {
.top_0()
.left_0()
.size_full()
.border_b()
.border_b_1()
.border_color(cx.theme().colors().border),
)
.child(
@ -146,8 +146,8 @@ impl RenderOnce for TabBar {
.flex_none()
.gap(Spacing::Small.rems(cx))
.px(Spacing::Medium.rems(cx))
.border_b()
.border_l()
.border_b_1()
.border_l_1()
.border_color(cx.theme().colors().border)
.children(self.end_children),
)