Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

New examples #10

Merged
merged 6 commits into from
Jan 4, 2025
Merged

New examples #10

merged 6 commits into from
Jan 4, 2025

Conversation

canack
Copy link
Member

@canack canack commented Jan 4, 2025

Add System Monitor and News Reader Examples

This PR adds two new examples that demonstrate different use cases of the Skeleton TUI library.

System Monitor Example

Features

  • Three tabs showing different system metrics:
    • CPU usage with real-time updates
    • Memory usage with GB and percentage display
    • Disk usage showing used and free space
  • Dynamic progress bars that change colors based on usage thresholds
  • Tab-specific colors that change when switching between tabs
  • Real-time updates every second
  • Time widget showing current system time

Technical Details

  • Uses gopsutil library for system metrics
  • Demonstrates how to handle IAMActivePage messages for tab-specific styling
  • Shows proper usage of UpdateMsg for periodic updates
  • Implements progress bars with warning/critical thresholds

News Reader Example

Features

  • Main news list tab showing:
    • Article titles with read/unread status
    • Interactive selection with keyboard navigation
    • Loading and error states
  • Dynamic detail tabs for each article showing:
    • Article title and publication date
    • Full article content
    • Original article link
  • Status widgets showing:
    • Total and unread article counts
    • Current system time
  • Gruvbox-inspired color theme

Technical Details

  • Uses gofeed library for RSS feed parsing
  • Demonstrates dynamic tab creation and deletion
  • Shows proper handling of async operations (RSS feed fetching)
  • Implements keyboard navigation (j/k, arrows, enter, ctrl+w)
  • Uses IAMActivePage messages for tab-specific styling

Screenshots

[Screenshots can be added here]

Usage

System Monitor:

cd examples/system-monitor
go mod tidy
go run main.go

News Reader:

cd examples/news-reader
go mod tidy
go run main.go

These examples serve as practical demonstrations of:

  • Tab management (static and dynamic)
  • Widget updates and real-time data
  • Async operations and error handling
  • Keyboard navigation
  • Custom styling and theming
  • Message handling

canack added 2 commits January 4, 2025 23:24
- Introduced a new Go module for the system monitor example.
- Implemented models for CPU, memory, and disk usage, utilizing the gopsutil library for system metrics.
- Added functionality to update and visualize resource usage with progress bars.
- Added color and borderColor fields to cpuModel, memoryModel, and diskModel for improved visual representation.
- Updated the Update method to set active tab colors based on the new fields when the page becomes active.
- Ensured consistent color coding across CPU, memory, and disk models for better user experience.
@canack canack added the enhancement New feature or request label Jan 4, 2025
@canack canack self-assigned this Jan 4, 2025
canack added 4 commits January 5, 2025 00:35
- Introduced dynamic calculation of available body height based on header and widget sizes.
- Updated styling to include a maximum height for the body content, improving layout management.
- Added padding to ensure body content fills available space when shorter than the calculated height.
- Enhanced the rendering logic for better visual consistency in the Skeleton view.
Refactor body height calculation and rendering in Skeleton view
- Introduced a new Go module for the news reader example, including a main application that fetches and displays news articles from an RSS feed.
- Implemented models for managing news items, including their metadata and read status.
@canack canack changed the base branch from improved-locking to main January 4, 2025 22:59
@canack canack merged commit 0451dc5 into main Jan 4, 2025
@canack canack deleted the new-examples branch January 5, 2025 07:55
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant