fix(ui): rail items centred, labels fit the item
- empty badge no longer sits in the flow and adds a gap - equal space above the icon and below the label (10px each) - 9px label with ellipsis, "Channels" no longer touches the edge Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -19,6 +19,8 @@ pub const RAIL_WIDTH: f32 = ITEM_WIDTH + 2. * ISLAND_GAP;
19
19
const ITEM_WIDTH: f32 = 48.;
20
20
const ITEM_HEIGHT: f32 = 52.;
21
21
const ICON_SIZE: f32 = 20.;
22
const LABEL_INSET: f32 = 2.;
23
const LABEL_HEIGHT: f32 = 12.;
22
24
23
25
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24
26
enum RailBadge {
@@ -141,6 +143,7 @@ fn item_element(item: &RailItem, active: bool) -> Stateful<Div> {
141
143
.flex_none()
142
144
.items_center()
143
145
.justify_center()
146
.pt(px(2.))
144
147
.gap(px(4.))
145
148
.rounded(px(10.))
146
149
.cursor_pointer()
@@ -151,13 +154,16 @@ fn item_element(item: &RailItem, active: bool) -> Stateful<Div> {
151
154
.child(icon(item.icon, ICON_SIZE, color))
152
155
.child(
153
156
div()
154
.whitespace_nowrap()
155
.text_size(px(10.))
157
.max_w(px(ITEM_WIDTH - 2. * LABEL_INSET))
158
.truncate()
159
.h(px(LABEL_HEIGHT))
160
.text_size(px(9.))
161
.line_height(px(LABEL_HEIGHT))
156
162
.font_weight(FontWeight::SEMIBOLD)
157
163
.text_color(color)
158
164
.child(item.label),
159
165
)
160
.child(badge(item.badge))
166
.children(badge(item.badge))
161
167
.tooltip(move |window, cx| Tooltip::new(tooltip.clone()).build(window, cx))
162
168
}
163
169
@@ -254,9 +260,9 @@ impl RailView {
254
260
}
255
261
}
256
262
257
fn badge(badge: RailBadge) -> Div {
258
match badge {
259
RailBadge::None => div(),
263
fn badge(badge: RailBadge) -> Option<Div> {
264
Some(match badge {
265
RailBadge::None => return None,
260
266
RailBadge::Dot => div()
261
267
.absolute()
262
268
.top(px(8.))
@@ -281,7 +287,7 @@ fn badge(badge: RailBadge) -> Div {
281
287
.line_height(px(16.))
282
288
.font_weight(FontWeight::BOLD)
283
289
.child(format::badge_text(count)),
284
}
290
})
285
291
}
286
292
287
293
impl Render for RailView {
@@ -19,6 +19,8 @@ pub const RAIL_WIDTH: f32 = ITEM_WIDTH + 2. * ISLAND_GAP;19
const ITEM_WIDTH: f32 = 48.;19
const ITEM_WIDTH: f32 = 48.;20
const ITEM_HEIGHT: f32 = 52.;20
const ITEM_HEIGHT: f32 = 52.;21
const ICON_SIZE: f32 = 20.;21
const ICON_SIZE: f32 = 20.;22
const LABEL_INSET: f32 = 2.;23
const LABEL_HEIGHT: f32 = 12.;22
24
23
#[derive(Debug, Clone, Copy, PartialEq, Eq)]25
#[derive(Debug, Clone, Copy, PartialEq, Eq)]24
enum RailBadge {26
enum RailBadge {@@ -141,6 +143,7 @@ fn item_element(item: &RailItem, active: bool) -> Stateful<Div> {141
.flex_none()143
.flex_none()142
.items_center()144
.items_center()143
.justify_center()145
.justify_center()146
.pt(px(2.))144
.gap(px(4.))147
.gap(px(4.))145
.rounded(px(10.))148
.rounded(px(10.))146
.cursor_pointer()149
.cursor_pointer()@@ -151,13 +154,16 @@ fn item_element(item: &RailItem, active: bool) -> Stateful<Div> {151
.child(icon(item.icon, ICON_SIZE, color))154
.child(icon(item.icon, ICON_SIZE, color))152
.child(155
.child(153
div()156
div()154
.whitespace_nowrap()157
.max_w(px(ITEM_WIDTH - 2. * LABEL_INSET))155
.text_size(px(10.))158
.truncate()159
.h(px(LABEL_HEIGHT))160
.text_size(px(9.))161
.line_height(px(LABEL_HEIGHT))156
.font_weight(FontWeight::SEMIBOLD)162
.font_weight(FontWeight::SEMIBOLD)157
.text_color(color)163
.text_color(color)158
.child(item.label),164
.child(item.label),159
)165
)160
.child(badge(item.badge))166
.children(badge(item.badge))161
.tooltip(move |window, cx| Tooltip::new(tooltip.clone()).build(window, cx))167
.tooltip(move |window, cx| Tooltip::new(tooltip.clone()).build(window, cx))162
}168
}163
169
@@ -254,9 +260,9 @@ impl RailView {254
}260
}255
}261
}256
262
257
fn badge(badge: RailBadge) -> Div {263
fn badge(badge: RailBadge) -> Option<Div> {258
match badge {264
Some(match badge {259
RailBadge::None => div(),265
RailBadge::None => return None,260
RailBadge::Dot => div()266
RailBadge::Dot => div()261
.absolute()267
.absolute()262
.top(px(8.))268
.top(px(8.))@@ -281,7 +287,7 @@ fn badge(badge: RailBadge) -> Div {281
.line_height(px(16.))287
.line_height(px(16.))282
.font_weight(FontWeight::BOLD)288
.font_weight(FontWeight::BOLD)283
.child(format::badge_text(count)),289
.child(format::badge_text(count)),284
}290
})285
}291
}286
292
287
impl Render for RailView {293
impl Render for RailView {