diff --git a/src/components/header.js b/src/components/header.js new file mode 100644 index 0000000..0f28b64 --- /dev/null +++ b/src/components/header.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Header = void 0; +var is_1 = require("../shared/is"); +var Header = function (_a) { + var icon = _a.icon, title = _a.title; + return "\n\t\t
\n\t\t\t".concat(!is_1.is.null(icon) && "{title}", "\n\t\t\t

{title}

\n\t\t
\n\t"); +}; +exports.Header = Header; diff --git a/src/components/header.tsx b/src/components/header.ts similarity index 51% rename from src/components/header.tsx rename to src/components/header.ts index 6e628cc..b0145ca 100644 --- a/src/components/header.tsx +++ b/src/components/header.ts @@ -1,4 +1,3 @@ -import React from "react"; import { is } from "../shared/is"; interface IProps { @@ -6,11 +5,11 @@ interface IProps { icon?: string; } -export const Header: React.FunctionComponent = ({ icon, title }) => { - return ( +export const Header = function ({ icon, title }) { + return `
- {!is.null(icon) && {title}} + ${!is.null(icon) && `{title}`}

{title}

- ); + `; }; diff --git a/src/pages/index.js b/src/pages/index.js new file mode 100644 index 0000000..80a6658 --- /dev/null +++ b/src/pages/index.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IndexPage = void 0; +var header_1 = require("../components/header"); +var config_json_1 = require("../config.json"); +var config_json_2 = require("../config/config.json"); +var is_1 = require("../shared/is"); +var variables_1 = require("../variables"); +var IndexPage = function (props) { + var icon = props.icon, title = props.title; + var mySerices = (is_1.is.null(config_json_1.default) ? config_json_2.default : config_json_1.default); + var headerClassName = "p-4"; + if (variables_1.SHOWHEADERTOP) { + headerClassName += " w-full"; + } + else { + headerClassName += " w-full xl:w-auto xl:max-w-xs xl:min-h-screen"; + } + if (variables_1.SHOWHEADERLINE) { + headerClassName += "border-0 border-solid border-gray-300 dark:border-gray-700"; + if (variables_1.SHOWHEADERTOP) { + headerClassName += " border-b"; + } + else { + headerClassName += " border-b xl:border-r xl:border-b-0"; + } + } + var pageWrapperClassName = "min-h-screen flex flex-col max-w-screen-2xl mx-auto"; + if (!variables_1.SHOWHEADERTOP) { + pageWrapperClassName += " xl:flex-row"; + } + var serviceCatalogListWrapperClassName = "p-4 flex-grow"; + if (!variables_1.SHOWHEADERTOP) { + serviceCatalogListWrapperClassName += " min-h-screen"; + } + return "\n\t\t
\n\t\t\t
\n\t\t\t\t").concat(variables_1.SHOWHEADER && + "\n\t\t\t\t\t
\n\t\t\t\t\t").concat((0, header_1.Header)({ icon: icon, title: title }), "\n\t\t\t\t\t
\n\t\t\t\t"), "\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t"); +}; +exports.IndexPage = IndexPage; diff --git a/src/pages/index.tsx b/src/pages/index.ts similarity index 76% rename from src/pages/index.tsx rename to src/pages/index.ts index f9863d6..d16eb09 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.ts @@ -1,6 +1,4 @@ -import React from "react"; import { Header } from "../components/header"; -import { ServiceCatalogList } from "../components/service-catalogs"; import userServicesOld from "../config.json"; import userServices from "../config/config.json"; import { is } from "../shared/is"; @@ -12,7 +10,8 @@ interface IProps { icon?: string; } -export const IndexPage: React.FunctionComponent = ({ icon, title }) => { +export const IndexPage = function (props: IProps): string { + const { icon, title } = props; const mySerices = (is.null(userServicesOld) ? userServices : userServicesOld) as IServiceCatalog[]; let headerClassName = "p-4"; @@ -45,18 +44,21 @@ export const IndexPage: React.FunctionComponent = ({ icon, title }) => { serviceCatalogListWrapperClassName += " min-h-screen"; } - return ( + return `
-
- {SHOWHEADER && ( -
-
+
+ ${ + SHOWHEADER && + ` +
+ ${Header({ icon, title })}
- )} -
+ ` + } +
- ); + `; }; diff --git a/src/shared/is.js b/src/shared/is.js new file mode 100644 index 0000000..e25da5b --- /dev/null +++ b/src/shared/is.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.is = void 0; +function IsArray(data) { + if (data === null || typeof data === "undefined") { + return false; + } + return data.constructor === Array; +} +function IsNull(data) { + return (typeof data === "undefined" || + data === null || + (typeof data === "string" && data.length === 0) || + (IsArray(data) && data.length === 0)); +} +exports.is = { + null: IsNull, +}; diff --git a/src/shared/types.js b/src/shared/types.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/src/shared/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/src/static.js b/src/static.js index 8b367d2..c57ff63 100644 --- a/src/static.js +++ b/src/static.js @@ -38,6 +38,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { Object.defineProperty(exports, "__esModule", { value: true }); var fs = require("fs/promises"); var path = require("path"); +var index_1 = require("./pages/index"); +var variables_1 = require("./variables"); var indexFilePath = path.join(__dirname, "../", "index.html"); function writeIndexPage(contents) { return __awaiter(this, void 0, void 0, function () { @@ -99,7 +101,7 @@ function start() { case 0: return [4 /*yield*/, readIndexPage()]; case 1: index = _a.sent(); - newText = "

Hello, world!

"; + newText = (0, index_1.IndexPage)({ icon: variables_1.PAGEICON, title: variables_1.PAGETITLE }); rootDiv = '
'; rootDivReplacement = '
$1
'; newIndex = index.replace(rootDiv, rootDivReplacement.replace("$1", newText)); diff --git a/src/static.ts b/src/static.ts index 3192897..9a121ca 100644 --- a/src/static.ts +++ b/src/static.ts @@ -1,5 +1,7 @@ import * as fs from "fs/promises"; import * as path from "path"; +import { IndexPage } from "./pages/index"; +import { PAGEICON, PAGETITLE } from "./variables"; const indexFilePath = path.join(__dirname, "../", "index.html"); @@ -31,7 +33,7 @@ async function readIndexPage(): Promise { async function start(): Promise { const index = await readIndexPage(); - const newText = "

Hello, world!

"; + const newText = IndexPage({ icon: PAGEICON, title: PAGETITLE }); const rootDiv = '
'; const rootDivReplacement = '
$1
'; diff --git a/src/variables.js b/src/variables.js new file mode 100644 index 0000000..fca83ba --- /dev/null +++ b/src/variables.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NEWWINDOW = exports.THEME = exports.CATEGORIES = exports.SHOWHEADERTOP = exports.SHOWHEADERLINE = exports.SHOWHEADER = exports.PAGEICON = exports.PAGETITLE = void 0; +exports.PAGETITLE = "My Website"; +exports.PAGEICON = "/logo.png"; +exports.SHOWHEADER = true; +exports.SHOWHEADERLINE = true; +exports.SHOWHEADERTOP = false; +exports.CATEGORIES = "normal"; +exports.THEME = "light"; +exports.NEWWINDOW = true; diff --git a/tsconfig.json b/tsconfig.json index 795e75b..8db37d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,8 @@ "outDir": "./dist", "strict": true, "esModuleInterop": true, + "resolveJsonModule": true, "module": "CommonJS" }, - "include": ["src/*.ts"] + "include": ["src"] }