Skip to content

Commit f822743

Browse files
add headline, body and button font sets in the cofig
1 parent 3b60f68 commit f822743

File tree

15 files changed

+117
-47
lines changed

15 files changed

+117
-47
lines changed

Examples/DemosApp/DemosApp/ComponentsPreview/Helpers/PreviewPickers.swift

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,45 @@ struct CornerRadiusPicker<Custom: View>: View {
9191
}
9292
}
9393

94-
// MARK: - FontPicker
94+
// MARK: - FontPickers
9595

96-
struct FontPicker: View {
96+
struct BodyFontPicker: View {
9797
@Binding var selection: UniversalFont?
9898

9999
var body: some View {
100100
Picker("Font", selection: self.$selection) {
101101
Text("Default").tag(Optional<UniversalFont>.none)
102-
Text("Small").tag(UniversalFont.Component.small)
103-
Text("Medium").tag(UniversalFont.Component.medium)
104-
Text("Large").tag(UniversalFont.Component.large)
102+
Text("Small").tag(UniversalFont.smBody)
103+
Text("Medium").tag(UniversalFont.mdBody)
104+
Text("Large").tag(UniversalFont.lgBody)
105+
Text("Custom: system bold of size 18").tag(UniversalFont.system(size: 18, weight: .bold))
106+
}
107+
}
108+
}
109+
110+
struct ButtonFontPicker: View {
111+
@Binding var selection: UniversalFont?
112+
113+
var body: some View {
114+
Picker("Font", selection: self.$selection) {
115+
Text("Default").tag(Optional<UniversalFont>.none)
116+
Text("Small").tag(UniversalFont.smButton)
117+
Text("Medium").tag(UniversalFont.mdButton)
118+
Text("Large").tag(UniversalFont.lgButton)
119+
Text("Custom: system bold of size 18").tag(UniversalFont.system(size: 18, weight: .bold))
120+
}
121+
}
122+
}
123+
124+
struct HeadlineFontPicker: View {
125+
@Binding var selection: UniversalFont?
126+
127+
var body: some View {
128+
Picker("Font", selection: self.$selection) {
129+
Text("Default").tag(Optional<UniversalFont>.none)
130+
Text("Small").tag(UniversalFont.smHeadline)
131+
Text("Medium").tag(UniversalFont.mdHeadline)
132+
Text("Large").tag(UniversalFont.lgHeadline)
105133
Text("Custom: system bold of size 18").tag(UniversalFont.system(size: 18, weight: .bold))
106134
}
107135
}

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/ButtonPreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct ButtonPreview: View {
2222
CornerRadiusPicker(selection: self.$model.cornerRadius) {
2323
Text("Custom: 20px").tag(ComponentRadius.custom(20))
2424
}
25-
FontPicker(selection: self.$model.font)
25+
ButtonFontPicker(selection: self.$model.font)
2626
Toggle("Enabled", isOn: self.$model.isEnabled)
2727
Toggle("Full Width", isOn: self.$model.isFullWidth)
2828
SizePicker(selection: self.$model.size)

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/CheckboxPreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct CheckboxPreview: View {
3434
CornerRadiusPicker(selection: self.$model.cornerRadius) {
3535
Text("Custom: 2px").tag(ComponentRadius.custom(2))
3636
}
37-
FontPicker(selection: self.$model.font)
37+
BodyFontPicker(selection: self.$model.font)
3838
Toggle("Enabled", isOn: self.$model.isEnabled)
3939
SizePicker(selection: self.$model.size)
4040
}

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/InputFieldPreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct InputFieldPreview: View {
3838
Text("Custom: 20px").tag(ComponentRadius.custom(20))
3939
}
4040
Toggle("Enabled", isOn: self.$model.isEnabled)
41-
FontPicker(selection: self.$model.font)
41+
BodyFontPicker(selection: self.$model.font)
4242
KeyboardTypePicker(selection: self.$model.keyboardType)
4343
Toggle("Placeholder", isOn: .init(
4444
get: {

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/RadioGroupPreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct RadioGroupPreview: View {
3333
AnimationScalePicker(selection: self.$model.animationScale)
3434
UniversalColorPicker(title: "Color", selection: self.$model.color)
3535
Toggle("Enabled", isOn: self.$model.isEnabled)
36-
FontPicker(selection: self.$model.font)
36+
BodyFontPicker(selection: self.$model.font)
3737
SizePicker(selection: self.$model.size)
3838
Picker("Spacing", selection: self.$model.spacing) {
3939
Text("8px").tag(CGFloat(8))

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/SegmentedControlPreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct SegmentedControlPreview: View {
4646
Text("Custom: 4px").tag(ComponentRadius.custom(4))
4747
}
4848
Toggle("Enabled", isOn: self.$model.isEnabled)
49-
FontPicker(selection: self.$model.font)
49+
BodyFontPicker(selection: self.$model.font)
5050
Toggle("Full Width", isOn: self.$model.isFullWidth)
5151
SizePicker(selection: self.$model.size)
5252
}

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/TextInputPreview.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct TextInputPreviewPreview: View {
3838
Text("Custom: 20px").tag(ComponentRadius.custom(20))
3939
}
4040
Toggle("Enabled", isOn: self.$model.isEnabled)
41-
FontPicker(selection: self.$model.font)
41+
BodyFontPicker(selection: self.$model.font)
4242
KeyboardTypePicker(selection: self.$model.keyboardType)
4343
Picker("Max Rows", selection: self.$model.maxRows) {
4444
Text("2 Rows").tag(2)

Sources/ComponentsKit/Button/Models/ButtonVM.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ extension ButtonVM {
104104

105105
switch self.size {
106106
case .small:
107-
return UniversalFont.Component.small
107+
return .smButton
108108
case .medium:
109-
return UniversalFont.Component.medium
109+
return .mdButton
110110
case .large:
111-
return UniversalFont.Component.large
111+
return .mdButton
112112
}
113113
}
114114
var height: CGFloat {

Sources/ComponentsKit/Checkbox/Models/CheckboxVM.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ extension CheckboxVM {
9898

9999
switch self.size {
100100
case .small:
101-
return UniversalFont.Component.small
101+
return .smBody
102102
case .medium:
103-
return UniversalFont.Component.medium
103+
return .mdBody
104104
case .large:
105-
return UniversalFont.Component.large
105+
return .lgBody
106106
}
107107
}
108108
}

Sources/ComponentsKit/Configuration/Layout.swift

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public struct Layout: Initializable, Updatable {
5050
}
5151
}
5252

53-
// MARK: Font
53+
// MARK: Fonts
5454

55-
public struct Font {
55+
public struct FontSet {
5656
public var small: UniversalFont
5757
public var medium: UniversalFont
5858
public var large: UniversalFont
@@ -64,13 +64,25 @@ public struct Layout: Initializable, Updatable {
6464
}
6565
}
6666

67+
public struct Typography {
68+
public var headline: FontSet
69+
public var body: FontSet
70+
public var button: FontSet
71+
72+
public init(headline: FontSet, body: FontSet, button: FontSet) {
73+
self.headline = headline
74+
self.body = body
75+
self.button = button
76+
}
77+
}
78+
6779
// MARK: Properties
6880

6981
public var disabledOpacity: CGFloat = 0.5
7082
public var componentRadius: Radius = .init(
7183
small: 10.0,
72-
medium: 14.0,
73-
large: 18.0
84+
medium: 12.0,
85+
large: 16.0
7486
)
7587
public var borderWidth: BorderWidth = .init(
7688
small: 1.0,
@@ -82,10 +94,22 @@ public struct Layout: Initializable, Updatable {
8294
medium: 0.98,
8395
large: 0.95
8496
)
85-
public var componentFont: Font = .init(
86-
small: .system(size: 14, weight: .regular),
87-
medium: .system(size: 18, weight: .regular),
88-
large: .system(size: 22, weight: .regular)
97+
public var typography: Typography = .init(
98+
headline: .init(
99+
small: .system(size: 14, weight: .semibold),
100+
medium: .system(size: 20, weight: .semibold),
101+
large: .system(size: 28, weight: .semibold)
102+
),
103+
body: .init(
104+
small: .system(size: 14, weight: .regular),
105+
medium: .system(size: 16, weight: .regular),
106+
large: .system(size: 18, weight: .regular)
107+
),
108+
button: .init(
109+
small: .system(size: 14, weight: .medium),
110+
medium: .system(size: 16, weight: .medium),
111+
large: .system(size: 20, weight: .medium)
112+
)
89113
)
90114

91115
public init() {}

0 commit comments

Comments
 (0)