Skip to content

Implement progress element for Slipstream#223

Merged
jverkoey merged 4 commits into
mainfrom
claude/implement-progress-element-011CUpjrrQjnkoFQEB27WU9D
Nov 5, 2025
Merged

Implement progress element for Slipstream#223
jverkoey merged 4 commits into
mainfrom
claude/implement-progress-element-011CUpjrrQjnkoFQEB27WU9D

Conversation

@jverkoey

@jverkoey jverkoey commented Nov 5, 2025

Copy link
Copy Markdown
Collaborator

Add a new Progress view that represents the HTML element, allowing developers to display task completion progress in their Slipstream applications.

Features:

  • Supports both determinate and indeterminate progress states
  • Optional value parameter (nil = indeterminate)
  • Configurable max parameter (defaults to 1.0 for percentage-style use)
  • Follows Slipstream patterns for SwiftUI-like API
  • Comprehensive test coverage including edge cases

The implementation balances W3C HTML semantics with SwiftUI idioms, providing a familiar API for SwiftUI developers while emitting standard HTML progress elements.

Part of #25

Add a new Progress view that represents the HTML <progress> element,
allowing developers to display task completion progress in their
Slipstream applications.

Features:
- Supports both determinate and indeterminate progress states
- Optional value parameter (nil = indeterminate)
- Configurable max parameter (defaults to 1.0 for percentage-style use)
- Follows Slipstream patterns for SwiftUI-like API
- Comprehensive test coverage including edge cases

The implementation balances W3C HTML semantics with SwiftUI idioms,
providing a familiar API for SwiftUI developers while emitting
standard HTML progress elements.
Rename the Progress struct to ProgressView to align with SwiftUI naming
conventions, making it more familiar to SwiftUI developers.

Changes:
- Rename Progress.swift to ProgressView.swift
- Update struct name from Progress to ProgressView
- Update all documentation references
- Rename ProgressTests to ProgressViewTests
- Update all test cases to use ProgressView

The view still emits the HTML <progress> element as specified by W3C.
Per the W3C spec, the max attribute defaults to 1.0 when not specified.
Update ProgressView to only render the max attribute when it differs
from the default value, producing more concise HTML output.

Before:
  ProgressView() → <progress max="1.0"></progress>
  ProgressView(value: 0.7) → <progress value="0.7" max="1.0"></progress>

After:
  ProgressView() → <progress></progress>
  ProgressView(value: 0.7) → <progress value="0.7"></progress>

Custom max values are still rendered when specified:
  ProgressView(value: 70, max: 100) → <progress value="70.0" max="100.0"></progress>
Change max parameter from Double with a default value to Double?
to avoid unreliable floating point equality checks. When max is nil,
the attribute is omitted from the HTML, allowing the W3C default of
1.0 to be used implicitly.

This approach is more robust and aligns with Swift best practices
for optional values versus default values with equality checks.

Before:
  public init(value: Double? = nil, max: Double = 1.0)
  if max != 1.0 { // Unreliable floating point comparison

After:
  public init(value: Double? = nil, max: Double? = nil)
  if let max { // Safe optional binding
@jverkoey jverkoey enabled auto-merge (squash) November 5, 2025 13:25
@jverkoey jverkoey merged commit 2754c46 into main Nov 5, 2025
2 checks passed
@jverkoey jverkoey deleted the claude/implement-progress-element-011CUpjrrQjnkoFQEB27WU9D branch November 5, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants