added standard style
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
97b6942127
commit
3f6e450739
@ -52,6 +52,10 @@ public struct TextStyle: Equatable, RawRepresentable {
|
|||||||
self.lineSpacing = lineSpacing
|
self.lineSpacing = lineSpacing
|
||||||
self.baselineOffset = baselineOffset
|
self.baselineOffset = baselineOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var isBold: Bool {
|
||||||
|
rawValue.hasPrefix("bold")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension VDSTypography {
|
extension VDSTypography {
|
||||||
@ -261,9 +265,43 @@ extension TextStyle {
|
|||||||
boldMicro
|
boldMicro
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension TextStyle {
|
||||||
|
public enum StandardStyle: String, CaseIterable {
|
||||||
|
case featureXLarge,
|
||||||
|
featureLarge,
|
||||||
|
featureMedium,
|
||||||
|
featureSmall,
|
||||||
|
featureXSmall,
|
||||||
|
title2XLarge,
|
||||||
|
titleXLarge,
|
||||||
|
titleLarge,
|
||||||
|
titleMedium,
|
||||||
|
titleSmall,
|
||||||
|
bodyLarge,
|
||||||
|
bodyMedium,
|
||||||
|
bodySmall,
|
||||||
|
micro
|
||||||
|
|
||||||
|
public var bold: TextStyle {
|
||||||
|
return TextStyle(rawValue: "bold\(rawValue.prefix(1).uppercased())\(rawValue.dropFirst())")!
|
||||||
|
}
|
||||||
|
|
||||||
|
public var regular: TextStyle {
|
||||||
|
TextStyle(rawValue: rawValue)!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func toStandardStyle() -> StandardStyle {
|
||||||
|
var rawName = rawValue
|
||||||
|
if rawName.hasPrefix("bold") {
|
||||||
|
let updatedRaw = rawName.replacingOccurrences(of: "bold", with: "")
|
||||||
|
rawName = updatedRaw.prefix(1).lowercased() + updatedRaw.dropFirst()
|
||||||
|
}
|
||||||
|
return StandardStyle(rawValue: rawName)!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//MARK: FontCategory
|
//MARK: FontCategory
|
||||||
extension TextStyle {
|
extension TextStyle {
|
||||||
@ -350,8 +388,8 @@ extension TextStyle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TextStyle {
|
extension RawRepresentable where Self.RawValue: Equatable {
|
||||||
public func isWithin(_ collection: [TextStyle]) -> Bool {
|
public func isWithin(_ collection: [Self]) -> Bool {
|
||||||
(collection.first(where: {$0 == self}) != nil)
|
(collection.first(where: {$0 == self}) != nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user