Skip to content

Commit 0ffc587

Browse files
Merge pull request #47 from componentskit/refactor/borders
Added border width param to modal, card and alert
2 parents 4fc24cf + 6e674e4 commit 0ffc587

File tree

15 files changed

+79
-9
lines changed

15 files changed

+79
-9
lines changed

Examples/DemosApp/DemosApp/ComponentsPreview/Helpers/ModalPreview+Helpers.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct ModalPreviewHelpers {
6565
Text("Warning Background").tag(ComponentColor.warning.background)
6666
Text("Danger Background").tag(ComponentColor.danger.background)
6767
}
68+
BorderWidthPicker(selection: self.$model.borderWidth)
6869
Toggle("Closes On Overlay Tap", isOn: self.$model.closesOnOverlayTap)
6970
.disabled(self.footer == nil)
7071
Picker("Outer Paddings", selection: self.$model.outerPaddings) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ struct AutocapitalizationPicker: View {
3232
}
3333
}
3434

35+
// MARK: - BorderWidthPicker
36+
37+
struct BorderWidthPicker: View {
38+
@Binding var selection: BorderWidth
39+
40+
var body: some View {
41+
Picker("Border Width", selection: self.$selection) {
42+
Text("None").tag(BorderWidth.none)
43+
Text("Small").tag(BorderWidth.small)
44+
Text("Medium").tag(BorderWidth.medium)
45+
Text("Large").tag(BorderWidth.large)
46+
}
47+
}
48+
}
49+
3550
// MARK: - ComponentColorPicker
3651

3752
struct ComponentColorPicker: View {

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/AlertPreview.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct AlertPreview: View {
8989
Text("Warning Background").tag(ComponentColor.warning.background)
9090
Text("Danger Background").tag(ComponentColor.danger.background)
9191
}
92+
BorderWidthPicker(selection: self.$model.borderWidth)
9293
Toggle("Closes On Overlay Tap", isOn: self.$model.closesOnOverlayTap)
9394
Picker("Content Paddings", selection: self.$model.contentPaddings) {
9495
Text("12px").tag(Paddings(padding: 12))

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/CardPreview.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct CardPreview: View {
2323
Text("Warning Background").tag(ComponentColor.warning.background)
2424
Text("Danger Background").tag(ComponentColor.danger.background)
2525
}
26+
BorderWidthPicker(selection: self.$model.borderWidth)
2627
Picker("Content Paddings", selection: self.$model.contentPaddings) {
2728
Text("12px").tag(Paddings(padding: 12))
2829
Text("16px").tag(Paddings(padding: 16))

Sources/ComponentsKit/Components/Alert/Models/AlertVM.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public struct AlertVM: ComponentVM {
2121
/// The background color of the modal.
2222
public var backgroundColor: UniversalColor?
2323

24+
/// The border thickness of the alert.
25+
///
26+
/// Defaults to `.small`.
27+
public var borderWidth: BorderWidth = .small
28+
2429
/// A Boolean value indicating whether the modal should close when tapping on the overlay.
2530
///
2631
/// Defaults to `false`.
@@ -56,6 +61,7 @@ extension AlertVM {
5661
var modalVM: CenterModalVM {
5762
return CenterModalVM {
5863
$0.backgroundColor = self.backgroundColor
64+
$0.borderWidth = self.borderWidth
5965
$0.closesOnOverlayTap = self.closesOnOverlayTap
6066
$0.contentPaddings = self.contentPaddings
6167
$0.cornerRadius = self.cornerRadius

Sources/ComponentsKit/Components/Card/Models/CardVM.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ public struct CardVM: ComponentVM {
55
/// The background color of the card.
66
public var backgroundColor: UniversalColor?
77

8+
/// The border thickness of the card.
9+
///
10+
/// Defaults to `.medium`.
11+
public var borderWidth: BorderWidth = .medium
12+
813
/// The padding applied to the card's content area.
914
///
1015
/// Defaults to a padding value of `16` for all sides.

Sources/ComponentsKit/Components/Card/SUCard.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public struct SUCard<Content: View>: View {
4444
.cornerRadius(self.model.cornerRadius.value)
4545
.overlay(
4646
RoundedRectangle(cornerRadius: self.model.cornerRadius.value)
47-
.stroke(UniversalColor.divider.color, lineWidth: 1.0)
47+
.stroke(UniversalColor.divider.color, lineWidth: self.model.borderWidth.value)
4848
)
4949
.shadow(self.model.shadow)
5050
}

Sources/ComponentsKit/Components/Card/UKCard.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ extension UKCard {
140140
static func mainView(_ view: UIView, model: Model) {
141141
view.backgroundColor = UniversalColor.background.uiColor
142142
view.layer.cornerRadius = model.cornerRadius.value
143-
view.layer.borderWidth = 1
143+
view.layer.borderWidth = model.borderWidth.value
144144
view.layer.borderColor = UniversalColor.divider.cgColor
145145
view.shadow(model.shadow)
146146
}

Sources/ComponentsKit/Components/Modal/Models/BottomModalVM.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ public struct BottomModalVM: ModalVM {
55
/// The background color of the modal.
66
public var backgroundColor: UniversalColor?
77

8+
/// The border thickness of the modal.
9+
///
10+
/// Defaults to `.small`.
11+
public var borderWidth: BorderWidth = .small
12+
813
/// A Boolean value indicating whether the modal should close when tapping on the overlay.
914
///
1015
/// Defaults to `true`.

Sources/ComponentsKit/Components/Modal/Models/CenterModalVM.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ public struct CenterModalVM: ModalVM {
55
/// The background color of the modal.
66
public var backgroundColor: UniversalColor?
77

8+
/// The border thickness of the modal.
9+
///
10+
/// Defaults to `.small`.
11+
public var borderWidth: BorderWidth = .small
12+
813
/// A Boolean value indicating whether the modal should close when tapping on the overlay.
914
///
1015
/// Defaults to `true`.

0 commit comments

Comments
 (0)