Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Docs/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![CI](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem/branch/main/graph/badge.svg)](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem)
[![Swift](https://img.shields.io/badge/Swift-6.0–6.2-orange.svg)](https://swift.org)
[![Swift](https://img.shields.io/badge/Swift-6.1+-orange.svg)](https://swift.org)
![iOS](https://img.shields.io/badge/iOS-18.0+-blue?logo=apple)
![Platform](https://img.shields.io/badge/Platform-iPhone%20%7C%20iPad-lightgrey)
![SPM](https://img.shields.io/badge/SPM-Compatible-success)
Expand Down
2 changes: 1 addition & 1 deletion Docs/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![CI](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem/branch/main/graph/badge.svg)](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem)
[![Swift](https://img.shields.io/badge/Swift-6.0–6.2-orange.svg)](https://swift.org)
[![Swift](https://img.shields.io/badge/Swift-6.1+-orange.svg)](https://swift.org)
![iOS](https://img.shields.io/badge/iOS-18.0+-blue?logo=apple)
![Platform](https://img.shields.io/badge/Platform-iPhone%20%7C%20iPad-lightgrey)
![SPM](https://img.shields.io/badge/SPM-Compatible-success)
Expand Down
2 changes: 1 addition & 1 deletion Docs/README.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![CI](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem/branch/main/graph/badge.svg)](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem)
[![Swift](https://img.shields.io/badge/Swift-6.0–6.2-orange.svg)](https://swift.org)
[![Swift](https://img.shields.io/badge/Swift-6.1+-orange.svg)](https://swift.org)
![iOS](https://img.shields.io/badge/iOS-18.0+-blue?logo=apple)
![Platform](https://img.shields.io/badge/Platform-iPhone%20%7C%20iPad-lightgrey)
![SPM](https://img.shields.io/badge/SPM-Compatible-success)
Expand Down
2 changes: 1 addition & 1 deletion Docs/architecture/api-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ typealias GentleTouchTokens = GentleSpacingScaleTokens
### GentleSurfaceRole (enum: String, Codable, Sendable, CaseIterable)
```
Cases: appBackground, card, cardElevated, cardSecondary, chrome,
overlaySheet, overlayPopover, floatingPanel, floatingWidget
overlaySheet, overlayPopover, overlayScrim, floatingPanel, floatingWidget

var displayName: String
var subtitle: String
Expand Down
6 changes: 3 additions & 3 deletions Docs/architecture/api-quick-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ design.color(.textPrimary) // Color for current scheme
design.color(.primaryCTA) // Color

// Convenience colors
design.surface // color(.surface)
design.surfaceBase // color(.surfaceBase)
design.background // color(.background)
design.borderSubtle // color(.borderSubtle)
design.textPrimary // color(.textPrimary)
Expand Down Expand Up @@ -269,8 +269,8 @@ let jsonData = try spec.encodedJSONData()
let jsonString = try spec.encodedJSONString()

// Decoding
let spec = try GentleDesignSystemSpec(jsonData: data)
let spec = try GentleDesignSystemSpec(jsonString: string)
let spec = try GentleDesignSystemSpec.fromJSONData(data)
let spec = try GentleDesignSystemSpec.fromJSONString(string)
```

---
Expand Down
2 changes: 1 addition & 1 deletion Docs/architecture/design-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Theme: themePrimary, themeSecondary
- `GentleColorRole.surfaceRoles` - container/background/border colors (6)
- `GentleColorRole.actionRoles` - interactive element colors (2)
- `GentleColorRole.themeRoles` - brand/accent colors (2)
- `GentleColorRole.surfaceBackgroundRoles` - subset valid for surface backgrounds (4): `background`, `surfaceBase`, `surfaceCardSecondary`, `surfaceOverlay`
- `GentleColorRole.surfaceBackgroundRoles` - subset valid for surface backgrounds (4): `background`, `surfaceBase`, `surfaceCardSecondary`, `surfaceTint`

Use `role.isTextRole`, `role.isSurfaceRole`, `role.isActionRole`, `role.isThemeRole`, or `role.isSurfaceBackgroundRole` for membership checks.

Expand Down
2 changes: 1 addition & 1 deletion Docs/architecture/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
| `GentleSurfaceBackgroundStyle` | Surface background type: .solid(colorRole:), .material(material:tintColorRole:tintOpacity:), .glass(fallbackMaterial:fallbackColorRole:) |
| `GentleAppleMaterial` | Apple's blur materials: noMaterial, ultraThin, thin, regular, thick, ultraThick, bar |
| `GentleSurfaceDepthEffect` | Surface depth effects: noEffect, highlightAndIndent(strength:) |
| `GentleVisualEffect` | Legacy visual effect type (appBackground, surface, surfaceOverlay) |
| `GentleVisualEffect` | Visual effect type (appBackground, surface, surfaceOverlay) |
| `GentleInsetRole` | Padding intent (4 roles) |
| `GentleGapIntent` | Spacing intent (7 levels) |

Expand Down
11 changes: 5 additions & 6 deletions Docs/architecture/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

## Build Commands

> **Always build for the iOS Simulator.** This package depends on UIKit, so bare `swift build` will fail on macOS. Use `xcodebuild` with a simulator destination for all build and test commands.

### Package
```bash
# Build package
swift build

# Build for release
swift build -c release
# Build package (iOS Simulator)
xcodebuild build -scheme GentleDesignSystem -destination 'platform=iOS Simulator,name=iPhone 16' -quiet

# Clean build
swift package clean && swift build
xcodebuild clean build -scheme GentleDesignSystem -destination 'platform=iOS Simulator,name=iPhone 16' -quiet
```

### Tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![CI](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gentle-giraffe-apps/GentleDesignSystem/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem/branch/main/graph/badge.svg)](https://codecov.io/gh/gentle-giraffe-apps/GentleDesignSystem)
[![Swift](https://img.shields.io/badge/Swift-6.0–6.2-orange.svg)](https://swift.org)
[![Swift](https://img.shields.io/badge/Swift-6.1+-orange.svg)](https://swift.org)
![iOS](https://img.shields.io/badge/iOS-18.0+-blue?logo=apple)
![Platform](https://img.shields.io/badge/Platform-iPhone%20%7C%20iPad-lightgrey)
![SPM](https://img.shields.io/badge/SPM-Compatible-success)
Expand Down
7 changes: 5 additions & 2 deletions Sources/GentleDesignSystem/GentleDesignStudioView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public struct GentleDesignStudioView: View {
} label: {
Label("Export PDF", systemImage: "doc.richtext")
}
.disabled(exportPDFURL == nil)
} label: {
Image(systemName: "square.and.arrow.up")
.gentleText(.title3_ml)
Expand Down Expand Up @@ -173,7 +172,7 @@ public struct GentleDesignStudioView: View {
ProgressView("Preparing PDF export…")
.presentationDetents([.height(260)])
.presentationDragIndicator(.visible)
.task { await refreshExportURLs() }
.task { await generatePDFExport() }
}

case .exportMenu:
Expand All @@ -190,7 +189,11 @@ public struct GentleDesignStudioView: View {
print("themeManager.exportURL error: \(error)")
exportJSONURL = nil
}
}

@MainActor
private func generatePDFExport() async {
exportPDFURL = nil
do {
exportPDFURL = try themeManager.exportPDFURL()
} catch {
Expand Down
29 changes: 13 additions & 16 deletions Sources/GentleDesignSystem/GentlePDFExporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum GentlePDFExportError: Error, LocalizedError {

// MARK: - PDF Exporter

@MainActor
public enum GentlePDFExporter {

// MARK: - Layout Constants
Expand Down Expand Up @@ -541,27 +542,23 @@ public enum GentlePDFExporter {
}

/// Renders a surface using SwiftUI and captures it as a UIImage
/// Note: This must be called from the main thread since ImageRenderer requires it
private static func renderSurfaceWithSwiftUI(spec: GentleDesignSystemSpec, role: GentleSurfaceRole, size: CGSize) -> UIImage? {
// Use assumeIsolated since PDF rendering happens on main thread via UIGraphicsPDFRenderer
return MainActor.assumeIsolated {
let theme = GentleTheme(defaultSpec: spec, editableSpec: spec)
let theme = GentleTheme(defaultSpec: spec, editableSpec: spec)

// Create a SwiftUI view that renders the surface with a gradient background to show the blur
let surfaceView = SurfacePreviewView(role: role, size: size)
// Create a SwiftUI view that renders the surface with a gradient background to show the blur
let surfaceView = SurfacePreviewView(role: role, size: size)

// Use ImageRenderer to capture the view
let renderer = ImageRenderer(content:
GentleThemeRoot(theme: theme) {
surfaceView
}
.environment(\.colorScheme, .light)
)
// Use ImageRenderer to capture the view
let renderer = ImageRenderer(content:
GentleThemeRoot(theme: theme) {
surfaceView
}
.environment(\.colorScheme, .light)
)

renderer.scale = 8.0 // 8x scale for crisp PDF output
renderer.scale = 8.0 // 8x scale for crisp PDF output

return renderer.uiImage
}
return renderer.uiImage
}

// MARK: - Colors Section
Expand Down