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

[WEAV-47] Design System - Shadow 구현 #12

Merged
merged 1 commit into from
Sep 21, 2024
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
45 changes: 45 additions & 0 deletions Projects/DesignSystem/DesignCore/Sources/Shadows.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Shadows.swift
// DesignCore
//
// Created by 김지수 on 9/21/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import SwiftUI

public enum ShadowType {
case `default`
case alert
}

fileprivate struct ShadowViewModifier: ViewModifier {
let type: ShadowType

fileprivate func body(content: Content) -> some View {
switch type {
case .default:
content
.shadow(
color: Color(hex: 0x000000).opacity(0.08),
radius: 8,
x: 0.0,
y: 4.0
)
case .alert:
content
.shadow(
color: Color(hex: 0xF2597F).opacity(0.08),
radius: 8,
x: 0.0,
y: 4.0
)
}
}
}

extension View {
public func shadow(_ type: ShadowType) -> some View {
modifier(ShadowViewModifier(type: type))
}
}
4 changes: 4 additions & 0 deletions Projects/Features/DesignPreview/Sources/DesignPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ fileprivate enum PreviewTypes: CaseIterable {
case colors
case typography
case textureBackground
case shadow

var name: String {
switch self {
case .colors: return "Colors"
case .typography: return "Typography"
case .textureBackground: return "Texture Background"
case .shadow: return "Shadow"
}
}

Expand All @@ -30,6 +32,8 @@ fileprivate enum PreviewTypes: CaseIterable {
DesignTypographyPreview()
case .textureBackground:
DesignBackgroundTextureView()
case .shadow:
DesignShadowView()
}
}
}
Expand Down
46 changes: 46 additions & 0 deletions Projects/Features/DesignPreview/Sources/DesignShadowView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// DesignShadowView.swift
// DesignPreview
//
// Created by 김지수 on 9/21/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import SwiftUI
import DesignCore

struct DesignShadowView: View {
var body: some View {
ZStack {
DesignCore.Colors.grey100

HStack(spacing: 36) {
ZStack {
RoundedRectangle(cornerRadius: 10)
.frame(width: 100, height: 100)
.foregroundStyle(.white)
.shadow(.default)
Text("Default")
.typography(.semibold_20)
}

ZStack {
RoundedRectangle(cornerRadius: 10)
.frame(width: 100, height: 100)
.foregroundStyle(.white)
.shadow(.alert)
Text("Alert")
.typography(.semibold_20)
.foregroundStyle(DesignCore.Colors.red300)
}
}
}
.ignoresSafeArea()
.navigationTitle("Shadow")
.toolbarTitleDisplayMode(.inline)
}
}

#Preview {
DesignShadowView()
}
Loading