Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/moon-ui-components/src/moon/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ pub enum MoonDataTableWidthPolicy {
pub struct MoonDataTableColumn {
pub key: SharedString,
pub title: SharedString,
/// Hover text for the header cell, e.g. the raw schema name behind a translated title.
/// `None` renders the bare title as before.
pub tooltip: Option<SharedString>,
/// Base column width in logical design pixels.
///
/// `MoonDataTable` treats this value as both the minimum width and the proportional weight for
Expand Down Expand Up @@ -136,6 +139,7 @@ impl MoonDataTableColumn {
Self {
key: key.into(),
title: title.into(),
tooltip: None,
width,
fill: false,
no_grow: false,
Expand Down Expand Up @@ -167,6 +171,12 @@ impl MoonDataTableColumn {
self
}

/// Attach a hover tooltip to the header cell.
pub fn tooltip(mut self, tooltip: impl Into<SharedString>) -> Self {
self.tooltip = Some(tooltip.into());
self
}

pub fn sortable(mut self, sortable: bool) -> Self {
self.sortable = sortable;
self
Expand Down
8 changes: 7 additions & 1 deletion crates/moon-ui-components/src/moon/data_table/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::super::{
table::{MoonTableAlign, MoonTableStyle},
theme::MoonTheme,
tokens::{MoonPalette, rgba_from},
tooltip::MoonTooltipView,
};
use super::drag::{MoonDataColumnDrag, MoonDataColumnResizeDrag};
use super::{
Expand Down Expand Up @@ -123,7 +124,12 @@ pub(super) fn render_header(
},
1.0,
))
.child(label);
.child(label)
.when_some(column.tooltip.clone(), |cell, tooltip| {
cell.tooltip(move |_window, cx| {
cx.new(|_| MoonTooltipView::new(tooltip.clone())).into()
})
});

cell = cell.child(
canvas(
Expand Down
2 changes: 1 addition & 1 deletion crates/moon-ui-components/src/moon/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl MoonThemeTokens {
table_head_foreground: rgba_from(p.text_soft, 1.0),
table_foot: rgba_from(p.head_row, 1.0),
table_foot_foreground: rgba_from(p.text_soft, 1.0),
table_hover: rgba_from(p.panel_high, 1.0),
table_hover: rgba_from(p.table_hover, 1.0),
table_row_border: rgba_from(p.row_line, 1.0),
title_bar: rgba_from(p.chrome, 1.0),
title_bar_border: rgba_from(p.border, 1.0),
Expand Down
5 changes: 5 additions & 0 deletions crates/moon-ui-components/src/moon/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub struct MoonPalette {
pub table_head: u32,
pub table_body: u32,
pub table_selected: u32,
/// Row hover fill for data tables: one step off the row surface in EITHER theme, so a
/// hovered row is visible on a white light-theme table (where `panel_high` is itself white).
pub table_hover: u32,
pub green: u32,
pub green_btn: u32,
pub green_text: u32,
Expand Down Expand Up @@ -132,6 +135,7 @@ impl MoonPalette {
table_head: 0x20232A,
table_body: 0x1A1C1F,
table_selected: 0xFFB347,
table_hover: 0x22252B,
green: 0x1E8C5B,
green_btn: 0x1E8C5B,
green_text: 0x1E8C5B,
Expand Down Expand Up @@ -178,6 +182,7 @@ impl MoonPalette {
table_head: 0xF3F6F8,
table_body: 0xFFFFFF,
table_selected: 0x009DFF,
table_hover: 0xEEF2F6,
green: 0x178A57,
green_btn: 0x178A57,
green_text: 0x0E6E45,
Expand Down
2 changes: 2 additions & 0 deletions crates/moon-ui-components/themes/moon-light.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ text_faint = 0x7D7669
table_head = 0x20232A
table_body = 0x1A1C1F
table_selected = 0xFFB347
table_hover = 0x22252B
green = 0x1E8C5B
green_btn = 0x1E8C5B
green_text = 0x1E8C5B
Expand Down Expand Up @@ -99,6 +100,7 @@ text_faint = 0x98A3AE
table_head = 0xF3F6F8
table_body = 0xFFFFFF
table_selected = 0x009DFF
table_hover = 0xEEF2F6
green = 0x178A57
green_btn = 0x178A57
green_text = 0x0E6E45
Expand Down
2 changes: 2 additions & 0 deletions crates/moon-ui-components/themes/moon-terminal.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ text_faint = 0x7D7669
table_head = 0x20232A
table_body = 0x1A1C1F
table_selected = 0xFFB347
table_hover = 0x22252B
green = 0x1E8C5B
green_btn = 0x1E8C5B
green_text = 0x1E8C5B
Expand Down Expand Up @@ -99,6 +100,7 @@ text_faint = 0x98A3AE
table_head = 0xF3F6F8
table_body = 0xFFFFFF
table_selected = 0x009DFF
table_hover = 0xEEF2F6
green = 0x178A57
green_btn = 0x178A57
green_text = 0x0E6E45
Expand Down
4 changes: 4 additions & 0 deletions docs/component-api-baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,10 @@
"file": "crates/moon-ui-components/src/moon/data_table.rs",
"signature": "pub fn tone(mut self, tone: MoonTone) -> Self"
},
{
"file": "crates/moon-ui-components/src/moon/data_table.rs",
"signature": "pub fn tooltip(mut self, tooltip: impl Into<SharedString>) -> Self"
},
{
"file": "crates/moon-ui-components/src/moon/data_table.rs",
"signature": "pub fn track_scroll(mut self, handle: &MoonVirtualListScrollHandle) -> Self"
Expand Down
Loading