Skip to content

Commit

Permalink
Allow text and background override for ButtonLink
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelHolec committed Nov 20, 2024
1 parent 89cde2a commit 71cb4ce
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import SwiftUI
/// Button style for Orbit ``ButtonLink`` component.
public struct OrbitButtonLinkButtonStyle<LeadingIcon: View, TrailingIcon: View>: PrimitiveButtonStyle {

@Environment(\.backgroundShape) private var backgroundShape
@Environment(\.buttonSize) private var buttonSize
@Environment(\.idealSize) private var idealSize
@Environment(\.status) private var status
@Environment(\.textColor) private var textColor

private let type: ButtonLinkType
@ViewBuilder private let icon: LeadingIcon
Expand All @@ -28,8 +30,8 @@ public struct OrbitButtonLinkButtonStyle<LeadingIcon: View, TrailingIcon: View>:
disclosureIcon
}
.textFontWeight(.medium)
.textColor(textColor)
.backgroundStyle(.clear, active: backgroundActive)
.textColor(textColor ?? labelColor)
.backgroundStyle(backgroundShape?.inactive ?? .clear, active: backgroundShape?.active ?? backgroundActive)
.buttonSize(resolvedButtonSize)
.idealSize(horizontal: idealSizeHorizontal, vertical: idealSize.vertical)
}
Expand All @@ -52,7 +54,7 @@ public struct OrbitButtonLinkButtonStyle<LeadingIcon: View, TrailingIcon: View>:
: (resolvedButtonSize == .compact || idealSize.horizontal == true)
}

private var textColor: Color {
private var labelColor: Color {
switch type {
case .primary: return .productNormal
case .critical: return .redNormal
Expand Down

0 comments on commit 71cb4ce

Please sign in to comment.