docs(react,angular): use ionPage prop for nested outlets and add navigation playgrounds#4454
docs(react,angular): use ionPage prop for nested outlets and add navigation playgrounds#4454
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
docs/angular/navigation.md
Outdated
| ## Live Example | ||
|
|
||
| If you would prefer to get hands on with the concepts and code described above, please checkout our [live example](https://stackblitz.com/edit/ionic-angular-routing?file=src/app/app-routing.module.ts) of the topics above on StackBlitz. | ||
| <NavigationPlayground /> |
There was a problem hiding this comment.
| <NavigationPlayground /> | |
| import NavigationPlayground from '@site/static/usage/v9/angular/navigation/index.md'; | |
| <NavigationPlayground /> |
We normally import the playgrounds right before they're used:
ionic-docs/docs/api/accordion.md
Lines 55 to 57 in 9443312
There was a problem hiding this comment.
This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)
docs/angular/navigation.md
Outdated
| --- | ||
|
|
||
| import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
| import NavigationPlayground from '@site/static/usage/v9/angular/navigation/index.md'; |
There was a problem hiding this comment.
| import NavigationPlayground from '@site/static/usage/v9/angular/navigation/index.md'; |
See my first comment lower in this file
There was a problem hiding this comment.
This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)
docs/react/navigation.md
Outdated
| ## Live Example | ||
|
|
||
| If you would prefer to get hands on with the concepts and code described above, please checkout our [live example](https://stackblitz.com/edit/ionic-react-routing?file=src/index.tsx) of the topics above on StackBlitz. | ||
| <NavigationPlayground /> |
There was a problem hiding this comment.
| <NavigationPlayground /> | |
| import NavigationPlayground from '@site/static/usage/v9/react/navigation/index.md'; | |
| <NavigationPlayground /> |
We normally import the playgrounds right before they're used:
ionic-docs/docs/api/accordion.md
Lines 55 to 57 in 9443312
There was a problem hiding this comment.
This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)
docs/react/navigation.md
Outdated
| --- | ||
|
|
||
| import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
| import NavigationPlayground from '@site/static/usage/v9/react/navigation/index.md'; |
There was a problem hiding this comment.
| import NavigationPlayground from '@site/static/usage/v9/react/navigation/index.md'; |
See my first comment lower in this file
There was a problem hiding this comment.
This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)
static/usage/v9/navigation/index.md
Outdated
| size="large" | ||
| includeIonContent={false} |
There was a problem hiding this comment.
| size="large" | |
| includeIonContent={false} | |
| includeIonContent={false} | |
| devicePreview={true} |
Can we put this inside a device preview so it looks a bit nicer?
There was a problem hiding this comment.
I didn't know how to do this before, thanks! This was done as part of my move to a unified Playground
| size="large" | ||
| includeIonContent={false} |
There was a problem hiding this comment.
| size="large" | |
| includeIonContent={false} | |
| includeIonContent={false} | |
| devicePreview={true} |
Can we put this inside a device preview so it looks a bit nicer?
There was a problem hiding this comment.
I didn't know how to do this before, thanks! This was done as part of my move to a unified Playground
static/usage/v9/navigation/index.md
Outdated
There was a problem hiding this comment.
Rather than putting these under separate angular and react folders should we do one playground with both frameworks? Structure:
static
└── usage
└── v9
└── navigation
├── angular
│ ├── app_component_html.md
│ ├── app_component_ts.md
│ ├── app_routes_ts.md
│ ├── dashboard_page_component_html.md
│ ├── dashboard_page_component_ts.md
│ ├── example_component_html.md
│ ├── example_component_ts.md
│ ├── item_detail_page_component_html.md
│ ├── item_detail_page_component_ts.md
│ ├── settings_page_component_html.md
│ └── settings_page_component_ts.md
├── react
│ ├── dashboard_page_tsx.md
│ ├── item_detail_page_tsx.md
│ ├── main_tsx.md
│ └── settings_page_tsx.md
├── demo.html
└── index.md
This would allow us to add a JavaScript and Vue one if we would like.
There was a problem hiding this comment.
So the reason was we couldn't previously is because then the React playground would show the Angular playground by default (unless you happened to have selected React from a component view before, in which case Angular would have shown React by default), which is a bad UX.
This inspired me to fix this, though, so in this commit (de72886) I added support for default frameworks and made the React and Angular pages use it, most of the work for combining them was done in this commit though (58873e4)
static/usage/v9/angular/navigation/angular/dashboard_page_component_ts.md
Outdated
Show resolved
Hide resolved
| ); | ||
| }; | ||
| const DashboardPage: React.FC = () => ( | ||
| <IonRouterOutlet ionPage> |
There was a problem hiding this comment.
I don't understand why ionPage is now required. We have never recommended adding this as a property and it is not added to any of the playgrounds.
There was a problem hiding this comment.
It's never been recommended because the docs have been known to be wrongly recommending wrapping IonRouterOutlet in IonPages for several years and nobody has fixed it (note the age of the issue this resolves).
Using the ionPage prop on the router outlet directly benefits mostly nested routes (it's required by them, technically). When you have an outlet containing routes and one of those routes renders another outlet, like in a tab layout, the inner outlet needs to know about and be able to participate in the outer outlet's page transitions. Setting the prop makes the inner outlet itself the animatable page element, so the outer StackManager can transition it properly.
It's generally best to do this everywhere so you don't have to remember to do it in the special nested routing edge cases, and that will also be the case in RR6.
…act navigation live example to use one playground
Resolves #2183
Description
Currently, several examples for using React Router are incorrectly showing wrapping IonRouter with IonPage instead of using the ionPage prop. Additionally, React and Angular have hard-coded links to StackBlitz that we do not control and have since moved away from in favor of playgrounds.
This PR does multiple things:
Change Type
Examples
Angular Navigation/Routing - Live Example
React Navigation/Routing - Should no longer have IonPage wrapping IonRouter and should use the ionPage prop instead. Additionally, stackblitz link under Live Example swapped for Playground