feat: Adds more svg's

This commit is contained in:
2025-02-27 13:47:59 -05:00
parent 3e17bf2a9a
commit 75e13520a9
3 changed files with 118 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@@ -42,30 +42,84 @@ public struct SVGSize: Sendable {
}
}
public enum SVGType: Sendable {
public enum SVGType: Sendable, CaseIterable {
case calculator
case droplets
case exclamation
case funnel
case house
case leftRightArrow
case menu
case ruler
case thermometer
case toolbox
case thermometerSun
case wind
case zap
// swiftlint:disable cyclomatic_complexity
public func html(_ size: SVGSize) -> some HTML {
switch self {
case .calculator: return calculatorSvg(size: size)
case .droplets: return dropletsSvg(size: size)
case .exclamation: return exclamationSvg(size: size)
case .funnel: return funnelSvg(size: size)
case .house: return houseSvg(size: size)
case .leftRightArrow: return leftRightArrowSvg(size: size)
case .menu: return menuSvg(size: size)
case .ruler: return rulerSvg(size: size)
case .thermometer: return thermometerSvg(size: size)
case .toolbox: return toolboxSvg(size: size)
case .thermometerSun: return thermometerSunSvg(size: size)
case .wind: return windSvg(size: size)
case .zap: return zapSvg(size: size)
}
}
// swiftlint:enable cyclomatic_complexity
}
// MARK: - SVGs
// swiftlint:disable line_length
private func houseSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg xmlns="http://www.w3.org/2000/svg" width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-house">
<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/>
<path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
</svg>
""")
}
private func zapSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg xmlns="http://www.w3.org/2000/svg" width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-zap">
<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>
</svg>
""")
}
private func rulerSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg xmlns="http://www.w3.org/2000/svg" width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ruler">
<path d="M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z"/>
<path d="m14.5 12.5 2-2"/>
<path d="m11.5 9.5 2-2"/>
<path d="m8.5 6.5 2-2"/>
<path d="m17.5 15.5 2-2"/>
</svg>
""")
}
private func leftRightArrowSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg xmlns="http://www.w3.org/2000/svg" width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-left-right">
<path d="M8 3 4 7l4 4"/>
<path d="M4 7h16"/>
<path d="m16 21 4-4-4-4"/>
<path d="M20 17H4"/>
</svg>
""")
}
// TODO: Requires attribution:
// Vectors and icons by <a href="https://dribbble.com/Laridae?ref=svgrepo.com" target="_blank">Laridae</a> in CC Attribution License via <a href="https://www.svgrepo.com/" target="_blank">SVG Repo</a>
// FIX: This doesn't work, but does as a file
@@ -95,6 +149,49 @@ private func toolboxSvg(size: SVGSize) -> HTMLRaw {
""")
}
private func funnelSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<g clip-path="url(#clip0_429_11128)">
<path d="M20 3.99994H4L9.6 11.4666C9.85964 11.8128 10 12.2339 10 12.6666V19.9999L14 17.9999V12.6666C14 12.2339 14.1404 11.8128 14.4 11.4666L20 3.99994Z" stroke="currentColor" stroke-width="2.5" stroke-linejoin="round"></path>
</g>
<defs>
<clipPath id="clip0_429_11128"> <rect width="24" height="24" fill="white"></rect>
</clipPath>
</defs>
</g>
</svg>
""")
}
private func dropletsSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg xmlns="http://www.w3.org/2000/svg" width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z"></path>
<path d="M12.56 6.6A10.97 10.97 0 0014 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 01-11.91 4.97"></path>
</g>
</svg>
""")
}
private func thermometerSunSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path stroke="currentColor" d="M12 9C11.1077 8.98562 10.2363 9.27003 9.52424 9.808C8.81222 10.346 8.30055 11.1066 8.07061 11.9688C7.84068 12.8311 7.90568 13.7455 8.25529 14.5665C8.6049 15.3876 9.21904 16.0682 10 16.5M12 3V5M6.6 18.4L5.2 19.8M4 13H2M6.6 7.6L5.2 6.2M20 14.5351V4C20 2.89543 19.1046 2 18 2C16.8954 2 16 2.89543 16 4V14.5351C14.8044 15.2267 14 16.5194 14 18C14 20.2091 15.7909 22 18 22C20.2091 22 22 20.2091 22 18C22 16.5194 21.1956 15.2267 20 14.5351Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
</g>
</svg>
""")
}
private func exclamationSvg(size: SVGSize) -> HTMLRaw {
HTMLRaw("""
<svg xmlns="http://www.w3.org/2000/svg" width="\(size.width)" height="\(size.height)" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-6 h-6">

View File

@@ -5,6 +5,7 @@ import Elementary
import Logging
import PsychrometricClient
import Routes
import Styleguide
public extension DependencyValues {
var viewController: ViewController {
@@ -48,8 +49,22 @@ extension ViewController: DependencyKey {
switch request.route {
case .index:
return MainPage {
p(.class("dark:text-gray-200")) {
"Professional calculators for HVAC system design and troubleshooting."
div {
div(.class("pb-8")) {
p(.class("dark:text-gray-200")) {
"Professional calculators for HVAC system design and troubleshooting."
}
}
div {
p(.class("font-2xl dark:text-gray-200 pb-6")) {
"SVG's"
}
div(.class("grid lg:grid-cols-8 gap-4")) {
for svg in SVGType.allCases {
SVG(svg, color: .blue)
}
}
}
}
}
case let .moldRisk(route):