-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs mention routers for frameworks (#2378)
* docs: usage of router links for frameworks * fix: route is defined in the wrong place
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Router usage | ||
|
||
> **Note:** At the moment, router links can only be used within the **DBNavigationItem** component! | ||
Unfortunately, the **DBLink** and **DBButton** components do not support router links. Explanation: Router links are usually rendered as anchor tags, which are not permitted within anchor or button tags. | ||
|
||
## Supported routers | ||
|
||
The following standard routers have been successfully implemented in the corresponding frameworks (Angular, React, Vue). Other routers should work in the same way, but have not yet been tested. | ||
|
||
- [Angular router](https://angular.io/api/router) | ||
- [React router](https://reactrouter.com/en/main) | ||
- [Vue router](https://v3.router.vuejs.org/) | ||
|
||
The routers are installed and used in accordance with the official docs: | ||
|
||
## How to use | ||
|
||
To create a DB Brand styled router link, place the corresponding router link component in the default slot of **DBNavigationItem**. | ||
|
||
[How to use DBNavigationItem](https://db-ui.github.io/mono/review/main/components/navigation-item/overview) | ||
|
||
**Angular** | ||
|
||
`RouterLink` must be imported from the `@angular/router` package. | ||
|
||
```html | ||
<db-navigation-item> | ||
<a [routerLink]="link.path"> {{ link.label }} </a> | ||
</db-navigation-item> | ||
``` | ||
|
||
**React** | ||
|
||
`Link` must be imported from the `react-router-dom` package. | ||
|
||
```html | ||
<DBNavigationItem> | ||
<Link to={link.path}> | ||
{link.label} | ||
</Link> | ||
</DBNavigationItem> | ||
``` | ||
|
||
**Vue** | ||
|
||
`RouterLink` can be used directly, as it is available globally. | ||
|
||
```html | ||
<DBNavigationItem> | ||
<RouterLink :to="link.path"> {{ link.label }} </RouterLink> | ||
</DBNavigationItem> | ||
``` |
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,6 @@ | ||
import DefaultPage from "../../../components/default-page"; | ||
import RouterUsage from "../../../../../packages/components/docs/router-usage.md"; | ||
|
||
<RouterUsage /> | ||
|
||
export default ({ children }) => <DefaultPage>{children}</DefaultPage>; |