Skip to content

Commit 1b24c42

Browse files
authored
Merge pull request #804 from JPToroDev/clean-up
Reimplement default behavior for max width in `frame()`.
2 parents c6b234d + 29fa2a3 commit 1b24c42

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/Ignite/Modifiers/Frame.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ private extension HTML {
155155
}
156156

157157
if let maxWidth {
158+
if width == nil {
159+
// If no width has been explicitly set, allow content
160+
// to scale with screen sizes smaller than the max width
161+
// as a sensible default
162+
dimensions.append(.init(.width, value: "100%"))
163+
}
158164
dimensions.append(.init(.maxWidth, value: maxWidth.stringValue))
159165
}
160166

Tests/IgniteTesting/Elements/Card.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CardTests: IgniteTestSuite {
7272
let output = element.render()
7373

7474
#expect(output == """
75-
<div class="card" style="max-width: 500px">\
75+
<div class="card" style="width: 100%; max-width: 500px">\
7676
<img src="/images/photos/dishwasher.jpg" alt="" class="card-img-top" /><div class="card-body">\
7777
<p class="card-text">Before putting your dishes into the dishwasher, give them a quick pre-clean.</p>\
7878
<a href="/" class="card-link btn btn-primary">Back to the homepage</a></div></div>

0 commit comments

Comments
 (0)