Commit Graph

5 Commits

Author SHA1 Message Date
Max Desiatov 637fdec44c
Convert Environment/Object/Values to classes 2021-02-13 20:42:27 +00:00
Max Desiatov 3451d9ea12
Pass sibling to `Renderer.mount`, fix update order (#301)
Resolves, but adds no tests cases to the test suite for #294. See the issue for the detailed description of the problem.

I will add end-to-end tests for this in future PRs.

I've tested these cases manually so far:

```swift
struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        Group {
          Text("true")
          Text("true")
        }
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}
```

Note the `Group` view with multiple children in this one, it uncovered required checks for `GroupView` conformance.

Also tested these more simple cases:

```swift
struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        Group {
          // single child
          Text("true")
        }
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}
```

and

```swift
struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        // single child, no nesting
        Text("true")
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}
```
2020-11-11 19:34:45 +00:00
Max Desiatov de72316efa
Use setAttribute, not properties to fix SVG update (#279)
Property assignment does not update SVG elements. We may want to use properties instead of `setAttribute` in the future for optimizations. For now I think that `setAttribute` works in all cases, including SVG, and seems safer to me.

Resolves #278.

* Use setAttribute, not properties to fix SVG update

* Add HTMLAttribute to cleanly apply DOM updates

* Add doc comment to HTMLAttribute

* Update Sources/TokamakStaticHTML/Views/HTML.swift

Co-authored-by: Jed Fox <git@jedfox.com>

* Use static func property in TokamakDOM/TextField.swift

* Make `static func property` public

* Declare `static let value` on `HTMLAttribute`

Co-authored-by: Jed Fox <git@jedfox.com>
2020-09-23 09:13:22 +01:00
Max Desiatov c7b5e75e1a
Add `ColorScheme` environment (#136)
You can see the dark scheme environment text representation updated in `EnvironmentDemo`. I suggest adding default dark mode styles in a separate PR, I've created #237 as a reminder for that.
2020-08-02 18:55:35 +01:00
Carson Katri 4c654da456
Add Static HTML Renderer and Documentation (#204) 2020-08-01 16:27:12 -04:00