-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Textに.font(charcoalTypography:)と.foregroundStyle(charcoalColor:)を足しました
- Loading branch information
Showing
4 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Sources/CharcoalSwiftUI/Components/Typographies/CharcoalTypography.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import SwiftUI | ||
|
||
public extension Text { | ||
enum CharcoalTypography { | ||
case regular10 | ||
case bold10 | ||
case regular12 | ||
case bold12 | ||
case regular14 | ||
case bold14 | ||
case regular16 | ||
case bold16 | ||
case regular20 | ||
case bold20 | ||
|
||
typealias Value = (size: CGFloat, weight: UIFont.Weight) | ||
|
||
var value: Value { | ||
switch self { | ||
case .regular10: | ||
return (size: 10, weight: .regular) | ||
case .bold10: | ||
return (size: 10, weight: .bold) | ||
case .regular12: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the12.fontSize), weight: .regular) | ||
case .bold12: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the12.fontSize), weight: .bold) | ||
case .regular14: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the14.fontSize), weight: .regular) | ||
case .bold14: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the14.fontSize), weight: .bold) | ||
case .regular16: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the16.fontSize), weight: .regular) | ||
case .bold16: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the16.fontSize), weight: .bold) | ||
case .regular20: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the20.fontSize), weight: .regular) | ||
case .bold20: | ||
return (size: CGFloat(charcoalFoundation.typography.size.the20.fontSize), weight: .bold) | ||
} | ||
} | ||
} | ||
|
||
func font(charcoalTypography: CharcoalTypography) -> Text { | ||
self | ||
.font( | ||
.custom(UIFont.monospacedSystemFont(ofSize: .zero, weight: charcoalTypography.value.weight).fontName, | ||
size: charcoalTypography.value.size, | ||
relativeTo: .body) | ||
) | ||
} | ||
} |