-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt Plot's new Component-based API (#111)
- Bump Plot to version `0.9.0`. - Publish now ships with a few implementations of Plot's new `Component` protocol - specifically `Markdown` (for rendering Markdown inline within a component hierarchy), `VideoPlayer` (for rendering an inline video player), and an extension that makes it possible to directly use Plot's `AudioPlayer` component with Publish's `Audio` model. - The `Content.Body` type now also conforms to `Component`, which makes it possible to place such instances directly within a component hierarchy. That type has now also been fully documented, since it was previously missing documentation for some of its properties and initializers. - The built-in Foundation theme as been rewritten using the new component API. While it remains functionally identical to the previous implementation, it should act as a nice example of how this new API can be used. - Because Publish now ships with a type called `Markdown`, it's possible that some API users might need to disambiguate between this new type and Ink's `Markdown` type. However, that tradeoff was considered worth it, since using the new `Markdown` component will likely be a much more common use case.
- Loading branch information
1 parent
9490cc8
commit 1402af3
Showing
9 changed files
with
317 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Plot | ||
import Ink | ||
|
||
public extension EnvironmentKey where Value == MarkdownParser { | ||
/// Environment key that can be used to pass what `MarkdownParser` that | ||
/// should be used when rendering `Markdown` components. | ||
static var markdownParser: Self { .init(defaultValue: .init()) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Ink | ||
import Plot | ||
|
||
public extension Component { | ||
/// Assign what `MarkdownParser` to use when rendering `Markdown` components | ||
/// within this component hierarchy. This value is placed in the environment, | ||
/// and is thus inherited by all child components. Note that this modifier | ||
/// does not affect nodes rendered using the `.markdown` API. | ||
/// - parameter parser: The parser to assign. | ||
func markdownParser(_ parser: MarkdownParser) -> Component { | ||
environmentValue(parser, key: .markdownParser) | ||
} | ||
} |
Oops, something went wrong.