diff options
Diffstat (limited to 'src/components/licenses.tsx')
-rw-r--r-- | src/components/licenses.tsx | 92 |
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 | |||
7 | import Link, { type Props as LinkProps } from '@docusaurus/Link'; | ||
8 | import { Certificate, Lock } from '@phosphor-icons/react'; | ||
9 | |||
10 | import { CreativeCommonsIcon } from '@site/src/components/icons'; | ||
11 | |||
12 | import styles from './licenses.module.css'; | ||
13 | |||
14 | export type LicenseLinkProps = LinkProps & { label?: string }; | ||
15 | |||
16 | export 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 | |||
26 | export function MITLicenseLink() { | ||
27 | return <LicenseLink to="https://spdx.org/licenses/MIT.html">MIT</LicenseLink>; | ||
28 | } | ||
29 | |||
30 | export 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 | |||
40 | export function CCBYLicenseLink() { | ||
41 | return ( | ||
42 | <CCLicenseLink to="https://creativecommons.org/licenses/by/4.0/"> | ||
43 | CC-BY-4.0 | ||
44 | </CCLicenseLink> | ||
45 | ); | ||
46 | } | ||
47 | |||
48 | export 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 | |||
62 | export type SpanProps = React.DetailedHTMLProps< | ||
63 | React.HTMLAttributes<HTMLSpanElement>, | ||
64 | HTMLSpanElement | ||
65 | >; | ||
66 | |||
67 | export 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 | |||
76 | export 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 | |||
85 | export 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 | } | ||