- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(admin-ui): Export Link component, add docs, update public api
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.1.0-next.4
- v3.1.0-next.3
- v3.1.0-next.2
- v3.1.0-next.1
- v3.1.0-next.0
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v3.0.0-next.0
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.7
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.2.0-next.8
- v2.2.0-next.7
- v2.2.0-next.6
- v2.2.0-next.5
- v2.2.0-next.4
- v2.2.0-next.3
- v2.2.0-next.2
- v2.2.0-next.1
- v2.2.0-next.0
- v2.1.9
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.1.0-next.7
- v2.1.0-next.6
- v2.1.0-next.5
- v2.1.0-next.4
- v2.1.0-next.3
1 parent
83d5756
commit 3e67837
Showing
18 changed files
with
268 additions
and
52 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
18 changes: 10 additions & 8 deletions
18
packages/admin-ui/src/lib/react/src/components/react-route.component.ts
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,26 +1,28 @@ | ||
import { Component, inject, InjectionToken } from '@angular/core'; | ||
import { SharedModule } from '@vendure/admin-ui/core'; | ||
import { ReactComponentHostDirective } from '../react-component-host.directive'; | ||
import { ReactRouteComponentOptions } from '../types'; | ||
|
||
export const ROUTE_COMPONENT_OPTIONS = new InjectionToken<{ | ||
component: any; | ||
title?: string; | ||
props?: Record<string, any>; | ||
}>('ROUTE_COMPONENT_OPTIONS'); | ||
export const ROUTE_COMPONENT_OPTIONS = new InjectionToken<ReactRouteComponentOptions>( | ||
'ROUTE_COMPONENT_OPTIONS', | ||
); | ||
|
||
@Component({ | ||
selector: 'vdr-react-route-component', | ||
template: ` | ||
<vdr-page-header> | ||
<vdr-page-title *ngIf="title" [title]="title"></vdr-page-title> | ||
<vdr-page-title *ngIf="title$ | async as title" [title]="title"></vdr-page-title> | ||
</vdr-page-header> | ||
<vdr-page-body><div [vdrReactComponentHost]="reactComponent" [props]="props"></div></vdr-page-body> | ||
<vdr-page-body | ||
><div [vdrReactComponentHost]="reactComponent" [props]="props" [context]="context"></div | ||
></vdr-page-body> | ||
`, | ||
standalone: true, | ||
imports: [ReactComponentHostDirective, SharedModule], | ||
}) | ||
export class ReactRouteComponent { | ||
protected title = inject(ROUTE_COMPONENT_OPTIONS).title; | ||
protected title$ = inject(ROUTE_COMPONENT_OPTIONS).title$; | ||
protected props = inject(ROUTE_COMPONENT_OPTIONS).props; | ||
protected context = inject(ROUTE_COMPONENT_OPTIONS); | ||
protected reactComponent = inject(ROUTE_COMPONENT_OPTIONS).component; | ||
} |
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
46 changes: 46 additions & 0 deletions
46
packages/admin-ui/src/lib/react/src/hooks/use-page-metadata.ts
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,46 @@ | ||
import { BreadcrumbValue } from '@vendure/admin-ui/core'; | ||
import { useContext } from 'react'; | ||
import { HostedComponentContext } from '../react-component-host.directive'; | ||
import { HostedReactComponentContext, ReactRouteComponentOptions } from '../types'; | ||
|
||
/** | ||
* @description | ||
* Provides functions for setting the current page title and breadcrumb. | ||
* | ||
* @example | ||
* ```ts | ||
* import { usePageMetadata } from '@vendure/admin-ui/react'; | ||
* import { useEffect } from 'react'; | ||
* | ||
* export const MyComponent = () => { | ||
* const { setTitle, setBreadcrumb } = usePageMetadata(); | ||
* useEffect(() => { | ||
* setTitle('My Page'); | ||
* setBreadcrumb([ | ||
* { link: ['./parent'], label: 'Parent Page' }, | ||
* { link: ['./'], label: 'This Page' }, | ||
* ]); | ||
* }, []); | ||
* // ... | ||
* return <div>...</div>; | ||
* } | ||
* ``` | ||
* | ||
* @docsCategory react-hooks | ||
*/ | ||
export function usePageMetadata() { | ||
const context = useContext( | ||
HostedComponentContext, | ||
) as HostedReactComponentContext<ReactRouteComponentOptions>; | ||
const setBreadcrumb = (newValue: BreadcrumbValue) => { | ||
context.breadcrumb$.next(newValue); | ||
}; | ||
const setTitle = (newTitle: string) => { | ||
context.title$.next(newTitle); | ||
}; | ||
|
||
return { | ||
setBreadcrumb, | ||
setTitle, | ||
}; | ||
} |
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.