Skip to content

Commit

Permalink
Merge pull request #20 from hotwired/jh-copy-edits
Browse files Browse the repository at this point in the history
Fix typos and make minor copy edits
  • Loading branch information
jayohms authored Sep 25, 2023
2 parents bff127b + e105ca5 commit c6fb51e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions _source/handbook/01_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ description: "Strada is a set of three libraries that coordinate across the web,

# Introduction

You can build [Turbo Native](https://turbo.hotwired.dev/handbook/native) apps to enjoy the best of the web alongside the best of native apps and fully native screens. But, there's a major limitation: there's no way for the native app to know what's happening within the `WebView` and adapt to the content that its displaying.
You can build [Turbo Native](https://turbo.hotwired.dev/handbook/native) apps to enjoy the best of the web alongside the best of native apps and fully native screens. But, there's a major limitation: there's no way for the native app to know what's happening within the `WebView` and adapt to the content that it's displaying.

Additionally, it'd be great for some web features to break out of the `WebView` container and drive native features — whether it's displaying native buttons in the top app bar, displaying native menu sheets, or calling native platform APIs. <strong>Strada</strong> enables you to do all of this and gives you the flexibility to build components that are specific to your app's needs.

Strada acts a "bridge" between your web code and your native app code, letting your web app and native app communicate through a component-based framework. It abstracts away the complexity of communicating with javascript code in a `WebView` and native code in your app.
Strada acts a "bridge" between your web code and your native app code, letting your web app and native app communicate through a component-based framework. It abstracts away the complexity of communicating with JavaScript code in a `WebView` and native code in your app.
22 changes: 11 additions & 11 deletions _source/handbook/02_how_it_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Strada uses a component-based approach to create a bidirectional communication c

Web components "send" messages to their corresponding native components. Native components "receive" the messages to build and display native controls, populating them with `data` supplied in the messages. When native components want to inform their corresponding web components of a user action or state change, the native components "reply" to the originally received messages. Web components "receive" the replies and invoke a callback to update the web component based on the reply message `data`.

Strada leverages [Stimulus](https://stimulus.hotwired.dev) to bring you the same power to your web components. In fact, the core `BridgeComponent` class is an extension of a Stimulus `Controller`, so you should be familiar with Stimulus before building Strada components.
Strada leverages [Stimulus](https://stimulus.hotwired.dev) to bring the same power to your web components. In fact, the core `BridgeComponent` class is an extension of a Stimulus `Controller`, so you should be familiar with Stimulus before building Strada components.

## Demo Examples

Expand Down Expand Up @@ -56,7 +56,7 @@ Let's update the form with bridge attributes and create a new web component, lev
</form>
```

Now, we'll create a new `"form"` component in a similar way you create Stimulus controllers, but extending the `BridgeComponent` class:
Now, we'll create a new `"form"` component. This is similar to the way you create Stimulus controllers, but extending the `BridgeComponent` class:
```javascript
// bridge/form_controller.js

Expand All @@ -70,7 +70,7 @@ export default class extends BridgeComponent {
}
```

The basic `"form"` component is now created we can send a `message` to a corresponding native `"form"` component in the native app. We'll send the submit button's title as JSON `data` in the message, so the native component can set the native button's title with the `submitTitle`.
With the basic `"form"` component created, we can now send a `message` to a corresponding native `"form"` component. We'll send the submit button's title as JSON `data` in the message, so the native component can set the native button's title with the `submitTitle`.
```javascript
// bridge/form_controller.js

Expand All @@ -91,9 +91,9 @@ export default class extends BridgeComponent {
}
```

Notice the 3rd parameter when calling `send()`. It's a callback function that will get called when the native component replies back to the `"connect"` message. The submit button in the `<form>` is clicked, submitting the form to the server, just as if the user had tapped the button directly.
Notice the third parameter when calling `send()`. It's a callback function that will be called when the native component replies to the `"connect"` message. The submit button in the `<form>` is clicked, submitting the form to the server, just as if the user had tapped the button directly.

The web component is now done and we can build a corresponding `"form"` component in the iOS and Android apps.
The web component is now ready and we can build a corresponding `"form"` component in the iOS and Android apps.

## Building a Native iOS Component

Expand Down Expand Up @@ -148,9 +148,9 @@ private extension FormComponent {
}
```

The component receives the `message` for the `"connect"` `event`, displays the native button with the `submitTitle`, and replies back to the web component when the native button is tapped.
The component receives the `message` for the `"connect"` `event`, displays the native button with the `submitTitle`, and replies to the web component when the native button is tapped.

_Note: There's additional work to setup [Strada iOS](https://github.com/hotwired/strada-ios) in your app for the first time. See the [Quick Start](https://github.com/hotwired/strada-ios/blob/main/docs/QUICK-START.md) guide to see the full instructions._
_Note: There's additional work to set up [Strada iOS](https://github.com/hotwired/strada-ios) in your app for the first time. See the [Quick Start](https://github.com/hotwired/strada-ios/blob/main/docs/QUICK-START.md) guide for complete instructions._

## Building a Native Android Component

Expand Down Expand Up @@ -208,15 +208,15 @@ class FormComponent(
}
```

The component receives the `message` for the `"connect"` `event`, displays the native button with the `submitTitle`, and replies back to the web component when the native button is tapped.
The component receives the `message` for the `"connect"` `event`, displays the native button with the `submitTitle`, and replies to the web component when the native button is tapped.

_Note: There's additional work to setup [Strada Android](https://github.com/hotwired/strada-android) in your app for the first time. See the [Quick Start](https://github.com/hotwired/strada-android/blob/main/docs/QUICK-START.md) guide to see the full instructions._
_Note: There's additional work to set up [Strada Android](https://github.com/hotwired/strada-android) in your app for the first time. See the [Quick Start](https://github.com/hotwired/strada-android/blob/main/docs/QUICK-START.md) guide for complete instructions._

## Add CSS to Hide Bridged Elements

We've now setup `"form"` components in the web and native apps. Whenever a native app supports the `"form"` component, it'll receive a message from the web component and display its native button.
We've now set up `"form"` components in the web and native apps. Whenever a native app supports the `"form"` component, it'll receive a message from the web component and display its native button.

However, there's one final piece to finish. We want to hide the web submit button in the `<form>` when a native button is being displayed. It's easy to write scoped css that is only applied if:
There's one final piece to finish. We want to hide the web submit button in the `<form>` when a native button is being displayed. It's easy to write scoped css that is only applied if:
- A particular version of the native app supports the `"form"` component
- A particular `<form>` in your app is connected to a `"form"` component

Expand Down
2 changes: 1 addition & 1 deletion _source/handbook/03_web.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "Strada Web..."

# Strada Web

Strada is a javascript library that makes it easy to create web components in your application using your existing HTML. See [how it works](/handbook/how-it-works) and the [installation instructions](/handbook/installing).
Strada is a JavaScript library that makes it easy to create web components in your application using your existing HTML. See [how it works](/handbook/how-it-works) and the [installation instructions](/handbook/installing).

<div class="landing-actions">
<a class="landing-actions__item" href="https://github.com/hotwired/strada-web">
Expand Down
4 changes: 2 additions & 2 deletions _source/handbook/06_installing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ description: "Learn how to install Strada in your application."

# Installing Strada in Your Application

Strada can either be referenced in compiled form via the Strada distributable script directly in the `<head>` of your application or through npm via a bundler like esbuild.
Strada can either be referenced in compiled form via the Strada distributable script directly in the `<head>` of your application, or through npm via a bundler like esbuild.

## Prerequisite: Install Stimulus

Strada leverages [Stimulus](https://stimulus.hotwired.dev) and the core `BridgeComponent` class is an extension of a Stimulus `Controller`. You must have Stimulus installed in your web app before installing Strada. See the [Stimulus installation instructions](https://stimulus.hotwired.dev/handbook/installing).

## In Compiled Form

You can float on the latest release of Strada using a CDN bundler or import <a href="https://unpkg.com/@hotwired/strada/dist/strada.js">strada.js</a> in a `<script type="module">` tag.
You can float on the latest release of Strada using a CDN bundler or import <a href="https://unpkg.com/@hotwired/strada/dist/strada.js">strada.js</a> using a `<script type="module">` tag.

## As An npm Package

Expand Down
3 changes: 1 addition & 2 deletions _source/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ <h1 class="landing-intro__text grid__item grid__item--start-2 grid__item--span-1
</ul>

<p>
Strada components leverage <a href="https://stimulus.hotwired.dev">Stimulus</a> and works seamlessly with <a href="https://turbo.hotwired.dev">Turbo</a> web and <a href="https://turbo.hotwired.dev/handbook/native">Turbo Native</a> apps.
Strada components leverage <a href="https://stimulus.hotwired.dev">Stimulus</a> and work seamlessly with <a href="https://turbo.hotwired.dev">Turbo</a> web and <a href="https://turbo.hotwired.dev/handbook/native">Turbo Native</a> apps.
</p>

</section>

<div class="landing-actions">
Expand Down
10 changes: 5 additions & 5 deletions _source/reference/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ description: "A reference of everything you can do with element attributes."

The following data attributes can be applied to any element accessed via the `BridgeElement` class:

* `data-bridge-title="My Title"`: Use a custom bridge title for your element.
* `data-bridge-disabled`: Specifies whether the bridge element is currently disabled or disabled for a particular platform. Values must be `"true"`, `"false"`, `"ios"`, or `"android"`.
* `data-bridge-*`: Add arbitrary attributes prefixed with `data-bridge-` to access their values from a `BridgeElement`.
* `data-bridge-title="My Title"`: Specifies a custom bridge title for your element.
* `data-bridge-disabled`: Specifies whether the bridge element should be disabled or disabled for a particular platform. Values must be `"true"`, `"false"`, `"ios"`, or `"android"`.
* `data-bridge-*`: Specifies arbitrary attributes prefixed with `data-bridge-` whose values are accessible from a `BridgeElement`.

The following data attributes can be applied to elements associated with a `data-controller` and a `BridgeComponent` class:

* `data-controller-optout-ios`: Opt-out the component for your iOS app using [strada-ios](https://github.com/hotwired/strada-ios). Let's you conditionally disable a component instance for iOS, even if the native app supports the component.
* `data-controller-optout-android`: Opt-out the component for your iOS app using [strada-android](https://github.com/hotwired/strada-android). Let's you conditionally disable a component instance for Android, even if the native app supports the component.
* `data-controller-optout-ios`: Opt-out the component for your iOS app using [strada-ios](https://github.com/hotwired/strada-ios). Allows you to conditionally disable a component instance for iOS, even if the native app supports the component.
* `data-controller-optout-android`: Opt-out the component for your Android app using [strada-android](https://github.com/hotwired/strada-android). Allows you to conditionally disable a component instance for Android, even if the native app supports the component.
10 changes: 5 additions & 5 deletions _source/reference/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ description: "A reference of everything you can do with bridge components."

The `BridgeComponent` class is an extension of a Stimulus [Controller](https://stimulus.hotwired.dev/reference/controllers). You have everything available in a standard `Controller` in addition to the following Strada-specific bridge functionality:

* `static component`: The unique name of the component. This must match the component name you use for the corresponding native component.
* `static component`: The unique name of the component. This must match the name you use for the corresponding native component.
* `this.platformOptingOut`: Specifies whether the controller is opted out for the current platform using the `data-controller-optout-<platform>` attribute.
* `this.enabled`: Specifies whether the component is enabled and supported by the current version of the native app.
* `this.bridgeElement`: Provides `this.element` for the component instance wrapped in a `BridgeElement`.
* `this.send(event, data = {}, callback)`: Send a message to the native component with the `event` name, optional JSON `data`, and a `callback` to run when the native component replies to the message.
* `this.send(event, data = {}, callback)`: Sends a message to the native component with the `event` name, optional JSON `data`, and a `callback` to be run when the native component replies to the message.

To create a `"form"` component that displays a native submit button in your native app, you'd add the following controller, target, and title attributes to your `<form>`:
For example, to create a `"form"` component that displays a native submit button in your native app, you'd add the following controller, target, and title attributes to your web `<form>`:

```html
<form
Expand All @@ -37,7 +37,7 @@ To create a `"form"` component that displays a native submit button in your nati
</form>
```

Create a `BridgeComponent` with the `"form"` name that sends a message to the native component with `data` that contains the form's `submitTitle`. Provide a callback to run when the native component replies to the message.
Next, create a `BridgeComponent` with named `"form"` that sends a message to the native component with `data` that contains the form's `submitTitle`. Provide a callback to run when the native component replies to the message.

```javascript
// bridge/form_controller.js
Expand All @@ -59,7 +59,7 @@ export default class extends BridgeComponent {
}
```

_Note: It's recommended to put your bridge components in a `/bridge` subdirectory where your Stimulus controllers live to make them easily identifiable and isolated from your other Stimulus controllers._
_Note: It's recommended to place your bridge components in a `/bridge` subdirectory where your Stimulus controllers live to make them easily identifiable and isolated from your other Stimulus controllers._

## Native Components

Expand Down

0 comments on commit c6fb51e

Please sign in to comment.