From 3c170b132c28e5a101efeedcef101950e1ee6301 Mon Sep 17 00:00:00 2001 From: JulesFILIOT Date: Thu, 21 Dec 2023 21:10:59 +0100 Subject: [PATCH 01/30] feat: init docusaurus-commenting-system plugin --- packages/docusaurus-commenting-system/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/docusaurus-commenting-system/README.md diff --git a/packages/docusaurus-commenting-system/README.md b/packages/docusaurus-commenting-system/README.md new file mode 100644 index 00000000..d848cf00 --- /dev/null +++ b/packages/docusaurus-commenting-system/README.md @@ -0,0 +1 @@ +# Docusaurus docs commenting system plugin From 5bf34377dd9b9c247ce7bfaaba34818f08111cfe Mon Sep 17 00:00:00 2001 From: JulesFILIOT Date: Thu, 21 Dec 2023 21:13:58 +0100 Subject: [PATCH 02/30] feat(commenting system plugin): add config files --- .../tsconfig.client.json | 17 +++++++++++++++++ .../tsconfig.json | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 packages/docusaurus-commenting-system/tsconfig.client.json create mode 100644 packages/docusaurus-commenting-system/tsconfig.json diff --git a/packages/docusaurus-commenting-system/tsconfig.client.json b/packages/docusaurus-commenting-system/tsconfig.client.json new file mode 100644 index 00000000..837fc3f4 --- /dev/null +++ b/packages/docusaurus-commenting-system/tsconfig.client.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "noEmit": false, + "composite": true, + "incremental": true, + "tsBuildInfoFile": "./lib/.tsbuildinfo-client", + "rootDir": "src", + "outDir": "lib", + "module": "CommonJS", + "target": "esnext", + "jsx": "react", + "lib": ["DOM"] + }, + "include": ["src/client", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] +} diff --git a/packages/docusaurus-commenting-system/tsconfig.json b/packages/docusaurus-commenting-system/tsconfig.json new file mode 100644 index 00000000..b1fa7fbe --- /dev/null +++ b/packages/docusaurus-commenting-system/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.json", + "references": [ + { + "path": "./tsconfig.client.json" + } + ], + "compilerOptions": { + "noEmit": false, + "incremental": true, + "tsBuildInfoFile": "./lib/.tsbuildinfo", + "rootDir": "src", + "outDir": "lib", + "jsx": "react", + "lib": ["DOM"] + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] +} From f0857296f722ebf01bc5e40169c9f0b2007286a1 Mon Sep 17 00:00:00 2001 From: JulesFILIOT Date: Thu, 21 Dec 2023 21:14:20 +0100 Subject: [PATCH 03/30] feat(commenting system plugin): add package.json --- .../docusaurus-commenting-system/package.json | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 packages/docusaurus-commenting-system/package.json diff --git a/packages/docusaurus-commenting-system/package.json b/packages/docusaurus-commenting-system/package.json new file mode 100644 index 00000000..cccdb31e --- /dev/null +++ b/packages/docusaurus-commenting-system/package.json @@ -0,0 +1,22 @@ +{ + "name": "@acid-info/docusaurus-commenting-system", + "version": "1.0.0-alpha", + "description": "Docusaurus docs commenting system plugin", + "main": "lib/index.js", + "repository": { + "type": "git", + "url": "https://github.com/acid-info/logos-docusaurus-plugins.git", + "directory": "packages/docusaurus-commenting-system" + }, + "scripts": { + "build": "tsc --build", + "watch": "tsc --build --watch", + "prepublishOnly": "yarn build" + }, + "dependencies": { + "@acid-info/lsd-react": "^0.1.0-beta.1", + "react": "^17.0.2", + "react-dom": "^17.0.2" + }, + "license": "MIT" +} From 54492c8f2b6042f3009a6c5646a1d9cf0ca98270 Mon Sep 17 00:00:00 2001 From: JulesFILIOT Date: Fri, 22 Dec 2023 01:06:30 +0100 Subject: [PATCH 04/30] feat(commenting system plugin): add sass files handling --- .../docusaurus-commenting-system/package.json | 9 ++++- .../scripts/copy-scss.js | 37 +++++++++++++++++++ .../src/deps.d.ts | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 packages/docusaurus-commenting-system/scripts/copy-scss.js create mode 100644 packages/docusaurus-commenting-system/src/deps.d.ts diff --git a/packages/docusaurus-commenting-system/package.json b/packages/docusaurus-commenting-system/package.json index cccdb31e..9e0a4837 100644 --- a/packages/docusaurus-commenting-system/package.json +++ b/packages/docusaurus-commenting-system/package.json @@ -9,7 +9,7 @@ "directory": "packages/docusaurus-commenting-system" }, "scripts": { - "build": "tsc --build", + "build": "tsc --build && node scripts/copy-scss.js", "watch": "tsc --build --watch", "prepublishOnly": "yarn build" }, @@ -18,5 +18,12 @@ "react": "^17.0.2", "react-dom": "^17.0.2" }, + "devDependencies": { + "copyfiles": "^2.4.1", + "css-loader": "^6.8.1", + "sass": "^1.69.5", + "sass-loader": "^13.3.2", + "style-loader": "^3.3.3" + }, "license": "MIT" } diff --git a/packages/docusaurus-commenting-system/scripts/copy-scss.js b/packages/docusaurus-commenting-system/scripts/copy-scss.js new file mode 100644 index 00000000..328a92f6 --- /dev/null +++ b/packages/docusaurus-commenting-system/scripts/copy-scss.js @@ -0,0 +1,37 @@ +const fs = require('fs') +const path = require('path') +const copyfiles = require('copyfiles') + +function copySCSS(srcDir, destDir) { + fs.readdir(srcDir, { withFileTypes: true }, (err, entries) => { + if (err) { + console.error(err) + return + } + + entries.forEach((entry) => { + const srcPath = path.join(srcDir, entry.name) + const destPath = path.join(destDir, entry.name) + + if (entry.isDirectory()) { + // Recursive call for directories + copySCSS(srcPath, destPath) + } else if (path.extname(entry.name) === '.scss') { + // Copying .scss files + copyfiles([srcPath, path.dirname(destPath)], { up: true }, (err) => { + if (err) console.error(err) + }) + } + }) + }) +} + +const srcClientPath = path.join(__dirname, '../src/client') +const libClientPath = path.join(__dirname, '../lib/client') + +// Ensure the destination directory exists +if (!fs.existsSync(libClientPath)) { + fs.mkdirSync(libClientPath, { recursive: true }) +} + +copySCSS(srcClientPath, libClientPath) diff --git a/packages/docusaurus-commenting-system/src/deps.d.ts b/packages/docusaurus-commenting-system/src/deps.d.ts new file mode 100644 index 00000000..99508d56 --- /dev/null +++ b/packages/docusaurus-commenting-system/src/deps.d.ts @@ -0,0 +1 @@ +declare module '*.scss' From e65f024b9e2b8b2c14648f2986e889b89e6aa875 Mon Sep 17 00:00:00 2001 From: JulesFILIOT Date: Fri, 22 Dec 2023 19:35:08 +0100 Subject: [PATCH 05/30] feat(commenting system plugin): add plugin index file --- packages/docusaurus-commenting-system/src/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 packages/docusaurus-commenting-system/src/index.ts diff --git a/packages/docusaurus-commenting-system/src/index.ts b/packages/docusaurus-commenting-system/src/index.ts new file mode 100644 index 00000000..a54c5c1d --- /dev/null +++ b/packages/docusaurus-commenting-system/src/index.ts @@ -0,0 +1,10 @@ +import path from 'path' + +export default function docusaurusCommentingSystemPlugin(context, options) { + return { + name: 'docusaurus-commenting-system', + clientModules() { + return [path.resolve(__dirname, './client')] + }, + } +} From e2237c53b86bb38a17dc9001b06b8d116df931ac Mon Sep 17 00:00:00 2001 From: JulesFILIOT Date: Fri, 22 Dec 2023 19:36:30 +0100 Subject: [PATCH 06/30] feat(commenting system UI): add Comment component --- .../components/Comment/Comment.module.scss | 4 ++++ .../src/client/components/Comment/Comment.tsx | 17 +++++++++++++++++ .../src/client/components/Comment/index.ts | 1 + 3 files changed, 22 insertions(+) create mode 100644 packages/docusaurus-commenting-system/src/client/components/Comment/Comment.module.scss create mode 100644 packages/docusaurus-commenting-system/src/client/components/Comment/Comment.tsx create mode 100644 packages/docusaurus-commenting-system/src/client/components/Comment/index.ts diff --git a/packages/docusaurus-commenting-system/src/client/components/Comment/Comment.module.scss b/packages/docusaurus-commenting-system/src/client/components/Comment/Comment.module.scss new file mode 100644 index 00000000..23318e4b --- /dev/null +++ b/packages/docusaurus-commenting-system/src/client/components/Comment/Comment.module.scss @@ -0,0 +1,4 @@ +.username { + font-weight: bold; + margin-bottom: 0.3rem; +} diff --git a/packages/docusaurus-commenting-system/src/client/components/Comment/Comment.tsx b/packages/docusaurus-commenting-system/src/client/components/Comment/Comment.tsx new file mode 100644 index 00000000..ef16d5b2 --- /dev/null +++ b/packages/docusaurus-commenting-system/src/client/components/Comment/Comment.tsx @@ -0,0 +1,17 @@ +import React from 'react' +import { CardBody } from '@acid-info/lsd-react' +import styles from './Comment.module.scss' + +export type CommentProps = { + username: string + comment: string +} + +export const Comment: React.FC = ({ username, comment }) => { + return ( + +
{username}
+
{comment}
+
+ ) +} diff --git a/packages/docusaurus-commenting-system/src/client/components/Comment/index.ts b/packages/docusaurus-commenting-system/src/client/components/Comment/index.ts new file mode 100644 index 00000000..85a5c820 --- /dev/null +++ b/packages/docusaurus-commenting-system/src/client/components/Comment/index.ts @@ -0,0 +1 @@ +export * from './Comment' From f15fca28804dd2745dff57e2682e009a37cac4bd Mon Sep 17 00:00:00 2001 From: JulesFILIOT Date: Fri, 22 Dec 2023 19:38:05 +0100 Subject: [PATCH 07/30] feat(commenting system UI): add WriteComment component --- .../WriteComment/WriteComment.module.scss | 11 +++++++ .../components/WriteComment/WriteComment.tsx | 31 +++++++++++++++++++ .../client/components/WriteComment/index.ts | 1 + 3 files changed, 43 insertions(+) create mode 100644 packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.module.scss create mode 100644 packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.tsx create mode 100644 packages/docusaurus-commenting-system/src/client/components/WriteComment/index.ts diff --git a/packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.module.scss b/packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.module.scss new file mode 100644 index 00000000..f7c227b3 --- /dev/null +++ b/packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.module.scss @@ -0,0 +1,11 @@ +.textarea { + width: 100%; + min-width: 100%; + max-width: 100%; +} + +.actionContainer { + display: flex; + justify-content: flex-end; + margin-top: 0.5rem; +} diff --git a/packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.tsx b/packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.tsx new file mode 100644 index 00000000..38688300 --- /dev/null +++ b/packages/docusaurus-commenting-system/src/client/components/WriteComment/WriteComment.tsx @@ -0,0 +1,31 @@ +import React from 'react' +import { CardBody, Button } from '@acid-info/lsd-react' +import styles from './WriteComment.module.scss' + +export type WriteCommentProps = { + handleSend: () => void + handleSignIn: () => void + isSignedIn?: boolean +} + +export const WriteComment: React.FC = ({ + handleSend, + handleSignIn, + isSignedIn = false, +}) => { + return ( + +