import Elementary
public struct SVG: HTML, Sendable {
let color: String
let size: SVGSize
let svg: SVGType
public init(
_ svg: SVGType,
color: String,
size: SVGSize = .init()
) {
self.svg = svg
self.size = size
self.color = color
}
public init(
_ svg: SVGType,
color: Color.TextColor,
size: SVGSize = .init()
) {
self.svg = svg
self.size = size
self.color = color.color
}
public var content: some HTML {
div(.class("block \(color)")) {
svg.html(size)
}
}
}
public struct SVGSize: Sendable {
let width: Int
let height: Int
public init(width: Int = 24, height: Int? = nil) {
self.width = width
self.height = height ?? width
}
}
public enum SVGType: Sendable {
case calculator
case exclamation
case menu
case thermometer
case toolbox
case wind
public func html(_ size: SVGSize) -> some HTML {
switch self {
case .calculator: return calculatorSvg(size: size)
case .exclamation: return exclamationSvg(size: size)
case .menu: return menuSvg(size: size)
case .thermometer: return thermometerSvg(size: size)
case .toolbox: return toolboxSvg(size: size)
case .wind: return windSvg(size: size)
}
}
}
// MARK: - SVGs
// swiftlint:disable line_length
// TODO: Requires attribution:
// Vectors and icons by Laridae in CC Attribution License via SVG Repo
// FIX: This doesn't work, but does as a file
private func toolboxSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
""")
}
private func exclamationSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
""")
}
private func windSvg(size: SVGSize) -> HTMLRaw {
return HTMLRaw("""
""")
}
private func calculatorSvg(size: SVGSize) -> HTMLRaw {
return HTMLRaw("""
""")
}
private func thermometerSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
""")
}
private func menuSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
""")
}
// swiftlint:enable line_length