Skip to content

Commit da0074e

Browse files
add docs for sucard
1 parent ba0c31e commit da0074e

File tree

3 files changed

+42
-15
lines changed

3 files changed

+42
-15
lines changed

Sources/ComponentsKit/Components/Card/SUCard.swift

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
11
import SwiftUI
22

3+
/// A SwiftUI component that serves as a container for provided content.
4+
///
5+
/// - Example:
6+
/// ```swift
7+
/// SUCard(
8+
/// model: .init(),
9+
/// content: {
10+
/// Text("This is the content of the card.")
11+
/// }
12+
/// )
313
public struct SUCard<Content: View>: View {
4-
let model: CardVM
14+
// MARK: - Properties
15+
16+
/// A model that defines the appearance properties.
17+
public let model: CardVM
518

619
@ViewBuilder private let content: () -> Content
720

8-
public init(model: CardVM, content: @escaping () -> Content) {
21+
// MARK: - Initialization
22+
23+
/// Initializer.
24+
///
25+
/// - Parameters:
26+
/// - model: A model that defines the appearance properties.
27+
/// - content: The content that is displayed in the card.
28+
public init(
29+
model: CardVM,
30+
content: @escaping () -> Content
31+
) {
932
self.model = model
1033
self.content = content
1134
}
1235

36+
// MARK: - Body
37+
1338
public var body: some View {
1439
self.content()
1540
.padding(self.model.contentPaddings.edgeInsets)
@@ -23,14 +48,3 @@ public struct SUCard<Content: View>: View {
2348
.shadow(self.model.shadow)
2449
}
2550
}
26-
27-
extension View {
28-
func shadow(_ shadow: Shadow) -> some View {
29-
self.shadow(
30-
color: shadow.color.color,
31-
radius: shadow.radius,
32-
x: shadow.offset.width,
33-
y: shadow.offset.height
34-
)
35-
}
36-
}

Sources/ComponentsKit/Components/Card/UKCard.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import UIKit
77
/// ```swift
88
/// let banner = UKCard(
99
/// model: .init(),
10-
/// content: { _ in
10+
/// content: {
1111
/// let label = UILabel()
1212
/// label.text = "This is the content of the card."
1313
/// label.numberOfLines = 0

Sources/ComponentsKit/Shared/Types/Shadow.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Foundation
1+
import SwiftUI
22

33
/// Defines shadow options for components.
44
public enum Shadow: Hashable {
@@ -50,3 +50,16 @@ extension Shadow {
5050
}
5151
}
5252
}
53+
54+
// MARK: - SwiftUI + Shadow
55+
56+
extension View {
57+
func shadow(_ shadow: Shadow) -> some View {
58+
self.shadow(
59+
color: shadow.color.color,
60+
radius: shadow.radius,
61+
x: shadow.offset.width,
62+
y: shadow.offset.height
63+
)
64+
}
65+
}

0 commit comments

Comments
 (0)