-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathplatformIcon.tsx
More file actions
370 lines (353 loc) · 9.75 KB
/
platformIcon.tsx
File metadata and controls
370 lines (353 loc) · 9.75 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
import * as React from 'react';
import { icons, iconsLg } from './icons.generated';
export const PLATFORM_TO_ICON = {
amazon: "amazon",
amd: "amd",
android: "android",
"android-phone": "android-phone",
"android-tablet": "android-tablet",
anthropic: "anthropic",
"anthropic-claude": "anthropic-claude",
apple: "apple",
"apple-ipad": "apple-ipad",
"apple-iphone": "apple-iphone",
"apple-tv": "apple-tv",
"apple-watch": "apple-watch",
arm: "arm",
bazzite: "bazzite",
bun: "bun",
capacitor: "capacitor",
chrome: "chrome",
chromium: "chromium",
clojure: "clojure",
cloudflare: "cloudflare",
cocoa: "apple",
"cocoa-objc": "apple",
"cocoa-swift": "swift",
cohere: "cohere",
convex: "convex",
cordova: "cordova",
cpp: "cpp",
cryengine: "cryengine",
crystal: "crystal",
css: "css",
csharp: "csharp",
"csharp-aspnetcore": "csharp",
dart: "dart",
deepseek: "deepseek",
default: "default",
deno: "deno",
dotnet: "dotnet",
"dotnet-aspnetcore": "dotnet",
"dotnet-aspnet": "dotnet",
"dotnet-awslambda": "awslambda",
"dotnet-blazor": "blazor",
"dotnet-csharp": "csharp",
"dotnet-gcpfunctions": "gcp-functions",
"dotnet-maui": "maui",
"dotnet-uno": "uno",
"dotnet-xamarin": "xamarin",
dotnetcore: "dotnetcore",
dotnetfx: "dotnetfx",
dotnetframework: "dotnetframework",
edge: "edge",
"edge-legacy": "edge-legacy",
electron: "electron",
elixir: "elixir",
fastmcp: "fastmcp",
firebase: "firebase",
firefox: "firefox",
flutter: "flutter",
font: "font",
fsharp: "fsharp",
gemini: "gemini",
git: "git",
go: "go",
"go-echo": "echo",
"go-fasthttp": "fasthttp",
"go-fiber": "fiber",
"go-gin": "gin",
"go-iris": "iris",
"go-martini": "martini",
"go-negroni": "go",
godot: "godot",
google: "google",
grok: "grok",
groq: "groq",
huggingface: "huggingface",
"internet-explorer": "internet-explorer",
java: "java",
"java-appengine": "app-engine",
"java-android": "android",
"java-log4j": "java",
"java-log4j2": "java",
"java-logback": "logback",
"java-logging": "java",
"java-ray": "ray",
"java-spring": "spring",
"java-spring-boot": "springboot",
javascript: "javascript",
"javascript-alpinejs": "alpinejs",
"javascript-analogjs": "analogjs",
"javascript-angular": "angularjs",
"javascript-angularjs": "angularjs",
"javascript-astro": "astro",
"javascript-awslambda": "awslambda",
"javascript-azurefunctions": "azure-functions",
"javascript-backbone": "backbone",
"javascript-browser": "javascript",
"javascript-capacitor": "capacitor",
"javascript-cloudflare-pages": "cloudflare-pages",
"javascript-cloudflare-workers": "cloudflare-workers",
"javascript-connect": "connect",
"javascript-cordova": "cordova",
"javascript-effect": "effect",
"javascript-electron": "electron",
"javascript-ember": "ember",
"javascript-express": "express",
"javascript-fastify": "fastify",
"javascript-firebase": "firebase",
"javascript-gatsby": "gatsby",
"javascript-gcpfunctions": "gcp-functions",
"javascript-hapi": "hapi",
"javascript-hono": "hono",
"javascript-hydrogen": "hydrogen",
"javascript-ionic": "ionic",
"javascript-koa": "koa",
"javascript-lit": "lit",
"javascript-meteor": "meteor",
"javascript-million": "million",
"javascript-nestjs": "nestjs",
"javascript-nextjs": "nextjs",
"javascript-nitro": "nitro",
"javascript-node": "nodejs",
"javascript-nuxt": "nuxt",
"javascript-opennext": "opennext",
"javascript-qwik": "qwik",
"javascript-react": "react",
"javascript-react-router": "react-router",
"javascript-remix": "remix",
"javascript-serverlesscloud": "serverless",
"javascript-solid": "solid",
"javascript-solidstart": "solidstart",
"javascript-svelte": "svelte",
"javascript-sveltekit": "svelte",
"javascript-tanstackstart-react": "tanstack",
"javascript-vue": "vue",
"javascript-wasm": "wasm",
ionic: "ionic",
kotlin: "kotlin",
"kotlin-android": "android",
langchain: "langchain",
langgraph: "langgraph",
launchdarkly: "launchdarkly",
litellm: "litellm",
linux: "linux",
mastra: "mastra",
mcp: "mcp",
mono: "mono",
motorola: "motorola",
mistral: "mistral",
native: "nativec",
"native-qt": "qt",
nintendo: "nintendo",
"nintendo-switch": "nintendo-switch",
"nintendo-switch-2": "nintendo-switch-2",
node: "nodejs",
nvidia: "nvidia",
openai: "openai",
openfeature: "openfeature",
opera: "opera",
perforce: "perforce",
perl: "perl",
perplexity: "perplexity",
php: "php",
playstation: "playstation",
powershell: "powershell",
"php-laravel": "laravel",
"php-livewire": "livewire",
"php-magento": "magento",
"php-monolog": "php",
"php-symfony2": "symfony",
"php-symfony": "symfony",
"pydantic-ai": "pydantic-ai",
python: "python",
"python-aiohttp": "aiohttp",
"python-airflow": "apache-airflow",
"python-ariadne": "ariadne",
"python-asyncpg": "postgresql",
"python-awslambda": "awslambda",
"python-azurefunctions": "azure-functions",
"python-beam": "apache-beam",
"python-boto3": "aws",
"python-bottle": "bottle",
"python-celery": "celery",
"python-chalice": "chalice",
"python-clickhouse-driver": "clickhouse",
"python-django": "django",
"python-dramatiq": "dramatiq",
"python-falcon": "falcon",
"python-fastapi": "fastapi",
"python-flask": "flask",
"python-gcpfunctions": "gcp-functions",
"python-gnu_backtrace": "gnu",
"python-gql": "graphql",
"python-graphene": "graphene",
"python-grpc": "grpc",
"python-httpx": "httpx",
"python-huey": "huey",
"python-litestar": "litestar",
"python-loguru": "loguru",
"python-pylons": "python",
"python-pymongo": "mongodb",
"python-pyramid": "pyramid",
"python-pythonawslambda": "awslambda",
"python-quart": "quart",
"python-ray": "ray",
"python-redis": "redis",
"python-rq": "redis",
"python-sanic": "sanic",
"python-serverless": "serverless",
"python-starlette": "starlette",
"python-strawberry": "strawberry",
"python-spark": "apache-spark",
"python-sqlalchemy": "sqlalchemy",
"python-tornado": "tornado",
"python-tryton": "tryton",
"python-typer": "typer",
qq: "qq",
qt: "qt",
"react-native": "react-native",
ruby: "ruby",
"ruby-activeadmin": "activeadmin",
"ruby-grape": "grape",
"ruby-hanami": "hanami",
"ruby-padrino": "padrino",
"ruby-rack": "ruby",
"ruby-rails": "rails",
"ruby-sidekiq": "sidekiq",
"ruby-sinatra": "sinatra",
"ruby-trailblazer": "trailblazer",
rust: "rust",
"rust-actix": "actix",
"rust-axum": "tokio",
"rust-tower": "tower",
"rust-tracing": "tracing",
safari: "safari",
samsung: "samsung",
scala: "scala",
steamos: "steamos",
stride3d: "stride3d",
supabase: "supabase",
sql: "sql",
sqlserver: "sqlserver",
swift: "swift",
tauri: "tauri",
ubuntu: "ubuntu",
unity: "unity",
unleash: "unleash",
// This will be deprecated in favor of 'unrealengine'
ue4: "unreal",
unreal: "unreal",
unrealengine: "unreal",
uwp: "windows",
vercel: "vercel",
visualbasic: "visual-basic",
vscode: "vscode",
windows: "windows",
xbox: "xbox",
// Don't add new platforms down here!
// Please add them where they belong alphabetically
} as const;
function normalizePlatform(platform: string): string {
// sentry uses format python-django, but docs uses python.django
// this function normalizes that
const dashedPlatform = platform.replace(".", "-");
// Allow `node` as an alias for `javascript` to ensure backwards compatibility
return dashedPlatform.replace(/^node-/, 'javascript-')
}
function getIcon(platform: string): Platform {
const normalizedPlatform = normalizePlatform(platform) as keyof typeof PLATFORM_TO_ICON;
const icon = PLATFORM_TO_ICON[normalizedPlatform];
if (icon) {
return icon;
}
if (normalizedPlatform.includes("-")) {
return getLanguageIcon(normalizedPlatform);
}
return "default";
}
function getLanguageIcon(platform: string): Platform {
const [language] = normalizePlatform(platform).split("-");
return getIcon(language);
}
type Platform = (typeof PLATFORM_TO_ICON)[keyof typeof PLATFORM_TO_ICON];
type Props = React.HTMLAttributes<HTMLDivElement | HTMLImageElement> & {
platform: string;
size?: string | number;
format?: "sm" | "lg";
radius?: number | null;
withLanguageIcon?: boolean;
languageIconStyles?: React.CSSProperties;
/** Accessible label for the icon. Defaults to the platform name. Pass an empty string to mark the icon as decorative. */
alt?: string;
};
const PlatformIcon = ({
platform,
size = 20,
format = "sm",
radius = 3,
withLanguageIcon,
languageIconStyles = {},
style = {},
alt = platform,
...otherProps
}: Props) => {
const icon = getIcon(platform);
const iconMap = format === "lg" ? iconsLg : icons;
const iconPath = iconMap[icon] ?? iconMap["default"];
const languageIcon = getLanguageIcon(platform);
const languageIconPath = icons[languageIcon] ?? icons["default"];
if (withLanguageIcon && languageIcon !== icon && languageIcon !== "default") {
return (
<div
role="img"
aria-label={alt}
{...otherProps}
style={{ position: "relative", ...style }}
>
<img
src={iconPath}
width={size}
height={size}
alt=""
style={{ borderRadius: `${radius}px` }}
/>
<img
src={languageIconPath}
alt=""
style={{
position: "absolute",
bottom: "-1px",
right: "-1px",
height: "30%",
width: "30%",
borderRadius: "2px",
...languageIconStyles,
}}
/>
</div>
);
}
return (
<img
src={iconPath}
width={size}
height={size}
alt={alt}
{...otherProps}
style={{ borderRadius: `${radius}px`, ...style }}
/>
);
};
export default PlatformIcon;