created a mapping method for the old values

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-02-13 09:25:27 -06:00
parent 28c15efba5
commit 9e6b2a2bd6

View File

@ -12,7 +12,7 @@ import VDS
extension Styler.Font {
//Converts Legacy Font to a VDS.TextStyle
public func vdsTextStyle() -> VDS.TextStyle? {
let updatedRaw = rawValue.replacingOccurrences(of: "Regular", with: "")
let updatedRaw = mapped().rawValue.replacingOccurrences(of: "Regular", with: "")
let newRaw = updatedRaw.prefix(1).lowercased() + updatedRaw.dropFirst()
guard let style = VDS.TextStyle(rawValue: newRaw) else { return nil }
return style
@ -27,6 +27,24 @@ extension Styler.Font {
}
return found
}
private func mapped() -> Styler.Font {
var mapped: Styler.Font = self
switch self {
case .Title2XLarge: mapped = .RegularTitle2XLarge
case .TitleXLarge: mapped = .RegularTitleXLarge
case .H1: mapped = .RegularTitle2XLarge
case .H32: mapped = .RegularTitleXLarge
case .H2: mapped = .RegularTitleLarge
case .B20: mapped = .RegularBodyLarge
case .H3: mapped = .BoldTitleMedium
case .B1: mapped = .BoldBodySmall
case .B2: mapped = .RegularBodySmall
case .B3: mapped = .RegularMicro
default: break
}
return mapped
}
}
extension VDS.Font {