diff --git a/Sources/MisticaSwiftUI/Components/Button/MisticaButtonStyle.swift b/Sources/MisticaSwiftUI/Components/Button/MisticaButtonStyle.swift index c4330aab..2c9ddda9 100644 --- a/Sources/MisticaSwiftUI/Components/Button/MisticaButtonStyle.swift +++ b/Sources/MisticaSwiftUI/Components/Button/MisticaButtonStyle.swift @@ -22,7 +22,20 @@ public struct MisticaButtonStyle: ButtonStyle { // MARK: Styles +private var _opacity = 0.5 +private var _opacityWithBackground = 0.1 + public extension ButtonStyle where Self == MisticaButtonStyle { + static var opacity: CGFloat { + get { _opacity } + set { _opacity = newValue } + } + + static var opacityWithBackground: CGFloat { + get { _opacityWithBackground } + set { _opacityWithBackground = newValue } + } + static func misticaPrimary( small: Bool = false, bleedingAlignment: ButtonBleedingAlignment = .none @@ -43,8 +56,8 @@ public extension ButtonStyle where Self == MisticaButtonStyle { ), .disabled: MisticaButton.StateStyle( textColor: .textButtonPrimary, - backgroundColor: .buttonPrimaryBackground.opacity(0.5), - borderColor: .buttonPrimaryBackground.opacity(0.1) + backgroundColor: .buttonPrimaryBackground.opacity(opacity), + borderColor: .buttonPrimaryBackground.opacity(opacityWithBackground) ), .loading: MisticaButton.StateStyle( textColor: .textButtonPrimary, @@ -78,8 +91,8 @@ public extension ButtonStyle where Self == MisticaButtonStyle { ), .disabled: MisticaButton.StateStyle( textColor: .textButtonPrimaryInverse, - backgroundColor: .buttonPrimaryBackgroundInverse, - borderColor: .buttonPrimaryBackgroundInverse + backgroundColor: .buttonPrimaryBackgroundInverse.opacity(opacity), + borderColor: .buttonPrimaryBackgroundInverse.opacity(opacityWithBackground) ), .loading: MisticaButton.StateStyle( textColor: .textButtonPrimaryInverse, @@ -112,9 +125,9 @@ public extension ButtonStyle where Self == MisticaButtonStyle { borderColor: .buttonSecondaryBackgroundSelected ), .disabled: MisticaButton.StateStyle( - textColor: .textButtonSecondary, + textColor: .textButtonSecondary.opacity(opacity), backgroundColor: .clear, - borderColor: .buttonSecondaryBorder + borderColor: .buttonSecondaryBorder.opacity(opacity) ), .loading: MisticaButton.StateStyle( textColor: .textButtonSecondary, @@ -147,9 +160,9 @@ public extension ButtonStyle where Self == MisticaButtonStyle { borderColor: .buttonSecondaryBorderInverseSelected ), .disabled: MisticaButton.StateStyle( - textColor: .textButtonSecondaryInverse, + textColor: .textButtonSecondaryInverse.opacity(opacity), backgroundColor: .clear, - borderColor: .buttonSecondaryBorderInverse + borderColor: .buttonSecondaryBorderInverse.opacity(opacity) ), .loading: MisticaButton.StateStyle( textColor: .textButtonSecondaryInverse, @@ -183,8 +196,8 @@ public extension ButtonStyle where Self == MisticaButtonStyle { ), .disabled: MisticaButton.StateStyle( textColor: .textButtonPrimary, - backgroundColor: .buttonDangerBackground, - borderColor: .buttonDangerBackground + backgroundColor: .buttonDangerBackground.opacity(opacity), + borderColor: .buttonDangerBackground.opacity(opacityWithBackground) ), .loading: MisticaButton.StateStyle( textColor: .textButtonPrimary, @@ -219,7 +232,7 @@ public extension ButtonStyle where Self == MisticaButtonStyle { borderColor: .clear ), .disabled: MisticaButton.StateStyle( - textColor: .textLink, + textColor: .textLink.opacity(opacity), backgroundColor: .clear, borderColor: .clear ), @@ -256,7 +269,7 @@ public extension ButtonStyle where Self == MisticaButtonStyle { borderColor: .clear ), .disabled: MisticaButton.StateStyle( - textColor: .textButtonSecondaryInverse, + textColor: .textButtonSecondaryInverse.opacity(opacity), backgroundColor: .clear, borderColor: .clear ), @@ -292,7 +305,7 @@ public extension ButtonStyle where Self == MisticaButtonStyle { borderColor: .clear ), .disabled: MisticaButton.StateStyle( - textColor: .textLinkSnackbar, + textColor: .textLinkSnackbar.opacity(opacity), backgroundColor: .clear, borderColor: .clear ), diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithDangerStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithDangerStyle.1.png index 7208a373..47908718 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithDangerStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithDangerStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseStyle.1.png index 90a7bf26..ff02bd3f 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseWithChevron.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseWithChevron.1.png index fbfd086b..75a0f093 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseWithChevron.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseWithChevron.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkStyle.1.png index 519aaf98..23f0dda4 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkWithChevron.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkWithChevron.1.png index 26d71e0b..926726a2 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkWithChevron.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkWithChevron.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithPrimaryInverseStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithPrimaryInverseStyle.1.png index f91bd5bc..3ad2caa2 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithPrimaryInverseStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithPrimaryInverseStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryInverseStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryInverseStyle.1.png index 57bd9435..de489272 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryInverseStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryInverseStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryStyle.1.png index 06f7c60a..3c027cdd 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithSecondaryStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithDangerStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithDangerStyle.1.png index 6350d0ce..6330795b 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithDangerStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithDangerStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseStyle.1.png index 6232b4c1..df56b852 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseWithChevron.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseWithChevron.1.png index 24c5d66b..64b8b7f4 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseWithChevron.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkInverseWithChevron.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkStyle.1.png index 5d59f4e8..f26d0150 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkWithChevron.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkWithChevron.1.png index bd1d497c..d1fd60a8 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkWithChevron.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithLinkWithChevron.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithPrimaryInverseStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithPrimaryInverseStyle.1.png index 1ae20ca9..7539c678 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithPrimaryInverseStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithPrimaryInverseStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryInverseStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryInverseStyle.1.png index a9ad6c36..b28e48dd 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryInverseStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryInverseStyle.1.png differ diff --git a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryStyle.1.png b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryStyle.1.png index 50aa9463..88d9652a 100644 Binary files a/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryStyle.1.png and b/Tests/MisticaSwiftUITests/UI/__Snapshots__/ButtonTests/testSmallSizeWithSecondaryStyle.1.png differ