Skip to content

Commit 0b980c9

Browse files
committed
Add example images to articles + fix minor issues in the package
1 parent 213ae2c commit 0b980c9

21 files changed

+43
-32
lines changed

Sources/HandySwiftUI/HandySwiftUI.docc/Essentials/Extensions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct ColorfulView: View {
7272
}
7373
```
7474

75-
TODO: add image of above view
75+
![](ColorfulView)
7676

7777
When adjusting color brightness, use .luminance instead of .brightness from the HSB color system. Luminance better represents how humans perceive light and dark, which is why HandySwiftUI includes support for the HLC color space.
7878

@@ -95,7 +95,7 @@ struct FormattedText: View {
9595
}
9696
```
9797

98-
TODO: add image of above view
98+
![](FormattedText)
9999

100100
In the above example, the built-in `.htmlLike` styling that ships with HandySwiftUI is combined with custom tags. Note that `.htmlLike` simply returns this:
101101

@@ -230,7 +230,7 @@ extension [String] {
230230
}
231231
```
232232

233-
TODO: add image of TranslateKit's menu bar
233+
![](CommonTranslations)
234234

235235
This highlighting feature was originally developed for [TranslateKit]'s menu bar "Common Translations" feature, where it helps users quickly spot matching phrases in their translation history. The function breaks down the search text into tokens and highlights each matching prefix, making it perfect for:
236236

Sources/HandySwiftUI/HandySwiftUI.docc/Essentials/New Types.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ HandySwiftUI provides a collection of views and types that fill common gaps in S
1313

1414
### Platform-Specific Values
1515

16-
HandySwiftUI provides an elegant way to handle platform-specific values of any type:
16+
HandySwiftUI provides an elegant way to handle platform-specific values:
1717

1818
```swift
1919
struct AdaptiveView: View {
@@ -27,25 +27,24 @@ struct AdaptiveView: View {
2727
Text("Welcome")
2828
.padding(Platform.value(default: 20.0, phone: 12.0))
2929

30-
// Different fonts per platform
31-
Text("Content")
32-
.font(Platform.value(default: .headline, mac: .title3, phone: .subheadline))
33-
3430
// Different colors per platform
3531
Circle()
3632
.fill(Platform.value(default: .blue, mac: .indigo, pad: .purple, vision: .cyan))
37-
38-
// Even custom enum values
39-
ContentLayout(style: Platform.value(default: .regular, phone: .compact, mac: .expanded))
4033
}
4134
}
4235
}
4336
```
4437

45-
TODO: add an image using "Last 30 Days" on Mac and iPhone with different font sizes
38+
![](Last30Days)
39+
40+
> Image: Getting a similar look across platforms for a title in [FreemiumKit] via:
41+
> ```swift
42+
> .font(Platform.value(default: .title2, phone: .headline))
43+
> ```
4644
4745
`Platform.value` works with any type - from simple numbers to colors, fonts, or your own custom types. Just provide a default and override specific platforms as needed. This can be enormously useful, especially given that it even has a specific case for iPad named `pad`, so you can even address phones and tablets separately.
4846
47+
This is by far my most-used HandySwiftUI helper saving me a ton of boilerplate `#if` checks. It's simple but so powerful!
4948
5049
### Readable Preview Detection
5150
@@ -136,7 +135,7 @@ struct SettingsView: View {
136135
}
137136
```
138137

139-
TODO: add video for above view
138+
![](SettingsView)
140139

141140
HandySwiftUI includes `Emoji` and `SFSymbol` enums that contain common emoji and symbols. You can also create custom enums by conforming to `SearchableOption` and providing `searchTerms` for each case to power the search functionality.
142141

@@ -231,7 +230,7 @@ struct SecureFileLoader {
231230
}
232231
```
233232

234-
TODO: add photo from FreemiumKit with access dialog
233+
![](OpenPanel)
235234

236235
The example taken right out of [FreemiumKit] demonstrates how `OpenPanel` simplifies handling security-scoped file access for dragged items on macOS while maintaining cross-platform compatibility.
237236

@@ -242,7 +241,7 @@ An alternative to SwiftUI's `TabView` that implements sidebar-style navigation c
242241

243242
```swift
244243
struct MainView: View {
245-
enum Tab: String, Identifiable, CustomLabelConvertible {
244+
enum Tab: String, CaseIterable, Identifiable, CustomLabelConvertible {
246245
case documents, recents, settings
247246

248247
var id: Self { self }
@@ -278,7 +277,7 @@ struct MainView: View {
278277
}
279278
```
280279

281-
TODO: add screenshot from Mac
280+
![](SideTabView)
282281

283282
`SideTabView` provides a vertical sidebar with icons and labels, optimized for larger screens with support for bottom-aligned tabs. The view automatically handles platform-specific styling and hover effects.
284283

Sources/HandySwiftUI/HandySwiftUI.docc/Essentials/Styles.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ struct ButtonShowcase: View {
2828
.buttonStyle(.secondary())
2929

3030
// Attention-grabbing pulsating button
31-
Button("Updates", systemName: "bell.fill") {}
32-
.buttonStyle(.pulsating(color: .blue, cornerRadius: 20, glowRadius: 8, duration: 2))
31+
Button {} label: {
32+
Label("Updates", systemImage: "bell.fill")
33+
.padding(15)
34+
}
35+
.buttonStyle(.pulsating(color: .blue, cornerRadius: 20, glowRadius: 8, duration: 2))
3336
}
3437
}
3538
}
3639
```
3740

38-
TODO: add video showcasing above view
41+
![](ButtonStyles)
3942

4043

4144
### Horizontal, Vertical, Fixed Icon-Width Labels
@@ -97,11 +100,11 @@ struct APIConfigView: View {
97100
}
98101
```
99102

100-
TODO: add image from FreemiumKit
103+
![](VerticalLabeledContent)
101104

102105
The `.vertical` style allows customizing alignment (defaults to `leading`) and spacing (defaults to 4). Pass `muteLabel: false` if you're providing a custom label style, as by default labels are automatically styled smaller and grayed out.
103106

104-
For example:
107+
For example, in [FreemiumKit]'s feature localization form, I want the vertical label to have a larger font:
105108

106109
```swift
107110
LabeledContent {
@@ -114,7 +117,7 @@ LabeledContent {
114117
.labeledContentStyle(.vertical(muteLabel: false))
115118
```
116119

117-
TODO: add image from FreemiumKit
120+
![](MuteLabelFalse)
118121

119122

120123
### Multi-Platform Toggle Style
@@ -138,7 +141,7 @@ struct ProductRow: View {
138141
}
139142
```
140143

141-
TODO: add image from FreemiumKit iOS
144+
![](CheckboxUniversal)
142145

143146
The example is extracted from [FreemiumKit]'s products screen, which is optimized for macOS but also supports other platforms.
144147

Sources/HandySwiftUI/HandySwiftUI.docc/Essentials/View Modifiers.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ struct AdaptiveText: View {
3333
}
3434
```
3535

36-
TODO: add example image from TranslateKit (API keys view when test unsuccessful)
36+
![](YellowWithContrast)
37+
38+
> Image: This warning indicator in [TranslateKit] uses `.yellow` but ensures a good contrast even in light mode to be legible.
3739
3840
The `minContrast` parameter (ranging from 0 to 1) determines the minimum contrast ratio against either white (in dark mode) or black (in light mode) using the luminance value (perceived brightness). This ensures text stays readable regardless of the current color scheme.
3941

@@ -106,7 +108,10 @@ Text("With HandySwiftUI")
106108
.roundedRectangleBorder(.blue, cornerRadius: 12, lineWidth: 2)
107109
```
108110

109-
TODO: add example from TranslateKit badges
111+
![](StateBadges)
112+
113+
> Image: Badges in [TranslateKit] use this for rounded borders, for example.
114+
110115

111116
### Conditional Modifiers
112117

@@ -226,7 +231,9 @@ struct TodoView: View {
226231
}
227232
```
228233

229-
TODO: add example from CrossCraft when deleting a puzzle
234+
![](ConfirmDelete)
235+
236+
> Image: Puzzle deletion in [CrossCraft] with a confirmation dialog to avoid accidental deletes.
230237
231238
The example shows how `.confirmDeleteDialog` handles the entire deletion flow – from confirmation to execution – with a single modifier. The dialog is automatically localized in ~40 languages and follows platform design guidelines. You can provide an optional `message` parameter in case you need to provide a different message. There's also an overload that takes a boolean for situations where no list is involved.
232239

38.1 KB
Loading
45.1 KB
Loading
25.2 KB
Loading
166 KB
Loading
327 KB
Loading
3.22 MB
Loading

0 commit comments

Comments
 (0)