Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion Sources/Bonsplit/Internal/Views/TabDragPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TabDragPreview: View {
}

Text(tab.title)
.font(.system(size: TabBarMetrics.titleFontSize))
.font(.system(size: appearance.tabTitleFontSize))
.lineLimit(1)
.foregroundStyle(TabBarColors.activeText(for: appearance))
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Bonsplit/Internal/Views/TabItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct TabItemView: View {
.onChange(of: tab.icon) { _ in updateGlobeFallback() }

Text(tab.title)
.font(.system(size: TabBarMetrics.titleFontSize))
.font(.system(size: appearance.tabTitleFontSize))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing lower-bound guard on primary title font

The zoom indicator and shortcut hint already protect against a sub-8 pt size via max(8, appearance.tabTitleFontSize - 2), but the main tab title text uses appearance.tabTitleFontSize directly. A caller who passes 0 or a very small value will silently render invisible tab titles while the secondary elements are clamped. Applying the same floor keeps behaviour consistent across all three callers.

Suggested change
.font(.system(size: appearance.tabTitleFontSize))
.font(.system(size: max(8, appearance.tabTitleFontSize)))

.lineLimit(1)
.foregroundStyle(
isSelected
Expand All @@ -133,7 +133,7 @@ struct TabItemView: View {
onZoomToggle()
} label: {
Image(systemName: "arrow.up.left.and.arrow.down.right")
.font(.system(size: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold))
.font(.system(size: max(8, appearance.tabTitleFontSize - 2), weight: .semibold))
.foregroundStyle(
isZoomHovered
? TabBarColors.activeText(for: appearance)
Expand Down Expand Up @@ -224,7 +224,7 @@ struct TabItemView: View {
}

private func shortcutHintWidth(for label: String) -> CGFloat {
let font = NSFont.systemFont(ofSize: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold)
let font = NSFont.systemFont(ofSize: max(8, appearance.tabTitleFontSize - 2), weight: .semibold)
let textWidth = (label as NSString).size(withAttributes: [.font: font]).width
return ceil(textWidth) + 8
}
Expand All @@ -234,7 +234,7 @@ struct TabItemView: View {
ZStack(alignment: .center) {
if let shortcutHintLabel {
Text(shortcutHintLabel)
.font(.system(size: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold, design: .rounded))
.font(.system(size: max(8, appearance.tabTitleFontSize - 2), weight: .semibold, design: .rounded))
.monospacedDigit()
.lineLimit(1)
.fixedSize(horizontal: true, vertical: false)
Expand Down
9 changes: 8 additions & 1 deletion Sources/Bonsplit/Public/BonsplitConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ extension BonsplitConfiguration {
/// Maximum width of a tab
public var tabMaxWidth: CGFloat

/// Font size for tab titles in the surface tab bar
public var tabTitleFontSize: CGFloat

/// Spacing between tabs
public var tabSpacing: CGFloat

Expand Down Expand Up @@ -198,13 +201,15 @@ extension BonsplitConfiguration {
public static let compact = Appearance(
tabBarHeight: 28,
tabMinWidth: 100,
tabMaxWidth: 160
tabMaxWidth: 160,
tabTitleFontSize: 11
)

public static let spacious = Appearance(
tabBarHeight: 38,
tabMinWidth: 160,
tabMaxWidth: 280,
tabTitleFontSize: 11,
tabSpacing: 2
)

Expand All @@ -214,6 +219,7 @@ extension BonsplitConfiguration {
tabBarHeight: CGFloat = 33,
tabMinWidth: CGFloat = 140,
tabMaxWidth: CGFloat = 220,
tabTitleFontSize: CGFloat = 11,
tabSpacing: CGFloat = 0,
minimumPaneWidth: CGFloat = 100,
minimumPaneHeight: CGFloat = 100,
Expand All @@ -228,6 +234,7 @@ extension BonsplitConfiguration {
self.tabBarHeight = tabBarHeight
self.tabMinWidth = tabMinWidth
self.tabMaxWidth = tabMaxWidth
self.tabTitleFontSize = tabTitleFontSize
self.tabSpacing = tabSpacing
self.minimumPaneWidth = minimumPaneWidth
self.minimumPaneHeight = minimumPaneHeight
Expand Down
Loading