Skip to content

Commit 0e566e3

Browse files
authored
Merge pull request #707 from kiwicom/706-illustration-does-not-respect-frame-alignment
Illustration does not respect frame alignment
2 parents eab119f + d07625e commit 0e566e3

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed
Loading
Loading

Sources/OrbitIllustrations/Components/Illustration.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public struct Illustration: View {
1616
public var body: some View {
1717
if name.isEmpty == false {
1818
switch layout {
19-
case .frame(let maxHeight, let alignment):
19+
case .frame(let height, let alignment):
2020
resizeableImage
21-
.frame(maxHeight: maxHeight)
21+
.frame(height: height)
2222
.frame(maxWidth: idealSize.horizontal == true ? nil : .infinity, alignment: .init(alignment))
2323
.fixedSize(horizontal: false, vertical: true)
2424
case .resizeable:
@@ -82,12 +82,12 @@ public extension Illustration {
8282
/// Illustration layout specifies how the illustration is resized and (optionally) horizontally aligned.
8383
enum Layout {
8484

85-
/// Default maximal illustration height using frame layout.
86-
public static let maxHeight: CGFloat = 200
85+
/// Default illustration height when using frame layout.
86+
public static let height: CGFloat = 200
8787

88-
/// Positions illustration, first scaled to fit the optional maxHeight, in a horizontally expanding frame with specified alignment.
88+
/// Positions illustration, first scaled to fit the height, in a horizontally expanding frame with specified alignment.
8989
case frame(
90-
maxHeight: CGFloat = maxHeight,
90+
height: CGFloat = height,
9191
alignment: HorizontalAlignment = .center
9292
)
9393
/// Applies `resizable` and `scaledToFit` modifiers to allow free resizing.
@@ -125,7 +125,7 @@ struct IllustrationPreviews: PreviewProvider {
125125
}
126126

127127
static var customResource: some View {
128-
Illustration("WomanWithPhone", bundle: .orbit, layout: .intrinsic)
128+
Illustration("WomanWithPhone", bundle: .orbitIllustrations, layout: .intrinsic)
129129
.previewDisplayName()
130130
}
131131

@@ -148,22 +148,22 @@ struct IllustrationPreviews: PreviewProvider {
148148
.border(.cloudNormal)
149149
}
150150

151-
Card("MaxHeight = 80", showBorder: false) {
151+
Card("Height = 80", showBorder: false) {
152152
VStack {
153153
Text("Frame - Center (default)")
154-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 80))
154+
Illustration(.womanWithPhone, layout: .frame(height: 80))
155155
.border(.cloudNormal)
156156
}
157157

158158
VStack {
159159
Text("Frame - Leading")
160-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 80, alignment: .leading))
160+
Illustration(.womanWithPhone, layout: .frame(height: 80, alignment: .leading))
161161
.border(.cloudNormal)
162162
}
163163

164164
VStack {
165165
Text("Frame - Trailing")
166-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 80, alignment: .trailing))
166+
Illustration(.womanWithPhone, layout: .frame(height: 80, alignment: .trailing))
167167
.border(.cloudNormal)
168168
}
169169

@@ -175,17 +175,17 @@ struct IllustrationPreviews: PreviewProvider {
175175
}
176176
}
177177

178-
Card("MaxHeight = 30", showBorder: false) {
178+
Card("Height = 30", showBorder: false) {
179179
HStack {
180180
VStack(alignment: .leading) {
181181
Text("Leading")
182-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 30, alignment: .leading))
182+
Illustration(.womanWithPhone, layout: .frame(height: 30, alignment: .leading))
183183
.border(.cloudNormal)
184184
}
185185

186186
VStack(alignment: .leading) {
187187
Text("Center")
188-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 30))
188+
Illustration(.womanWithPhone, layout: .frame(height: 30))
189189
.border(.cloudNormal)
190190
}
191191

@@ -198,7 +198,7 @@ struct IllustrationPreviews: PreviewProvider {
198198

199199
VStack(alignment: .leading) {
200200
Text("Trailing")
201-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 30, alignment: .trailing))
201+
Illustration(.womanWithPhone, layout: .frame(height: 30, alignment: .trailing))
202202
.border(.cloudNormal)
203203
}
204204
}

Sources/OrbitIllustrations/Extensions/Dialog+Illustration.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public extension Dialog {
1212
@ButtonStackBuilder buttons: () -> Buttons
1313
) where Illustration == OrbitIllustrations.Illustration {
1414
self.init(title, description: description, content: content, buttons: buttons) {
15-
Illustration(illustration, layout: .frame(maxHeight: 120, alignment: .leading))
15+
Illustration(illustration, layout: .frame(height: 120, alignment: .leading))
1616
}
1717
}
1818
}

Sources/OrbitIllustrations/Extensions/EmptyState+Illustration.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public extension EmptyState {
1212
@ButtonStackBuilder buttons: () -> Buttons
1313
) where Illustration == OrbitIllustrations.Illustration {
1414
self.init(title, description: description, content: content, buttons: buttons) {
15-
Illustration(illustration, layout: .frame(maxHeight: 160))
15+
Illustration(illustration, layout: .frame(height: 160))
1616
}
1717
}
1818

Sources/OrbitStorybook/Detail/Items/StorybookIllustration.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ struct StorybookIllustration {
1111
.border(.cloudNormal)
1212
}
1313

14-
Card("MaxHeight = 80", showBorder: false) {
14+
Card("height = 80", showBorder: false) {
1515
VStack {
1616
Text("Frame - Center (default)")
17-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 80))
17+
Illustration(.womanWithPhone, layout: .frame(height: 80))
1818
.border(.cloudNormal)
1919
}
2020

2121
VStack {
2222
Text("Frame - Leading")
23-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 80, alignment: .leading))
23+
Illustration(.womanWithPhone, layout: .frame(height: 80, alignment: .leading))
2424
.border(.cloudNormal)
2525
}
2626

2727
VStack {
2828
Text("Frame - Trailing")
29-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 80, alignment: .trailing))
29+
Illustration(.womanWithPhone, layout: .frame(height: 80, alignment: .trailing))
3030
.border(.cloudNormal)
3131
}
3232

@@ -38,17 +38,17 @@ struct StorybookIllustration {
3838
}
3939
}
4040

41-
Card("MaxHeight = 30", showBorder: false) {
41+
Card("height = 30", showBorder: false) {
4242
HStack {
4343
VStack(alignment: .leading) {
4444
Text("Leading")
45-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 30, alignment: .leading))
45+
Illustration(.womanWithPhone, layout: .frame(height: 30, alignment: .leading))
4646
.border(.cloudNormal)
4747
}
4848

4949
VStack(alignment: .leading) {
5050
Text("Center")
51-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 30))
51+
Illustration(.womanWithPhone, layout: .frame(height: 30))
5252
.border(.cloudNormal)
5353
}
5454

@@ -61,7 +61,7 @@ struct StorybookIllustration {
6161

6262
VStack(alignment: .leading) {
6363
Text("Trailing")
64-
Illustration(.womanWithPhone, layout: .frame(maxHeight: 30, alignment: .trailing))
64+
Illustration(.womanWithPhone, layout: .frame(height: 30, alignment: .trailing))
6565
.border(.cloudNormal)
6666
}
6767
}

0 commit comments

Comments
 (0)