Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[PBIOS-635] Update Padding Prop to PBNavItem #475

Merged
merged 21 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
90ea3e6
fix colors for pill kit
RachelRadford21 Jun 24, 2024
6244830
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Jun 27, 2024
2d26fe6
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Jul 1, 2024
30185d4
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Jul 11, 2024
0ce7f96
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Jul 19, 2024
4d691ae
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Jul 31, 2024
fba282c
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Aug 2, 2024
3f7f99c
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Aug 7, 2024
03ffde2
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Aug 12, 2024
b88c77c
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Aug 14, 2024
8645719
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Aug 26, 2024
2764aeb
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Aug 29, 2024
d1cfd33
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Sep 4, 2024
60d92a1
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Sep 20, 2024
9d7e62c
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Sep 30, 2024
60b4e12
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Oct 14, 2024
e75b3e7
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Oct 21, 2024
7c161ce
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Nov 7, 2024
be0c26f
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Nov 11, 2024
4d8ee40
Merge remote-tracking branch 'refs/remotes/origin/main'
RachelRadford21 Nov 25, 2024
19ca44e
add ability to chnage padding
RachelRadford21 Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions Sources/Playbook/Components/Nav/PBNavItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,28 @@ public struct PBNavItem<Content: View>: View {
var icon: NavigationIcon?
var accessory: FontAwesome?
let isFullWidth: Bool
var horizontalOrientationPadding: CGFloat?
var vertOrientationPadding: CGFloat?
var vertPadding: CGFloat?
var content: Content?

public init(
_ label: String? = nil,
icon: NavigationIcon? = nil,
accessory: FontAwesome? = nil,
isFullWidth: Bool = false,
horizontalOrientationPadding: CGFloat? = nil,
vertOrientationPadding: CGFloat? = nil,
vertPadding: CGFloat? = nil,
@ViewBuilder content: @escaping () -> Content = { EmptyView() }
) {
self.label = label
self.icon = icon
self.accessory = accessory
self.isFullWidth = isFullWidth
self.horizontalOrientationPadding = horizontalOrientationPadding
self.vertOrientationPadding = vertOrientationPadding
self.vertPadding = vertPadding
self.content = content()
}

Expand Down Expand Up @@ -63,7 +72,7 @@ public struct PBNavItem<Content: View>: View {
.scaledToFill()
.frame(maxWidth: isFullWidth ? .infinity : nil, alignment: .center)
.foregroundColor(captionForegroundColor)
.padding(.horizontal, horizontalPadding)
.padding(.horizontal, orientationPadding)
.padding(.vertical, verticalPadding)
.background(backgroundColor)
.cornerRadius(cornerRadius)
Expand Down Expand Up @@ -198,26 +207,26 @@ extension PBNavItem {
}
}

var horizontalPadding: CGFloat {
var orientationPadding: CGFloat {
switch variant {
case .normal:
switch orientation {
case .horizontal: return Spacing.medium
case .vertical: return Spacing.small
case .horizontal: return horizontalOrientationPadding ?? Spacing.medium
case .vertical: return vertOrientationPadding ?? Spacing.small
}

case .subtle, .bold:
switch orientation {
case .horizontal: return 14
case .vertical: return 14
case .horizontal: return horizontalOrientationPadding ?? 14
case .vertical: return vertOrientationPadding ?? 14
}
}
}

var verticalPadding: CGFloat {
switch variant {
case .normal: return Spacing.small
case .subtle, .bold: return Spacing.xSmall
case .normal: return vertPadding ?? Spacing.small
case .subtle, .bold: return vertPadding ?? Spacing.xSmall
}
}

Expand Down