Created
April 8, 2022 12:21
-
-
Save damodarnamala/f22b6d6972c3f8eb2dfbbd50f82f3d11 to your computer and use it in GitHub Desktop.
DesignSystem Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
var body: some View { | |
HStack { | |
Rectangle() | |
.frame(width: 200, height: 200, alignment: .center) | |
}.card() | |
} | |
} | |
public class DesignSystem { | |
public typealias CornerRadious = DesignSystem.CornerRadiousOptions | |
public struct CornerRadiousOptions { | |
static var small : CGFloat = 8 | |
static var medium : CGFloat = 16 | |
static var large : CGFloat = 32 | |
} | |
} | |
struct RoundedView: ViewModifier { | |
func body(content: Content) -> some View { | |
content | |
.foregroundColor(.white) | |
.cornerRadius(DesignSystem.CornerRadious.medium) | |
.shadow(color: Color(.lightGray), radius: 4, x: 4, y: 4) | |
} | |
} | |
extension View { | |
func card() -> some View { | |
modifier(RoundedView()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment