From 2259372a95ead9afa168bfbdc17931f0b1e2cf8a Mon Sep 17 00:00:00 2001 From: NiklasBuchfink Date: Mon, 16 Sep 2024 16:32:38 +0200 Subject: [PATCH] feat: FINK-79 add footer --- inlang/source-code/fink2/package.json | 10 +- .../fink2/scripts/updateVersion.js | 59 +++++++ .../fink2/src/components/Footer.tsx | 165 ++++++++++++++++++ inlang/source-code/fink2/src/layout.tsx | 28 +-- inlang/source-code/fink2/version.json | 5 + 5 files changed, 251 insertions(+), 16 deletions(-) create mode 100644 inlang/source-code/fink2/scripts/updateVersion.js create mode 100644 inlang/source-code/fink2/src/components/Footer.tsx create mode 100644 inlang/source-code/fink2/version.json diff --git a/inlang/source-code/fink2/package.json b/inlang/source-code/fink2/package.json index 6a6fb751d8..3c1a2c61e8 100644 --- a/inlang/source-code/fink2/package.json +++ b/inlang/source-code/fink2/package.json @@ -4,11 +4,13 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite --host", - "build": "vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "dev": "node ./scripts/updateVersion.js && vite --host", + "build": "node ./scripts/updateVersion.js && vite build", "preview": "vite preview", - "generate": "node ./scripts/generateDemoData.js" + "generate": "node ./scripts/generateDemoData.js", + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "format": "prettier --write .", + "clean": "rm -rf ./dist ./node_modules" }, "dependencies": { "@inlang/bundle-component": "workspace:*", diff --git a/inlang/source-code/fink2/scripts/updateVersion.js b/inlang/source-code/fink2/scripts/updateVersion.js new file mode 100644 index 0000000000..5c7e1604e7 --- /dev/null +++ b/inlang/source-code/fink2/scripts/updateVersion.js @@ -0,0 +1,59 @@ +import { execSync } from "node:child_process"; +import fs from "node:fs"; + +// Function to execute shell commands +function execCommand(command) { + try { + return execSync(command).toString(); + } catch (error) { + console.error(`Error executing command: ${command}`, error); + return undefined; + } +} + +// Function to update the version.json file +function updateVersionFile() { + // Fetch package versions + const pnpmOutput = execCommand("pnpm m ls --depth -1 --json"); + if (!pnpmOutput) return; + + const packages = JSON.parse(pnpmOutput); + const finkVersion = packages.find( + (pkg) => pkg.name === "@inlang/fink2" + ).version; + const inlangVersion = packages.find( + (pkg) => pkg.name === "@inlang/sdk" + ).version; + // if working directory is not clean set commit hash to "dev" + const gitStatus = execCommand("git status --porcelain"); + const commitHash = gitStatus + ? "dev" + : execCommand("git rev-parse HEAD").trim(); + + // Read the current version.json + const versionFilePath = "./version.json"; + // Create version.json if it does not exist + if (!fs.existsSync(versionFilePath)) { + fs.writeFileSync( + versionFilePath, + `{ + "@inlang/fink2": "", + "commit-hash": "", + "@inlang/sdk": "", + } + ` + ); + } + const versionFile = JSON.parse(fs.readFileSync(versionFilePath)); + + // Update version.json file + versionFile["@inlang/fink2"] = finkVersion; + versionFile["commit-hash"] = commitHash; + versionFile["@inlang/sdk"] = inlangVersion; + + // Write the updated version.json + fs.writeFileSync(versionFilePath, JSON.stringify(versionFile, undefined, 2)); +} + +// Execute the update +updateVersionFile(); diff --git a/inlang/source-code/fink2/src/components/Footer.tsx b/inlang/source-code/fink2/src/components/Footer.tsx new file mode 100644 index 0000000000..1b6d706ed5 --- /dev/null +++ b/inlang/source-code/fink2/src/components/Footer.tsx @@ -0,0 +1,165 @@ +import version from "../../version.json" +import { SlDropdown, SlMenu } from "@shoelace-style/shoelace/dist/react" + +export const getFinkResourcesLinks = () => { + return [ + { + name: "About Fink", + href: import.meta.env.PROD + ? "https://inlang.com/m/tdozzpar" + : "http://localhost:3000/m/tdozzpar", + }, + { + name: "User Guide", + href: import.meta.env.PROD + ? "https://inlang.com/g/6ddyhpoi" + : "http://localhost:3000/g/6ddyhpoi", + }, + { + name: "About the ecosystem", + href: import.meta.env.PROD + ? "https://inlang.com/documentation" + : "http://localhost:3000/documentation", + }, + { + name: "Support Forum", + href: "https://discord.gg/gdMPPWy57R", + }, + { + name: "Report a Bug", + href: "https://github.com/opral/inlang-fink/issues/new", + }, + { + name: "Feature Request", + href: "https://github.com/opral/monorepo/discussions/categories/-fink-general", + }, + { + name: "Submit Feedback", + href: "https://github.com/orgs/opral/discussions/categories/-fink-general", + }, + ] +} + +const Footer = () => { + const socialMediaLinks = [ + { + name: "Twitter", + href: "https://twitter.com/finkEditor", + Icon: IconX, + screenreader: "Twitter Profile", + }, + { + name: "GitHub", + href: "https://github.com/opral/monorepo", + Icon: IconGitHub, + screenreader: "GitHub Repository", + }, + { + name: "Discord", + href: "https://discord.gg/gdMPPWy57R", + Icon: IconDiscord, + screenreader: "Discord Server", + }, + ] + + return ( + + ) +} + +export default Footer + +export function IconX() { + return ( + + + + ) +} + +export function IconGitHub() { + return ( + + + + ) +} + +export function IconDiscord() { + return ( + + + + ) +} diff --git a/inlang/source-code/fink2/src/layout.tsx b/inlang/source-code/fink2/src/layout.tsx index c680f53ed7..b4e9a579f2 100644 --- a/inlang/source-code/fink2/src/layout.tsx +++ b/inlang/source-code/fink2/src/layout.tsx @@ -22,6 +22,7 @@ import { merge } from "../../../../lix/packages/sdk/dist/merge/merge.js"; import { SlSelectEvent } from "@shoelace-style/shoelace"; import SubNavigation from "./components/SubNavigation.tsx"; import { handleDownload } from "./helper/utils.ts"; +import Footer from "./components/Footer.tsx"; export default function Layout(props: { children: React.ReactNode }) { const [, setWithPolling] = useAtom(withPollingAtom); @@ -51,19 +52,22 @@ export default function Layout(props: { children: React.ReactNode }) { }, [authorName, project?.lix.currentAuthor]) return ( -
-
- - - - + <> +
+
+ + + + +
+ {props.children} +
- {props.children} - -
+