-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify Ignite: Eliminate PageContext
by incorporating it into EnvironmentValues
#479
base: main
Are you sure you want to change the base?
Conversation
…plit `EnvironmentReader` functionality between the new `Layoutable` protocol and `RootElement`. Remove requirement for `HTMLHead` and `HTMLBody` to require being initialized with a page. Misc. type renaming.
@@ -5,7 +5,7 @@ | |||
// See LICENSE for license information. | |||
// | |||
|
|||
public struct HTMLDocument: HTML { | |||
struct Root: HTML { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the name Root
. Document
, perhaps? Or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the hesitation with Root
? That'd be the most accurate HTML terminology for it and complement RootElement
nicely.
PageContext
by incorporating it into EnvironmentStore
PageContext
by incorporating it into EnvironmentValues
PageContext
is essentially the same exact object asEnvironmentStore
—a singleton that creates a context for the current page being published, and infuses that context with relevant values.This similarity gives us the opportunity to consolidate these objects and make creating layouts even simpler.
This PR is the first in a larger series, and while it contains several changes, they are all in service of simplifying this code:
Into this code:
Head
andBody
now mirror scenes in SwiftUI, and the defaultHead
is automatically provided by the result builder, hence its omission above.Head
needs to be included only if you want extra head elements likeAnalytics
.The superficial changes:
HTMLHead
andHTMLBody
toHead
andBody
by reworking the associated type names that originally confused the compiler. RenamedHTMLDocument
toRoot
.environment
default property toRootHTML
The main change is adding a
page
property toEnvironmentValues
, which we access in the initializers ofHead
andBody
now, instead of requiring a page as an input.The final PR of this series will thoroughly polish variable and type names. The important thing here is functionality.