aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/licenses.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/licenses.tsx')
-rw-r--r--src/components/licenses.tsx92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/components/licenses.tsx b/src/components/licenses.tsx
new file mode 100644
index 0000000..85b0cb2
--- /dev/null
+++ b/src/components/licenses.tsx
@@ -0,0 +1,92 @@
1/*
2 * SPDX-FileCopyrightText: 2024 Kristóf Marussy
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7import Link, { type Props as LinkProps } from '@docusaurus/Link';
8import { Certificate, Lock } from '@phosphor-icons/react';
9
10import { CreativeCommonsIcon } from '@site/src/components/icons';
11
12import styles from './licenses.module.css';
13
14export type LicenseLinkProps = LinkProps & { label?: string };
15
16export function LicenseLink({ children, label, ...props }: LicenseLinkProps) {
17 return (
18 <Link className={styles.link} {...props}>
19 <Certificate weight="bold" aria-hidden="true" className={styles.icon} />
20 <span className="sr-only">{label ?? 'License'}: </span>
21 {children}
22 </Link>
23 );
24}
25
26export function MITLicenseLink() {
27 return <LicenseLink to="https://spdx.org/licenses/MIT.html">MIT</LicenseLink>;
28}
29
30export function CCLicenseLink({ children, label, ...props }: LicenseLinkProps) {
31 return (
32 <Link className={styles.link} {...props}>
33 <CreativeCommonsIcon className={styles.icon} hidden />
34 <span className="sr-only">{label ?? 'Creative Commons license'}: </span>
35 {children}
36 </Link>
37 );
38}
39
40export function CCBYLicenseLink() {
41 return (
42 <CCLicenseLink to="https://creativecommons.org/licenses/by/4.0/">
43 CC-BY-4.0
44 </CCLicenseLink>
45 );
46}
47
48export function ClosedAccessLink({
49 children,
50 label,
51 ...props
52}: LicenseLinkProps) {
53 return (
54 <Link className={styles.link} {...props}>
55 <Lock weight="bold" aria-hidden="true" className={styles.icon} />
56 <span className="sr-only">{label ?? 'Closed access'}: </span>
57 {children}
58 </Link>
59 );
60}
61
62export type SpanProps = React.DetailedHTMLProps<
63 React.HTMLAttributes<HTMLSpanElement>,
64 HTMLSpanElement
65>;
66
67export function LicenseText({ children, ...props }: SpanProps) {
68 return (
69 <span className={styles.text} {...props}>
70 <Certificate weight="bold" aria-hidden="true" className={styles.icon} />
71 {children}
72 </span>
73 );
74}
75
76export function CCLicenseText({ children, ...props }: SpanProps) {
77 return (
78 <span className={styles.text} {...props}>
79 <CreativeCommonsIcon className={styles.icon} hidden />
80 {children}
81 </span>
82 );
83}
84
85export function ClosedAccessText({ children, ...props }: SpanProps) {
86 return (
87 <span className={styles.text} {...props}>
88 <Lock weight="bold" aria-hidden="true" className={styles.icon} />
89 {children}
90 </span>
91 );
92}