Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
refactor: retire less
Johnny372fc3655ad1
diff --git a/web/.prettierrc.js b/web/.prettierrc.jsindex 09a8189d1..1b07b8aa1 100644--- a/web/.prettierrc.js+++ b/web/.prettierrc.js@@ -4,5 +4,5 @@ module.exports = {semi: true,singleQuote: false,plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")],- importOrder: ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^@/((?!less).+)", "^[./]", "^(.+).less"],+ importOrder: ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^[./]", "^(.+).css"],};diff --git a/web/package.json b/web/package.jsonindex 472e225a1..5daa7c01b 100644--- a/web/package.json+++ b/web/package.json@@ -73,7 +73,6 @@"eslint-config-prettier": "^9.1.0","eslint-plugin-prettier": "^5.2.1","eslint-plugin-react": "^7.37.3",- "less": "^4.2.2","long": "^5.2.3","nice-grpc-web": "^3.3.5","postcss": "^8.4.49",diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yamlindex 5df3a2d3c..f2e0ae6f4 100644--- a/web/pnpm-lock.yaml+++ b/web/pnpm-lock.yaml@@ -195,9 +195,6 @@ importers:eslint-plugin-react:specifier: ^7.37.3version: 7.37.3([email protected])- less:- specifier: ^4.2.2- version: 4.2.2long:specifier: ^5.2.3version: 5.2.3@@ -5074,6 +5071,7 @@ snapshots:dependencies:is-what: 3.14.1+ optional: truedependencies:@@ -6020,7 +6018,8 @@ snapshots:call-bound: 1.0.3get-intrinsic: 1.2.6- [email protected]: {}+ optional: true@@ -6130,6 +6129,7 @@ snapshots:mime: 1.6.0needle: 3.3.1source-map: 0.6.1+ optional: truedependencies:@@ -6380,7 +6380,8 @@ snapshots:json-parse-even-better-errors: 2.3.1lines-and-columns: 1.2.4- [email protected]: {}+ optional: truediff --git a/web/src/components/ChangeMemberPasswordDialog.tsx b/web/src/components/ChangeMemberPasswordDialog.tsxindex 01652a950..c7317aaba 100644--- a/web/src/components/ChangeMemberPasswordDialog.tsx+++ b/web/src/components/ChangeMemberPasswordDialog.tsx@@ -64,16 +64,16 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {};return (- <>- <div className="dialog-header-container !w-64">- <p className="title-text">+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center mb-4 gap-2 w-full">+ <p>{t("setting.account-section.change-password")} ({user.nickname})</p><Button size="sm" variant="plain" onClick={handleCloseBtnClick}><XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container">+ <div className="flex flex-col justify-start items-start !w-80"><p className="text-sm mb-1">{t("auth.new-password")}</p><InputclassName="w-full"@@ -99,7 +99,7 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {</Button></div></div>- </>+ </div>);};diff --git a/web/src/components/CreateAccessTokenDialog.tsx b/web/src/components/CreateAccessTokenDialog.tsxindex 50600591d..cb3505f42 100644--- a/web/src/components/CreateAccessTokenDialog.tsx+++ b/web/src/components/CreateAccessTokenDialog.tsx@@ -84,14 +84,14 @@ const CreateAccessTokenDialog: React.FC<Props> = (props: Props) => {};return (- <>- <div className="dialog-header-container">- <p className="title-text">{t("setting.access-token-section.create-dialog.create-access-token")}</p>+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center w-full mb-4 gap-2">+ <p>{t("setting.access-token-section.create-dialog.create-access-token")}</p><Button size="sm" variant="plain" onClick={() => destroy()}><XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container !w-80">+ <div className="flex flex-col justify-start items-start !w-80"><div className="w-full flex flex-col justify-start items-start mb-3"><span className="mb-2">{t("setting.access-token-section.create-dialog.description")} <span className="text-red-600">*</span>@@ -127,7 +127,7 @@ const CreateAccessTokenDialog: React.FC<Props> = (props: Props) => {</Button></div></div>- </>+ </div>);};diff --git a/web/src/components/CreateIdentityProviderDialog.tsx b/web/src/components/CreateIdentityProviderDialog.tsxindex b835a20e6..025ecefb8 100644--- a/web/src/components/CreateIdentityProviderDialog.tsx+++ b/web/src/components/CreateIdentityProviderDialog.tsx@@ -242,14 +242,14 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {};return (- <>- <div className="dialog-header-container">+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center mb-4 gap-2 w-full"><p>{t(isCreating ? "setting.sso-section.create-sso" : "setting.sso-section.update-sso")}</p><Button size="sm" variant="plain" onClick={handleCloseBtnClick}><XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container min-w-[19rem]">+ <div className="flex flex-col justify-start items-start w-80">{isCreating && (<><Typography className="!mb-1" level="body-md">@@ -429,7 +429,7 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {</Button></div></div>- </>+ </div>);};diff --git a/web/src/components/CreateShortcutDialog.tsx b/web/src/components/CreateShortcutDialog.tsxindex 5fc485d2d..8fc73e2f4 100644--- a/web/src/components/CreateShortcutDialog.tsx+++ b/web/src/components/CreateShortcutDialog.tsx@@ -62,14 +62,14 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {};return (- <>- <div className="dialog-header-container">+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center mb-4 gap-2 w-full"><p className="title-text">{`${isCreating ? t("common.create") : t("common.edit")} ${t("common.shortcuts")}`}</p><Button size="sm" variant="plain" onClick={() => destroy()}><XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container max-w-md min-w-72">+ <div className="flex flex-col justify-start items-start max-w-md min-w-72"><div className="w-full flex flex-col justify-start items-start mb-3"><span className="text-sm whitespace-nowrap mb-1">{t("common.title")}</span><Input className="w-full" type="text" placeholder="" value={shortcut.title} onChange={onShortcutTitleChange} />@@ -116,7 +116,7 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {</Button></div></div>- </>+ </div>);};diff --git a/web/src/components/CreateWebhookDialog.tsx b/web/src/components/CreateWebhookDialog.tsxindex bf9f870d2..a70d63289 100644--- a/web/src/components/CreateWebhookDialog.tsx+++ b/web/src/components/CreateWebhookDialog.tsx@@ -93,8 +93,8 @@ const CreateWebhookDialog: React.FC<Props> = (props: Props) => {};return (- <>- <div className="dialog-header-container">+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center mb-4 gap-2 w-full"><p className="title-text">{isCreating ? t("setting.webhook-section.create-dialog.create-webhook") : t("setting.webhook-section.create-dialog.edit-webhook")}</p>@@ -102,7 +102,7 @@ const CreateWebhookDialog: React.FC<Props> = (props: Props) => {<XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container !w-80">+ <div className="flex flex-col justify-start items-start !w-80"><div className="w-full flex flex-col justify-start items-start mb-3"><span className="mb-2">{t("setting.webhook-section.create-dialog.title")} <span className="text-red-600">*</span>@@ -140,7 +140,7 @@ const CreateWebhookDialog: React.FC<Props> = (props: Props) => {</Button></div></div>- </>+ </div>);};diff --git a/web/src/components/Dialog/BaseDialog.tsx b/web/src/components/Dialog/BaseDialog.tsxindex 5b9ede17b..2ce85f8a7 100644--- a/web/src/components/Dialog/BaseDialog.tsx+++ b/web/src/components/Dialog/BaseDialog.tsx@@ -5,7 +5,6 @@ import { createRoot } from "react-dom/client";import dialogStore from "@/store/v2/dialog";import theme from "@/theme";import { cn } from "@/utils";-import "@/less/base-dialog.less";interface DialogConfig {dialogName: string;@@ -53,8 +52,14 @@ const BaseDialog = observer((props: Props) => {};return (- <div className={cn("dialog-wrapper", className)} onMouseDown={handleSpaceClicked}>- <div ref={dialogContainerRef} className={cn("dialog-container")} onMouseDown={(e) => e.stopPropagation()}>+ <div+ className={cn(+ "fixed top-0 left-0 flex flex-col justify-start items-center w-full h-full pt-16 pb-8 px-4 z-1000 overflow-x-hidden overflow-y-scroll bg-transparent transition-all hide-scrollbar bg-black bg-opacity-60",+ className,+ )}+ onMouseDown={handleSpaceClicked}+ >+ <div ref={dialogContainerRef} onMouseDown={(e) => e.stopPropagation()}>{children}</div></div>diff --git a/web/src/components/PreviewImageDialog.tsx b/web/src/components/PreviewImageDialog.tsxindex 768ff19d0..f6f3f578c 100644--- a/web/src/components/PreviewImageDialog.tsx+++ b/web/src/components/PreviewImageDialog.tsx@@ -1,7 +1,7 @@+import { Button } from "@usememos/mui";import { XIcon } from "lucide-react";import React, { useEffect, useState } from "react";import { generateDialog } from "./Dialog";-import "@/less/preview-image-dialog.less";const MIN_SCALE = 0.5;const MAX_SCALE = 5;@@ -154,13 +154,14 @@ const PreviewImageDialog: React.FC<Props> = ({ destroy, imgUrls, initialIndex }:return (<>- <div className="btns-container">- <button className="btn" onClick={handleCloseBtnClick}>- <XIcon className="icon-img" />- </button>+ <div className="fixed top-8 right-8 flex flex-col justify-start items-center">+ <Button onClick={handleCloseBtnClick}>+ <XIcon className="w-6 h-auto" />+ </Button></div>- <div className="img-container" onClick={handleImgContainerClick}>+ <div className="w-full h-full p-4 sm:p-20 flex flex-col justify-center items-center hide-scrollbar" onClick={handleImgContainerClick}><img+ className="h-auto w-auto max-w-full max-h-full shadow"style={imageComputedStyle}src={imgUrls[currentIndex]}onClick={(e) => e.stopPropagation()}@@ -179,7 +180,7 @@ const PreviewImageDialog: React.FC<Props> = ({ destroy, imgUrls, initialIndex }:export default function showPreviewImageDialog(imgUrls: string[] | string, initialIndex?: number): void {generateDialog({- className: "preview-image-dialog",+ className: "preview-image-dialog p-0 z-[1001]",dialogName: "preview-image-dialog",},PreviewImageDialog,diff --git a/web/src/components/RenameTagDialog.tsx b/web/src/components/RenameTagDialog.tsxindex f46b50cca..86d67ee04 100644--- a/web/src/components/RenameTagDialog.tsx+++ b/web/src/components/RenameTagDialog.tsx@@ -47,14 +47,14 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {};return (- <>- <div className="dialog-header-container">+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center mb-4 gap-2 w-full"><p className="title-text">{"Rename tag"}</p><Button size="sm" variant="plain" onClick={() => destroy()}><XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container max-w-xs">+ <div className="flex flex-col justify-start items-start max-w-xs"><div className="w-full flex flex-col justify-start items-start mb-3"><div className="relative w-full mb-2 flex flex-row justify-start items-center space-x-2"><span className="w-20 text-sm whitespace-nowrap shrink-0 text-right">Old Name</span>@@ -79,7 +79,7 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {</Button></div></div>- </>+ </div>);};diff --git a/web/src/components/UpdateAccountDialog.tsx b/web/src/components/UpdateAccountDialog.tsxindex 1eaa2fd18..fbf86254b 100644--- a/web/src/components/UpdateAccountDialog.tsx+++ b/web/src/components/UpdateAccountDialog.tsx@@ -140,14 +140,14 @@ const UpdateAccountDialog = ({ destroy }: Props) => {};return (- <>- <div className="dialog-header-container !w-64">+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center mb-4 gap-2 w-full"><p className="title-text">{t("setting.account-section.update-information")}</p><Button size="sm" variant="plain" onClick={handleCloseBtnClick}><XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container space-y-2">+ <div className="flex flex-col justify-start items-start !w-64 space-y-2"><div className="w-full flex flex-row justify-start items-center"><span className="text-sm mr-2">{t("common.avatar")}</span><label className="relative cursor-pointer hover:opacity-80">@@ -208,7 +208,7 @@ const UpdateAccountDialog = ({ destroy }: Props) => {</Button></div></div>- </>+ </div>);};diff --git a/web/src/components/UpdateCustomizedProfileDialog.tsx b/web/src/components/UpdateCustomizedProfileDialog.tsxindex 64989e750..9e0a7663d 100644--- a/web/src/components/UpdateCustomizedProfileDialog.tsx+++ b/web/src/components/UpdateCustomizedProfileDialog.tsx@@ -97,14 +97,14 @@ const UpdateCustomizedProfileDialog = ({ destroy }: Props) => {};return (- <>- <div className="dialog-header-container">+ <div className="max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg">+ <div className="flex flex-row justify-between items-center mb-4 gap-2 w-full"><p className="title-text">{t("setting.system-section.customize-server.title")}</p><Button size="sm" variant="plain" onClick={handleCloseButtonClick}><XIcon className="w-5 h-auto" /></Button></div>- <div className="dialog-content-container min-w-[16rem]">+ <div className="flex flex-col justify-start items-start min-w-[16rem]"><p className="text-sm mb-1">{t("setting.system-section.server-name")}</p><Input className="w-full" type="text" value={customProfile.title} onChange={handleNameChanged} /><p className="text-sm mb-1 mt-2">{t("setting.system-section.customize-server.icon-url")}</p>@@ -131,7 +131,7 @@ const UpdateCustomizedProfileDialog = ({ destroy }: Props) => {</div></div></div>- </>+ </div>);};diff --git a/web/src/css/highlight.css b/web/src/css/highlight.cssnew file mode 100644index 000000000..235ed3a8b--- /dev/null+++ b/web/src/css/highlight.css@@ -0,0 +1,7 @@+html.dark {+ @import "highlight.js/styles/atom-one-dark.css";+}++html:not(.dark) {+ @import "highlight.js/styles/github.css";+}diff --git a/web/src/less/base-dialog.less b/web/src/less/base-dialog.lessdeleted file mode 100644index e40e2080f..000000000--- a/web/src/less/base-dialog.less+++ /dev/null@@ -1,29 +0,0 @@-.dialog-wrapper {- @apply fixed top-0 left-0 flex flex-col justify-start items-center w-full h-full pt-16 pb-8 px-4 z-1000 overflow-x-hidden overflow-y-scroll bg-transparent transition-all hide-scrollbar bg-black bg-opacity-60;-- > .dialog-container {- @apply max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg;-- > .dialog-header-container {- @apply flex flex-row justify-between items-center w-full mb-4;-- > .title-text {- > .icon-text {- @apply mr-2 text-base dark:text-gray-300;- }- }-- .btn {- @apply flex flex-col justify-center items-center w-6 h-6 rounded hover:bg-gray-100 dark:hover:bg-zinc-900 hover:shadow;- }- }-- > .dialog-content-container {- @apply flex flex-col justify-start items-start w-full;- }-- > .dialog-footer-container {- @apply flex flex-row justify-end items-center w-full mt-4;- }- }-}diff --git a/web/src/less/common-dialog.less b/web/src/less/common-dialog.lessdeleted file mode 100644index 05b296c12..000000000--- a/web/src/less/common-dialog.less+++ /dev/null@@ -1,29 +0,0 @@-.common-dialog {- > .dialog-container {- @apply w-80;-- > .dialog-content-container {- @apply flex flex-col justify-start items-start;-- > .btns-container {- @apply flex flex-row justify-end items-center w-full mt-4;-- > .btn {- @apply text-sm py-1 px-3 mr-2 rounded-md hover:opacity-80 cursor-pointer;-- &.confirm-btn {- @apply bg-red-100 border border-solid border-blue-600 text-blue-600;-- &.warning {- @apply border-red-600 text-red-600;- }- }- }- }-- > .content-text{- @apply whitespace-pre-wrap;- }- }- }-}diff --git a/web/src/less/highlight.less b/web/src/less/highlight.lessdeleted file mode 100644index 6d95345bc..000000000--- a/web/src/less/highlight.less+++ /dev/null@@ -1,7 +0,0 @@-html.dark {- @import (less) "highlight.js/styles/atom-one-dark.css";-}--html:not(.dark) {- @import (less) "highlight.js/styles/github.css";-}diff --git a/web/src/less/preview-image-dialog.less b/web/src/less/preview-image-dialog.lessdeleted file mode 100644index f343d2295..000000000--- a/web/src/less/preview-image-dialog.less+++ /dev/null@@ -1,31 +0,0 @@-.preview-image-dialog {- @apply p-0;- z-index: 1001;- background-color: rgba(0, 0, 0, 0.6);-- > .dialog-container {- @apply flex flex-col justify-center items-center relative w-full h-full p-0;- background-color: unset;-- > .btns-container {- @apply fixed top-8 right-8 flex flex-col justify-start items-center;-- > .btn {- @apply mb-3 last:mb-0 w-8 h-8 p-1 cursor-pointer rounded opacity-90 bg-gray-300 dark:bg-zinc-600 z-10 shadow-md hover:opacity-70;-- > .icon-img {- @apply w-6 h-auto;- }- }- }-- > .img-container {- @apply w-full h-full p-4 sm:p-20 flex flex-col justify-center items-center hide-scrollbar;- background-color: unset;-- > img {- @apply h-auto w-auto max-w-full max-h-full shadow;- }- }- }-}diff --git a/web/src/main.tsx b/web/src/main.tsxindex 847c2430a..87309eb71 100644--- a/web/src/main.tsx+++ b/web/src/main.tsx@@ -6,9 +6,9 @@ import { observer } from "mobx-react-lite";import { createRoot } from "react-dom/client";import { Toaster } from "react-hot-toast";import { RouterProvider } from "react-router-dom";+import "./css/highlight.css";import "./css/tailwind.css";import "./i18n";-import "./less/highlight.less";import router from "./router";import { initialUserStore } from "./store/v2/user";import { initialWorkspaceStore } from "./store/v2/workspace";