Skip to content

Commit e3c566a

Browse files
committed
doc(elements): Improve documentation of pos-rich-link and explain that custom content can be rendered.
1 parent 6ed7054 commit e3c566a

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

docs/elements/components/pos-rich-link/readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
<!-- Auto Generated Below -->
66

77

8+
## Overview
9+
10+
Renders a link to a resource. The resource is either identified by the given `uri` property, by the resource in
11+
context (given by a surrounding `pos-resource` element), or by following a relation from or to the resource in
12+
context (`rel` / `rev` attributes).
13+
14+
By default, it renders a label and description of the resource. You can override this by providing custom content as
15+
child elements.
16+
17+
**Important:** This component will fire a `pod-os:link` event when clicked instead of doing a normal browser navigation.
18+
To actually navigate to the link target, you have to listen to the event and then perform the navigation
19+
programmatically. Other link-related behaviours (like open in a new tab and copy link target) are working normally.
20+
This is to support client-side navigation.
21+
822
## Properties
923

1024
| Property | Attribute | Description | Type | Default |

elements/src/components.d.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ export namespace Components {
246246
}
247247
interface PosReverseRelations {
248248
}
249+
/**
250+
* Renders a link to a resource. The resource is either identified by the given `uri` property, by the resource in
251+
* context (given by a surrounding `pos-resource` element), or by following a relation from or to the resource in
252+
* context (`rel` / `rev` attributes).
253+
* By default, it renders a label and description of the resource. You can override this by providing custom content as
254+
* child elements.
255+
* **Important:** This component will fire a `pod-os:link` event when clicked instead of doing a normal browser navigation.
256+
* To actually navigate to the link target, you have to listen to the event and then perform the navigation
257+
* programmatically. Other link-related behaviours (like open in a new tab and copy link target) are working normally.
258+
* This is to support client-side navigation.
259+
*/
249260
interface PosRichLink {
250261
/**
251262
* Link will be obtained by following the predicate with this URI forward from a resource
@@ -1080,6 +1091,17 @@ declare global {
10801091
"pod-os:resource": any;
10811092
"pod-os:error": any;
10821093
}
1094+
/**
1095+
* Renders a link to a resource. The resource is either identified by the given `uri` property, by the resource in
1096+
* context (given by a surrounding `pos-resource` element), or by following a relation from or to the resource in
1097+
* context (`rel` / `rev` attributes).
1098+
* By default, it renders a label and description of the resource. You can override this by providing custom content as
1099+
* child elements.
1100+
* **Important:** This component will fire a `pod-os:link` event when clicked instead of doing a normal browser navigation.
1101+
* To actually navigate to the link target, you have to listen to the event and then perform the navigation
1102+
* programmatically. Other link-related behaviours (like open in a new tab and copy link target) are working normally.
1103+
* This is to support client-side navigation.
1104+
*/
10831105
interface HTMLPosRichLinkElement extends Components.PosRichLink, HTMLStencilElement {
10841106
addEventListener<K extends keyof HTMLPosRichLinkElementEventMap>(type: K, listener: (this: HTMLPosRichLinkElement, ev: PosRichLinkCustomEvent<HTMLPosRichLinkElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
10851107
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
@@ -1661,6 +1683,17 @@ declare namespace LocalJSX {
16611683
interface PosReverseRelations {
16621684
"onPod-os:resource"?: (event: PosReverseRelationsCustomEvent<any>) => void;
16631685
}
1686+
/**
1687+
* Renders a link to a resource. The resource is either identified by the given `uri` property, by the resource in
1688+
* context (given by a surrounding `pos-resource` element), or by following a relation from or to the resource in
1689+
* context (`rel` / `rev` attributes).
1690+
* By default, it renders a label and description of the resource. You can override this by providing custom content as
1691+
* child elements.
1692+
* **Important:** This component will fire a `pod-os:link` event when clicked instead of doing a normal browser navigation.
1693+
* To actually navigate to the link target, you have to listen to the event and then perform the navigation
1694+
* programmatically. Other link-related behaviours (like open in a new tab and copy link target) are working normally.
1695+
* This is to support client-side navigation.
1696+
*/
16641697
interface PosRichLink {
16651698
"onPod-os:error"?: (event: PosRichLinkCustomEvent<any>) => void;
16661699
"onPod-os:link"?: (event: PosRichLinkCustomEvent<any>) => void;
@@ -2010,6 +2043,17 @@ declare module "@stencil/core" {
20102043
"pos-relations": LocalJSX.IntrinsicElements["pos-relations"] & JSXBase.HTMLAttributes<HTMLPosRelationsElement>;
20112044
"pos-resource": LocalJSX.IntrinsicElements["pos-resource"] & JSXBase.HTMLAttributes<HTMLPosResourceElement>;
20122045
"pos-reverse-relations": LocalJSX.IntrinsicElements["pos-reverse-relations"] & JSXBase.HTMLAttributes<HTMLPosReverseRelationsElement>;
2046+
/**
2047+
* Renders a link to a resource. The resource is either identified by the given `uri` property, by the resource in
2048+
* context (given by a surrounding `pos-resource` element), or by following a relation from or to the resource in
2049+
* context (`rel` / `rev` attributes).
2050+
* By default, it renders a label and description of the resource. You can override this by providing custom content as
2051+
* child elements.
2052+
* **Important:** This component will fire a `pod-os:link` event when clicked instead of doing a normal browser navigation.
2053+
* To actually navigate to the link target, you have to listen to the event and then perform the navigation
2054+
* programmatically. Other link-related behaviours (like open in a new tab and copy link target) are working normally.
2055+
* This is to support client-side navigation.
2056+
*/
20132057
"pos-rich-link": LocalJSX.IntrinsicElements["pos-rich-link"] & JSXBase.HTMLAttributes<HTMLPosRichLinkElement>;
20142058
/**
20152059
* The responsibility of pos-router is to handle the `uri` query param, that specifies the URI of the resource that is currently opened.

elements/src/components/pos-rich-link/pos-rich-link.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ import { Relation, Thing } from '@pod-os/core';
22
import { Component, Element, Event, EventEmitter, h, Prop, State } from '@stencil/core';
33
import { ResourceAware, ResourceEventEmitter, subscribeResource } from '../events/ResourceAware';
44

5+
/**
6+
* Renders a link to a resource. The resource is either identified by the given `uri` property, by the resource in
7+
* context (given by a surrounding `pos-resource` element), or by following a relation from or to the resource in
8+
* context (`rel` / `rev` attributes).
9+
*
10+
* By default, it renders a label and description of the resource. You can override this by providing custom content as
11+
* child elements.
12+
*
13+
* **Important:** This component will fire a `pod-os:link` event when clicked instead of doing a normal browser navigation.
14+
* To actually navigate to the link target, you have to listen to the event and then perform the navigation
15+
* programmatically. Other link-related behaviours (like open in a new tab and copy link target) are working normally.
16+
* This is to support client-side navigation.
17+
*/
518
@Component({
619
tag: 'pos-rich-link',
720
shadow: true,

0 commit comments

Comments
 (0)