From 0b63de799f1f49ebf1017eb3294898aa92cd79f9 Mon Sep 17 00:00:00 2001 From: Liu Date: Sat, 21 Nov 2026 18:53:16 +0800 Subject: [PATCH] fix(doc-viewer): demo code tabs should show a visible hover background - use a foreground overlay instead of `bg-muted`, which matched the code header background exactly - add a pointer cursor to the clickable tabs - add a regression test for light and dark hover --- examples/doc-viewer/app/global.css | 6 ++-- .../tests/test_demo_header_layout.c | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/examples/doc-viewer/app/global.css b/examples/doc-viewer/app/global.css index 96750387..adfadc0e 100644 --- a/examples/doc-viewer/app/global.css +++ b/examples/doc-viewer/app/global.css @@ -504,11 +504,11 @@ p { .demo-tab { display: inline-block; - @apply px-2 py-1 text-sm rounded-lg mr-1; + @apply px-2 py-1 text-sm rounded-lg mr-1 cursor-pointer; } .demo-tab:hover { - @apply bg-muted; - @apply dark:bg-muted-dark; + @apply bg-foreground/10; + @apply dark:bg-foreground-dark/10; } .demo-tab.active { box-shadow: theme("boxShadow.sm"); diff --git a/examples/doc-viewer/tests/test_demo_header_layout.c b/examples/doc-viewer/tests/test_demo_header_layout.c index 4798cc31..acb99140 100644 --- a/examples/doc-viewer/tests/test_demo_header_layout.c +++ b/examples/doc-viewer/tests/test_demo_header_layout.c @@ -305,6 +305,41 @@ static void run_file_width(void) with_scene(DEMO_BLOCK_WIDTH, true, test_file_group_stays_inside_header); } +static void test_demo_tab_hover_background(void) +{ + ui_widget_t *tab = ui_create_widget("text"); + int alpha; + + ui_widget_add_class(tab, "demo-tab"); + ui_text_set_content(tab, "XML"); + ui_widget_append(ui_root(), tab); + ui_update(); + + alpha = (int)((tab->computed_style.background_color >> 24) & 0xff); + ctest_equal_int("demo tab should start with a transparent background", + alpha, 0); + + ui_widget_add_status(tab, "hover"); + ui_update(); + alpha = (int)((tab->computed_style.background_color >> 24) & 0xff); + ctest_equal_bool("hovered demo tab should use a translucent overlay", + alpha > 0 && alpha < 255, true); + + ui_widget_remove_status(tab, "hover"); + ui_widget_add_class(ui_root(), "dark"); + ui_widget_add_status(tab, "hover"); + ui_update(); + alpha = (int)((tab->computed_style.background_color >> 24) & 0xff); + ctest_equal_bool( + "hovered demo tab should stay translucent in dark mode", + alpha > 0 && alpha < 255, true); + + ui_widget_remove_status(tab, "hover"); + ui_widget_remove_class(ui_root(), "dark"); + ui_widget_destroy(tab); + ui_clear_trash(); +} + void test_demo_header_layout(void) { lcui_window_options_t opt = { 0 }; @@ -322,6 +357,7 @@ void test_demo_header_layout(void) ctest_describe("demo header language height", run_language_height); ctest_describe("demo header language width", run_language_width); ctest_describe("demo header file width", run_file_width); + ctest_describe("demo header tab hover", test_demo_tab_hover_background); lcui_destroy(); }