Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: FontSystem μ™„μ„± #19

Merged
merged 5 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
52 changes: 52 additions & 0 deletions Projects/Core/DesignSystem/Sources/Font/Font+sms.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import SwiftUI

public extension Font {
enum SMSFontSystem: SMSFontable {
case headline1
case headline2
case headline3
case title1
case title2
case body1
case body2
case caption1
case caption2
}

static func sms(_ style: SMSFontSystem) -> Font {
return style.font
}
}

public extension Font.SMSFontSystem {
var font: Font {
switch self {
case .headline1:
return Font(DesignSystemFontFamily.Pretendard.bold.font(size: 40))

case .headline2:
return Font(DesignSystemFontFamily.Pretendard.bold.font(size: 32))

case .headline3:
return Font(DesignSystemFontFamily.Pretendard.bold.font(size: 28))

case .title1:
return Font(DesignSystemFontFamily.Pretendard.bold.font(size: 20))

case .title2:
return Font(DesignSystemFontFamily.Pretendard.bold.font(size: 17))

case .body1:
return Font(DesignSystemFontFamily.Pretendard.regular.font(size: 15))

case .body2:
return Font(DesignSystemFontFamily.Pretendard.regular.font(size: 14))

case .caption1:
return Font(DesignSystemFontFamily.Pretendard.regular.font(size: 13))

case .caption2:
return Font(DesignSystemFontFamily.Pretendard.regular.font(size: 12))
}
}
}
5 changes: 5 additions & 0 deletions Projects/Core/DesignSystem/Sources/Font/SMSFontable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import SwiftUI

protocol SMSFontable {
var font: Font { get }
}
16 changes: 16 additions & 0 deletions Projects/Core/DesignSystem/Sources/Text/SMSText.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import SwiftUI

public struct SMSText: View {
var text: String
var font: Font.SMSFontSystem

public init(_ text: String, font: Font.SMSFontSystem = .body1) {
self.text = text
self.font = font
}

public var body: some View {
Text(text)
.font(font.font)
}
}