import SwiftUI

public extension View {
    /// For views where you want a glass border style without the compromises of a glass background
    func glassBorder<S: InsettableShape>(shape: S = .rect(cornerRadius: 8), enabled: Bool = true) -> some View {
        self
            .overlay {
                shape
                    .strokeBorder(
                        .linearGradient(
                            colors: [
                                .white.opacity(0.8),
                                .white.opacity(0.3),
                                .white.opacity(0.6),
                            ],
                            startPoint: .topLeading,
                            endPoint: .bottomTrailing
                        ),
                        lineWidth: 1
                    )
                    .blendMode(.softLight)
                    .opacity(enabled ? 1.0 : 0)
            }
            .compositingGroup()
    }
}
