Repository navigation
Expand file tree
/
Copy pathTeamMember.tsx
More file actions
166 lines (161 loc) · 5.54 KB
/
Copy pathTeamMember.tsx
File metadata and controls
166 lines (161 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
import * as React from 'react';
import Image from 'next/legacy/image';
import {IconTwitter} from '../Icon/IconTwitter';
import {IconThreads} from '../Icon/IconThreads';
import {IconBsky} from '../Icon/IconBsky';
import {IconGitHub} from '../Icon/IconGitHub';
import {ExternalLink} from '../ExternalLink';
import {H3} from './Heading';
import {IconLink} from 'components/Icon/IconLink';
interface TeamMemberProps {
name: string;
title: string;
permalink: string;
children?: React.ReactNode;
photo: string;
twitter?: string;
threads?: string;
bsky?: string;
github?: string;
personal?: string;
// Comma-separated list of working groups. Suffix a group with `*` to mark
// that the member represents it on the Leadership Council, e.g. "Fiber*, DOM".
group?: string;
}
function GroupBadges({group}: {group: string}) {
const groups = group
.split(',')
.map((g) => g.trim())
.filter(Boolean);
if (groups.length === 0) {
return null;
}
return (
<div className="flex flex-row flex-wrap gap-2 my-3">
{groups.map((g) => {
const isLead = g.endsWith('*');
const label = isLead ? g.slice(0, -1).trim() : g;
return (
<span
key={g}
className="inline-flex items-center rounded-full bg-blue-10 dark:bg-gray-80 text-link dark:text-link-dark px-3 py-1 text-sm font-medium whitespace-nowrap">
{label}
{isLead && (
<span
className="ps-1 text-yellow-50"
aria-label="Leadership Council"
title="Leadership Council">
★
</span>
)}
</span>
);
})}
</div>
);
}
// TODO: good alt text for images
export function TeamMember({
name,
title,
permalink,
children,
photo,
github,
twitter,
threads,
bsky,
personal,
group,
}: TeamMemberProps) {
if (name == null || title == null || permalink == null) {
const identifier = name ?? title ?? permalink ?? 'unknown';
throw new Error(`Expected name, title, and permalink for ${identifier}`);
}
return (
<div className="pb-6 sm:pb-10">
<div className="flex flex-col sm:flex-row height-auto">
<div
className="hidden sm:block basis-2/5 rounded overflow-hidden relative"
style={{width: 300, height: 250}}>
<Image src={photo} layout="fill" objectFit="cover" alt={name} />
</div>
<div
style={{minHeight: 300}}
className="block w-full sm:hidden flex-grow basis-2/5 rounded overflow-hidden relative">
<Image src={photo} layout="fill" objectFit="cover" alt={name} />
</div>
<div className="ps-0 sm:ps-6 basis-3/5 items-start">
<H3 className="mb-1 sm:my-0" id={permalink}>
{name}
</H3>
{title && <div>{title}</div>}
{group && <GroupBadges group={group} />}
{children}
<div className="sm:flex sm:flex-row flex-wrap text-secondary dark:text-secondary-dark">
{twitter && (
<div className="me-4">
<ExternalLink
aria-label={`${name} on Twitter`}
href={`https://twitter.com/${twitter}`}
className="hover:text-primary hover:underline dark:text-primary-dark flex flex-row items-center">
<IconTwitter className="pe-1" aria-hidden="true" />
{twitter}
</ExternalLink>
</div>
)}
{threads && (
<div className="me-4">
<ExternalLink
aria-label={`${name} on Threads`}
href={`https://threads.net/${threads}`}
className="hover:text-primary hover:underline dark:text-primary-dark flex flex-row items-center">
<IconThreads className="pe-1" aria-hidden="true" />
{threads}
</ExternalLink>
</div>
)}
{bsky && (
<div className="me-4">
<ExternalLink
aria-label={`${name} on Bluesky`}
href={`https://bsky.app/profile/${bsky}`}
className="hover:text-primary hover:underline dark:text-primary-dark flex flex-row items-center">
<IconBsky className="pe-1" aria-hidden="true" />
{bsky}
</ExternalLink>
</div>
)}
{github && (
<div className="me-4">
<ExternalLink
aria-label={`${name} on GitHub`}
href={`https://github.com/${github}`}
className="hover:text-primary hover:underline dark:text-primary-dark flex flex-row items-center">
<IconGitHub className="pe-1" aria-hidden="true" /> {github}
</ExternalLink>
</div>
)}
{personal && (
<ExternalLink
aria-label={`${name}'s personal website`}
href={`https://${personal}`}
className="hover:text-primary hover:underline dark:text-primary-dark flex flex-row items-center">
<IconLink className="pe-1" aria-hidden="true" /> {personal}
</ExternalLink>
)}
</div>
</div>
</div>
</div>
);
}