Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: Design System - Chip μ œμž‘ #43

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 37 additions & 0 deletions Projects/Core/DesignSystem/Sources/Chip/SMSChip.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import SwiftUI

public struct SMSChip<Content: View>: View {
var iconLabel: Content
var text: String
var action: () -> Void

public init(
_ text: String,
action: @escaping () -> Void = {},
iconLabel: @escaping () -> Content = {
SMSIcon(.plus, renderingMode: .template, width: 12, height: 12)
}
) {
self.text = text
self.iconLabel = iconLabel()
self.action = action
}

public var body: some View {
Button(action: action) {
HStack(spacing: 4) {
iconLabel

Text(text)
}
.smsFont(.body1, color: .neutral(.n30))
}
.buttonStyle(SMSChipButtonStyle())
}
}

struct SMSChip_Previews: PreviewProvider {
static var previews: some View {
SMSChip("Text")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import SwiftUI

struct SMSChipButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding(8)
.background {
configuration.isPressed ? Color.sms(.neutral(.n10)) : .sms(.system(.white))
}
.cornerRadius(8)
}
}