Files
TUIkit/Sources/TUIKit/Views/Box.swift
T
phranck 2cf72c2b19 feat: Add comprehensive DocC documentation with tutorials
Add complete Apple-style DocC documentation for TUIKit framework:

## Documentation Structure
- Main landing page (TUIKit.md) with quick-start and topic navigation
- 8 guide articles: GettingStarted, ViewHierarchy, StateManagement, Theming, Appearance, Focus, Modifiers, Architecture
- 3 step-by-step tutorials: BuildYourFirstApp, BuildInteractiveMenu, BuildThemableUI
- Documentation catalog with proper Info.plist configuration

## Code Improvements
- Enhanced Box.swift documentation with clear container comparison
- Added comprehensive examples and usage patterns
- Explained appearance integration and sizing behavior

## Infrastructure
- GitHub Actions workflow (.github/workflows/docc.yml) for automatic DocC building
- Configured for deployment to GitHub Pages on push to main
- Uses xcrun docc build with proper artifact handling

## Documentation Includes
- API reference stubs for all major components
- Comprehensive guide articles with code examples
- Interactive tutorials following Apple's documentation style
- Cross-references using DocC syntax (``Type``)
- Best practices and design patterns explained

The documentation is ready for automated building and deployment to GitHub Pages.
2026-01-29 02:42:29 +01:00

111 lines
2.8 KiB
Swift

//
// Box.swift
// TUIKit
//
// A simple bordered container view.
//
/// A simple bordered container view.
///
/// `Box` wraps content in a border without additional styling, padding, or background.
/// It's the most minimal container - just a border around content.
///
/// # Choosing the Right Container
///
/// - **Box**: Minimal - just a border, no padding or background
/// - **Card**: Padded and filled - includes padding and subtle background
/// - **Panel**: Titled box - includes optional title in the border
/// - **ContainerView**: Full-featured - header, body, footer sections
///
/// # Appearance Integration
///
/// `Box` respects the current ``Appearance`` style. By default, it uses the
/// theme's border color and the current appearance (rounded, doubleLine, etc.):
///
/// ```swift
/// Box {
/// Text("Uses current appearance")
/// }
/// .environment(\.appearance, .block) // Now renders with block characters
/// ```
///
/// You can override both style and color:
///
/// ```swift
/// Box(.heavy, color: .theme.accent) {
/// Text("Heavy bold border in accent color")
/// }
/// ```
///
/// # Example - Basic Usage
///
/// ```swift
/// Box {
/// Text("Simple bordered content")
/// }
/// ```
///
/// # Example - Custom Styling
///
/// ```swift
/// VStack {
/// Box(.doubleLine, color: .brightCyan) {
/// Text("Double-line border")
/// Text("In cyan")
/// }
///
/// Box(.line, color: .yellow) {
/// Text("Thin ASCII border")
/// }
/// }
/// ```
///
/// # Example - With Multiple Children
///
/// ```swift
/// Box {
/// VStack(spacing: 1) {
/// Text("Item 1").bold()
/// Text("Item 2")
/// Text("Item 3")
/// }
/// }
/// ```
///
/// # Size Behavior
///
/// The `Box` size is determined by its content:
/// - If content has a fixed size, `Box` will be that size plus border
/// - If content is flexible, `Box` expands to fill available space
/// - Content inside `Box` respects its layout constraints
public struct Box<Content: View>: View {
/// The content of the box.
public let content: Content
/// The border style (nil uses appearance default).
public let borderStyle: BorderStyle?
/// The border color.
public let borderColor: Color?
/// Creates a box with the specified border.
///
/// - Parameters:
/// - borderStyle: The border style (default: appearance borderStyle).
/// - color: The border color (default: theme border).
/// - content: The content of the box.
public init(
_ borderStyle: BorderStyle? = nil,
color: Color? = nil,
@ViewBuilder content: () -> Content
) {
self.content = content()
self.borderStyle = borderStyle
self.borderColor = color
}
public var body: some View {
content.border(borderStyle, color: borderColor)
}
}