aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgUI/Views/VerbatimBlock.swift
blob: 722c3f3be39f58763c7c383a95fdd52088d6f6a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import SwiftUI

struct VerbatimBlock: View {
  @Environment(\.norgTheme) private var theme

  let label: String?
  let content: String

  var body: some View {
    VStack(alignment: .leading, spacing: 4) {
      if let label, !label.isEmpty {
        Text(label)
          .font(.caption2)
          .foregroundStyle(.secondary)
      }
      Text(content)
        .font(theme.codeFont)
        .frame(maxWidth: .infinity, alignment: .leading)
    }
    .padding(10)
    .background(theme.codeBackground, in: RoundedRectangle(cornerRadius: 8))
  }
}