forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstructionMarkdownTheme.swift
More file actions
68 lines (65 loc) · 2.39 KB
/
InstructionMarkdownTheme.swift
File metadata and controls
68 lines (65 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import Foundation
import MarkdownUI
import SwiftUI
extension MarkdownUI.Theme {
static func instruction(fontSize: Double) -> MarkdownUI.Theme {
.gitHub.text {
ForegroundColor(.primary)
BackgroundColor(Color.clear)
FontSize(fontSize)
}
.code {
FontFamilyVariant(.monospaced)
FontSize(.em(0.85))
BackgroundColor(Color.secondary.opacity(0.2))
}
.codeBlock { configuration in
let wrapCode = UserDefaults.shared.value(for: \.wrapCodeInChatCodeBlock)
if wrapCode {
configuration.label
.codeBlockLabelStyle()
.codeBlockStyle(
configuration,
backgroundColor: Color(nsColor: .textBackgroundColor).opacity(0.7),
labelColor: Color.secondary.opacity(0.7)
)
} else {
ScrollView(.horizontal) {
configuration.label
.codeBlockLabelStyle()
}
.workaroundForVerticalScrollingBugInMacOS()
.codeBlockStyle(
configuration,
backgroundColor: Color(nsColor: .textBackgroundColor).opacity(0.7),
labelColor: Color.secondary.opacity(0.7)
)
}
}
.table { configuration in
configuration.label
.fixedSize(horizontal: false, vertical: true)
.markdownTableBorderStyle(.init(
color: .init(nsColor: .separatorColor),
strokeStyle: .init(lineWidth: 1)
))
.markdownTableBackgroundStyle(
.alternatingRows(Color.secondary.opacity(0.1), Color.secondary.opacity(0.2))
)
.markdownMargin(top: 0, bottom: 16)
}
.tableCell { configuration in
configuration.label
.markdownTextStyle {
if configuration.row == 0 {
FontWeight(.semibold)
}
BackgroundColor(nil)
}
.fixedSize(horizontal: false, vertical: true)
.padding(.vertical, 6)
.padding(.horizontal, 13)
.relativeLineSpacing(.em(0.25))
}
}
}