Fix linter and layout issues

This commit is contained in:
Carson Katri 2020-08-04 14:25:07 -04:00
parent c0a580653a
commit fff9909a5a
6 changed files with 34 additions and 18 deletions

View File

@ -93,6 +93,8 @@ public struct _NavigationLinkProxy<Label, Destination> where Label: View, Destin
}
public func activate() {
subject.navigationContext.destination = subject.destination
if !isSelected {
subject.navigationContext.destination = subject.destination
}
}
}

View File

@ -39,13 +39,14 @@ public struct _NavigationViewProxy<Content: View>: View {
public init(_ subject: NavigationView<Content>) { self.subject = subject }
public var content: Content { subject.content }
public var content: some View {
subject.content
.environmentObject(subject.context)
}
public var body: some View {
HStack {
content
subject.context.destination.view
}
.environmentObject(subject.context)
subject.context.destination.view
.environmentObject(subject.context)
}
}

View File

@ -35,7 +35,7 @@ struct NavItem: Identifiable {
init<V>(_ id: String, destination: V) where V: View {
self.id = id
self.destination = title(destination.frame(minWidth: 300), title: id)
self.destination = title(destination, title: id)
}
init(unavailable id: String) {
@ -141,11 +141,7 @@ struct TokamakDemoView: View {
let list = title(
List(links) { link in
if let dest = link.destination {
NavigationLink(link.id, destination: HStack {
Spacer()
dest
Spacer()
})
NavigationLink(link.id, destination: dest)
} else {
#if os(WASI)
Text(link.id)

View File

@ -37,9 +37,13 @@ extension _ShapeView: ViewDeferredToRenderer {
if let shapeAttributes = shape as? ShapeAttributes {
return AnyView(HTML("div", shapeAttributes.attributes(style)) { path })
} else if let color = style as? Color {
return AnyView(HTML("div", ["style": "fill: \(color.cssValue(environment));"]) { path })
return AnyView(HTML("div", [
"style": "fill: \(color.cssValue(environment));",
]) { path })
} else if let foregroundColor = foregroundColor {
return AnyView(HTML("div", ["style": "fill: \(foregroundColor.cssValue(environment));"]) { path })
return AnyView(HTML("div", [
"style": "fill: \(foregroundColor.cssValue(environment));",
]) { path })
} else {
return path
}

View File

@ -22,7 +22,17 @@ extension NavigationView: ViewDeferredToRenderer {
width: 100%; height: 100%;
""",
]) {
_NavigationViewProxy(self)
_NavigationViewProxy(self).content
HTML("div", [
"style": """
display: flex; flex-direction: column;
align-items: center; justify-content: center;
flex-grow: 1;
height: 100%;
""",
]) {
_NavigationViewProxy(self)
}
})
}
}

View File

@ -157,11 +157,15 @@ extension Text {
underline = (active, color)
}
}
let hasStrikethrough = strikethrough?.0 ?? false
let hasUnderline = underline?.0 ?? false
let textDecoration = !hasStrikethrough && !hasUnderline ?
"none" :
"\(hasStrikethrough ? "line-through" : "") \(hasUnderline ? "underline" : "")"
let decorationColor = strikethrough?.1?.cssValue(environment)
?? underline?.1?.cssValue(environment)
?? "inherit"
return [
"style": """
@ -179,8 +183,7 @@ extension Text {
letter-spacing: \(kerning);
vertical-align: \(baseline == nil ? "baseline" : "\(baseline!)em");
text-decoration: \(textDecoration);
text-decoration-color: \(strikethrough?.1?.cssValue(environment) ?? underline?.1?.cssValue(environment)
?? "inherit")
text-decoration-color: \(decorationColor)
""",
"class": isRedacted ? "_tokamak-text-redacted" : "",
]