From 21ba28c8eb28c139db34e78bfb9f99cee4cd64cc Mon Sep 17 00:00:00 2001 From: Aadin Date: Mon, 23 Nov 2026 03:18:43 +0530 Subject: [PATCH] feat(profile): add profile page with local activity graph Replaces the small name/email/logout popup in the sidebar with a full profile page. - Profile page (src/pages/profile): account header, activity heatmap, coding time, streaks, active days and a top-languages strip that follows the theme accent color. Works signed out with a Sign in button. - Activity tracker (src/lib/activity.js): tracks coding time, typed lines, created files and languages. Stored only on the device. - Sidebar: avatar tap opens the profile page; logout is a reusable handler; starts the tracker on launch. - Adds i18n strings for the profile page. --- src/components/sidebar/index.js | 143 +++--- src/components/sidebar/style.scss | 77 --- src/lang/ar-ye.json | 21 + src/lang/az-az.json | 23 +- src/lang/be-by.json | 21 + src/lang/bn-bd.json | 21 + src/lang/cs-cz.json | 21 + src/lang/de-de.json | 21 + src/lang/en-us.json | 23 +- src/lang/es-sv.json | 23 +- src/lang/fr-fr.json | 21 + src/lang/he-il.json | 21 + src/lang/hi-in.json | 21 + src/lang/hu-hu.json | 21 + src/lang/id-id.json | 21 + src/lang/ir-fa.json | 21 + src/lang/it-it.json | 21 + src/lang/ja-jp.json | 21 + src/lang/ko-kr.json | 21 + src/lang/ln-ln.json | 21 + src/lang/ml-in.json | 21 + src/lang/mm-unicode.json | 21 + src/lang/mm-zawgyi.json | 21 + src/lang/pl-pl.json | 21 + src/lang/pt-br.json | 21 + src/lang/pu-in.json | 21 + src/lang/ru-ru.json | 21 + src/lang/tl-ph.json | 21 + src/lang/tr-tr.json | 21 + src/lang/uk-ua.json | 21 + src/lang/uz-uz.json | 21 + src/lang/vi-vn.json | 21 + src/lang/zh-cn.json | 21 + src/lang/zh-hant.json | 21 + src/lang/zh-tw.json | 21 + src/lib/activity.js | 265 ++++++++++ src/lib/editorManager.js | 2 + src/pages/profile/heatmap.js | 56 +++ src/pages/profile/index.js | 15 + src/pages/profile/profile.js | 810 ++++++++++++++++++++++++++++++ src/pages/profile/profile.scss | 551 ++++++++++++++++++++ src/pages/profile/shareCard.js | 149 ++++++ src/utils/helpers.js | 3 + 43 files changed, 2615 insertions(+), 155 deletions(-) create mode 100644 src/lib/activity.js create mode 100644 src/pages/profile/heatmap.js create mode 100644 src/pages/profile/index.js create mode 100644 src/pages/profile/profile.js create mode 100644 src/pages/profile/profile.scss create mode 100644 src/pages/profile/shareCard.js diff --git a/src/components/sidebar/index.js b/src/components/sidebar/index.js index 807510153..6d317d6e1 100644 --- a/src/components/sidebar/index.js +++ b/src/components/sidebar/index.js @@ -1,10 +1,10 @@ import "./style.scss"; import fsOperation from "fileSystem"; import toast from "components/toast"; -import confirm from "dialogs/confirm"; import loader from "dialogs/loader"; import Ref from "html-tag-js/ref"; import actionStack from "lib/actionStack"; +import activity from "lib/activity"; import auth, { loginEvents } from "lib/auth"; import config from "lib/config"; import helpers from "utils/helpers"; @@ -42,7 +42,6 @@ function create($container, $toggler) { const MAX_WIDTH = () => innerWidth * 0.7; //Max width of the side bar const resizeBar = Ref(); const userAvatar = Ref(); - const userContextMenu = Ref(); $container = $container || app; let mode = innerWidth > 750 ? "tab" : "phone"; @@ -67,18 +66,6 @@ function create($container, $toggler) { onmousedown={onresize} ontouchstart={onresize} > - -
-
-
-
-
- {/*
*/} -
- - {strings.logout} -
-
); const mask = ; @@ -106,78 +93,84 @@ function create($container, $toggler) { } loginEvents.addListener(updateSidebarAvatar); + activity.init(); - async function handleUserIconClick(e) { - try { - loader.create(strings["login"], strings["loading..."]); - let user = await auth.getLoggedInUser(); - - if (!user) { - const confirmation = await confirm( - strings.confirm, - strings["confirm-login"], - ); + let openingProfile = false; - if (!confirmation) { - return; - } + async function handleUserIconClick() { + // A second tap while the profile is still opening would stack two pages. + if (openingProfile) return; + openingProfile = true; - loader.show(); + // Cached users resolve instantly, so only show a loader if the + // account check is actually slow. + let loaderShown = false; + const loaderTimer = setTimeout(() => { + loaderShown = true; + loader.create(strings["login"], strings["loading..."]); + loader.show(); + }, 250); + + const stopLoader = () => { + clearTimeout(loaderTimer); + if (loaderShown) { + loaderShown = false; + loader.destroy(); + } + }; - await auth.login(); + try { + let user = null; + try { user = await auth.getLoggedInUser(); - if (!user) { - return; - } + } catch (error) { + // offline or server error: still open the page as signed out + console.error("Error checking login status:", error); } + stopLoader(); - const menu = userContextMenu.el; - const isActive = menu.classList.toggle("active"); - - if (isActive) { - const menuName = userContextMenu.el.querySelector(".user-menu-name"); - const menuEmail = userContextMenu.el.querySelector(".user-menu-email"); - - if (menuName) { - menuName.content = ( -
- {user.name} - {Boolean(user.verified) && ( - - )} - {Boolean(user.acode_pro) && Pro} -
- ); - } - - if (menuEmail) { - menuEmail.textContent = user.email || ""; - } - - setTimeout(() => { - document.addEventListener("click", handleClickOutside); - }, 10); - } else { - document.removeEventListener("click", handleClickOutside); - } + const { default: openProfile } = await import( + /* webpackChunkName: "profile" */ "pages/profile" + ); + await openProfile({ + user, + getAvatarSrc, + onLogin: handleLogin, + onLogout: handleLogout, + }); } catch (error) { - console.error("Error checking login status:", error); + console.error("Error opening profile:", error); } finally { - loader.destroy(); + stopLoader(); + openingProfile = false; } } - function handleClickOutside(e) { - if ( - !userContextMenu.el.contains(e.target) && - e.target !== userAvatar.el && - !userAvatar.el.contains(e.target) - ) { - userContextMenu.el.classList.remove("active"); - document.removeEventListener("click", handleClickOutside); + /** + * Starts the Acode login flow. Used by the profile page. + * @returns {Promise} the logged in user, if any + */ + async function handleLogin() { + try { + await auth.login(); + return (await auth.getLoggedInUser(true)) || null; + } catch (error) { + console.error("Error during login:", error); + return null; } } + async function getAvatarSrc(user) { + const avatarFile = await getUserAvatar(user).catch(() => null); + return avatarFile + ? await helpers.toInternalUri(avatarFile) + : generateInitialsAvatar(user.name || user.email || "?"); + } + + /** + * Logs the user out. Used by the profile page. + * @returns {Promise} + */ async function handleLogout() { loader.create(strings["logout"], strings["loading..."]); loader.show(); @@ -185,8 +178,6 @@ function create($container, $toggler) { const user = await auth.getLoggedInUser(); const success = await auth.logout(); if (success) { - userContextMenu.el.classList.remove("active"); - document.removeEventListener("click", handleClickOutside); updateSidebarAvatar(); toast("Logged out successfully"); @@ -196,11 +187,13 @@ function create($container, $toggler) { await fsOperation(avatarFile).delete(); } } catch {} - } else { - toast("Failed to logout"); + return true; } + toast("Failed to logout"); + return false; } catch (error) { console.error("Error during logout:", error); + return false; } finally { loader.destroy(); } diff --git a/src/components/sidebar/style.scss b/src/components/sidebar/style.scss index 92b6dbbd9..5d4edc84c 100644 --- a/src/components/sidebar/style.scss +++ b/src/components/sidebar/style.scss @@ -423,80 +423,3 @@ body.no-animation { transform: scale(0.94); } } - -.user-menu { - position: absolute; - bottom: 55px; - left: 30px; - width: 200px; - background-color: var(--popup-background-color); - border: 1px solid var(--border-color); - border-radius: 6px; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); - display: none; - z-index: 1000; - overflow: hidden; - - &.active { - display: block; - } - - .user-menu-header { - padding: 12px; - border-bottom: 1px solid var(--border-color); - - .user-menu-name { - font-weight: 500; - margin-bottom: 4px; - - .badge { - display: inline-flex; - align-items: center; - background-color: var(--popup-background-color); - background-color: color-mix(in srgb, - var(--error-text-color) 20%, - transparent); - color: var(--error-text-color); - padding: 2px 6px; - border-radius: 4px; - font-size: 12px; - font-weight: 500; - margin-left: 4px; - - &.verified { - color: var(--active-color); - background-color: transparent; - padding: 0; - } - } - } - - .user-menu-email { - font-size: 12px; - color: var(--popup-text-color); - color: color-mix(in srgb, var(--popup-text-color) 70%, transparent); - } - } - - .user-menu-item { - padding: 10px 12px; - cursor: pointer; - display: flex; - align-items: center; - gap: 8px; - - &:hover { - background-color: var(--active-icon-color); - } - } - - .user-menu-separator { - height: 1px; - background-color: var(--border-color); - margin: 4px 0; - } -} - -@supports not (gap: 1px) { - .user-menu-item > * + * { margin-left: 8px; } -} diff --git a/src/lang/ar-ye.json b/src/lang/ar-ye.json index 237e0e00d..758ae9e7f 100644 --- a/src/lang/ar-ye.json +++ b/src/lang/ar-ye.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "يجب ألا يتجاوز التقييم {max} حرفًا.", "plugin-review:error-downvote-comment": "أخبر المطوّر بما يمكن تحسينه.", "plugin-review:error-empty": "أضف تعليقًا أو اختر «أعجبني».", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "غير مقيّم", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/az-az.json b/src/lang/az-az.json index 8d52f9435..176675c20 100644 --- a/src/lang/az-az.json +++ b/src/lang/az-az.json @@ -915,5 +915,26 @@ "files saved count": "Files saved: {count}", "files not saved count": "Files not saved: {count}", "use native index": "Use native index", - "use native index hint": "Search local folders faster using the native file index." + "use native index hint": "Search local folders faster using the native file index.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week" } diff --git a/src/lang/be-by.json b/src/lang/be-by.json index e35007f98..b02c350b5 100644 --- a/src/lang/be-by.json +++ b/src/lang/be-by.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Водгук павінен змяшчаць не больш за {max} сімвалаў.", "plugin-review:error-downvote-comment": "Раскажыце распрацоўшчыку, што можна палепшыць.", "plugin-review:error-empty": "Дадайце каментарый або выберыце «Падабаецца».", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Без ацэнкі", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/bn-bd.json b/src/lang/bn-bd.json index 4a09aab67..9d7f53bd5 100644 --- a/src/lang/bn-bd.json +++ b/src/lang/bn-bd.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "পর্যালোচনা {max} অক্ষর বা তার কম হতে হবে।", "plugin-review:error-downvote-comment": "কী উন্নত করা যায় তা ডেভেলপারকে জানান।", "plugin-review:error-empty": "একটি মন্তব্য যোগ করুন বা পছন্দ নির্বাচন করুন।", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "এখনও মূল্যায়ন নেই", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/cs-cz.json b/src/lang/cs-cz.json index 4aff3839c..7d0870a8e 100644 --- a/src/lang/cs-cz.json +++ b/src/lang/cs-cz.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Recenze může mít nejvýše {max} znaků.", "plugin-review:error-downvote-comment": "Sdělte vývojáři, co by se dalo zlepšit.", "plugin-review:error-empty": "Přidejte komentář nebo zvolte Líbí se mi.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Nehodnoceno", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/de-de.json b/src/lang/de-de.json index fc6d09481..4315a89b7 100644 --- a/src/lang/de-de.json +++ b/src/lang/de-de.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Die Bewertung darf höchstens {max} Zeichen lang sein.", "plugin-review:error-downvote-comment": "Sage dem Entwickler, was verbessert werden könnte.", "plugin-review:error-empty": "Füge einen Kommentar hinzu oder wähle „Gefällt mir“.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Nicht bewertet", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/en-us.json b/src/lang/en-us.json index aaadfb66f..4ab8823cd 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -915,5 +915,26 @@ "files saved count": "Files saved: {count}", "files not saved count": "Files not saved: {count}", "use native index": "Use native index", - "use native index hint": "Search local folders faster using the native file index." + "use native index hint": "Search local folders faster using the native file index.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week" } diff --git a/src/lang/es-sv.json b/src/lang/es-sv.json index a593de3f4..6444de586 100644 --- a/src/lang/es-sv.json +++ b/src/lang/es-sv.json @@ -915,5 +915,26 @@ "files saved count": "Archivos guardados: {count}", "files not saved count": "Archivos sin guardar: {count}", "use native index": "Usar índice nativo", - "use native index hint": "Buscar más rapido en carpetas locales usando el índice de archivo nativo." + "use native index hint": "Buscar más rapido en carpetas locales usando el índice de archivo nativo.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week" } diff --git a/src/lang/fr-fr.json b/src/lang/fr-fr.json index 5ee85deaf..e47c20cea 100644 --- a/src/lang/fr-fr.json +++ b/src/lang/fr-fr.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "L’avis doit contenir au maximum {max} caractères.", "plugin-review:error-downvote-comment": "Indiquez au développeur ce qui pourrait être amélioré.", "plugin-review:error-empty": "Ajoutez un commentaire ou choisissez J’aime.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Non évalué", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/he-il.json b/src/lang/he-il.json index 140eee0cb..f538839f5 100644 --- a/src/lang/he-il.json +++ b/src/lang/he-il.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "הביקורת צריכה להכיל עד {max} תווים.", "plugin-review:error-downvote-comment": "ספר למפתח מה אפשר לשפר.", "plugin-review:error-empty": "הוסף תגובה או בחר באהבתי.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "ללא דירוג", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/hi-in.json b/src/lang/hi-in.json index dd73c9058..eabd03136 100644 --- a/src/lang/hi-in.json +++ b/src/lang/hi-in.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "समीक्षा {max} वर्णों या उससे कम की होनी चाहिए।", "plugin-review:error-downvote-comment": "डेवलपर को बताएँ कि क्या बेहतर किया जा सकता है।", "plugin-review:error-empty": "टिप्पणी जोड़ें या पसंद चुनें।", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "अभी रेटिंग नहीं", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/hu-hu.json b/src/lang/hu-hu.json index 3a65b167c..bb4325973 100644 --- a/src/lang/hu-hu.json +++ b/src/lang/hu-hu.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "A megjegyzés szövege legfeljebb {max} karakter lehet.", "plugin-review:error-downvote-comment": "Írja meg a fejlesztőknek, hogy min lehetne javítani.", "plugin-review:error-empty": "Adjon hozzá megjegyzést vagy válassza a „Tetszik” lehetőséget.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Még nem értékelte senki", "wrapped line indent": "Tördelt sorok behúzása", "wrap-indent-same": "Azonos", diff --git a/src/lang/id-id.json b/src/lang/id-id.json index 494c3721e..204e7c083 100644 --- a/src/lang/id-id.json +++ b/src/lang/id-id.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Ulasan harus terdiri dari {max} karakter atau kurang.", "plugin-review:error-downvote-comment": "Beri tahu developer apa yang dapat ditingkatkan.", "plugin-review:error-empty": "Tambahkan komentar atau pilih Suka.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Belum dinilai", "wrapped line indent": "Indentasi baris terbungkus", "wrap-indent-same": "Sama", diff --git a/src/lang/ir-fa.json b/src/lang/ir-fa.json index 8a39c355e..0b635adf5 100644 --- a/src/lang/ir-fa.json +++ b/src/lang/ir-fa.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "نظر باید حداکثر {max} نویسه باشد.", "plugin-review:error-downvote-comment": "به توسعه‌دهنده بگویید چه چیزی می‌تواند بهتر شود.", "plugin-review:error-empty": "یک دیدگاه بنویسید یا «پسندیدم» را انتخاب کنید.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "بدون امتیاز", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/it-it.json b/src/lang/it-it.json index 2bef6cd64..7bba28b5f 100644 --- a/src/lang/it-it.json +++ b/src/lang/it-it.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "La recensione deve contenere al massimo {max} caratteri.", "plugin-review:error-downvote-comment": "Spiega allo sviluppatore cosa potrebbe essere migliorato.", "plugin-review:error-empty": "Aggiungi un commento o scegli Mi piace.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Non valutato", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/ja-jp.json b/src/lang/ja-jp.json index 7bc5350ce..f14a60c9f 100644 --- a/src/lang/ja-jp.json +++ b/src/lang/ja-jp.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "レビューは {max} 文字以内で入力してください。", "plugin-review:error-downvote-comment": "改善してほしい点を開発者に伝えてください。", "plugin-review:error-empty": "コメントを追加するか、高評価を選んでください。", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "未評価", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/ko-kr.json b/src/lang/ko-kr.json index 4d262e789..dd1da7491 100644 --- a/src/lang/ko-kr.json +++ b/src/lang/ko-kr.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "리뷰는 {max}자 이하여야 합니다.", "plugin-review:error-downvote-comment": "개발자에게 개선할 점을 알려 주세요.", "plugin-review:error-empty": "댓글을 추가하거나 좋아요를 선택하세요.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "평가 없음", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/ln-ln.json b/src/lang/ln-ln.json index 91aba76da..d173853be 100644 --- a/src/lang/ln-ln.json +++ b/src/lang/ln-ln.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Review must be {max} characters or less.", "plugin-review:error-downvote-comment": "Tell the developer what could be improved.", "plugin-review:error-empty": "Add a comment or choose thumbs up.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Unrated", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/ml-in.json b/src/lang/ml-in.json index 440414396..3861f2983 100644 --- a/src/lang/ml-in.json +++ b/src/lang/ml-in.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "അവലോകനം {max} അക്ഷരങ്ങളോ അതിൽ കുറവോ ആയിരിക്കണം.", "plugin-review:error-downvote-comment": "എന്താണ് മെച്ചപ്പെടുത്താനാകുന്നതെന്ന് ഡെവലപ്പറോട് പറയുക.", "plugin-review:error-empty": "ഒരു അഭിപ്രായം ചേർക്കുക അല്ലെങ്കിൽ ഇഷ്ടപ്പെട്ടു തിരഞ്ഞെടുക്കുക.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "വിലയിരുത്തിയിട്ടില്ല", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/mm-unicode.json b/src/lang/mm-unicode.json index da5651ec6..00fa98bec 100644 --- a/src/lang/mm-unicode.json +++ b/src/lang/mm-unicode.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "သုံးသပ်ချက်သည် စာလုံးရေ {max} လုံး သို့မဟုတ် ထိုထက်နည်းရမည်။", "plugin-review:error-downvote-comment": "မည်သည့်အရာကို ပိုကောင်းအောင်လုပ်နိုင်ကြောင်း developer ကို ပြောပါ။", "plugin-review:error-empty": "မှတ်ချက်ထည့်ပါ သို့မဟုတ် ကြိုက်သည်ကို ရွေးပါ။", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "အဆင့်မသတ်မှတ်ရသေးပါ", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/mm-zawgyi.json b/src/lang/mm-zawgyi.json index 1a0a0d1a4..965292a08 100644 --- a/src/lang/mm-zawgyi.json +++ b/src/lang/mm-zawgyi.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "သုံးသပ္ခ်က္သည္ စာလုံးေရ {max} လုံး သို႔မဟုတ္ ထိုထက္နည္းရမည္။", "plugin-review:error-downvote-comment": "မည္သည့္အရာကို ပိုေကာင္းေအာင္လုပ္ႏိုင္ေၾကာင္း developer ကို ေျပာပါ။", "plugin-review:error-empty": "မွတ္ခ်က္ထည့္ပါ သို႔မဟုတ္ ႀကိဳက္သည္ကို ေ႐ြးပါ။", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "အဆင့္မသတ္မွတ္ရေသးပါ", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/pl-pl.json b/src/lang/pl-pl.json index 6df27618d..eab3f3571 100644 --- a/src/lang/pl-pl.json +++ b/src/lang/pl-pl.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Opinia może mieć maksymalnie {max} znaków.", "plugin-review:error-downvote-comment": "Powiedz deweloperowi, co można poprawić.", "plugin-review:error-empty": "Dodaj komentarz lub wybierz „Lubię”.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Bez oceny", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/pt-br.json b/src/lang/pt-br.json index c8d10df39..5b700e345 100644 --- a/src/lang/pt-br.json +++ b/src/lang/pt-br.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "A avaliação deve ter no máximo {max} caracteres.", "plugin-review:error-downvote-comment": "Diga ao desenvolvedor o que pode ser melhorado.", "plugin-review:error-empty": "Adicione um comentário ou escolha Gostei.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Sem avaliação", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/pu-in.json b/src/lang/pu-in.json index fa9faa09e..4fab8f2c1 100644 --- a/src/lang/pu-in.json +++ b/src/lang/pu-in.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "ਸਮੀਖਿਆ {max} ਅੱਖਰਾਂ ਜਾਂ ਇਸ ਤੋਂ ਘੱਟ ਦੀ ਹੋਣੀ ਚਾਹੀਦੀ ਹੈ।", "plugin-review:error-downvote-comment": "ਡਿਵੈਲਪਰ ਨੂੰ ਦੱਸੋ ਕਿ ਕੀ ਸੁਧਾਰਿਆ ਜਾ ਸਕਦਾ ਹੈ।", "plugin-review:error-empty": "ਟਿੱਪਣੀ ਸ਼ਾਮਲ ਕਰੋ ਜਾਂ ਪਸੰਦ ਚੁਣੋ।", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "ਹਾਲੇ ਮੁਲਾਂਕਣ ਨਹੀਂ", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/ru-ru.json b/src/lang/ru-ru.json index 18990d3b4..c7b060cd8 100644 --- a/src/lang/ru-ru.json +++ b/src/lang/ru-ru.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Отзыв должен содержать не более {max} символов.", "plugin-review:error-downvote-comment": "Расскажите разработчику, что можно улучшить.", "plugin-review:error-empty": "Добавьте комментарий или выберите «Нравится».", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Нет оценок", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/tl-ph.json b/src/lang/tl-ph.json index bf6942d43..b1bb78806 100644 --- a/src/lang/tl-ph.json +++ b/src/lang/tl-ph.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Dapat {max} character o mas kaunti ang review.", "plugin-review:error-downvote-comment": "Sabihin sa developer kung ano ang maaaring mapabuti.", "plugin-review:error-empty": "Magdagdag ng komento o piliin ang Gusto.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Walang rating", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/tr-tr.json b/src/lang/tr-tr.json index 588fef21a..e3672f659 100644 --- a/src/lang/tr-tr.json +++ b/src/lang/tr-tr.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Değerlendirme en fazla {max} karakter olmalıdır.", "plugin-review:error-downvote-comment": "Geliştiriciye nelerin iyileştirilebileceğini söyleyin.", "plugin-review:error-empty": "Yorum ekleyin veya Beğendim’i seçin.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Değerlendirilmedi", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/uk-ua.json b/src/lang/uk-ua.json index 2f4104fbf..6f2c0971c 100644 --- a/src/lang/uk-ua.json +++ b/src/lang/uk-ua.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Відгук має містити не більше {max} символів.", "plugin-review:error-downvote-comment": "Розкажіть розробнику, що можна покращити.", "plugin-review:error-empty": "Додайте коментар або виберіть «Подобається».", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Без оцінки", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/uz-uz.json b/src/lang/uz-uz.json index e54da9d85..2cead9f38 100644 --- a/src/lang/uz-uz.json +++ b/src/lang/uz-uz.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Sharh {max} ta yoki undan kam belgidan iborat bo‘lishi kerak.", "plugin-review:error-downvote-comment": "Dasturchiga nimani yaxshilash mumkinligini ayting.", "plugin-review:error-empty": "Izoh qo‘shing yoki “Yoqdi”ni tanlang.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Baholanmagan", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/vi-vn.json b/src/lang/vi-vn.json index dfe6e920d..c9adc1794 100644 --- a/src/lang/vi-vn.json +++ b/src/lang/vi-vn.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "Đánh giá phải có tối đa {max} ký tự.", "plugin-review:error-downvote-comment": "Hãy cho nhà phát triển biết điều gì có thể được cải thiện.", "plugin-review:error-empty": "Thêm bình luận hoặc chọn Thích.", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "Chưa đánh giá", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index ab03b1f80..184bcd9e0 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "评价不能超过 {max} 个字符。", "plugin-review:error-downvote-comment": "告诉开发者哪些地方可以改进。", "plugin-review:error-empty": "添加评论或选择“赞”。", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "暂无评分", "wrapped line indent": "折行缩进", "wrap-indent-same": "与首行对齐", diff --git a/src/lang/zh-hant.json b/src/lang/zh-hant.json index 5164bc893..e7429041e 100644 --- a/src/lang/zh-hant.json +++ b/src/lang/zh-hant.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "評論不得超過 {max} 個字元。", "plugin-review:error-downvote-comment": "告訴開發者哪些地方可以改進。", "plugin-review:error-empty": "新增留言或選擇「讚」。", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "尚未評分", "wrapped line indent": "換行縮排", "wrap-indent-same": "與首行對齊", diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index afb65dde2..d372f0d98 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -879,6 +879,27 @@ "plugin-review:error-max-length": "評論不得超過 {max} 個字元。", "plugin-review:error-downvote-comment": "告訴開發者哪些地方可以改進。", "plugin-review:error-empty": "新增留言或選擇「讚」。", + "profile not signed in": "Not signed in", + "profile sign in prompt": "Sign in with your Acode account.", + "acode account": "Acode account", + "member since": "Member since {date}", + "activity": "Activity", + "top languages": "Top languages", + "last 12 months": "Last 12 months", + "coding time": "Coding time", + "streak": "Streak", + "active days": "Active days", + "less": "Less", + "today time": "Today {time}", + "nothing yet today": "Nothing yet today", + "no activity on": "No activity on {date}", + "languages empty": "Languages show up here as you code.", + "reset activity": "Reset activity", + "reset activity warning": "This clears the time, lines, files and streaks tracked on this device.", + "activity reset": "Activity reset", + "logout confirm": "Are you sure you want to log out of your Acode account?", + "best streak": "Best streak", + "this week": "This week", "plugin-review:unrated": "尚未評分", "wrapped line indent": "Word wrap indentation", "wrap-indent-same": "Same", diff --git a/src/lib/activity.js b/src/lib/activity.js new file mode 100644 index 000000000..ca9502ea7 --- /dev/null +++ b/src/lib/activity.js @@ -0,0 +1,265 @@ +/** + * Local coding activity for the profile page. + * + * Everything is stored on this device only (localStorage), one small record + * per day: time spent coding, lines written, files created and time spent + * typing in each language. Lines and files only influence how bright a day + * looks. Nothing is sent anywhere. + */ +import { getMode, getModeForPath } from "cm/modelist"; + +const STORAGE_KEY = "acode-activity-v1"; +const KEEP_DAYS = 400; +const TICK_MS = 10 * 1000; +// No touch/key input for this long means the person stepped away. +const IDLE_MS = 2 * 60 * 1000; +const SAVE_DELAY = 3000; +const DAY_MS = 24 * 60 * 60 * 1000; +// Score (about "minutes of coding") needed for each shade 1 to 4. +const LEVELS = [1, 10, 30, 60]; + +let days = {}; +let started = false; +let lastInput = 0; +let lastTick = 0; +let lastEditAt = 0; +let lastEditLanguage = ""; +let saveTimer = null; + +const pad = (n) => String(n).padStart(2, "0"); + +export function dayKey(date = new Date()) { + const month = pad(date.getMonth() + 1); + return `${date.getFullYear()}-${month}-${pad(date.getDate())}`; +} + +function normalizeDay(day) { + return { + ms: Number(day?.ms) || 0, + lines: Number(day?.lines) || 0, + files: Number(day?.files) || 0, + code: day?.code && typeof day.code === "object" ? day.code : {}, + }; +} + +function load() { + days = {}; + try { + const parsed = JSON.parse(localStorage.getItem(STORAGE_KEY) || "{}"); + const cutoff = dayKey(new Date(Date.now() - KEEP_DAYS * DAY_MS)); + for (const [key, value] of Object.entries(parsed?.days || {})) { + if (key >= cutoff) days[key] = normalizeDay(value); + } + } catch { + days = {}; + } +} + +function save() { + clearTimeout(saveTimer); + saveTimer = null; + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify({ days })); + } catch {} +} + +function scheduleSave() { + if (!saveTimer) saveTimer = setTimeout(save, SAVE_DELAY); +} + +function today() { + const key = dayKey(); + if (!days[key]) days[key] = normalizeDay(); + return days[key]; +} + +function languageOf(file) { + const mode = + (file.currentMode && getMode(file.currentMode)) || + getModeForPath(file.filename || ""); + if (!mode || mode.name === "text") return ""; + return mode.caption || mode.name; +} + +function tick() { + const now = Date.now(); + const elapsed = Math.min(now - lastTick, TICK_MS * 2); + lastTick = now; + + if (document.visibilityState !== "visible") return; + if (now - lastInput > IDLE_MS) return; + + const day = today(); + day.ms += elapsed; + // A language only gets credit while you are typing in it, so opening or + // scrolling a file doesn't count. + if (lastEditLanguage && now - lastEditAt <= IDLE_MS) { + day.code[lastEditLanguage] = (day.code[lastEditLanguage] || 0) + elapsed; + } + scheduleSave(); +} + +/** Start tracking. Safe to call more than once. */ +function init() { + if (started || typeof document === "undefined") return; + started = true; + load(); + lastTick = Date.now(); + + const markInput = () => { + lastInput = Date.now(); + }; + for (const type of ["touchstart", "pointerdown", "keydown"]) { + document.addEventListener(type, markInput, { + capture: true, + passive: true, + }); + } + + setInterval(tick, TICK_MS); + document.addEventListener("visibilitychange", () => { + if (document.visibilityState === "hidden") save(); + }); + document.addEventListener("pause", save); +} + +/** + * Called from the editor's update listener. Typing and deleting credit the + * file's language; typed lines add to the day's score. Pastes, drops, + * undo/redo and formatters never count as lines. + * @param {import("@codemirror/view").ViewUpdate} update + * @param {object} [file] the EditorFile being edited + */ +function recordEdit(update, file) { + if (!started) return; + const now = Date.now(); + lastInput = now; + + let lines = 0; + let typed = false; + for (const tr of update.transactions) { + if (!tr.docChanged) continue; + if (!tr.isUserEvent("input") && !tr.isUserEvent("delete")) continue; + typed = true; + if (tr.isUserEvent("input.paste") || tr.isUserEvent("input.drop")) continue; + tr.changes.iterChanges((_fromA, _toA, _fromB, _toB, inserted) => { + lines += Math.max(0, inserted.lines - 1); + }); + } + + if (typed) { + lastEditAt = now; + lastEditLanguage = file ? languageOf(file) : ""; + } + + if (!lines) return; + today().lines += lines; + scheduleSave(); +} + +/** Count a file the person created (file tree or file browser). */ +function recordFileCreated() { + if (!started) return; + lastInput = Date.now(); + today().files += 1; + scheduleSave(); +} + +/** Wipe everything that was tracked. */ +function reset() { + days = {}; + save(); +} + +/** Roughly "minutes of coding" for one day, used to pick the shade. */ +function scoreOf(day) { + return day.ms / 60000 + day.lines / 4 + day.files * 2; +} + +function levelOf(score) { + let level = 0; + for (const [index, min] of LEVELS.entries()) { + if (score >= min) level = index + 1; + } + return level; +} + +/** + * Everything the profile page needs. + * @returns {{ + * year: Array<{date:string, ms:number, lines:number, files:number, level:number}>, + * totals: {ms:number, lines:number, files:number, activeDays:number}, + * current: number, + * longest: number, + * languages: Array<{name:string, ms:number, share:number}>, + * today: {ms:number, lines:number, files:number}, + * }} + */ +function getSummary() { + if (!started) load(); + + const year = []; + const now = new Date(); + for (let i = 364; i >= 0; i--) { + const date = new Date(now.getFullYear(), now.getMonth(), now.getDate() - i); + const key = dayKey(date); + const day = days[key] || normalizeDay(); + year.push({ + date: key, + ms: day.ms, + lines: day.lines, + files: day.files, + level: levelOf(scoreOf(day)), + }); + } + + const totals = { ms: 0, lines: 0, files: 0, activeDays: 0 }; + const languageMs = {}; + let longest = 0; + let run = 0; + for (const day of year) { + totals.ms += day.ms; + totals.lines += day.lines; + totals.files += day.files; + if (day.level > 0) { + totals.activeDays++; + run++; + longest = Math.max(longest, run); + } else { + run = 0; + } + for (const [name, ms] of Object.entries(days[day.date]?.code || {})) { + languageMs[name] = (languageMs[name] || 0) + ms; + } + } + + // An unfinished day shouldn't break the streak. + let current = 0; + let i = year.length - 1; + if (year[i].level === 0) i--; + for (; i >= 0 && year[i].level > 0; i--) current++; + + const languageTotal = Object.values(languageMs).reduce((a, b) => a + b, 0); + const languages = Object.entries(languageMs) + .sort((a, b) => b[1] - a[1]) + .slice(0, 5) + .map(([name, ms]) => ({ name, ms, share: ms / languageTotal })); + + const latest = year[year.length - 1]; + return { + year, + totals, + current, + longest, + languages, + today: { ms: latest.ms, lines: latest.lines, files: latest.files }, + }; +} + +export default { + init, + recordEdit, + recordFileCreated, + reset, + getSummary, +}; diff --git a/src/lib/editorManager.js b/src/lib/editorManager.js index ae95b065c..71d0a3e91 100644 --- a/src/lib/editorManager.js +++ b/src/lib/editorManager.js @@ -112,6 +112,7 @@ import ScrollBar from "components/scrollbar"; import SideButton, { sideButtonContainer } from "components/sideButton"; import keyboardHandler, { keydownState } from "handlers/keyboard"; import { animate } from "motion"; +import activity from "./activity"; import config from "./config"; import EditorFile, { AUTO_SAVE } from "./editorFile"; import openFile from "./openFile"; @@ -3868,6 +3869,7 @@ async function EditorManager($header, $body) { } file.markEdited(); + activity.recordEdit(update, file); // Debounced change handling (unsaved flag, cache, autosave) const timers = getDocSyncTimers(file); diff --git a/src/pages/profile/heatmap.js b/src/pages/profile/heatmap.js new file mode 100644 index 000000000..4c15e2155 --- /dev/null +++ b/src/pages/profile/heatmap.js @@ -0,0 +1,56 @@ +const MONTHS = [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", +]; + +/** Groups days into Sunday-first weeks of 7 (null = padding). */ +export function buildWeeks(days) { + const weeks = []; + const offset = new Date(`${days[0].date}T00:00:00Z`).getUTCDay(); + let week = new Array(offset).fill(null); + + for (const day of days) { + week.push(day); + if (week.length === 7) { + weeks.push(week); + week = []; + } + } + if (week.length) { + while (week.length < 7) week.push(null); + weeks.push(week); + } + return weeks; +} + +/** Month name for the column where a new month starts, else undefined. */ +export function monthLabels(weeks) { + const starts = []; + let prev = -1; + weeks.forEach((week, i) => { + const day = week.find((d) => d?.date.endsWith("-01")) || week.find(Boolean); + if (!day) return; + const month = Number(day.date.slice(5, 7)) - 1; + if (month !== prev) { + starts.push({ i, month }); + prev = month; + } + }); + + // A tiny first month would collide with the next label, so drop it. + if (starts.length > 1 && starts[1].i - starts[0].i < 3) starts.shift(); + + const labels = {}; + for (const { i, month } of starts) labels[i] = MONTHS[month]; + return labels; +} diff --git a/src/pages/profile/index.js b/src/pages/profile/index.js new file mode 100644 index 000000000..6023b0eb5 --- /dev/null +++ b/src/pages/profile/index.js @@ -0,0 +1,15 @@ +//jshint ignore:start + +/** + * Open the profile page. + * @param {object} options + * @param {object} options.user - logged in user + * @param {() => Promise} [options.getAvatarSrc] + * @param {() => Promise} [options.onLogout] + */ +function Profile(options) { + return import(/* webpackChunkName: "profile" */ "./profile").then((res) => { + return res.default(options); + }); +} +export default Profile; diff --git a/src/pages/profile/profile.js b/src/pages/profile/profile.js new file mode 100644 index 000000000..29a87d15c --- /dev/null +++ b/src/pages/profile/profile.js @@ -0,0 +1,810 @@ +import "./profile.scss"; +import fsOperation from "fileSystem"; +import Page from "components/page"; +import Sidebar from "components/sidebar"; +import toast from "components/toast"; +import confirm from "dialogs/confirm"; +import actionStack from "lib/actionStack"; +import tracker from "lib/activity"; +import config from "lib/config"; +import { LOADED_PLUGINS } from "lib/loadPlugins"; +import openFile from "lib/openFile"; +import openFolder from "lib/openFolder"; +import recents from "lib/recents"; +import helpers from "utils/helpers"; +import Uri from "utils/Uri"; +import Url from "utils/Url"; +import { buildWeeks, monthLabels } from "./heatmap"; +import renderShareCard from "./shareCard"; + +/* Feather-style stroke icons, so the page never depends on the icon font. */ +const ICONS = { + package: + '', + file: '', + folder: + '', + sliders: + '', + contrast: + '', + info: '', + external: + '', + logout: + '', + login: + '', + trash: + '', + user: '', + chevron: '', + share: + '', + verified: + '', +}; + +/** + * Translated string with an English fallback, so a key that has not been + * added to a language file yet still shows readable text. + * `{name}` placeholders are filled from `vars`. + * @param {string} key + * @param {string} fallback + * @param {Record} [vars] + */ +function t(key, fallback, vars = {}) { + let text = strings[key] || fallback; + for (const [name, value] of Object.entries(vars)) { + text = text.replaceAll(`{${name}}`, String(value)); + } + return text; +} + +/* Familiar colors for common languages; anything else gets a stable hue. */ +const LANG_COLORS = { + javascript: "#f1e05a", + jsx: "#f1e05a", + typescript: "#3178c6", + tsx: "#3178c6", + html: "#e34c26", + css: "#7b5bb6", + scss: "#c6538c", + json: "#8f9aa5", + markdown: "#519aba", + python: "#3572a5", + java: "#b07219", + kotlin: "#a97bff", + php: "#4f5d95", + go: "#00add8", + rust: "#dea584", + ruby: "#cc342d", + yaml: "#cb171e", + xml: "#0060ac", + sql: "#e38c00", + dart: "#00b4ab", + swift: "#f05138", + lua: "#4a5bd1", +}; + +function langColor(name) { + const key = String(name).toLowerCase(); + if (LANG_COLORS[key]) return LANG_COLORS[key]; + let hue = 0; + for (const ch of key) hue = (hue * 31 + ch.charCodeAt(0)) % 360; + return `hsl(${hue} 55% 55%)`; +} + +function icon(name, size = 20) { + const el = document.createElement("span"); + el.className = "pf-icon"; + el.innerHTML = ``; + return el; +} + +function formatMonthYear(value) { + const date = new Date(value); + if (Number.isNaN(date.getTime())) return ""; + return date.toLocaleDateString(undefined, { + month: "short", + year: "numeric", + }); +} + +function formatDuration(ms) { + const minutes = Math.round(ms / 60000); + if (minutes < 1) return ms > 0 ? "<1m" : "0m"; + if (minutes < 60) return `${minutes}m`; + const hours = Math.floor(minutes / 60); + const rest = minutes % 60; + if (hours >= 100 || !rest) return `${hours}h`; + return `${hours}h ${rest}m`; +} + +/** + * Deterministic sample activity shaped like a real year (quieter weekends, + * a few busy streaks). Only used as a faded preview, never as real data. + */ +function samplePattern(year) { + return year.map((day, i) => { + const weekday = new Date(`${day.date}T00:00:00Z`).getUTCDay(); + const wave = (Math.sin(i / 9) + Math.sin(i / 23 + 1) + 2) / 4; + const noise = ((i * 7919) % 13) / 13; + const score = + wave + noise * 0.5 - (weekday === 0 || weekday === 6 ? 0.35 : 0); + let level = 4; + if (score < 0.45) level = 0; + else if (score < 0.7) level = 1; + else if (score < 0.9) level = 2; + else if (score < 1.05) level = 3; + return { date: day.date, ms: 0, level }; + }); +} + +function tipText(day) { + const when = new Date(`${day.date}T00:00:00Z`).toLocaleDateString(undefined, { + month: "short", + day: "numeric", + year: "numeric", + timeZone: "UTC", + }); + if (!day.level) { + return t("no activity on", "No activity on {date}", { date: when }); + } + return `${when} · ${formatDuration(day.ms)}`; +} + +/** Same path breakdown the "recent" picker uses. */ +function pathDetails(url) { + url = Url.parse(url).url; + const isSafUri = /^content:/.test(url); + const displayPath = isSafUri + ? Uri.getDisplayPath(url) + : helpers.getVirtualPath(url); + const documentPath = isSafUri ? Uri.getDisplayPath(url, []) : displayPath; + const name = Url.basename(displayPath) || Url.basename(documentPath) || url; + const location = + Url.dirname(isSafUri ? documentPath : displayPath)?.replace(/\/$/, "") || + "/"; + return { name, location }; +} + +const openUrl = (url) => () => system.openInBrowser(url); + +/** Saves the image to the cache folder and opens the system share sheet. */ +async function shareImage(blob, name) { + const buffer = await blob.arrayBuffer(); + const url = Url.join(CACHE_STORAGE, name); + if (await fsOperation(url).exists()) await fsOperation(url).delete(); + await fsOperation(CACHE_STORAGE).createFile(name, buffer); + const { url: shareUrl } = await fsOperation(url).stat(); + const onFail = () => toast(strings["no app found to handle this file"]); + system.fileAction(shareUrl, name, "SEND", "image/png", onFail); +} + +function section(title) { + const $trail = ; + const $body =
; + const $el = ( +
+
+

{title}

+ {$trail} +
+ {$body} +
+ ); + return { $el, $body, $trail }; +} + +function row({ + iconName, + title, + subtitle, + value, + onclick, + danger = false, + chevron = true, +}) { + const $text = ( +
+
{title}
+
+ ); + if (subtitle) { + $text.append(
{subtitle}
); + } + const $row = ( +
+ {icon(iconName, 20)} + {$text} +
+ ); + if (value) { + // Plain strings get the same muted style as element values. + $row.append( + typeof value === "string" ? ( + {value} + ) : ( + value + ), + ); + } + if (chevron) $row.append(icon("chevron", 18)); + return $row; +} + +const metric = (value, label) => ( +
+
{String(value)}
+
{label}
+
+); + +/** Avatar circle: initial first, swaps to the picture once it has loaded. */ +function buildAvatar(user, getAvatarSrc) { + const initial = (user.name || user.email || "?") + .trim() + .charAt(0) + .toUpperCase(); + const $img = ; + const $avatar = ( +
+ {initial} + {$img} +
+ ); + $img.onload = () => $avatar.classList.add("loaded"); + if (typeof getAvatarSrc === "function") { + Promise.resolve(getAvatarSrc(user)) + .then((src) => { + if (src) $img.src = src; + }) + .catch(() => {}); + } + return $avatar; +} + +/** Header for a logged in user. */ +function buildUserHero(user, getAvatarSrc) { + const $nameRow = ( +
+

{user.name}

+
+ ); + if (user.verified) { + const $v = ; + $v.append(icon("verified", 16)); + $nameRow.append($v); + } + if (user.acode_pro) { + $nameRow.append(PRO); + } + if (user.isAdmin) { + $nameRow.append(ADMIN); + } + + const $meta =
; + const since = formatMonthYear(user.created_at); + if (since) { + $meta.append( + {t("member since", "Member since {date}", { date: since })}, + ); + } + if (user.website) { + const site = String(user.website); + const url = /^https?:\/\//.test(site) ? site : `https://${site}`; + if (since) $meta.append(·); + $meta.append( + + {site.replace(/^https?:\/\//, "")} + , + ); + } + + return ( +
+ {buildAvatar(user, getAvatarSrc)} +
+ {$nameRow} +
{user.email || ""}
+ {$meta} +
+
+ ); +} + +/** Header shown when nobody is logged in, with a sign in button. */ +function buildGuestHero(onSignIn) { + const signInText = t("login", "Login"); + const $label = {signInText}; + const $btn = ; + $btn.append(icon("login", 16), $label); + $btn.onclick = async () => { + if ($btn.disabled) return; + $btn.disabled = true; + $label.textContent = t("loading...", "Loading..."); + try { + await onSignIn(); + } finally { + $btn.disabled = false; + $label.textContent = signInText; + } + }; + + return ( +
+
{icon("user", 30)}
+
+

+ {t("profile not signed in", "Not signed in")} +

+
+ {t("profile sign in prompt", "Sign in with your Acode account.")} +
+ {$btn} +
+
+ ); +} + +/** + * Open the profile page. Works logged in or out. + * @param {object} options + * @param {object|null} [options.user] - logged in user, if any + * @param {(user:object) => Promise} [options.getAvatarSrc] + * @param {() => Promise} [options.onLogin] - resolves the new user + * @param {() => Promise} [options.onLogout] + */ +export default function ProfileInclude({ + user: initialUser = null, + getAvatarSrc, + onLogin, + onLogout, +} = {}) { + let user = initialUser; + + const $page = Page(t("my profile", "My profile")); + $page.classList.add("profile-page"); + + const close = () => { + $page.hide(); + Sidebar.hide(); + }; + const goto = (fn) => () => { + close(); + setTimeout(() => { + try { + fn(); + } catch (error) { + helpers.error(error); + } + }, 200); + }; + + const $heroSlot =
; + const $footSlot =
; + const activity = section(t("activity", "Activity")); + const languages = section(t("top languages", "Top languages")); + + /* ---------- account ---------- */ + async function signIn() { + if (!onLogin) return; + const next = await onLogin(); + if (next) { + user = next; + refreshAccount(); + } + } + + async function signOut() { + const ok = await confirm( + t("logout", "Logout"), + t( + "logout confirm", + "Are you sure you want to log out of your Acode account?", + ), + ); + if (!ok) return; + const success = onLogout ? await onLogout() : true; + if (success === false) return; + user = null; + refreshAccount(); + } + + async function resetActivity() { + const ok = await confirm( + t("reset activity", "Reset activity"), + t( + "reset activity warning", + "This clears the time, lines, files and streaks tracked on this device.", + ), + ); + if (!ok) return; + tracker.reset(); + renderActivity(); + renderLanguages(); + toast(t("activity reset", "Activity reset")); + } + + function renderHero() { + $heroSlot.textContent = ""; + $heroSlot.append( + user ? buildUserHero(user, getAvatarSrc) : buildGuestHero(signIn), + ); + } + + function renderFoot() { + $footSlot.textContent = ""; + const $card =
; + $card.append( + row({ + iconName: "trash", + title: t("reset activity", "Reset activity"), + chevron: false, + onclick: resetActivity, + }), + ); + if (user) { + $card.append( + row({ + iconName: "logout", + title: t("logout", "Logout"), + danger: true, + chevron: false, + onclick: signOut, + }), + ); + } + $footSlot.append($card); + } + + function refreshAccount() { + // After the first render, sign in/out also swaps the sample heatmap. + if (activity.$body.firstChild) renderActivity(); + renderHero(); + renderFoot(); + } + + /* ---------- activity ---------- */ + const $share = ; + $share.setAttribute("aria-label", t("share", "Share")); + $share.append(icon("share", 16)); + activity.$trail.append( + {t("last 12 months", "Last 12 months")}, + $share, + ); + + let sharing = false; + $share.onclick = async () => { + if (sharing) return; + sharing = true; + try { + const blob = await renderShareCard($share, { + name: user?.name || t("activity", "Activity"), + data: tracker.getSummary(), + formatDuration, + label: t, + }); + await shareImage(blob, "acode-activity.png"); + } catch (error) { + console.error(error); + toast(t("share failed", "Could not share your activity")); + } finally { + sharing = false; + } + }; + + function renderActivity() { + const data = tracker.getSummary(); + // Signed out with nothing tracked yet: show a faded sample instead of + // a blank grid. + const isPlaceholder = !user && !data.totals.activeDays; + $share.style.display = data.totals.activeDays ? "" : "none"; + const weeks = buildWeeks( + isPlaceholder ? samplePattern(data.year) : data.year, + ); + const labels = monthLabels(weeks); + const todayKey = data.year[data.year.length - 1].date; + const $grid =
; + + weeks.forEach((week, i) => { + const $week =
; + $week.append(
{labels[i] || ""}
); + for (const day of week) { + let cellClass = "pf-gh-cell none"; + if (day) { + cellClass = `pf-gh-cell lv${day.level}`; + if (day.date === todayKey && !isPlaceholder) cellClass += " today"; + } + const $cell =
; + if (day && !isPlaceholder) $cell.dataset.tip = tipText(day); + $week.append($cell); + } + $grid.append($week); + }); + + // Tapping a day highlights it and shows its details. + let $selected = null; + $grid.onclick = (e) => { + const $cell = e.target; + const tip = $cell?.dataset?.tip; + if (!tip) return; + $selected?.classList.remove("selected"); + $selected = $cell; + $cell.classList.add("selected"); + toast(tip); + }; + + const $scroll =
{$grid}
; + + // Weekday labels (Mon/Wed/Fri) stay put while the grid scrolls. + const $days =
; + $days.append(
); + for (let row = 0; row < 7; row++) { + // 2024-01-07 was a Sunday, matching the Sunday-first grid. + const name = + row % 2 === 1 + ? new Date(2024, 0, 7 + row).toLocaleDateString(undefined, { + weekday: "short", + }) + : ""; + $days.append(
{name}
); + } + const $heat = ( +
+ {$days} + {$scroll} +
+ ); + + const $legend =
; + $legend.append({t("less", "Less")}); + for (let n = 0; n <= 4; n++) { + $legend.append(); + } + $legend.append({t("more", "More")}); + + const { today, totals } = data; + const todayText = today.ms + ? t("today time", "Today {time}", { time: formatDuration(today.ms) }) + : t("nothing yet today", "Nothing yet today"); + + activity.$body.textContent = ""; + activity.$body.append( +
+ {metric(formatDuration(totals.ms), t("coding time", "Coding time"))} + {metric(`${data.current}d`, t("streak", "Streak"))} + {metric(`${data.longest}d`, t("best streak", "Best streak"))} + {metric(String(totals.activeDays), t("active days", "Active days"))} +
, + $heat, +
+ + {isPlaceholder + ? t( + "activity placeholder hint", + "Sign in and start coding to fill this in", + ) + : todayText} + + {$legend} +
, + ); + + // Newest weeks are on the right, so start scrolled to the end. + setTimeout(() => { + $scroll.scrollLeft = $scroll.scrollWidth; + }, 50); + + renderWeek(data); + return data; + } + + /* ---------- this week (last 7 days) ---------- */ + const thisWeek = section(t("this week", "This week")); + + function renderWeek(data) { + const days = data.year.slice(-7); + const max = Math.max(...days.map((day) => day.ms), 1); + const total = days.reduce((sum, day) => sum + day.ms, 0); + thisWeek.$trail.textContent = total ? formatDuration(total) : ""; + + const $chart =
; + days.forEach((day, i) => { + const isToday = i === days.length - 1; + const percent = day.ms + ? Math.max(8, Math.round((day.ms / max) * 100)) + : 0; + const barClass = ["pf-week-bar", !day.ms && "empty", isToday && "today"] + .filter(Boolean) + .join(" "); + const name = new Date(`${day.date}T00:00:00Z`).toLocaleDateString( + undefined, + { weekday: "short", timeZone: "UTC" }, + ); + $chart.append( +
toast(tipText(day))}> +
+ +
+ + {name} + +
, + ); + }); + thisWeek.$body.textContent = ""; + thisWeek.$body.append($chart); + } + + function renderLanguages(list = tracker.getSummary().languages) { + languages.$body.textContent = ""; + if (!list.length) { + languages.$body.append( +
+ {t("languages empty", "Languages show up here as you code.")} +
, + ); + return; + } + const $strip =
; + for (const lang of list) { + $strip.append( + , + ); + } + languages.$body.append($strip); + + for (const lang of list) { + const percent = lang.share * 100; + const label = percent < 1 ? "<1%" : `${Math.round(percent)}%`; + languages.$body.append( +
+ + {lang.name} + {label} +
, + ); + } + } + + /* ---------- recents ---------- */ + const recent = section(t("recently used", "Recently used")); + const recentFiles = recents.files.filter(Boolean).slice(0, 4); + const recentFolders = recents.folders.filter((f) => f?.url).slice(0, 2); + + for (const file of recentFiles) { + const { name, location } = pathDetails(file); + recent.$body.append( + row({ + iconName: "file", + title: name, + subtitle: location, + chevron: false, + onclick: goto(() => + Promise.resolve(openFile(file, { render: true })).catch((err) => + helpers.error(err), + ), + ), + }), + ); + } + for (const folder of recentFolders) { + const { name, location } = pathDetails(folder.url); + recent.$body.append( + row({ + iconName: "folder", + title: name, + subtitle: location, + chevron: false, + onclick: goto(() => openFolder(folder.url, folder.opts)), + }), + ); + } + + /* ---------- menu ---------- */ + // Count of plugins downloaded to this device; tapping opens the + // Plugins page, which starts on its "Installed" tab. + const $pluginCount = –; + + const menu = section(t("more", "More")); + const menuRows = [ + { + iconName: "package", + title: t("plugins", "Plugins"), + value: $pluginCount, + onclick: goto(async () => + ( + await import(/* webpackChunkName: "plugins" */ "pages/plugins") + ).default(), + ), + }, + { + iconName: "sliders", + title: t("settings", "Settings"), + onclick: goto(async () => + ( + await import( + /* webpackChunkName: "mainSettings" */ "settings/mainSettings" + ) + ).default(), + ), + }, + { + iconName: "contrast", + title: t("app theme", "App theme"), + onclick: goto(async () => + ( + await import( + /* webpackChunkName: "changeTheme" */ "palettes/changeTheme" + ) + ).default("app"), + ), + }, + { + iconName: "folder", + title: t("open folder", "Open folder"), + onclick: goto(() => acode.exec("open-folder")), + }, + { + iconName: "external", + title: t("acode account", "Acode account"), + value: String(config.BASE_URL || "").replace(/^https?:\/\//, ""), + onclick: openUrl(config.BASE_URL), + }, + { + iconName: "info", + title: t("about", "About"), + value: window.BuildInfo?.version || "", + onclick: goto(async () => + (await import(/* webpackChunkName: "about" */ "pages/about")).default(), + ), + }, + ]; + for (const item of menuRows) menu.$body.append(row(item)); + + async function fillPlugins() { + let total = LOADED_PLUGINS.size; + try { + const list = await fsOperation(PLUGIN_DIR).lsDir(); + total = list.length; + } catch {} + $pluginCount.textContent = String(total); + } + + /* ---------- assemble ---------- */ + const $main =
; + $main.append($heroSlot, activity.$el, thisWeek.$el, languages.$el); + if (recentFiles.length || recentFolders.length) $main.append(recent.$el); + $main.append(menu.$el, $footSlot); + + refreshAccount(); + renderLanguages(renderActivity().languages); + fillPlugins(); + + // Index per section drives the staggered entrance (see profile.scss). + [...$main.children].forEach(($el, i) => $el.style.setProperty("--pf-i", i)); + + $page.body = $main; + + actionStack.push({ + id: "profile", + action: $page.hide, + }); + + $page.onhide = function () { + actionStack.remove("profile"); + }; + + app.append($page); +} diff --git a/src/pages/profile/profile.scss b/src/pages/profile/profile.scss new file mode 100644 index 000000000..879f627a1 --- /dev/null +++ b/src/pages/profile/profile.scss @@ -0,0 +1,551 @@ +@keyframes pf-rise { + from { + opacity: 0; + transform: translateY(12px); + } + to { + opacity: 1; + transform: none; + } +} + +#profile-page { + --pf-blue: #3b82f6; + /* Follows the active theme; the button keeps a fixed blue for contrast. */ + --pf-accent: var(--active-color, var(--pf-blue)); + --pf-muted: color-mix(in srgb, var(--primary-text-color) 60%, transparent); + --pf-border: var(--border-color, rgba(255, 255, 255, 0.1)); + --pf-danger: var(--danger-color, #ff5c5c); + + /* Activity graph: one blue, five steps (works on light and dark themes) */ + --pf-lv0: color-mix(in srgb, var(--primary-text-color) 9%, transparent); + --pf-lv1: color-mix(in srgb, var(--pf-accent) 28%, transparent); + --pf-lv2: color-mix(in srgb, var(--pf-accent) 50%, transparent); + --pf-lv3: color-mix(in srgb, var(--pf-accent) 75%, transparent); + --pf-lv4: var(--pf-accent); + + box-sizing: border-box; + width: 100%; + max-width: 560px; + margin: 0 auto; + padding: 20px 16px 40px; + display: flex; + flex-direction: column; + gap: 24px; + overflow-y: auto; + color: var(--primary-text-color); + + .pf-icon { + display: inline-flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + } + + /* Sections fade up one after another (--pf-i is set in profile.js). */ + > .pf-slot, + > .pf-section { + animation: pf-rise 0.4s ease-out both; + animation-delay: calc(var(--pf-i, 0) * 60ms); + } + + @media (prefers-reduced-motion: reduce) { + > .pf-slot, + > .pf-section { animation: none; } + } + + /* Faded sample graph for signed-out users with no activity yet. */ + .pf-gh-wrap.placeholder { + opacity: 0.35; + pointer-events: none; + } + + .pf-slot { + display: flex; + flex-direction: column; + } + + .pf-link { + color: var(--pf-accent); + &:active { opacity: 0.6; } + } + + /* ---------- header ---------- */ + .pf-hero { + display: flex; + align-items: center; + gap: 16px; + padding: 0 4px; + } + + .pf-hero-text { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 2px; + } + + .pf-avatar { + position: relative; + flex-shrink: 0; + width: 68px; + height: 68px; + border-radius: 50%; + overflow: hidden; + display: flex; + align-items: center; + justify-content: center; + border: 1px solid var(--pf-border); + background: var(--pf-lv0); + + .pf-avatar-initial { + font-size: 28px; + font-weight: 600; + } + + .pf-avatar-img { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; + opacity: 0; + transition: opacity 0.25s ease; + } + + &.loaded { + .pf-avatar-img { opacity: 1; } + .pf-avatar-initial { display: none; } + } + + &.guest { color: var(--pf-muted); } + + /* Pro: subtle gold ring */ + &.pro { + border-color: transparent; + box-shadow: + 0 0 0 2px #ffc94d, + 0 0 14px rgba(255, 201, 77, 0.3); + } + } + + .pf-name-row { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; + } + + .pf-name { + margin: 0; + font-size: 20px; + font-weight: 600; + line-height: 1.25; + word-break: break-word; + } + + .pf-verified { + display: inline-flex; + color: var(--pf-accent); + } + + .pf-badge { + padding: 1px 7px; + border-radius: 999px; + font-size: 10.5px; + font-weight: 600; + letter-spacing: 0.06em; + color: var(--pf-muted); + border: 1px solid var(--pf-border); + + &.pro { + color: #1b1300; + border-color: transparent; + background: #ffc94d; + } + } + + .pf-email { + font-size: 13.5px; + color: var(--pf-muted); + word-break: break-all; + } + + .pf-meta { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 6px; + margin-top: 2px; + font-size: 12.5px; + color: var(--pf-muted); + + .pf-link { color: var(--pf-accent); } + } + + /* ---------- sections ---------- */ + .pf-section { + display: flex; + flex-direction: column; + gap: 8px; + } + + .pf-section-head { + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 4px; + font-size: 13px; + } + + .pf-section-title { + margin: 0; + font-size: 12px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--pf-muted); + } + + .pf-section-trail { + display: flex; + align-items: center; + gap: 10px; + font-size: 12px; + color: var(--pf-muted); + } + + .pf-share { + display: inline-flex; + align-items: center; + justify-content: center; + width: 28px; + height: 28px; + margin: -6px -6px -6px 0; + padding: 0; + border: none; + border-radius: 50%; + background: transparent; + color: var(--pf-muted); + transition: + transform 0.12s ease, + background 0.12s ease; + + &:active { + background: var(--pf-lv0); + transform: scale(0.9); + } + } + + .pf-card { + display: flex; + flex-direction: column; + border-radius: 14px; + border: 1px solid var(--pf-border); + overflow: hidden; + } + + /* ---------- activity ---------- */ + .pf-metrics { + display: flex; + padding: 14px 8px 4px; + } + + .pf-metric { + flex: 1; + min-width: 0; + text-align: center; + + .pf-metric-value { + font-size: 17px; + font-weight: 600; + white-space: nowrap; + } + + .pf-metric-label { + margin-top: 2px; + font-size: 11px; + color: var(--pf-muted); + white-space: nowrap; + } + } + + .pf-gh-scroll { + flex: 1; + min-width: 0; + overflow-x: auto; + padding: 14px 14px 10px 6px; + scrollbar-width: none; + -webkit-overflow-scrolling: touch; + + &::-webkit-scrollbar { display: none; } + } + + .pf-gh-grid { + display: flex; + gap: 3px; + width: max-content; + } + + .pf-gh-week { + display: flex; + flex-direction: column; + gap: 3px; + } + + .pf-gh-month { + flex: none; + width: 11px; + height: 14px; + line-height: 14px; + font-size: 10.5px; + white-space: nowrap; + overflow: visible; + color: var(--pf-muted); + } + + .pf-gh-cell { + flex: none; + width: 11px; + height: 11px; + border-radius: 2px; + background: var(--pf-lv0); + + &.lv1 { background: var(--pf-lv1); } + &.lv2 { background: var(--pf-lv2); } + &.lv3 { background: var(--pf-lv3); } + &.lv4 { background: var(--pf-lv4); } + &.none { background: transparent; } + &.today { box-shadow: 0 0 0 1.5px var(--pf-muted); } + &.selected { box-shadow: 0 0 0 1.5px var(--primary-text-color); } + } + + .pf-gh-wrap { + display: flex; + align-items: flex-start; + } + + /* Rows line up with the grid: spacer = month label row, then 7 days. */ + .pf-gh-days { + flex: none; + display: flex; + flex-direction: column; + gap: 3px; + padding: 14px 0 10px 14px; + + .pf-gh-spacer { height: 14px; } + + .pf-gh-daylabel { + height: 11px; + line-height: 11px; + font-size: 9.5px; + white-space: nowrap; + color: var(--pf-muted); + } + } + + .pf-gh-foot { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 8px 12px; + padding: 0 14px 12px; + font-size: 12px; + color: var(--pf-muted); + } + + .pf-gh-legend { + display: flex; + align-items: center; + gap: 3px; + + span:first-child { margin-right: 4px; } + span:last-child { margin-left: 4px; } + } + + /* ---------- this week ---------- */ + .pf-week { + display: flex; + gap: 8px; + padding: 16px 14px 12px; + } + + .pf-week-col { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + align-items: center; + gap: 8px; + + &:active { opacity: 0.7; } + } + + .pf-week-area { + display: flex; + align-items: flex-end; + justify-content: center; + width: 100%; + height: 64px; + } + + .pf-week-bar { + display: block; + width: 100%; + max-width: 26px; + min-height: 3px; + border-radius: 5px; + background: color-mix(in srgb, var(--pf-accent) 55%, transparent); + + &.empty { background: var(--pf-lv0); } + &.today { background: var(--pf-accent); } + } + + .pf-week-day { + font-size: 11px; + color: var(--pf-muted); + + &.today { + color: var(--primary-text-color); + font-weight: 600; + } + } + + /* ---------- languages ---------- */ + .pf-lang-strip { + display: flex; + gap: 2px; + height: 8px; + margin: 14px 14px 6px; + border-radius: 999px; + overflow: hidden; + + .pf-lang-seg { + flex: 1 1 0; + min-width: 4px; + } + } + + .pf-lang { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 14px; + border-bottom: 1px solid var(--pf-border); + font-size: 14px; + + &:last-child { border-bottom: none; } + + .pf-lang-dot { + flex-shrink: 0; + width: 10px; + height: 10px; + border-radius: 50%; + } + + .pf-lang-name { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .pf-lang-percent { color: var(--pf-muted); } + } + + /* ---------- rows ---------- */ + .pf-row { + display: flex; + align-items: center; + gap: 14px; + transition: + transform 0.12s ease, + background 0.12s ease; + padding: 14px; + border-bottom: 1px solid var(--pf-border); + color: var(--primary-text-color); + + &:last-child { border-bottom: none; } + &:active { + background: var(--pf-lv0); + transform: scale(0.98); + } + + > .pf-icon { color: var(--pf-muted); } + + .pf-row-text { + flex: 1; + min-width: 0; + } + + .pf-row-title { + font-size: 15px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .pf-row-sub { + margin-top: 2px; + font-size: 12px; + color: var(--pf-muted); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .pf-row-value { + font-size: 13.5px; + color: var(--pf-muted); + } + + &.danger { + > .pf-icon, + .pf-row-title { color: var(--pf-danger); } + } + } + + /* ---------- empty / buttons ---------- */ + .pf-empty { + display: flex; + flex-direction: column; + align-items: center; + gap: 12px; + padding: 22px 16px; + font-size: 13.5px; + text-align: center; + color: var(--pf-muted); + } + + .pf-btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + margin-top: 6px; + padding: 10px 22px; + border: 1px solid transparent; + border-radius: 10px; + font-family: inherit; + font-size: 14px; + font-weight: 600; + color: #fff; + background: var(--pf-blue); + transition: + transform 0.12s ease, + filter 0.12s ease; + + &.small { padding: 7px 16px; font-size: 13px; margin-top: 0; } + &:active { + filter: brightness(0.9); + transform: scale(0.97); + } + &:disabled { opacity: 0.6; } + } + + .pf-hero-text .pf-btn { margin-top: 8px; } +} diff --git a/src/pages/profile/shareCard.js b/src/pages/profile/shareCard.js new file mode 100644 index 000000000..76ddc5880 --- /dev/null +++ b/src/pages/profile/shareCard.js @@ -0,0 +1,149 @@ +import { buildWeeks, monthLabels } from "./heatmap"; + +const WIDTH = 1200; +const PAD = 72; +const GAP = 5; +const FONT = "sans-serif"; + +/** Resolves any CSS color (var(), color-mix()...) to a value canvas can paint. */ +function resolveColor($ref, value) { + const $probe = document.createElement("i"); + $probe.style.position = "absolute"; + $probe.style.visibility = "hidden"; + $probe.style.background = value; + $ref.append($probe); + const color = getComputedStyle($probe).backgroundColor; + $probe.remove(); + return color; +} + +function roundRect(ctx, x, y, w, h, r) { + ctx.beginPath(); + ctx.moveTo(x + r, y); + ctx.arcTo(x + w, y, x + w, y + h, r); + ctx.arcTo(x + w, y + h, x, y + h, r); + ctx.arcTo(x, y + h, x, y, r); + ctx.arcTo(x, y, x + w, y, r); + ctx.closePath(); +} + +/** + * Draws the activity card (stats + heatmap) to a PNG using the current theme. + * @param {HTMLElement} $ref element inside the profile page, used to read the + * theme colors + * @param {object} options + * @param {string} options.name title shown at the top + * @param {object} options.data summary from the activity tracker + * @param {(ms:number) => string} options.formatDuration + * @param {(key:string, fallback:string) => string} options.label + * @returns {Promise} + */ +export default function renderShareCard($ref, options) { + const { name, data, formatDuration, label } = options; + const paint = (value) => resolveColor($ref, value); + const colors = { + bg: paint("var(--primary-color, #1e1e1e)"), + text: paint("var(--primary-text-color, #ffffff)"), + muted: paint("var(--pf-muted)"), + accent: paint("var(--pf-accent)"), + levels: [0, 1, 2, 3, 4].map((n) => paint(`var(--pf-lv${n})`)), + }; + + const weeks = buildWeeks(data.year); + const months = monthLabels(weeks); + const cols = weeks.length; + const cell = Math.floor((WIDTH - PAD * 2 - GAP * (cols - 1)) / cols); + const gridH = cell * 7 + GAP * 6; + + const metricsTop = PAD + 130; + const monthBase = metricsTop + 170; + const gridTop = monthBase + 18; + const legendBase = gridTop + gridH + 72; + const height = legendBase + PAD; + + const canvas = document.createElement("canvas"); + canvas.width = WIDTH; + canvas.height = height; + const ctx = canvas.getContext("2d"); + + ctx.fillStyle = colors.bg; + ctx.fillRect(0, 0, WIDTH, height); + ctx.textAlign = "left"; + ctx.textBaseline = "alphabetic"; + + // Title + ctx.fillStyle = colors.text; + ctx.font = `700 54px ${FONT}`; + ctx.fillText(name, PAD, PAD + 50, WIDTH - PAD * 2); + ctx.fillStyle = colors.muted; + ctx.font = `400 28px ${FONT}`; + ctx.fillText(label("last 12 months", "Last 12 months"), PAD, PAD + 96); + + // Stats + const { totals } = data; + const metrics = [ + [formatDuration(totals.ms), label("coding time", "Coding time")], + [`${data.current}d`, label("streak", "Streak")], + [`${data.longest}d`, label("best streak", "Best streak")], + [String(totals.activeDays), label("active days", "Active days")], + ]; + const colW = (WIDTH - PAD * 2) / metrics.length; + metrics.forEach(([value, caption], i) => { + const left = PAD + colW * i; + ctx.fillStyle = colors.text; + ctx.font = `700 56px ${FONT}`; + ctx.fillText(value, left, metricsTop + 60, colW - 16); + ctx.fillStyle = colors.muted; + ctx.font = `400 26px ${FONT}`; + ctx.fillText(caption, left, metricsTop + 104, colW - 16); + }); + + // Heatmap + ctx.font = `400 22px ${FONT}`; + weeks.forEach((week, i) => { + const left = PAD + i * (cell + GAP); + if (months[i]) { + ctx.fillStyle = colors.muted; + ctx.fillText(months[i], left, monthBase); + } + week.forEach((day, row) => { + if (!day) return; + ctx.fillStyle = colors.levels[day.level] || colors.levels[0]; + roundRect(ctx, left, gridTop + row * (cell + GAP), cell, cell, 3); + ctx.fill(); + }); + }); + + // Legend and brand + ctx.font = `400 24px ${FONT}`; + const less = label("less", "Less"); + const more = label("more", "More"); + const swatch = 22; + const swatchGap = 6; + const lessW = ctx.measureText(less).width; + const moreW = ctx.measureText(more).width; + const swatchesW = swatch * 5 + swatchGap * 4; + let lx = WIDTH - PAD - (lessW + moreW + swatchesW + 32); + ctx.fillStyle = colors.muted; + ctx.fillText(less, lx, legendBase); + lx += lessW + 16; + for (const level of colors.levels) { + ctx.fillStyle = level; + roundRect(ctx, lx, legendBase - swatch + 3, swatch, swatch, 4); + ctx.fill(); + lx += swatch + swatchGap; + } + ctx.fillStyle = colors.muted; + ctx.fillText(more, lx + 10, legendBase); + + ctx.fillStyle = colors.accent; + ctx.font = `700 30px ${FONT}`; + ctx.fillText("Acode", PAD, legendBase); + + return new Promise((resolve, reject) => { + canvas.toBlob((blob) => { + if (blob) resolve(blob); + else reject(new Error("Unable to render the activity card")); + }, "image/png"); + }); +} diff --git a/src/utils/helpers.js b/src/utils/helpers.js index f9c092190..a71b43316 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -1,6 +1,7 @@ import fsOperation from "fileSystem"; import alert from "dialogs/alert"; import escapeStringRegexp from "escape-string-regexp"; +import activity from "lib/activity"; import adRewards from "lib/adRewards"; import config from "lib/config"; import fileIcons from "lib/fileIcons"; @@ -463,6 +464,8 @@ export default { ? await fsOperation(baseUri).createFile(name) : await fsOperation(baseUri).createDirectory(name); + if (expectedType === "file") activity.recordFileCreated(); + return { url: createdUrl || targetUri, created: true,