From 5b061cda1d8c6edb3400ec19be7bdfd283603bad Mon Sep 17 00:00:00 2001 From: lsh1202 Date: Thu, 1 Aug 2024 17:46:14 +0900 Subject: [PATCH] :sparkles: :: typography --- .../QDS/Component/Button/QvickButton.swift | 2 +- .../Component/TextField/QvickTextField.swift | 6 +- .../QDS/Foundation/Typography/Font+Ext.swift | 62 ++++++ .../Typography/QvickTextStyle+Ext.swift | 181 ++++++++++++++++++ .../Typography/QvickTextStyle.swift | 30 +++ 5 files changed, 278 insertions(+), 3 deletions(-) create mode 100644 Sources/QDS/Foundation/Typography/QvickTextStyle+Ext.swift create mode 100644 Sources/QDS/Foundation/Typography/QvickTextStyle.swift diff --git a/Sources/QDS/Component/Button/QvickButton.swift b/Sources/QDS/Component/Button/QvickButton.swift index c42a59d..feb686b 100644 --- a/Sources/QDS/Component/Button/QvickButton.swift +++ b/Sources/QDS/Component/Button/QvickButton.swift @@ -33,7 +33,7 @@ public struct QvickButton: View { .foregroundStyle(disable ? Color.labelLightDisable : .primaryNormal) .overlay { Text(text) - .font(.pretendard(.bold, size: 17)) + .font(.pretendard(.semibold, size: 17)) .foregroundStyle(.white) } } diff --git a/Sources/QDS/Component/TextField/QvickTextField.swift b/Sources/QDS/Component/TextField/QvickTextField.swift index 12eaa45..36becf2 100644 --- a/Sources/QDS/Component/TextField/QvickTextField.swift +++ b/Sources/QDS/Component/TextField/QvickTextField.swift @@ -33,7 +33,9 @@ public struct QvickTextField: View { if isSecure { SecureField( text: $text, - prompt: Text(prompt).font(.pretendard(.regular, size: 14)) + prompt: + Text(prompt) + .font(.label1Normal(.regular)) ) { } @@ -61,7 +63,7 @@ public struct QvickTextField: View { } else { TextField( text: $text, - prompt: Text(prompt).font(.pretendard(.regular, size: 14)) + prompt: Text(prompt).font(.label1Normal(.regular)) ) { } diff --git a/Sources/QDS/Foundation/Typography/Font+Ext.swift b/Sources/QDS/Foundation/Typography/Font+Ext.swift index e263ced..38541dc 100644 --- a/Sources/QDS/Foundation/Typography/Font+Ext.swift +++ b/Sources/QDS/Foundation/Typography/Font+Ext.swift @@ -4,4 +4,66 @@ extension Font { public static func pretendard( _ weight: QvickFont.Pretendard = .regular, size: CGFloat ) -> Font { return weight.font(size: size) } + + public static func display1( _ style: QvickTextStyle.Display1 ) -> Font { + return style.font + } + public static func display2( _ style: QvickTextStyle.Display2 ) -> Font { + return style.font + } + + public static func title1( _ style: QvickTextStyle.Title1 ) -> Font { + return style.font + } + public static func title2( _ style: QvickTextStyle.Title2 ) -> Font { + return style.font + } + public static func title3( _ style: QvickTextStyle.Title3 ) -> Font { + return style.font + } + + public static func heading1( _ style: QvickTextStyle.Heading1 ) -> Font { + return style.font + } + public static func heading2( _ style: QvickTextStyle.Heading2 ) -> Font { + return style.font + } + + public static func headline1( _ style: QvickTextStyle.HeadLine1 ) -> Font { + return style.font + } + public static func headline2( _ style: QvickTextStyle.HeadLine2 ) -> Font { + return style.font + } + + public static func body1Normal( _ style: QvickTextStyle.Body1Normal ) -> Font { + return style.font + } + public static func body1Reading( _ style: QvickTextStyle.Body1Reading ) -> Font { + return style.font + } + + public static func body2Normal( _ style: QvickTextStyle.Body2Normal ) -> Font { + return style.font + } + public static func body2Reading( _ style: QvickTextStyle.Body2Reading ) -> Font { + return style.font + } + + public static func label1Normal( _ style: QvickTextStyle.Label1Normal ) -> Font { + return style.font + } + public static func label1Reading( _ style: QvickTextStyle.Label1Reading ) -> Font { + return style.font + } + public static func label2( _ style: QvickTextStyle.Label2 ) -> Font { + return style.font + } + + public static func caption1( _ style: QvickTextStyle.Caption1 ) -> Font { + return style.font + } + public static func caption2( _ style: QvickTextStyle.Caption2 ) -> Font { + return style.font + } } diff --git a/Sources/QDS/Foundation/Typography/QvickTextStyle+Ext.swift b/Sources/QDS/Foundation/Typography/QvickTextStyle+Ext.swift new file mode 100644 index 0000000..387cdb7 --- /dev/null +++ b/Sources/QDS/Foundation/Typography/QvickTextStyle+Ext.swift @@ -0,0 +1,181 @@ +import SwiftUI + +extension QvickTextStyle.Display1: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 56) + case .medium: .pretendard(.medium, size: 56) + case .regular: .pretendard(.regular, size: 56) + } + } +} + +extension QvickTextStyle.Display2: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 40) + case .medium: .pretendard(.medium, size: 40) + case .regular: .pretendard(.regular, size: 40) + } + } +} + +extension QvickTextStyle.Title1: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 36) + case .medium: .pretendard(.medium, size: 36) + case .regular: .pretendard(.regular, size: 36) + } + } +} + +extension QvickTextStyle.Title2: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 28) + case .medium: .pretendard(.medium, size: 28) + case .regular: .pretendard(.regular, size: 28) + } + } +} + +extension QvickTextStyle.Title3: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 24) + case .medium: .pretendard(.medium, size: 24) + case .regular: .pretendard(.regular, size: 24) + } + } +} + +extension QvickTextStyle.Heading1: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 22) + case .medium: .pretendard(.medium, size: 22) + case .regular: .pretendard(.regular, size: 22) + } + } +} + +extension QvickTextStyle.Heading2: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 20) + case .medium: .pretendard(.medium, size: 20) + case .regular: .pretendard(.regular, size: 20) + } + } +} + +extension QvickTextStyle.HeadLine1: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 18) + case .medium: .pretendard(.medium, size: 18) + case .regular: .pretendard(.regular, size: 18) + } + } +} + +extension QvickTextStyle.HeadLine2: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 17) + case .medium: .pretendard(.medium, size: 17) + case .regular: .pretendard(.regular, size: 17) + } + } +} + +extension QvickTextStyle.Body1Normal: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 16) + case .medium: .pretendard(.medium, size: 16) + case .regular: .pretendard(.regular, size: 16) + } + } +} + +extension QvickTextStyle.Body1Reading: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 16) + case .medium: .pretendard(.medium, size: 16) + case .regular: .pretendard(.regular, size: 16) + } + } +} + +extension QvickTextStyle.Body2Normal: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 15) + case .medium: .pretendard(.medium, size: 15) + case .regular: .pretendard(.regular, size: 15) + } + } +} + +extension QvickTextStyle.Body2Reading: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 15) + case .medium: .pretendard(.medium, size: 15) + case .regular: .pretendard(.regular, size: 15) + } + } +} + +extension QvickTextStyle.Label1Normal: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 14) + case .medium: .pretendard(.medium, size: 14) + case .regular: .pretendard(.regular, size: 14) + } + } +} + +extension QvickTextStyle.Label1Reading: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 14) + case .medium: .pretendard(.medium, size: 14) + case .regular: .pretendard(.regular, size: 14) + } + } +} + +extension QvickTextStyle.Label2: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 13) + case .medium: .pretendard(.medium, size: 13) + case .regular: .pretendard(.regular, size: 13) + } + } +} + +extension QvickTextStyle.Caption1: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 12) + case .medium: .pretendard(.medium, size: 12) + case .regular: .pretendard(.regular, size: 12) + } + } +} + +extension QvickTextStyle.Caption2: QvickFont.Fontable { + public var font: Font { + switch self { + case .bold: .pretendard(.bold, size: 11) + case .medium: .pretendard(.medium, size: 11) + case .regular: .pretendard(.regular, size: 11) + } + } +} diff --git a/Sources/QDS/Foundation/Typography/QvickTextStyle.swift b/Sources/QDS/Foundation/Typography/QvickTextStyle.swift new file mode 100644 index 0000000..6d99ef7 --- /dev/null +++ b/Sources/QDS/Foundation/Typography/QvickTextStyle.swift @@ -0,0 +1,30 @@ +import SwiftUI + +public struct QvickTextStyle { + public enum Display1 { case bold, medium, regular } + public enum Display2 { case bold, medium, regular } + + public enum Title1 { case bold, medium, regular } + public enum Title2 { case bold, medium, regular } + public enum Title3 { case bold, medium, regular } + + public enum Heading1 { case bold, medium, regular } + public enum Heading2 { case bold, medium, regular } + + public enum HeadLine1 { case bold, medium, regular } + public enum HeadLine2 { case bold, medium, regular } + + public enum Body1Normal { case bold, medium, regular } + public enum Body1Reading { case bold, medium, regular } + + public enum Body2Normal { case bold, medium, regular } + public enum Body2Reading { case bold, medium, regular } + + public enum Label1Normal { case bold, medium, regular } + public enum Label1Reading { case bold, medium, regular } + public enum Label2 { case bold, medium, regular } + + public enum Caption1 { case bold, medium, regular } + public enum Caption2 { case bold, medium, regular } + +}