diff --git a/Projects/Shared/DesignSystem/Example/Sources/Component/ButtonDetailView.swift b/Projects/Shared/DesignSystem/Example/Sources/Component/ButtonDetailView.swift index f75b70e..2bb4c84 100644 --- a/Projects/Shared/DesignSystem/Example/Sources/Component/ButtonDetailView.swift +++ b/Projects/Shared/DesignSystem/Example/Sources/Component/ButtonDetailView.swift @@ -195,29 +195,19 @@ struct ButtonDetailView: View { .disabled(false) } } - -// VStack { -// Text("Secondary") -// .frame(maxWidth: .infinity) -// .foregroundStyle(Global.Color.white) -// .background(Global.Color.black) -// HStack(spacing: 10) { -// Button( -// icon: Image(systemName: "center"), -// action: { /*action*/ } -// ) -// .buttonStyle(.round(color: .secondary)) -// -// Button( -// icon: Image(systemName: "center"), -// action: { /*action*/ } -// ) -// .buttonStyle(.round(color: .primary)) -// } -// } - - - + } + + VStack(spacing: 40) { + Text("Bottom CTA") + .font(.title) + VStack { + Button( + title: "Button", + action: { /*action*/ } + ) + .buttonStyle(.box(size: .large, color: .primary, width: .low)) + .padding(.horizontal, 20) + } } } } diff --git a/Projects/Shared/DesignSystem/Sources/Component/Button/Box/BoxButtonStyle.swift b/Projects/Shared/DesignSystem/Sources/Component/Button/Box/BoxButtonStyle.swift index c4d8f91..274dcef 100644 --- a/Projects/Shared/DesignSystem/Sources/Component/Button/Box/BoxButtonStyle.swift +++ b/Projects/Shared/DesignSystem/Sources/Component/Button/Box/BoxButtonStyle.swift @@ -12,18 +12,22 @@ public struct BoxButtonStyle: ButtonStyle { @Environment(\.isEnabled) var isEnabled let size: BoxButtonStyleSize let color: BoxButtonStyleColor + let width: ButtonHuggingPriorityHorizontal public init( size: BoxButtonStyleSize, - color: BoxButtonStyleColor + color: BoxButtonStyleColor, + width: ButtonHuggingPriorityHorizontal ) { self.size = size self.color = color + self.width = width } public func makeBody(configuration: Configuration) -> some View { configuration.label .frame(height: size.buttonHeight) + .frame(maxWidth: width.width) .font(size.font) .padding(.horizontal, size.horizontalSideSpacing) .background( @@ -65,9 +69,10 @@ public struct BoxButtonStyle: ButtonStyle { extension ButtonStyle where Self == BoxButtonStyle { public static func box( size: BoxButtonStyleSize, - color: BoxButtonStyleColor + color: BoxButtonStyleColor, + width: ButtonHuggingPriorityHorizontal = .high ) -> Self { - return BoxButtonStyle(size: size, color: color) + return BoxButtonStyle(size: size, color: color, width: width) } } diff --git a/Projects/Shared/DesignSystem/Sources/Component/Button/ButtonHuggingPriorityHorizontal.swift b/Projects/Shared/DesignSystem/Sources/Component/Button/ButtonHuggingPriorityHorizontal.swift new file mode 100644 index 0000000..5673d14 --- /dev/null +++ b/Projects/Shared/DesignSystem/Sources/Component/Button/ButtonHuggingPriorityHorizontal.swift @@ -0,0 +1,25 @@ +// +// ButtonHuggingPriorityHorizontal.swift +// DesignSystem +// +// Created by devMinseok on 8/10/24. +// Copyright © 2024 PomoNyang. All rights reserved. +// + +import Foundation + +public enum ButtonHuggingPriorityHorizontal { + case high + case low +} + +extension ButtonHuggingPriorityHorizontal { + var width: CGFloat? { + switch self { + case .high: + return nil + case .low: + return .infinity + } + } +}