preact-components/source/links/privacy-link.ts

28 lines
733 B
TypeScript
Raw Normal View History

2022-03-16 00:06:35 +00:00
import {html} from 'htm/preact';
import {Component, ComponentChildren, VNode} from 'preact';
/**
* Component properties for {@linkcode PrivacyLink}.
*/
export type PrivacyLinkProps = {
attributes: Record<string, unknown>;
2022-03-16 00:06:35 +00:00
children: ComponentChildren;
};
/**
* A simple {@linkcode https://developer.mozilla.org/docs/Web/HTML/Element/a <a>}
* element wrapper with `rel="noopener noreferrer"` and `target="_blank"`
* already set.
*/
export class PrivacyLink extends Component<PrivacyLinkProps> {
render(): VNode {
const props: Record<string, string> = {
...this.props.attributes,
2022-03-16 00:06:35 +00:00
rel: 'noopener noreferrer',
target: '_blank',
};
return html`<a ...${props}>${this.props.children}</a>`;
}
}