Skip to content

Commit 7c78558

Browse files
committed
update docs
1 parent 093b9a5 commit 7c78558

22 files changed

Lines changed: 1450 additions & 11 deletions

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 Muhammad Fiaz
3+
Copyright (c) 2026 Muhammad Fiaz
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/.vitepress/config.mts

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ export default defineConfig({
5454
["meta", { property: "og:url", content: SITE_URL }],
5555
["meta", { property: "og:title", content: SITE_NAME }],
5656
["meta", { property: "og:description", content: SITE_DESCRIPTION }],
57-
["meta", { property: "og:image", content: `${SITE_URL}/cover.png` }],
57+
["meta", { property: "og:image", content: `${SITE_URL}/loader-thumbnail.png` }],
5858
["meta", { property: "og:image:width", content: "1200" }],
5959
["meta", { property: "og:image:height", content: "630" }],
60-
["meta", { property: "og:image:alt", content: "loaders.zig - High-performance terminal loading indicators for Zig" }],
60+
["meta", { property: "og:image:alt", content: "loaders.zig - High-performance terminal loading indicators and progress bars for Zig" }],
6161
["meta", { property: "og:site_name", content: SITE_NAME }],
6262
["meta", { property: "og:locale", content: "en_US" }],
6363
["meta", { name: "twitter:card", content: "summary_large_image" }],
6464
["meta", { name: "twitter:url", content: SITE_URL }],
6565
["meta", { name: "twitter:title", content: SITE_NAME }],
6666
["meta", { name: "twitter:description", content: SITE_DESCRIPTION }],
67-
["meta", { name: "twitter:image", content: `${SITE_URL}/cover.png` }],
67+
["meta", { name: "twitter:image", content: `${SITE_URL}/loader-thumbnail.png` }],
6868
["meta", { name: "twitter:creator", content: "@muhammadfiaz_" }],
6969

7070
["link", { rel: "icon", href: "/loaders.zig/favicon.ico" }],
@@ -164,6 +164,7 @@ gtag('config', '${GA_ID}');`,
164164
{ text: "Home", link: "/" },
165165
{ text: "Guide", link: "/guide/" },
166166
{ text: "API", link: "/api/" },
167+
{ text: "Examples", link: "/examples/" },
167168
],
168169

169170
sidebar: [
@@ -172,6 +173,7 @@ gtag('config', '${GA_ID}');`,
172173
items: [
173174
{ text: "Guide Overview", link: "/guide/" },
174175
{ text: "API Reference", link: "/api/" },
176+
{ text: "Examples", link: "/examples/" },
175177
],
176178
},
177179
{
@@ -187,6 +189,27 @@ gtag('config', '${GA_ID}');`,
187189
{ text: "Advanced", link: "/guide/advanced" },
188190
],
189191
},
192+
{
193+
text: "Examples",
194+
items: [
195+
{ text: "Overview", link: "/examples/" },
196+
{ text: "Basic Bar", link: "/examples/01-basic-bar" },
197+
{ text: "Basic Bar (100)", link: "/examples/basic-bar" },
198+
{ text: "Styled Bar", link: "/examples/02-styled-bar" },
199+
{ text: "Custom Style", link: "/examples/custom-style" },
200+
{ text: "Themed Bar", link: "/examples/themed-bar" },
201+
{ text: "ETA and Rate", link: "/examples/eta-and-rate" },
202+
{ text: "Download Simulation", link: "/examples/download-simulation" },
203+
{ text: "Advanced Options", link: "/examples/advanced-options" },
204+
{ text: "Custom Template", link: "/examples/custom-template" },
205+
{ text: "Nested Bars", link: "/examples/nested-bars" },
206+
{ text: "Spinner", link: "/examples/spinner" },
207+
{ text: "Multi Spinner", link: "/examples/multi-spinner" },
208+
{ text: "Multi Progress", link: "/examples/multi-progress" },
209+
{ text: "Iterator Wrap", link: "/examples/iterator-wrap" },
210+
{ text: "Animations", link: "/examples/animations" },
211+
],
212+
},
190213
],
191214

192215
socialLinks: [
@@ -195,7 +218,7 @@ gtag('config', '${GA_ID}');`,
195218

196219
footer: {
197220
message: "Released under the MIT License.",
198-
copyright: `Copyright © 2025-${new Date().getFullYear()} Muhammad Fiaz`,
221+
copyright: `Copyright © 2026-${new Date().getFullYear()} Muhammad Fiaz`,
199222
},
200223

201224
search: {
@@ -246,7 +269,7 @@ gtag('config', '${GA_ID}');`,
246269
["meta", { name: "description", content: pageDescription }],
247270
["meta", { name: "twitter:title", content: `${pageTitle} | ${SITE_NAME}` }],
248271
["meta", { name: "twitter:description", content: pageDescription }],
249-
["meta", { name: "twitter:image", content: `${SITE_URL}/cover.png` }],
272+
["meta", { name: "twitter:image", content: `${SITE_URL}/loader-thumbnail.png` }],
250273
);
251274

252275
if (pageData.frontmatter.description) {
@@ -294,7 +317,7 @@ gtag('config', '${GA_ID}');`,
294317
name: isHome ? SITE_NAME : pageTitle,
295318
description: pageDescription,
296319
url: canonicalUrl,
297-
image: `${SITE_URL}/cover.png`,
320+
image: `${SITE_URL}/loader-thumbnail.png`,
298321
author: authorSchema,
299322
publisher: {
300323
"@type": "Organization",
@@ -334,7 +357,7 @@ gtag('config', '${GA_ID}');`,
334357
"@type": "WebPage",
335358
"@id": canonicalUrl,
336359
},
337-
datePublished: "2025-01-01T00:00:00Z",
360+
datePublished: "2026-01-01T00:00:00Z",
338361
dateModified: lastUpdated,
339362
});
340363
}

docs/examples/01-basic-bar.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
description: Minimal progress bar example with loaders.zig. Create a 50-step bar with percentage display in under 20 lines.
3+
head:
4+
- - meta
5+
- name: keywords
6+
content: loaders.zig basic progress bar, zig progress bar example, minimal loading bar
7+
- - meta
8+
- property: og:title
9+
content: Basic Bar Example — loaders.zig
10+
- - meta
11+
- property: og:description
12+
content: Minimal progress bar example with loaders.zig. Create a 50-step bar with percentage display.
13+
---
14+
15+
# Basic Bar
16+
17+
Minimal 50-step progress bar with percentage display.
18+
19+
---
20+
21+
## Source
22+
23+
```zig
24+
const std = @import("std");
25+
const loaders = @import("loaders");
26+
27+
pub fn main(init: std.process.Init) !void {
28+
const io = init.io;
29+
const total: usize = 50;
30+
31+
var bar = loaders.Bar.init(io, .{
32+
.label = "Processing",
33+
.total = total,
34+
.show_percent = true,
35+
});
36+
defer bar.done();
37+
38+
for (0..total) |i| {
39+
bar.setCompleted(i + 1);
40+
bar.render();
41+
try io.sleep(std.Io.Duration.fromMilliseconds(40), .awake);
42+
}
43+
}
44+
```
45+
46+
## Run
47+
48+
```bash
49+
zig build run-01_basic_bar
50+
```
51+
52+
## Output
53+
54+
```
55+
Processing [██████████████████████████████████████████████████] 100%
56+
```
57+
58+
The bar animates from 0% to 100%, overwriting the same line on each frame.

docs/examples/02-styled-bar.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
description: Side-by-side comparison of 7 built-in bar styles in loaders.zig. Block, ascii, shaded, green, cyan, gradient, and minimal.
3+
head:
4+
- - meta
5+
- name: keywords
6+
content: loaders.zig bar styles comparison, zig bar presets, progress bar styles
7+
- - meta
8+
- property: og:title
9+
content: Styled Bar Example — loaders.zig
10+
- - meta
11+
- property: og:description
12+
content: Side-by-side comparison of 7 built-in bar styles.
13+
---
14+
15+
# Styled Bar
16+
17+
7 bar styles rendered side by side at 30 columns wide.
18+
19+
---
20+
21+
## Source
22+
23+
```zig
24+
const std = @import("std");
25+
const loaders = @import("loaders");
26+
27+
pub fn main(init: std.process.Init) !void {
28+
const io = init.io;
29+
const total: usize = 40;
30+
31+
const styles = [_]struct { name: []const u8, style: loaders.BarStyle }{
32+
.{ .name = "block ", .style = .{} },
33+
.{ .name = "ascii ", .style = .ascii },
34+
.{ .name = "shaded ", .style = .shaded },
35+
.{ .name = "green ", .style = .green },
36+
.{ .name = "cyan ", .style = .cyan },
37+
.{ .name = "gradient", .style = .gradient },
38+
.{ .name = "minimal ", .style = .minimal },
39+
};
40+
41+
for (styles) |s| {
42+
var bar = loaders.Bar.init(io, .{
43+
.label = s.name,
44+
.total = total,
45+
.style = s.style,
46+
.show_percent = true,
47+
.width = 30,
48+
});
49+
defer bar.done();
50+
51+
for (0..total) |i| {
52+
bar.setCompleted(i + 1);
53+
bar.render();
54+
try io.sleep(std.Io.Duration.fromMilliseconds(20), .awake);
55+
}
56+
}
57+
}
58+
```
59+
60+
## Run
61+
62+
```bash
63+
zig build run-02_styled_bar
64+
```
65+
66+
## Output
67+
68+
```
69+
block [██████████████████████████████] 100%
70+
ascii [##############################] 100%
71+
shaded [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒] 100%
72+
green [██████████████████████████████] 100%
73+
cyan [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒] 100%
74+
gradient [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒] 100%
75+
minimal ──────────────────────────────▶─ 100%
76+
```
77+
78+
Each style renders at a fixed 30-column width for easy visual comparison.

docs/examples/advanced-options.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
description: Advanced progress customization with decorators, timestamps, colored labels, responsive width, and dynamic messages in loaders.zig.
3+
head:
4+
- - meta
5+
- name: keywords
6+
content: loaders.zig advanced options, zig progress bar decorators, colored progress bar, zig timestamps
7+
- - meta
8+
- property: og:title
9+
content: Advanced Options Example — loaders.zig
10+
- - meta
11+
- property: og:description
12+
content: Advanced progress customization with decorators, timestamps, and colored labels.
13+
---
14+
15+
# Advanced Options
16+
17+
Custom decorators, timestamps, colored labels, responsive width, and dynamic messages.
18+
19+
---
20+
21+
## Source
22+
23+
```zig
24+
const std = @import("std");
25+
const loaders = @import("loaders");
26+
27+
pub fn main(init: std.process.Init) !void {
28+
const io = init.io;
29+
30+
const total_steps = 100;
31+
32+
var bar = loaders.Bar.init(io, .{
33+
.total = total_steps,
34+
.label = "Processing",
35+
.label_color = .bright_cyan,
36+
.show_percent = true,
37+
.percent_color = .bright_green,
38+
.bracket_color = .bright_black,
39+
.show_count = true,
40+
.show_elapsed = true,
41+
.show_eta = true,
42+
.show_rate = true,
43+
.message = "initializing...",
44+
.complete_message = "Done! All steps complete.",
45+
46+
.custom_start = "🚀 ",
47+
.custom_end = " [Task #1]",
48+
49+
.show_date = false,
50+
.show_time = true,
51+
.timezone_offset_sec = 19800,
52+
53+
.width = 0,
54+
.style = loaders.BarStyle.gradient,
55+
});
56+
defer bar.done();
57+
58+
for (0..total_steps) |i| {
59+
bar.setCompleted(i + 1);
60+
bar.render();
61+
try io.sleep(std.Io.Duration.fromMilliseconds(80), .awake);
62+
}
63+
}
64+
```
65+
66+
## Run
67+
68+
```bash
69+
zig build run-advanced_options
70+
```
71+
72+
## Output
73+
74+
```
75+
🚀 [17:19:41] Processing [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 100/100 00:08 12.5/s initializing... [Task #1]
76+
🚀 [17:19:41] Processing [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 100/100 00:08 12.5/s Done! All steps complete. [Task #1]
77+
```
78+
79+
Key features demonstrated:
80+
- `custom_start` / `custom_end` — line decorators
81+
- `show_time` + `timezone_offset_sec` — local time prefix
82+
- `label_color`, `percent_color`, `bracket_color` — per-element colors
83+
- `message` / `complete_message` — dynamic text before/after completion
84+
- `width = 0` — auto-resizes to terminal width

0 commit comments

Comments
 (0)