|
@@ -0,0 +1,171 @@
|
|
|
|
|
+import { codeToHtml } from "shiki";
|
|
|
|
|
+import { CodeTabs } from "./code-tabs";
|
|
|
|
|
+
|
|
|
|
|
+const vercelDarkTheme = {
|
|
|
|
|
+ name: "vercel-dark",
|
|
|
|
|
+ type: "dark" as const,
|
|
|
|
|
+ colors: {
|
|
|
|
|
+ "editor.background": "transparent",
|
|
|
|
|
+ "editor.foreground": "#EDEDED",
|
|
|
|
|
+ },
|
|
|
|
|
+ settings: [
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["comment", "punctuation.definition.comment"],
|
|
|
|
|
+ settings: { foreground: "#666666" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["string", "string.quoted", "string.template"],
|
|
|
|
|
+ settings: { foreground: "#50E3C2" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: [
|
|
|
|
|
+ "constant.numeric",
|
|
|
|
|
+ "constant.language.boolean",
|
|
|
|
|
+ "constant.language.null",
|
|
|
|
|
+ ],
|
|
|
|
|
+ settings: { foreground: "#50E3C2" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["keyword", "storage.type", "storage.modifier"],
|
|
|
|
|
+ settings: { foreground: "#FF0080" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["keyword.operator", "keyword.control"],
|
|
|
|
|
+ settings: { foreground: "#FF0080" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["entity.name.function", "support.function", "meta.function-call"],
|
|
|
|
|
+ settings: { foreground: "#7928CA" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["variable", "variable.other", "variable.parameter"],
|
|
|
|
|
+ settings: { foreground: "#EDEDED" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["entity.name.tag", "support.class.component", "entity.name.type"],
|
|
|
|
|
+ settings: { foreground: "#FF0080" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["punctuation", "meta.brace", "meta.bracket"],
|
|
|
|
|
+ settings: { foreground: "#888888" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: [
|
|
|
|
|
+ "support.type.property-name",
|
|
|
|
|
+ "entity.name.tag.json",
|
|
|
|
|
+ "meta.object-literal.key",
|
|
|
|
|
+ ],
|
|
|
|
|
+ settings: { foreground: "#EDEDED" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["entity.other.attribute-name"],
|
|
|
|
|
+ settings: { foreground: "#50E3C2" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["support.type.primitive", "entity.name.type.primitive"],
|
|
|
|
|
+ settings: { foreground: "#50E3C2" },
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const vercelLightTheme = {
|
|
|
|
|
+ name: "vercel-light",
|
|
|
|
|
+ type: "light" as const,
|
|
|
|
|
+ colors: {
|
|
|
|
|
+ "editor.background": "transparent",
|
|
|
|
|
+ "editor.foreground": "#171717",
|
|
|
|
|
+ },
|
|
|
|
|
+ settings: [
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["comment", "punctuation.definition.comment"],
|
|
|
|
|
+ settings: { foreground: "#6b7280" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["string", "string.quoted", "string.template"],
|
|
|
|
|
+ settings: { foreground: "#067a6e" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: [
|
|
|
|
|
+ "constant.numeric",
|
|
|
|
|
+ "constant.language.boolean",
|
|
|
|
|
+ "constant.language.null",
|
|
|
|
|
+ ],
|
|
|
|
|
+ settings: { foreground: "#067a6e" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["keyword", "storage.type", "storage.modifier"],
|
|
|
|
|
+ settings: { foreground: "#d6409f" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["keyword.operator", "keyword.control"],
|
|
|
|
|
+ settings: { foreground: "#d6409f" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["entity.name.function", "support.function", "meta.function-call"],
|
|
|
|
|
+ settings: { foreground: "#6e56cf" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["variable", "variable.other", "variable.parameter"],
|
|
|
|
|
+ settings: { foreground: "#171717" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["entity.name.tag", "support.class.component", "entity.name.type"],
|
|
|
|
|
+ settings: { foreground: "#d6409f" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["punctuation", "meta.brace", "meta.bracket"],
|
|
|
|
|
+ settings: { foreground: "#6b7280" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: [
|
|
|
|
|
+ "support.type.property-name",
|
|
|
|
|
+ "entity.name.tag.json",
|
|
|
|
|
+ "meta.object-literal.key",
|
|
|
|
|
+ ],
|
|
|
|
|
+ settings: { foreground: "#171717" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["entity.other.attribute-name"],
|
|
|
|
|
+ settings: { foreground: "#067a6e" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ scope: ["support.type.primitive", "entity.name.type.primitive"],
|
|
|
|
|
+ settings: { foreground: "#067a6e" },
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+interface PackageInstallProps {
|
|
|
|
|
+ packages: string;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const packageManagers = [
|
|
|
|
|
+ { label: "npm", value: "npm", command: "npm install" },
|
|
|
|
|
+ { label: "pnpm", value: "pnpm", command: "pnpm add" },
|
|
|
|
|
+ { label: "yarn", value: "yarn", command: "yarn add" },
|
|
|
|
|
+ { label: "bun", value: "bun", command: "bun add" },
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
|
|
+export async function PackageInstall({ packages }: PackageInstallProps) {
|
|
|
|
|
+ const tabs = await Promise.all(
|
|
|
|
|
+ packageManagers.map(async (pm) => {
|
|
|
|
|
+ const code = `${pm.command} ${packages}`;
|
|
|
|
|
+ const html = await codeToHtml(code, {
|
|
|
|
|
+ lang: "bash",
|
|
|
|
|
+ themes: {
|
|
|
|
|
+ light: vercelLightTheme,
|
|
|
|
|
+ dark: vercelDarkTheme,
|
|
|
|
|
+ },
|
|
|
|
|
+ defaultColor: false,
|
|
|
|
|
+ });
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: pm.label,
|
|
|
|
|
+ value: pm.value,
|
|
|
|
|
+ code,
|
|
|
|
|
+ html,
|
|
|
|
|
+ };
|
|
|
|
|
+ }),
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ return <CodeTabs tabs={tabs} />;
|
|
|
|
|
+}
|