feat: rework header; add footer; padding for content
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m37s
Release Zig Application / Release zig project (release) Has been cancelled

This commit is contained in:
2025-10-30 16:28:49 +01:00
parent c07cfd5f3d
commit 5acca12abf
3 changed files with 204 additions and 30 deletions

View File

@@ -19,41 +19,65 @@ pub fn main() !void {
}, .{});
defer container.deinit();
var header: App.Container = try .init(allocator, .{
.size = .{
.dim = .{ .y = 1 },
.grow = .horizontal,
},
}, .{});
var navigation: App.Container = try .init(allocator, .{
.layout = .{
.separator = .{ .enabled = true },
},
}, .{});
// about navigation button
// header with navigation buttons and content's title
{
var button: App.Button(.about) = .init(&app.queue, .init(.default, "about"));
try navigation.append(try .init(allocator, .{
var header: App.Container = try .init(allocator, .{
.size = .{
.dim = .{ .x = 5 + 2 },
.grow = .vertical,
.dim = .{ .y = 1 },
.grow = .horizontal,
},
}, button.element()));
.layout = .{
.separator = .{ .enabled = true },
},
}, .{});
// title
{
var title: Title = .init();
try header.append(try .init(allocator, .{}, title.element()));
}
// about navigation button
{
var button: NavigationButton(.about) = .init(&app.model, &app.queue);
try header.append(try .init(allocator, .{
.size = .{
.dim = .{ .x = 5 + 2 },
.grow = .vertical,
},
}, button.element()));
}
// blog navigation button
{
var button: NavigationButton(.blog) = .init(&app.model, &app.queue);
try header.append(try .init(allocator, .{
.size = .{
.dim = .{ .x = 4 + 2 },
.grow = .vertical,
},
}, button.element()));
}
try container.append(header);
}
// blog navigation button
// main actual tui_website page content
{
var button: App.Button(.blog) = .init(&app.queue, .init(.default, "blog"));
try navigation.append(try .init(allocator, .{
.size = .{
.dim = .{ .x = 4 + 2 },
.grow = .vertical,
},
}, button.element()));
// intermediate container for *padding*
var content: Content = .init(allocator);
var content_container: App.Container = try .init(allocator, .{
.layout = .{ .padding = .horizontal(2) },
}, .{});
try content_container.append(try .init(allocator, .{}, content.element()));
try container.append(content_container);
}
// footer
{
var info_banner: InfoBanner = .init();
const footer: App.Container = try .init(allocator, .{
.size = .{
.dim = .{ .y = 1 },
.grow = .horizontal,
},
}, info_banner.element());
try container.append(footer);
}
try header.append(navigation);
try container.append(header);
var content: Content = .init(allocator);
try container.append(try .init(allocator, .{}, content.element()));
try app.start();
defer app.stop() catch |err| log.err("Failed to stop application: {any}", .{err});
@@ -107,8 +131,12 @@ const App = zterm.App(
},
);
const contents = @import("content.zig");
const Model = @import("model.zig");
const Content = @import("content.zig").Content(App);
const Content = contents.Content(App);
const Title = contents.Title(App);
const InfoBanner = contents.InfoBanner(App);
const NavigationButton = @import("navigation.zig").NavigationButton(App);
test {
std.testing.refAllDeclsRecursive(@This());