import SwiftUI

struct AvatarView: View {
    
    var url: URL?
    
    var body: some View {
        Group {
            if let imageUrl = url {
                URLImage(url: imageUrl)
            } else {
                ColorName.background.color(variation: .secondary)
            }
        }
        
        .clipped()
        .clipShape(Circle())
        .overlay(
            Circle()
                .stroke(ColorName.background.color(variation: .tertiary))
        )
    }
}

#if DEBUG
struct AvatarView_Previews: PreviewProvider {
    static let author: Author? = {
        Post.previewContent.first?.author.first
    }()
    
    static var previews: some View {
        VStack {
            AvatarView(url: Self.author?.avatar)
                .frame(width: 100, height: 100)
        }
        
    }
}
#endif
