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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UICatalogButtonsViewController: UITableViewController {
Style(buttonStyle: .secondaryInverse, title: "Secondary Inverse", isInverse: true, isSmall: false),
Style(buttonStyle: .primaryBrand, title: "Primary Brand", isInverse: true, isSmall: false),
Style(buttonStyle: .secondaryBrand, title: "Secondary Brand", isInverse: true, isSmall: false),
Style(buttonStyle: .linkBrand, title: "Link Brand", isInverse: true, isSmall: false),
Style(buttonStyle: .linkInverse, title: "Link Inverse", isInverse: true, isSmall: false),
Style(buttonStyle: .linkDangerInverse, title: "Link Danger Inverse", isInverse: true, isSmall: false),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct ButtonsCatalogView: View {
Style(buttonStyle: .misticaLinkInverse(), title: "Link Inverse", inverse: true),
Style(buttonStyle: .misticaPrimaryBrand(), title: "Primary Brand", inverse: true),
Style(buttonStyle: .misticaSecondaryBrand(), title: "Secondary Brand", inverse: true),
Style(buttonStyle: .misticaLinkBrand(), title: "Link Brand", inverse: true),

Style(buttonStyle: .misticaPrimary(small: true), title: "Primary Small", inverse: false),
Style(buttonStyle: .misticaSecondary(small: true), title: "Secondary Small", inverse: false),
Expand Down
17 changes: 17 additions & 0 deletions Sources/Mistica/Components/Button/ButtonStyle+Toolkit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ public extension Button.Style {
)
}

static var linkBrand: Button.Style {
let backgroundColor: UIColor = .clear
var style = Button.Style(
allowsBleedingAlignment: true,
stateStyleByState: [
.normal: Button.StateStyle(textColor: .textLinkBrand, backgroundColor: backgroundColor, borderColor: backgroundColor),
.selected: Button.StateStyle(textColor: .textLinkBrand, backgroundColor: .buttonLinkBackgroundBrandPressed, borderColor: backgroundColor),
.disabled: Button.StateStyle(textColor: .textLinkBrand, backgroundColor: backgroundColor, borderColor: backgroundColor),
.loading: Button.StateStyle(textColor: .textLinkBrand, backgroundColor: backgroundColor, borderColor: backgroundColor)
]
)

style.overriddenSizes = linkOverriddenSizes

return style
}

func insets(isSmall: Bool) -> UIEdgeInsets {
if let overriddenSizes = overriddenSizes {
return overriddenSizes.insets
Expand Down
37 changes: 37 additions & 0 deletions Sources/MisticaSwiftUI/Components/Button/MisticaButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,43 @@ public extension ButtonStyle where Self == MisticaButtonStyle {
)
}

static func misticaLinkBrand(
small: Bool = false,
bleedingAlignment: ButtonBleedingAlignment = .none,
withChevron: Bool = false
) -> Self {
Self(
style: MisticaButton.Style(
bleedingAlignment: bleedingAlignment,
hasMinWidth: false,
styleByState: [
.normal: MisticaButton.StateStyle(
textColor: .textLinkBrand,
backgroundColor: .clear,
borderColor: .clear
),
.selected: MisticaButton.StateStyle(
textColor: .textLinkBrand,
backgroundColor: .buttonLinkBackgroundBrandPressed,
borderColor: .clear
),
.disabled: MisticaButton.StateStyle(
textColor: .textLinkBrand.opacity(opacity),
backgroundColor: .clear,
borderColor: .clear
),
.loading: MisticaButton.StateStyle(
textColor: .textLinkBrand,
backgroundColor: .clear,
borderColor: .clear
)
]
),
small: small,
rightImage: withChevron ? .chevron : nil
)
}

static func misticaSnackbar(
small: Bool = false,
bleedingAlignment: ButtonBleedingAlignment = .none
Expand Down
7 changes: 7 additions & 0 deletions Tests/MisticaSwiftUITests/UI/ButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ final class ButtonTests: XCTestCase {
as: .image
)
}

func testSmallSizeWithLinkBrandWithChevron() {
assertSnapshot(
of: makeTemplateWithAllButtonStates(style: .misticaLinkBrand(small: true, withChevron: true), inverse: true),
as: .image
)
}
}

// MARK: - Helpers
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Tests/MisticaTests/UI/ButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ final class ButtonTests: XCTestCase {
)
}

func testSmallSizeWithLinkBrandWithChevronStyle() {
assertSnapshotForAllBrandsAndStyles(
as: .image,
viewBuilder: makeTemplateWithAllButtonStates(style: .linkBrand, isSmall: true, rightImage: .chevron)
)
}

func testSmallSizeWithLinkWithLeftImageStyle() {
assertSnapshotForAllBrandsAndStyles(
as: .image,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.