diff --git a/app/srv/api/code.ts b/app/srv/api/code.ts index 74f74d47..22548daa 100644 --- a/app/srv/api/code.ts +++ b/app/srv/api/code.ts @@ -4,6 +4,13 @@ export const _ = { url: "/code/:site_id/:action", async api(site_id: string, action: "list") { const { req, res } = apiContext(this); + + if (action === "list") { + return (await db.code.findMany({ where: { id_site: site_id } })).map( + (e) => ({ name: e.name, id: e.id }) + ); + } + return "This is code.ts"; }, }; diff --git a/app/web/src/render/ed/panel/popup/code/code.tsx b/app/web/src/render/ed/panel/popup/code/code.tsx index 1f6efc2c..729da757 100644 --- a/app/web/src/render/ed/panel/popup/code/code.tsx +++ b/app/web/src/render/ed/panel/popup/code/code.tsx @@ -7,7 +7,7 @@ import { Tooltip } from "../../../../../utils/ui/tooltip"; import { EDGlobal } from "../../../logic/ed-global"; import { Popover } from "../../../../../utils/ui/popover"; import { iconChevronDown, iconGear, iconLoading, iconLog } from "./icons"; -import { CodeNameList } from "./name-list"; +import { CodeNameList, NameIcon } from "./name-list"; export const EdPopCode = () => { const p = useGlobal(EDGlobal, "EDITOR"); @@ -67,8 +67,9 @@ export const EdPopCode = () => { local.render(); }} > -
- {p.ui.popup.code.name} +
+ +
{p.ui.popup.code.name}
`; +export const iconSite = ``; export const iconChevronDown = ``; export const iconLoading = ``; - +export const iconPlus = ``; export const iconGear = ``; 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 0f25cc67..2807935d 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,12 +1,13 @@ import { FC, useEffect } from "react"; import { useGlobal, useLocal } from "web-utils"; import { EDGlobal } from "../../../logic/ed-global"; +import { iconPlus, iconSite } from "./icons"; export const CodeNameList: FC<{}> = ({}) => { const p = useGlobal(EDGlobal, "EDITOR"); const local = useLocal( { - list: [], + list: [] as { name: string; id: string }[], }, async () => { local.list = await api.code(p.site.id, "list"); @@ -16,10 +17,40 @@ export const CodeNameList: FC<{}> = ({}) => { return ( <> -
-
- {JSON.stringify(local.list)} +
+ {local.list.map((e) => ( +
+ + {e.name} +
+ ))} +
+ + New Code Module +
); }; + +export const NameIcon: FC<{ name: string; className?: string }> = ({ + name, + className, +}) => { + const n = name.toLowerCase(); + + let html = ""; + if (n === "site") { + html = iconSite; + } + + return ( +
+ ); +}; diff --git a/app/web/src/utils/css/font.ts b/app/web/src/utils/css/font.ts index 6f998e0a..cd7df4c1 100644 --- a/app/web/src/utils/css/font.ts +++ b/app/web/src/utils/css/font.ts @@ -21,7 +21,7 @@ export const cssFont = ( if (glbFont.loadedFonts.indexOf(font.family) < 0) { glbFont.loadedFonts.push(font.family); const doc = document; - const _href = `https://prasi.web.andromedia.co.id/css2?family=${fontName}${weight}`; + const _href = `https://prasi.web.andromedia.co.id/_font/css2?family=${fontName}${weight}`; if (!doc.querySelector(`link[href="${_href}]`)) { const link = doc.createElement("link"); link.type = "text/css";