diff --git a/web/src/components/AboutDialog.tsx b/web/src/components/AboutDialog.tsx new file mode 100644 index 00000000..fb12a783 --- /dev/null +++ b/web/src/components/AboutDialog.tsx @@ -0,0 +1,140 @@ +import { ExternalLinkIcon, ScissorsIcon } from "lucide-react"; +import { Badge } from "@/components/ui/badge"; +import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; +import { useInstance } from "@/contexts/InstanceContext"; +import { WEB_CLIPPER_URL } from "@/lib/constants"; +import { useTranslate } from "@/utils/i18n"; + +const GITHUB_COMMIT_URL_PREFIX = "https://github.com/usememos/memos/commit/"; +const GITHUB_RELEASE_URL_PREFIX = "https://github.com/usememos/memos/releases/tag/v"; + +const DEFAULT_TITLE = "Memos"; +const DEFAULT_TAGLINE = "Capture first. Keep it yours."; +const DEFAULT_LOGO = "/logo.webp"; + +const isCommitSha = (commit: string) => /^[0-9a-f]{7,40}$/i.test(commit); +const isSemver = (version: string) => /^\d+\.\d+\.\d+/.test(version); + +const Chip = ({ href, children }: { href?: string; children: React.ReactNode }) => { + const className = "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 font-mono text-xs text-muted-foreground"; + if (href) { + return ( + + {children} + + ); + } + return {children}; +}; + +const SectionLabel = ({ children }: { children: React.ReactNode }) => ( +

{children}

+); + +interface Props { + open: boolean; + onOpenChange: (open: boolean) => void; +} + +const AboutDialog = ({ open, onOpenChange }: Props) => { + const t = useTranslate(); + const { profile, generalSetting } = useInstance(); + + const customProfile = generalSetting.customProfile; + const instanceTitle = customProfile?.title || DEFAULT_TITLE; + const instanceTagline = customProfile?.description || DEFAULT_TAGLINE; + const instanceLogo = customProfile?.logoUrl || DEFAULT_LOGO; + const isCustomBranded = instanceTitle !== DEFAULT_TITLE; + + const hasSemver = isSemver(profile.version); + const releaseUrl = hasSemver ? `${GITHUB_RELEASE_URL_PREFIX}${profile.version}` : ""; + const versionLabel = hasSemver ? `v${profile.version}` : profile.version; + const hasCommitSha = isCommitSha(profile.commit); + const commitUrl = hasCommitSha ? `${GITHUB_COMMIT_URL_PREFIX}${profile.commit}` : ""; + const shortCommit = hasCommitSha ? profile.commit.slice(0, 7) : ""; + + const buildRows: { label: string; value: React.ReactNode }[] = []; + if (profile.version) { + buildRows.push({ label: t("common.version"), value: {versionLabel} }); + } + if (shortCommit) { + buildRows.push({ label: t("about.commit"), value: {shortCommit} }); + } + buildRows.push({ label: t("about.license"), value: MIT }); + if (isCustomBranded) { + buildRows.push({ + label: t("about.distribution"), + value: {t("about.powered-by")}, + }); + } + + const projectLinks = [ + { label: t("about.official-website"), note: t("about.official-website-note"), href: "https://usememos.com/" }, + { label: t("about.documents"), note: t("about.documents-note"), href: "https://usememos.com/docs" }, + { label: t("about.api-docs"), note: t("about.api-docs-note"), href: "https://usememos.com/docs/api" }, + { + label: t("about.github-repository"), + note: t("about.github-repository-note"), + href: "https://github.com/usememos/memos", + }, + { label: t("about.web-clipper"), note: t("about.web-clipper-platforms"), href: WEB_CLIPPER_URL, icon: ScissorsIcon }, + ]; + + return ( + + + {t("common.about")} +
+
+ +
+
+

{instanceTitle}

+ {profile.demo && {t("about.demo")}} +
+

{instanceTagline}

+
+
+ +
+ {t("about.build")} +
+ {buildRows.map((row) => ( +
+
{row.label}
+
{row.value}
+
+ ))} +
+
+ +
+ {t("about.project")} + +
+
+
+
+ ); +}; + +export default AboutDialog; diff --git a/web/src/components/ActivityCalendar/CalendarCell.tsx b/web/src/components/ActivityCalendar/CalendarCell.tsx index 1b03d50b..e3d1d426 100644 --- a/web/src/components/ActivityCalendar/CalendarCell.tsx +++ b/web/src/components/ActivityCalendar/CalendarCell.tsx @@ -27,7 +27,7 @@ export const CalendarCell = memo((props: CalendarCellProps) => { const smallExtraClasses = size === "small" ? `${SMALL_CELL_SIZE.dimensions} min-h-0` : ""; const baseClasses = cn( - "aspect-square w-full flex items-center justify-center text-center transition-all duration-150 select-none border border-border/10 bg-muted/20", + "relative aspect-square w-full flex items-center justify-center text-center transition-[background-color,color,filter,box-shadow] duration-150 ease-out select-none", sizeConfig.font, sizeConfig.borderRadius, smallExtraClasses, @@ -36,7 +36,7 @@ export const CalendarCell = memo((props: CalendarCellProps) => { const ariaLabel = day.isSelected ? `${tooltipText} (selected)` : tooltipText; if (!day.isCurrentMonth) { - return
{day.label}
; + return
{day.label}
; } const intensityClass = getCellIntensityClass(day, maxCount); @@ -46,7 +46,9 @@ export const CalendarCell = memo((props: CalendarCellProps) => { baseClasses, intensityClass, getCalendarCellStateClass(day), - isInteractive ? "cursor-pointer hover:bg-muted/40 hover:border-border/30" : "cursor-default", + isInteractive + ? "cursor-pointer hover:brightness-[0.97] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-inset" + : "cursor-default", ); const button = ( @@ -60,6 +62,12 @@ export const CalendarCell = memo((props: CalendarCellProps) => { className={buttonClasses} > {day.label} + {day.isToday && ( +