From a75e254064433c0220a480e296d6d3e4e843b9dc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 12 Jul 2023 16:03:35 -0500 Subject: [PATCH] badge documentation Signed-off-by: Matt Bruce --- VDS/Components/Badge/Badge.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index 85760edd..da8ff792 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -24,6 +24,8 @@ open class Badge: View { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + + /// Label used to render text open var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.adjustsFontSizeToFitWidth = false @@ -32,12 +34,17 @@ open class Badge: View { $0.textStyle = .boldBodySmall } + /// This will render the badges fill color based on the available options. + /// When used in conjunction with the surface prop, this fill color will change its tint automatically based on a light or dark surface. open var fillColor: FillColor = .red { didSet { setNeedsUpdate() }} + /// The text that will be shown in the label. open var text: String = "" { didSet { setNeedsUpdate() }} - + + /// When applied, this property takes a px value that will restrict the width at that point open var maxWidth: CGFloat? { didSet { setNeedsUpdate() }} + /// This will restrict the badge height to a specific number of lines. If the text overflows the allowable space, ellipsis will show. open var numberOfLines: Int = 1 { didSet { setNeedsUpdate() }} //-------------------------------------------------- @@ -86,6 +93,8 @@ open class Badge: View { //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- + + /// ColorConfiguration that is mapped to the 'fillColor' for the surface private var backgroundColorConfiguration: AnyColorable = { let config = KeyedColorConfiguration(keyPath: \.fillColor) config.setSurfaceColors(VDSColor.backgroundBrandhighlight, VDSColor.backgroundBrandhighlight, forKey: .red) @@ -98,8 +107,10 @@ open class Badge: View { return config.eraseToAnyColorable() }() + /// ColorConfiguration for the Text private var textColorConfiguration = ViewColorConfiguration() + /// Updates the textColorConfiguration based on the fillColor public func updateTextColorConfig() { textColorConfiguration.reset()