SPB Git

Repository Public

NVPreviews.swift 4.3 KB 90 lines swift

1// SP Notes Core2// File: Sources/SPNotesDesign/NVPreviews.swift3// Description: SwiftUI previews of the tokens and components (debug builds only; no app code).4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import SwiftUI89#if DEBUG10struct NVGallery: View {11    @State private var saved = 012    @State private var level = 213    @State private var panel = false14    @Environment(\.accessibilityReduceMotion) private var reduceMotion1516    var body: some View {17        ScrollView {18            VStack(alignment: .leading, spacing: NVSpace.xl) {19                Text(verbatim: "Graphite & Ultramarine · Lumen").nvFont(.display).foregroundStyle(NVColor.fg)20                NVSectionHeader("Couleurs", subtitle: "18 jetons, clair et sombre")21                LazyVGrid(columns: [GridItem(.adaptive(minimum: 96))], spacing: NVSpace.sm) {22                    ForEach(NVColor.Token.all) { token in23                        VStack(spacing: NVSpace.xs) {24                            NVRadius.shape(NVRadius.md).fill(token.color).frame(height: 40)25                                .overlay(NVRadius.shape(NVRadius.md).strokeBorder(NVColor.line))26                            Text(verbatim: token.name).nvFont(.micro).foregroundStyle(NVColor.fgMuted)27                        }28                    }29                }30                NVRadius.shape(NVRadius.xl).fill(NVColor.lumen).frame(height: 56)31                NVSectionHeader("Composants") { NVAIBadge(style: .compact) }32                NVCard {33                    VStack(alignment: .leading, spacing: NVSpace.md) {34                        Text(verbatim: "Titre de lecture").nvFont(.h2)35                        Text(verbatim: "Corps de lecture en serif éditorial.").nvFont(.reading)36                        Text(verbatim: "let x = 1").nvFont(.code)37                        HStack {38                            NVChip("recherche", systemImage: "number")39                            NVChip("actif", tone: .accent, isSelected: true) {}40                            NVChip("retard", tone: .danger)41                            NVAIBadge(model: "claude")42                        }43                        HStack {44                            NVCitationChip(index: 1, label: "Boucher 2026")45                            NVCitationChip(label: "Note liée") {}46                        }47                        HStack { NVProgressDots(count: 5, current: 2); NVProgressDots(tone: .ai) }48                    }49                }50                .nvCapturePulse(trigger: saved)51                NVToolbarGlass {52                    NVMorphingToolbar(id: level) { Text(verbatim: "Niveau \(level)").nvFont(.uiStrong) }53                    Button("Zoom") { level = level % 3 + 1 }54                    Button("Capturer") { saved += 1 }55                    Button("Panneau") { withNVAnimation(.base, reduceMotion: reduceMotion) { panel.toggle() } }56                }57                NVSemanticZoom(level: level) { level in58                    VStack(alignment: .leading, spacing: NVSpace.sm) {59                        ForEach(0..<(level * 3), id: \.self) { i in60                            Text(verbatim: "Bloc \(i + 1)").nvFont(.body).nvBlockReveal(index: i)61                        }62                    }63                    .frame(maxWidth: .infinity, alignment: .leading)64                }65                ZStack {66                    NVEdgeLine(from: CGPoint(x: 10, y: 10), to: CGPoint(x: 220, y: 70), curvature: 0.2)67                    NVEdgeLine(from: CGPoint(x: 220, y: 70), to: CGPoint(x: 60, y: 90), delay: 0.2)68                }69                .frame(height: 100)70                if panel {71                    NVCard { Text(verbatim: "Panneau intelligent").nvFont(.ui) }.nvPanelTransition(edge: .trailing)72                }73                NVEmptyState(systemImage: "tray", title: "Rien à trier", message: "Les captures apparaîtront ici.", actionTitle: "Capturer") {}74                    .frame(height: 240)75            }76            .padding(NVSpace.xl)77            .frame(maxWidth: NVSpace.readingMeasure)78        }79        .background(NVColor.bg)80    }81}8283struct NVGallery_Previews: PreviewProvider {84    static var previews: some View {85        NVGallery().preferredColorScheme(.light).previewDisplayName("Clair")86        NVGallery().preferredColorScheme(.dark).previewDisplayName("Sombre")87    }88}89#endif90
Files main
Menu

Theme