Skip to content

Commit

Permalink
Update Button to use Label1 (#1900)
Browse files Browse the repository at this point in the history
* fix: change font for all button sizes to be label 1, matching Figma

* update documentation snapshots

* Record snapshots

* Updated snapshots

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
gert-janvercauteren and github-actions[bot] committed Mar 15, 2024
1 parent 1b0986b commit b639882
Show file tree
Hide file tree
Showing 151 changed files with 8 additions and 21 deletions.
16 changes: 6 additions & 10 deletions Backpack-SwiftUI/Button/Classes/BPKButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,9 @@ private struct ButtonContentView: View {
}
}

private var fontStyle: BPKFontStyle {
size == .default ? .label2 : .label1
}

private func content(withTitle title: String) -> some View {
Text(title)
.font(style: fontStyle)
.font(style: .label1)
.lineLimit(1)
.sizeCategory(.large)
}
Expand Down Expand Up @@ -203,11 +199,11 @@ private struct ButtonContentView: View {
struct BPKButton_Previews: PreviewProvider {
static var previews: some View {
VStack {
BPKButton("Click Me!") {}
BPKButton("Click Me!", icon: BPKButton.Icon(icon: .account, position: .leading)) {}
BPKButton("Click Me!", loading: .constant(true)) {}
BPKButton("Click Me!") {}
.buttonStyle(.link)
BPKButton("Label") {}
BPKButton("Label", icon: BPKButton.Icon(icon: .lightning, position: .leading)) {}
BPKButton("Label", icon: BPKButton.Icon(icon: .longArrowRight, position: .trailing)) {}
BPKButton(icon: .longArrowRight, accessibilityLabel: "Continue") {}
BPKButton("Label", loading: .constant(true)) {}
}
.previewLayout(.sizeThatFits)
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 2 additions & 11 deletions Backpack/Button/Classes/BPKButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ - (UIView *)createContentView {
}

- (BPKLabel *)createTitleLabel {
BPKLabel *titleLabel = [[BPKLabel alloc] initWithFontStyle:[self fontStyleForSize:self.size]];
BPKLabel *titleLabel = [[BPKLabel alloc] initWithFontStyle:BPKFontStyleTextLabel1];
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
[titleLabel setUserInteractionEnabled:NO];
return titleLabel;
Expand Down Expand Up @@ -213,7 +213,7 @@ - (void)addContentInOrder {

- (void)updateSize {
BPKButtonSize size = self.size;
self.titleLabel.fontStyle = [self fontStyleForSize:size];
self.titleLabel.fontStyle = BPKFontStyleTextLabel1;
self.heightConstraint.constant = [self heightForSize:size];

self.spinner.transform = [self spinnerTransformForSize:size];
Expand Down Expand Up @@ -408,15 +408,6 @@ - (BPKGradient *)gradientWithTopColor:(UIColor *)top bottomColor:(UIColor *)bott
endPoint:[BPKGradient endPointForDirection:direction]];
}

- (BPKFontStyle)fontStyleForSize:(BPKButtonSize)size {
switch (size) {
case BPKButtonSizeDefault:
return BPKFontStyleTextLabel2;
case BPKButtonSizeLarge:
return BPKFontStyleTextLabel1;
}
}

- (CGFloat)cornerRadiusForStyle:(BPKButtonStyle)style {
if (style == BPKButtonStyleLink || style == BPKButtonStyleLinkOnDark) {
return 0;
Expand Down
Binary file modified screenshots/iPhone-button___destructive_dm.png
Binary file modified screenshots/iPhone-button___destructive_lm.png
Binary file modified screenshots/iPhone-button___featured_dm.png
Binary file modified screenshots/iPhone-button___featured_lm.png
Binary file modified screenshots/iPhone-button___linkOnDark_dm.png
Binary file modified screenshots/iPhone-button___linkOnDark_lm.png
Binary file modified screenshots/iPhone-button___link_dm.png
Binary file modified screenshots/iPhone-button___link_lm.png
Binary file modified screenshots/iPhone-button___primaryOnDark_dm.png
Binary file modified screenshots/iPhone-button___primaryOnDark_lm.png
Binary file modified screenshots/iPhone-button___primaryOnLight_dm.png
Binary file modified screenshots/iPhone-button___primaryOnLight_lm.png
Binary file modified screenshots/iPhone-button___primary_dm.png
Binary file modified screenshots/iPhone-button___primary_lm.png
Binary file modified screenshots/iPhone-button___secondaryOnDark_dm.png
Binary file modified screenshots/iPhone-button___secondaryOnDark_lm.png
Binary file modified screenshots/iPhone-button___secondary_dm.png
Binary file modified screenshots/iPhone-button___secondary_lm.png
Binary file modified screenshots/iPhone-swiftui_button___destructive_dm.png
Binary file modified screenshots/iPhone-swiftui_button___destructive_lm.png
Binary file modified screenshots/iPhone-swiftui_button___featured_dm.png
Binary file modified screenshots/iPhone-swiftui_button___featured_lm.png
Binary file modified screenshots/iPhone-swiftui_button___link_dm.png
Binary file modified screenshots/iPhone-swiftui_button___link_lm.png
Binary file modified screenshots/iPhone-swiftui_button___primaryOnDark_dm.png
Binary file modified screenshots/iPhone-swiftui_button___primaryOnDark_lm.png
Binary file modified screenshots/iPhone-swiftui_button___primaryOnLight_dm.png
Binary file modified screenshots/iPhone-swiftui_button___primaryOnLight_lm.png
Binary file modified screenshots/iPhone-swiftui_button___primary_dm.png
Binary file modified screenshots/iPhone-swiftui_button___primary_lm.png
Binary file modified screenshots/iPhone-swiftui_button___secondary_dm.png
Binary file modified screenshots/iPhone-swiftui_button___secondary_lm.png

0 comments on commit b639882

Please sign in to comment.