-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nav-link): merge nav-push/pop/set-root into a single component (#…
- Loading branch information
1 parent
d031434
commit c3044f5
Showing
32 changed files
with
313 additions
and
19 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
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
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
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,20 @@ | ||
import { ComponentProps, NavComponent } from '../../interface'; | ||
import { RouterDirection } from '../router/utils/interface'; | ||
|
||
export const navLink = (el: HTMLElement, routerDirection: RouterDirection, component?: NavComponent, componentProps?: ComponentProps) => { | ||
const nav = el.closest('ion-nav'); | ||
if (nav) { | ||
if (routerDirection === 'forward') { | ||
if (component !== undefined) { | ||
return nav.push(component, componentProps, { skipIfBusy: true }); | ||
} | ||
} else if (routerDirection === 'root') { | ||
if (component !== undefined) { | ||
return nav.setRoot(component, componentProps, { skipIfBusy: true }); | ||
} | ||
} else if (routerDirection === 'back') { | ||
return nav.pop({ skipIfBusy: true }); | ||
} | ||
} | ||
return Promise.resolve(false); | ||
}; |
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,37 @@ | ||
import { Component, ComponentInterface, Element, Host, Prop, h } from '@stencil/core'; | ||
|
||
import { ComponentProps, NavComponent, RouterDirection } from '../../interface'; | ||
|
||
import { navLink } from './nav-link-utils'; | ||
|
||
@Component({ | ||
tag: 'ion-nav-link' | ||
}) | ||
export class NavLink implements ComponentInterface { | ||
@Element() el!: HTMLElement; | ||
|
||
/** | ||
* Component to navigate to. Only used if the `routerDirection` is `"forward"` or `"root"`. | ||
*/ | ||
@Prop() component?: NavComponent; | ||
|
||
/** | ||
* Data you want to pass to the component as props. Only used if the `"routerDirection"` is `"forward"` or `"root"`. | ||
*/ | ||
@Prop() componentProps?: ComponentProps; | ||
|
||
/** | ||
* The transition direction when navigating to another page. | ||
*/ | ||
@Prop() routerDirection: RouterDirection = 'forward'; | ||
|
||
private onClick = () => { | ||
return navLink(this.el, this.routerDirection, this.component, this.componentProps); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Host onClick={this.onClick}></Host> | ||
); | ||
} | ||
} |
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,22 @@ | ||
# ion-nav-link | ||
|
||
A navigation link is used to navigate to a specified component. The component can be navigated to by going `forward`, `back` or as a `root` component. | ||
|
||
It is the element form of calling the `push()`, `pop()`, and `setRoot()` methods on the navigation controller. | ||
|
||
|
||
<!-- Auto Generated Below --> | ||
|
||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| ----------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ----------- | | ||
| `component` | `component` | Component to navigate to. Only used if the `routerDirection` is `"forward"` or `"root"`. | `Function \| HTMLElement \| ViewController \| null \| string \| undefined` | `undefined` | | ||
| `componentProps` | -- | Data you want to pass to the component as props. Only used if the `"routerDirection"` is `"forward"` or `"root"`. | `undefined \| { [key: string]: any; }` | `undefined` | | ||
| `routerDirection` | `router-direction` | The transition direction when navigating to another page. | `"back" \| "forward" \| "root"` | `'forward'` | | ||
|
||
|
||
---------------------------------------------- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
Oops, something went wrong.