-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding a resolveRouteSegments function (#148)
* Adding a resolveRouteSegments function * Added changeset files * Fix CI * Fix CI * Update Github action to actions/checkout@v3
- Loading branch information
1 parent
905c71c
commit a448347
Showing
54 changed files
with
3,089 additions
and
3,447 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,5 @@ | ||
--- | ||
"@squide/react-router": minor | ||
--- | ||
|
||
Added a `resolveRouteSegments` function. |
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,5 @@ | ||
--- | ||
"@squide/firefly": patch | ||
--- | ||
|
||
Internal changes. |
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,5 @@ | ||
--- | ||
"@squide/webpack-configs": patch | ||
--- | ||
|
||
Removed `@squide/webpack-module-federation` dependency. |
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,5 @@ | ||
--- | ||
"@squide/firefly-configs": patch | ||
--- | ||
|
||
Internal changes. |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
--- | ||
order: 90 | ||
toc: | ||
depth: 2-3 | ||
--- | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
priority: 100 | ||
order: 100 | ||
toc: | ||
depth: 2-3 | ||
--- | ||
|
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,33 @@ | ||
--- | ||
order: -200 | ||
toc: | ||
depth: 2-3 | ||
--- | ||
|
||
# isNavigationLink | ||
|
||
Indicate whether or not a navigation item should be rendered as a link. This utility is particularly handy when rendering a menu [with nested items](../runtime/runtime-class.md#register-nested-navigation-items). | ||
|
||
## Reference | ||
|
||
```ts | ||
const isLink = isNavigationLink(item) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `item`: A navigation item rendering props. | ||
|
||
### Returns | ||
|
||
A boolean value indicating whether or not the navigation item should be rendered as a link. | ||
|
||
## Usage | ||
|
||
```ts | ||
import { isNavigationLink, type RenderItemFunction } from "@squide/firefly"; | ||
|
||
const renderItem: RenderItemFunction = item => { | ||
return isNavigationLink(item) ? renderLinkItem(item) : renderSectionItem(item); | ||
}; | ||
``` |
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,40 @@ | ||
--- | ||
order: 60 | ||
toc: | ||
depth: 2-3 | ||
--- | ||
|
||
# resolveRouteSegments | ||
|
||
Replace a route segments (paths starting with `:`) with the provided values. For a value to be applied to a segment, the value `key` must match the segment minus the `:`. | ||
|
||
## Reference | ||
|
||
```ts | ||
const resolvedRoute = resolveRouteSegments("/page/:arg1", { arg1: "value-1" }) | ||
``` | ||
|
||
### Parameters | ||
|
||
- `to`: A route with segments. | ||
- `values`: An object literal of segment values. | ||
|
||
### Returns | ||
|
||
The resolved route. | ||
|
||
## Usage | ||
|
||
```ts | ||
import { resolveRouteSegments, type NavigationLinkRenderProps } from "@squide/firefly"; | ||
|
||
function renderLinkItem({ label, linkProps: { to, ...linkProps } }: NavigationLinkRenderProps, index: number, level: number) { | ||
return ( | ||
<li key={`${level}-${index}`}> | ||
<Link to={resolveRouteSegments(to as string, { arg1: "value-1" })} {...linkProps}> | ||
{label} | ||
</Link> | ||
</li> | ||
); | ||
} | ||
``` |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
--- | ||
order: 70 | ||
toc: | ||
depth: 2-3 | ||
--- | ||
|
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
Oops, something went wrong.