Repository Public MIT
1{2 "accessibility" : [3 "A loaded card is one element: title aside, VoiceOver reads the value, the unit and \"Up 4.2 %, vs last month\".",4 "The direction is carried by the symbol's shape and by a word; colour (`tone`) is an addition, never the only signal.",5 "Loading and missing states have explicit labels instead of a silent placeholder.",6 "Text follows Dynamic Type and wraps; the value uses monospaced digits.",7 "Values and percentages are formatted with `FormatStyle` in the environment's locale."8 ],9 "category" : "data",10 "changelog" : [11 {12 "changes" : [13 "Release 1.1.0: see the project changelog."14 ],15 "date" : "2026-12-03",16 "version" : "1.1.0"17 },18 {19 "changes" : [20 "Initial release."21 ],22 "date" : "2026-12-02",23 "version" : "1.0.0"24 }25 ],26 "dependencies" : [27 {28 "id" : "glass-button",29 "version" : "1.1.0"30 },31 {32 "id" : "glass-components-support",33 "version" : "1.1.0"34 },35 {36 "id" : "glass-data-support",37 "version" : "1.1.0"38 },39 {40 "id" : "glass-foundation",41 "version" : "1.1.0"42 }43 ],44 "description" : "A value with unit, change and period, and states for missing, loading and failed data.",45 "examples" : [46 {47 "code" : "import SwiftUI\nimport SPGlassKit\n\npublic struct GlassMetricCardExample: GlassExample {\n public static let componentID = \"glass-metric-card\"\n\n // Fictitious figures.\n @State private var latency: GlassLoadState<GlassMetric> = .loaded(\n GlassMetric(value: 182, unit: \"ms\", change: -0.062, period: \"vs last week\", tone: .negativeIsGood)\n )\n\n public init() {}\n\n public var body: some View {\n ScrollView {\n LazyVGrid(columns: [GridItem(.adaptive(minimum: 220), spacing: 12)], spacing: 12) {\n GlassMetricCard(\"Response time\", state: latency) {\n latency = .loaded(GlassMetric(value: 175, unit: \"ms\", change: -0.098, period: \"vs last week\", tone: .negativeIsGood))\n }\n GlassMetricCard(\"Monthly revenue\", state: .loaded(\n GlassMetric(value: 48_250.5, unit: \"$\", change: 0.042, period: \"vs last month\", fractionDigits: 2...2, tone: .positiveIsGood)\n ))\n GlassMetricCard(\"Bookings\", systemImage: \"calendar\", state: .loaded(\n GlassMetric(value: 1284, change: 0.082, period: \"vs last week\", tone: .positiveIsGood, sparkline: [31, 34, 33, 38, 41, 40, 46])\n ))\n GlassMetricCard(\"Open tickets\", state: .loaded(GlassMetric(value: 37, change: 0, period: \"since yesterday\")))\n GlassMetricCard(\"Active sessions\", state: .loading)\n GlassMetricCard(\"Conversion\", state: .empty)\n GlassMetricCard(\"Forecast\", state: .idle)\n GlassMetricCard(\"Churn\", state: .failed(message: \"The report could not be loaded.\")) {}\n }\n .padding()\n\n HStack {\n GlassButton(\"Simulate a failure\", size: .small) { latency = .failed(message: \"The probe did not answer.\") }\n GlassButton(\"Reload\", size: .small) { latency = .loading }\n }\n .padding(.bottom)\n }\n }\n}\n\n#Preview(\"GlassMetricCard\") { GlassMetricCardExample().glassTheme(.emerald) }\n",48 "title" : "GlassMetricCard example"49 }50 ],51 "files" : [52 {53 "bytes" : 16812,54 "path" : "Data/Data/GlassMetricCard.swift",55 "sha256" : "0f475f61957aba25b903318e1fd2d85163960c5675dadc95303f0bfac66ae39d"56 }57 ],58 "frameworks" : [5960 ],61 "id" : "glass-metric-card",62 "kind" : "content-component",63 "license" : "MIT",64 "minimumOS" : {65 "iOS" : "26.0",66 "iPadOS" : "26.0",67 "macOS" : "26.0"68 },69 "name" : "GlassMetricCard",70 "platforms" : [71 "iOS",72 "iPadOS",73 "macOS"74 ],75 "schemaVersion" : 1,76 "sha256" : "108e06a83542232d184e332f077fa42d4755545851d172ccf1d683e6d27e0cb8",77 "symbols" : [78 "GlassMetric",79 "GlassMetricTone",80 "GlassMetricFormatter",81 "GlassMetricCard"82 ],83 "version" : "1.1.0"84}85