Skip to content

Commit

Permalink
[WEAV-47] Design Core - shadow 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jisu15-kim committed Sep 20, 2024
1 parent c2a695d commit ef5cf39
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
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()
}

0 comments on commit ef5cf39

Please sign in to comment.