`;
-export const iconSite = `
`;
+
+export const iconSite = `
`;
+
+export const iconSSR = `
`;
+
export const iconChevronDown = `
`;
+
export const iconLoading = `
`;
+
export const iconPlus = `
`;
+
export const iconGear = `
`;
+
+export const iconModule = `
`;
diff --git a/app/web/src/render/ed/panel/popup/code/name-list.tsx b/app/web/src/render/ed/panel/popup/code/name-list.tsx
index 2807935d..08435ee9 100644
--- a/app/web/src/render/ed/panel/popup/code/name-list.tsx
+++ b/app/web/src/render/ed/panel/popup/code/name-list.tsx
@@ -1,30 +1,65 @@
import { FC, useEffect } from "react";
import { useGlobal, useLocal } from "web-utils";
import { EDGlobal } from "../../../logic/ed-global";
-import { iconPlus, iconSite } from "./icons";
+import { iconModule, iconPlus, iconSSR, iconSite } from "./icons";
-export const CodeNameList: FC<{}> = ({}) => {
- const p = useGlobal(EDGlobal, "EDITOR");
- const local = useLocal(
- {
- list: [] as { name: string; id: string }[],
- },
- async () => {
- local.list = await api.code(p.site.id, "list");
- local.render();
- }
+const codeName = {
+ loading: false,
+ list: [] as { name: string; id: string }[],
+};
+
+export const CodeNameItem: FC<{ name: string }> = ({ name }) => {
+ let className = "";
+ if (name === "site") {
+ className = css`
+ border-left: 4px solid #34a853;
+ margin-left: -4px;
+ height: 18px;
+ `;
+ }
+ if (name === "SSR") {
+ className = css`
+ border-left: 4px solid #4dcfe0;
+ margin-left: -4px;
+ height: 18px;
+ `;
+ }
+ return (
+ <>
+
+
+
{name === "site" ? "Main Site" : name}
+ >
);
+};
+export const CodeNameList: FC<{
+ onPick: (mod: { name: string; id: string }) => void;
+}> = ({ onPick }) => {
+ const p = useGlobal(EDGlobal, "EDITOR");
+ const local = useLocal({}, async () => {
+ codeName.loading = true;
+ codeName.list = await api.code(p.site.id, "list");
+ codeName.loading = false;
+ local.render();
+ });
return (
<>
- {local.list.map((e) => (
+ {codeName.list.length === 0 && (
+
+ Loading...
+
+ )}
+ {codeName.list.map((e) => (
{
+ onPick(e);
+ }}
>
-
- {e.name}
+
))}
@@ -45,6 +80,10 @@ export const NameIcon: FC<{ name: string; className?: string }> = ({
let html = "";
if (n === "site") {
html = iconSite;
+ } else if (n === "ssr") {
+ html = iconSSR;
+ } else {
+ html = iconModule;
}
return (