feat: Modo minimal para tabs (estilo Laravel)

- Añadir config.minimal: bool para activar estilo sin fondos
- Añadir config.indicator_height para altura personalizable del underline
- En modo minimal: no dibujar fondos de tabs
- Texto inactivo usa text_secondary, activo usa primary
- Hover en minimal ilumina el texto
- Mantener retrocompatibilidad (minimal=false por defecto)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
R.Eugenio 2025-12-30 00:13:51 +01:00
parent 8b15d3f80f
commit ae600f4341

View file

@ -99,6 +99,10 @@ pub const TabsConfig = struct {
show_close: bool = false, show_close: bool = false,
/// Close button size /// Close button size
close_size: u32 = 14, close_size: u32 = 14,
/// Minimal style (no backgrounds, only text + underline indicator)
minimal: bool = false,
/// Underline indicator height (for minimal mode)
indicator_height: u32 = 2,
}; };
/// Tabs colors /// Tabs colors
@ -257,6 +261,8 @@ pub fn tabsRect(
state.hovered = @intCast(i); state.hovered = @intCast(i);
} }
// Minimal mode: no backgrounds, just text + underline
if (!config.minimal) {
// Determine tab background // Determine tab background
const tab_bg = if (tab.disabled) const tab_bg = if (tab.disabled)
colors.tab_bg.darken(10) colors.tab_bg.darken(10)
@ -275,10 +281,11 @@ pub fn tabsRect(
} else { } else {
ctx.pushCommand(Command.rect(tab_rect.x, tab_rect.y, tab_rect.w, tab_rect.h, tab_bg)); ctx.pushCommand(Command.rect(tab_rect.x, tab_rect.y, tab_rect.w, tab_rect.h, tab_bg));
} }
}
// Draw active indicator // Draw active indicator (underline)
if (is_selected) { if (is_selected) {
const indicator_h: u32 = 2; const indicator_h = config.indicator_height;
const indicator_y = if (config.position == .top) const indicator_y = if (config.position == .top)
bar_rect.y + @as(i32, @intCast(config.tab_height - indicator_h)) bar_rect.y + @as(i32, @intCast(config.tab_height - indicator_h))
else else
@ -286,13 +293,16 @@ pub fn tabsRect(
ctx.pushCommand(Command.rect(tab_rect.x, indicator_y, tab_rect.w, indicator_h, colors.indicator)); ctx.pushCommand(Command.rect(tab_rect.x, indicator_y, tab_rect.w, indicator_h, colors.indicator));
} }
// Draw tab text // Draw tab text (minimal mode: primary for active, text_secondary for inactive)
const theme = Style.currentTheme().*;
const text_color = if (tab.disabled) const text_color = if (tab.disabled)
colors.tab_disabled_text colors.tab_disabled_text
else if (is_selected) else if (is_selected)
colors.tab_active_text if (config.minimal) theme.primary else colors.tab_active_text
else if (is_hovered and config.minimal)
colors.tab_active_text // Brighten on hover in minimal mode
else else
colors.tab_text; if (config.minimal) theme.text_secondary else colors.tab_text;
const text_y = bar_rect.y + @as(i32, @intCast((config.tab_height - 8) / 2)); const text_y = bar_rect.y + @as(i32, @intCast((config.tab_height - 8) / 2));
ctx.pushCommand(Command.text(tab_x + @as(i32, @intCast(config.padding_h)), text_y, tab.label, text_color)); ctx.pushCommand(Command.text(tab_x + @as(i32, @intCast(config.padding_h)), text_y, tab.label, text_color));