added Typography
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
017f7eadb0
commit
2ed981f0ad
@ -46,6 +46,7 @@
|
||||
EAB1D2A328A5994800DAE764 /* Debuggable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2A228A5994800DAE764 /* Debuggable.swift */; };
|
||||
EAB1D2C728A6E76300DAE764 /* ModelHandlerPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C628A6E76300DAE764 /* ModelHandlerPublisher.swift */; };
|
||||
EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CC28ABE76000DAE764 /* Withable.swift */; };
|
||||
EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */; };
|
||||
EAF7F0952899861000B287F5 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0932899861000B287F5 /* Checkbox.swift */; };
|
||||
EAF7F0962899861000B287F5 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0942899861000B287F5 /* CheckboxModel.swift */; };
|
||||
EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0992899B17200B287F5 /* CATransaction.swift */; };
|
||||
@ -128,6 +129,7 @@
|
||||
EAB1D2A228A5994800DAE764 /* Debuggable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debuggable.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C628A6E76300DAE764 /* ModelHandlerPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHandlerPublisher.swift; sourceTree = "<group>"; };
|
||||
EAB1D2CC28ABE76000DAE764 /* Withable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Withable.swift; sourceTree = "<group>"; };
|
||||
EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typography.swift; sourceTree = "<group>"; };
|
||||
EAF7F0932899861000B287F5 /* Checkbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; };
|
||||
EAF7F0942899861000B287F5 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = "<group>"; };
|
||||
EAF7F0992899B17200B287F5 /* CATransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CATransaction.swift; sourceTree = "<group>"; };
|
||||
@ -209,6 +211,7 @@
|
||||
EA3361DF2891D0F10071C351 /* Fonts */,
|
||||
EA3361AB288B25EC0071C351 /* Protocols */,
|
||||
EAB1D29F28A598D000DAE764 /* PropertyWrappers */,
|
||||
EAB1D2D028ABEF3100DAE764 /* Typography */,
|
||||
EA3361B9288B2BE30071C351 /* Utilities */,
|
||||
EA3361FE2891E14C0071C351 /* SupportingFiles */,
|
||||
EA336170288B19200071C351 /* VDS.docc */,
|
||||
@ -365,6 +368,14 @@
|
||||
path = PropertyWrappers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EAB1D2D028ABEF3100DAE764 /* Typography */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */,
|
||||
);
|
||||
path = Typography;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EAF7F092289985E200B287F5 /* Checkbox */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -551,6 +562,7 @@
|
||||
EAF7F13328A2A16500B287F5 /* LabelAttributeAttachment.swift in Sources */,
|
||||
EAF7F0B9289C139800B287F5 /* ColorConfiguration.swift in Sources */,
|
||||
EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */,
|
||||
EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */,
|
||||
EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */,
|
||||
EAB1D29E28A5619500DAE764 /* RadioButtonGroupModel.swift in Sources */,
|
||||
EAF7F0A2289AFB3900B287F5 /* Errorable.swift in Sources */,
|
||||
|
||||
253
VDS/Typography/Typography.swift
Normal file
253
VDS/Typography/Typography.swift
Normal file
@ -0,0 +1,253 @@
|
||||
//
|
||||
// Typography.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/16/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import VDSTypographyTokens
|
||||
|
||||
public enum TypographicalStyle: String, Codable, CaseIterable {
|
||||
|
||||
case FeatureXLarge
|
||||
case BoldFeatureXLarge
|
||||
case FeatureLarge
|
||||
case BoldFeatureLarge
|
||||
case FeatureMedium
|
||||
case BoldFeatureMedium
|
||||
case FeatureSmall
|
||||
case BoldFeatureSmall
|
||||
case FeatureXSmall
|
||||
case BoldFeatureXSmall
|
||||
|
||||
case Title2XLarge
|
||||
case BoldTitle2XLarge
|
||||
case TitleXLarge
|
||||
case BoldTitleXLarge
|
||||
case TitleLarge
|
||||
case BoldTitleLarge
|
||||
case TitleMedium
|
||||
case BoldTitleMedium
|
||||
case TitleSmall
|
||||
case BoldTitleSmall
|
||||
|
||||
case BodyLarge
|
||||
case BoldBodyLarge
|
||||
case BodyMedium
|
||||
case BoldBodyMedium
|
||||
case BodySmall
|
||||
case BoldBodySmall
|
||||
|
||||
case Micro
|
||||
case BoldMicro
|
||||
|
||||
public static var defaultStyle: TypographicalStyle {
|
||||
return .BodyLarge
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: FontWeight
|
||||
extension TypographicalStyle {
|
||||
public enum FontWeight {
|
||||
case light
|
||||
case regular
|
||||
case bold
|
||||
}
|
||||
|
||||
public var fontWeight: FontWeight {
|
||||
switch self {
|
||||
case .BoldFeatureXLarge,
|
||||
.BoldFeatureLarge,
|
||||
.BoldFeatureMedium,
|
||||
.BoldFeatureSmall,
|
||||
.BoldFeatureXSmall,
|
||||
.BoldTitle2XLarge,
|
||||
.BoldTitleXLarge,
|
||||
.BoldTitleLarge,
|
||||
.BoldTitleMedium,
|
||||
.BoldTitleSmall,
|
||||
.BoldBodyLarge,
|
||||
.BoldBodyMedium,
|
||||
.BoldBodySmall,
|
||||
.BoldMicro:
|
||||
return .bold
|
||||
|
||||
case .FeatureXLarge,
|
||||
.FeatureLarge,
|
||||
.FeatureMedium,
|
||||
.FeatureSmall,
|
||||
.FeatureXSmall,
|
||||
.Title2XLarge,
|
||||
.TitleXLarge,
|
||||
.TitleLarge:
|
||||
return .light
|
||||
|
||||
case .TitleMedium,
|
||||
.TitleSmall,
|
||||
.BodyLarge,
|
||||
.BodyMedium,
|
||||
.BodySmall,
|
||||
.Micro:
|
||||
return .regular
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//MARK: PointSize
|
||||
extension TypographicalStyle {
|
||||
public var pointSize: CGFloat {
|
||||
switch self {
|
||||
case .FeatureXLarge, .BoldFeatureXLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96
|
||||
case .FeatureLarge, .BoldFeatureLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80
|
||||
case .FeatureMedium, .BoldFeatureMedium:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64
|
||||
case .FeatureSmall, .BoldFeatureSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48
|
||||
case .FeatureXSmall, .BoldFeatureXSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40
|
||||
case .Title2XLarge, .BoldTitle2XLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40
|
||||
case .TitleXLarge, .BoldTitleXLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32
|
||||
case .TitleLarge, .BoldTitleLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24
|
||||
case .TitleMedium, .BoldTitleMedium:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20
|
||||
case .TitleSmall, .BoldTitleSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16
|
||||
case .BodyLarge, .BoldBodyLarge:
|
||||
return VDSTypography.fontSizeBody16
|
||||
case .BodyMedium, .BoldBodyMedium:
|
||||
return VDSTypography.fontSizeBody14
|
||||
case .BodySmall, .BoldBodySmall:
|
||||
return VDSTypography.fontSizeBody12
|
||||
case .Micro, .BoldMicro:
|
||||
return VDSTypography.fontSizeMicro11
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: LineHeight
|
||||
extension TypographicalStyle {
|
||||
public var lineHeight: CGFloat {
|
||||
switch self {
|
||||
case .FeatureXLarge, .BoldFeatureXLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88
|
||||
case .FeatureLarge, .BoldFeatureLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76
|
||||
case .FeatureMedium, .BoldFeatureMedium:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64
|
||||
case .FeatureSmall, .BoldFeatureSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48
|
||||
case .FeatureXSmall, .BoldFeatureXSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40
|
||||
case .Title2XLarge, .BoldTitle2XLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40
|
||||
case .TitleXLarge, .BoldTitleXLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36
|
||||
case .TitleLarge, .BoldTitleLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28
|
||||
case .TitleMedium, .BoldTitleMedium:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24
|
||||
case .TitleSmall, .BoldTitleSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20
|
||||
case .BodyLarge, .BoldBodyLarge:
|
||||
return VDSTypography.lineHeightBody20
|
||||
case .BodyMedium, .BoldBodyMedium:
|
||||
return VDSTypography.lineHeightBody18
|
||||
case .BodySmall, .BoldBodySmall:
|
||||
return VDSTypography.lineHeightBody16
|
||||
case .Micro, .BoldMicro:
|
||||
return VDSTypography.lineHeightMicro16
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: LetterSpacing
|
||||
extension TypographicalStyle {
|
||||
public var letterSpacing: CGFloat {
|
||||
switch self {
|
||||
case .FeatureXLarge,
|
||||
.FeatureLarge,
|
||||
.FeatureMedium,
|
||||
.FeatureSmall,
|
||||
.FeatureXSmall,
|
||||
.Title2XLarge,
|
||||
.TitleXLarge,
|
||||
.TitleLarge:
|
||||
return 0.25
|
||||
|
||||
case .BoldBodyLarge, .BodyLarge,
|
||||
.BoldBodyMedium, .BodyMedium:
|
||||
return 0.5
|
||||
|
||||
default:
|
||||
return 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Alignments
|
||||
extension TypographicalStyle {
|
||||
public var aligments: [TextPosition] {
|
||||
return [.left, .center]
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Fonts
|
||||
extension TypographicalStyle {
|
||||
public var fontFace: Fonts {
|
||||
switch self {
|
||||
case .BoldFeatureXLarge,
|
||||
.BoldFeatureLarge,
|
||||
.BoldFeatureMedium,
|
||||
.BoldFeatureSmall,
|
||||
.BoldFeatureXSmall,
|
||||
.BoldTitle2XLarge,
|
||||
.BoldTitleXLarge,
|
||||
.BoldTitleLarge,
|
||||
.BoldTitleMedium,
|
||||
.BoldTitleSmall,
|
||||
.BoldBodyLarge,
|
||||
.BoldBodyMedium,
|
||||
.BoldBodySmall:
|
||||
return .dsBold
|
||||
|
||||
case .FeatureXLarge,
|
||||
.FeatureLarge,
|
||||
.FeatureMedium,
|
||||
.FeatureSmall,
|
||||
.FeatureXSmall,
|
||||
.Title2XLarge,
|
||||
.TitleXLarge,
|
||||
.TitleLarge:
|
||||
return .dsLight
|
||||
|
||||
case .TitleMedium,
|
||||
.TitleSmall,
|
||||
.BodyLarge,
|
||||
.BodyMedium,
|
||||
.BodySmall:
|
||||
return .dsRegular
|
||||
|
||||
case .BoldMicro:
|
||||
return .txBold
|
||||
|
||||
case .Micro:
|
||||
return .txRegular
|
||||
}
|
||||
}
|
||||
|
||||
public var font: UIFont {
|
||||
return fontFace.font(ofSize: pointSize)
|
||||
}
|
||||
|
||||
public var superScriptFont: UIFont {
|
||||
return fontFace.font(ofSize: pointSize / 2)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user