From fb7fb60574f5a338fde0ab7963e4d08222da46b5 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Mon, 11 Nov 2024 12:29:55 +0000 Subject: [PATCH] Various DataTable style fixes - fix text colors, fixed header styling in themes --- examples/theme_sandbox.py | 2 ++ src/textual/widgets/_data_table.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/theme_sandbox.py b/examples/theme_sandbox.py index cb038720f..d29515062 100644 --- a/examples/theme_sandbox.py +++ b/examples/theme_sandbox.py @@ -436,6 +436,8 @@ class ChangingThemeApp(App[None]): table.add_columns(*HEADERS) table.add_rows(ROWS) table.zebra_stripes = True + table.fixed_columns = 1 + table.cursor_type = "row" yield table yield ListView( ListItem(Label("One")), diff --git a/src/textual/widgets/_data_table.py b/src/textual/widgets/_data_table.py index 08a76d5de..a8bca4b7d 100644 --- a/src/textual/widgets/_data_table.py +++ b/src/textual/widgets/_data_table.py @@ -319,6 +319,10 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True): color: $foreground; height: auto; max-height: 100%; + + &.datatable--fixed-cursor { + background: $block-cursor-blurred-background; + } &:focus { background-tint: $foreground 5%; @@ -331,12 +335,17 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True): & > .datatable--header { background-tint: $foreground 5%; } + + & > .datatable--fixed-cursor { + color: $block-cursor-foreground; + background: $block-cursor-background; + } } &:dark { background: $surface; & > .datatable--even-row { - background: $surface-lighten-1 50%; + background: $surface-darken-1 40%; } } @@ -352,7 +361,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True): & > .datatable--fixed { background: $secondary 50%; - color: $text; + color: $foreground; } & > .datatable--odd-row { @@ -370,13 +379,13 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True): } & > .datatable--fixed-cursor { - background: $block-cursor-background; - color: $text; + background: $block-cursor-blurred-background; + color: $foreground; } & > .datatable--header-cursor { background: $accent-darken-1; - color: $text; + color: $foreground; } & > .datatable--header-hover {