Commit Graph

505 Commits

Author SHA1 Message Date
Carson Katri cca9150336 Fix packages 2020-08-10 14:40:25 -04:00
Carson Katri 086ae30ac3 Add Chrome extension 2020-08-10 14:22:54 -04:00
Carson Katri 488f9f2865 Merge dark-mode 2020-08-10 14:18:44 -04:00
Carson Katri b5acc16a60 Fix DOMRef when used with Button 2020-08-10 10:53:09 -04:00
Carson Katri 06536f6718 Add license to BuiltinColors.swift 2020-08-10 09:02:19 -04:00
Carson Katri 94510a0c9e Fix Button on Safari 2020-08-09 22:12:10 -04:00
Carson Katri 365e0c7be9 Merge branch 'main' of https://github.com/swiftwasm/Tokamak into dark-mode 2020-08-09 20:41:28 -04:00
Carson Katri bc5470d05a Add ViewTree, onHover modifier, and various other debug changes 2020-08-07 11:05:41 -04:00
Max Desiatov 2a49b7808b
Link to the renderers guide from `README.md` (#251)
* Link to the renderers guide from `README.md`

The guide itself was merged into a single file for easier navigation.

* Update RenderersGuide.md
2020-08-07 16:01:27 +01:00
Max Desiatov e11effdd8c
Use the latest 5.3 snapshot in `.swift-version` (#252)
* Use the latest 5.3 snapshot in `.swift-version`

These SwiftWasm snapshots should be more stable in general and also have a workaround for https://github.com/swiftwasm/JavaScriptKit/issues/6 included. They still use the old metadata layout, so Runtime and OpenCombine dependencies had to be updated in `Package.swift` for `@ObservableObject` to work with these snapshots.

* Fix linter warning
2020-08-06 13:57:36 +01:00
Max Desiatov 487543d692
Merge branch 'main' of github.com:swiftwasm/Tokamak into dark-mode
# Conflicts:
#	Sources/TokamakCore/Modifiers/FlexFrameLayout.swift
#	Sources/TokamakCore/Modifiers/ModifiedContent.swift
#	Sources/TokamakCore/Tokens/Color.swift
#	Sources/TokamakCore/Views/Text/Text.swift
#	Sources/TokamakDemo/TokamakDemo.swift
#	Sources/TokamakStaticHTML/Views/Containers/List.swift
2020-08-05 17:44:29 +01:00
Max Desiatov de37894f83
Fix color scheme observer crashes in Safari (#249)
Resolve #245. Turns out `matchMediaDarkScheme` object doesn't have `addEventListener`, but only `addListener` in Safari 13.1.2.
2020-08-05 17:30:50 +01:00
Max Desiatov c4c9eb595e
Update to the latest version of SwiftFormat (#250)
* Update to the latest version of SwiftFormat

This fixes inconsistencies in argument and parameter formatting that we previously had.

* Fix function length in `Path.swift`

* Fix linter warnings

* More formatting cleanups

* Add `StrokeStyle.zero` in the `StaticHTML` module
2020-08-05 17:30:19 +01:00
Carson Katri efdca3a9ad Merge branch 'dark-mode' of https://github.com/swiftwasm/Tokamak into dark-mode 2020-08-05 08:17:30 -04:00
Carson Katri 73fcb4ac4a Make buttons always light mode 2020-08-05 08:17:15 -04:00
Max Desiatov 04d91aa717
Reduce `attributes` function line length in `Text` 2020-08-05 10:05:26 +01:00
Carson Katri 7ab7178004 Add class for NavigationView and content 2020-08-04 18:24:08 -04:00
Carson Katri bbcd1fb439 Add constant colors 2020-08-04 18:15:22 -04:00
Carson Katri 9c94361e2b Fix macOS build 2020-08-04 15:46:44 -04:00
Carson Katri 208c260f81 Fix List 2020-08-04 15:41:56 -04:00
Carson Katri ccd2035026 Fix Sidebar section headers to match macOS 2020-08-04 14:54:35 -04:00
Carson Katri aae1686bae Merge branch 'main' 2020-08-04 14:35:02 -04:00
Carson Katri fd57bf3328 Move flexible frame check to TokamakCore 2020-08-04 14:30:02 -04:00
Carson Katri fff9909a5a Fix linter and layout issues 2020-08-04 14:25:07 -04:00
Jed Fox 88064fd5bc
Split demo list into sections (#243)
* Split demo list into sections

* Remove slider demo

* Update RedactDemo.swift

* Redact → Redaction, move DOM refs to a TokamakDOM section, additional adjustments

* RedactDemo → RedactionDemo
2020-08-04 06:49:43 -04:00
Max Desiatov 62c05ae9aa
Remove some `AnyView` in the `List` implementation (#246) 2020-08-04 07:38:27 +01:00
Carson Katri c0a580653a Fix segmented Text 2020-08-03 18:27:27 -04:00
Carson Katri cb6359431d Add _NavigationLinkStyle for sidebar lists 2020-08-03 18:09:40 -04:00
Carson Katri 4b05fd8523 Merge branch main 2020-08-03 17:08:57 -04:00
Carson Katri abc59f048a Style fixes for NavigationLink, DisclosureGroup, Button, TextField, Picker, and more 2020-08-03 17:07:44 -04:00
Carson Katri cdc452b7a5 Add dark styles for most elements 2020-08-02 20:22:52 -04:00
Max Desiatov b93be40a19
Add `_targetRef` and `_domRef` modifiers (#240)
Resolves partially #231. `_targetRef` is a modifier that can be used by any renderer, while `_domRef` is an adaptation of that for `DOMRenderer`. Both are underscored as they are not available in SwiftUI, and also their stability is currently not so well known to us, we may consider changing this API in the future.

Example use:

```swift
struct DOMRefDemo: View {
  @State var button: JSObjectRef?

  var body: some View {
    Button("Click me") {
      button?.innerHTML = "This text was set directly through a DOM reference"
    }._domRef($button)
  }
}
```

I've also fixed all known line length warnings in this PR.
2020-08-02 22:01:38 +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 70d31b2e5b
Add `redacted` modifier (#232) 2020-08-01 17:18:23 -04:00
Carson Katri 4c654da456
Add Static HTML Renderer and Documentation (#204) 2020-08-01 16:27:12 -04:00
Max Desiatov fbb893739b
Fix tests, move DefaultButtonStyle to TokamakCore (#234)
Merging #214 broke the tests. Also, `DefaultButtonStyle` seems to be trivial enough to be shared through `TokamakCore` between all renderers.
2020-08-01 20:07:10 +01:00
Max Desiatov 050e917161
Add `test-suite` label to `label.yml` 2020-08-01 19:41:25 +01:00
Max Desiatov 40804d4542
Remove `DefaultApp`, make `DOMRenderer` internal (#227)
Removes the `View`-based initializer of `DOMRenderer` which no longer leaves any `public` initializers on it, means we can make it fully internal. `DOMNode` is now internal too, which is great as it was an implementation detail anyway. Corollary, `DefaultApp` is no longer needed.

`Target` was cleaned up is it doesn't need to hold `App` or `Scene` values, now it's just a simple protocol.

I've updated `README.md` to show usage of the `App` protocol in the basic example.

Closes #224.
2020-08-01 18:46:59 +01:00
Max Desiatov e37d13017c
Add basic `ButtonStyle` implementation (#214)
This based off the `buttonstyles` branch by @Outcue.

Initially it didn't work because mounted host views didn't propagate their environment on updates. This is now fixed by adding `updateEnvironment` function on `MountedElement` base class and calling it in the initializer. Manual environment updates are no longer needed in `makeMounted...` factory functions. `makeMountedApp` is no longer needed at all and `MountedApp` initializer can be used directly then.
2020-08-01 18:46:34 +01:00
Max Desiatov 2c539d9319
Make reconciler tests build and run on macOS (#229)
We can't run our basic reconciler tests in a WASI environment yet because `XCTestExpectation` is not available on WASI as it relies on the presence of `Dispatch`. We can run these tests on macOS though, and even on Linux in the future when Swift 5.3 is available for Linux on GitHub Actions.

My current OpenCombine fork doesn't build on macOS and it was much easier to add a new `CombineShim` module that uses native Combine there.
2020-07-30 16:48:09 +01:00
Max Desiatov 1271281b75
Fix environment changes causing remounted scenes with lost state (#223)
Implements support for custom scenes by adding the new `MountedScene` type and fixes environment propagation from mounted parent to mounted child elements.

This will unblock https://github.com/swiftwasm/Tokamak/pull/136 and potentially https://github.com/swiftwasm/Tokamak/pull/214. In the former scenes are always completely unmounted and remounted from scratch when root environment changes, which causes descendants to lose all `@State` values. I saw some environment propagation issues in the latter, but not sure if those were caused by the lack of correct scene updates, just wanted to tackle the usual suspects first.

I've also improved reconciler-related doc comments to clarify some of the design desicions and naming.

Resolves #222.
2020-07-29 21:37:38 +01:00
Max Desiatov 7c6b1812ae
Add `DefaultApp` type to simplify `DOMRenderer.init` (#217)
This means that the `View` initializer of `DOMRenderer` now can delegate to the `App` initializer by creating a wrapping `DefaultApp`. It would simplify https://github.com/swiftwasm/Tokamak/pull/136 for me, where I no longer need to implement color scheme observation for these two different codepaths separately.
2020-07-29 09:26:08 +01:00
Outcue 8041732dc9
Implement `SidebarListStyle` (#210)
First pass at the SidebarListStyle.

For this to be truly complete, work needs to be completed on ButtonStyles. I can look at that next. NavigationLinks in a Sidebar are Text items that draw a blue background when clicked (and perhaps when item is active.)

Co-authored-by: Gene Z. Ragan <diskzero@mac.com>
Co-authored-by: Jed Fox <git@jedfox.com>
Co-authored-by: Gene Ragan <gene@semitone.audio>
2020-07-29 09:25:33 +01:00
Max Desiatov f5af009db2
Unify code of `MountedApp`/`MountedCompositeView` (#219)
We currently have the reconciler code duplicated in these types. I also have a draft `MountedScene` implementation, which most probably would rely on the same reconcilliation algorithm. In this PR it's made generic and can be shared across these types of mounted elements.
2020-07-28 18:01:29 +01:00
Max Desiatov 66248448ab
Generalize style and environment in `DOMRenderer` (#215)
Moves `DOMNode` to a separate file and reduces style and environment duplication in overloaded `DOMRenderer` initializers.
2020-07-27 09:36:08 +01:00
Carson Katri c68c70a7d7
Implement `DynamicProperty` (#213) 2020-07-25 17:32:28 -04:00
Max Desiatov a24f49f298
Warn against beta versions of Xcode in README.md (#207)
Seems like Xcode beta 3 is particularly problematic.Seems like Xcode 12 beta 3 is particularly problematic due to https://github.com/swiftwasm/carton/issues/65
2020-07-23 21:58:19 +01:00
Max Desiatov e372075ab6
Fix typo in `TokamakDemo.swift` (#206) 2020-07-23 13:46:03 +01:00
Max Desiatov f15f598d7b
Update "Requirements" and "Getting started" README sections (#205)
I hope this makes `README.md` a bit more friendly for our early adopters, but any feedback is welcome as usual 🙂
2020-07-22 22:27:19 +01:00
Jed Fox ac50208447
Initial `NavigationView` implementation (#130)
* Initial NavigationView implementation

* Make the _ButtonProxy type more generic

* Split Navigation.swift files

* Move this too

* Implement Navigation controls

* Update progress.md

* Make NavigationLinks links

* Break line

(wishing for Prettier for Swift)

* Update Path.swift

* n-th time’s the charm

* Update Path.swift

* Update project.pbxproj

* Fixes

* Hopefully fix build issues

* Update Navigation.swift

* Improve ColorDemo

* Fixes & reverts

* Fix crash

* Revert "Fix crash"

This reverts commit ae6f13dcc9.

* Tweak rendering of demos

* add todo for accessibility

* Apply suggestions from @MaxDesiatov

Co-authored-by: Max Desiatov <max@desiatov.com>

* Update TokamakDemo.swift

* Move things to Core.swift

* Switch default destination to EmptyView

* Fix build for macOS

* Revert "Apply suggestions from @MaxDesiatov"

This reverts commit 73c9c3f6ac.

Co-authored-by: Max Desiatov <max@desiatov.com>
Co-authored-by: Carson Katri <Carson.katri@gmail.com>
2020-07-22 17:12:15 -04:00