From d3a8243abf0933e000427a940c6d03866b550ede Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Sun, 6 Apr 2025 20:06:54 +0200 Subject: [PATCH] Enhance: Update Activity component and ProseIcon styles - Added optional 'assets' field to LanyardActivity interface for small text. - Introduced 'Cursor' IDE to the IDEs list. - Improved color variant styles in ProseIcon component for better visibility. - Refactored Activity component to handle 'Cursor' IDE and updated activity message formatting. --- app/components/content/ProseIcon.vue | 28 ++++++++-------- app/components/home/Activity.vue | 49 +++++++++++++++------------- app/components/home/Link.vue | 6 ++-- types.ts | 8 +++-- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/app/components/content/ProseIcon.vue b/app/components/content/ProseIcon.vue index 862fa3e..b5ecdda 100644 --- a/app/components/content/ProseIcon.vue +++ b/app/components/content/ProseIcon.vue @@ -11,19 +11,19 @@ defineProps({ }) const colorVariants = { - gray: 'text-gray-500 decoration-gray-400', - red: 'text-red-500 decoration-red-400', - yellow: 'text-yellow-500 decoration-yellow-400', - green: 'text-green-500 decoration-green-400', - blue: 'text-blue-500 decoration-blue-400', - indigo: 'text-indigo-500 decoration-indigo-400', - purple: 'text-purple-500 decoration-purple-400', - pink: 'text-pink-500 decoration-pink-400', - sky: 'text-sky-500 decoration-sky-400', - zinc: 'text-zinc-500 decoration-zinc-400', - orange: 'text-orange-500 decoration-orange-400', - amber: 'text-amber-500 decoration-amber-400', - emerald: 'text-emerald-500 decoration-emerald-400', + gray: 'text-gray-500/60 decoration-gray-400/60', + red: 'text-red-500/60 decoration-red-400/60', + yellow: 'text-yellow-500/60 decoration-yellow-400/60', + green: 'text-green-500/60 decoration-green-400/60', + blue: 'text-blue-500/60 decoration-blue-400/60', + indigo: 'text-indigo-500/60 decoration-indigo-400/60', + purple: 'text-purple-500/60 decoration-purple-400/60', + pink: 'text-pink-500/60 decoration-pink-400/60', + sky: 'text-sky-500/60 decoration-sky-400/60', + zinc: 'text-zinc-500/60 decoration-zinc-400/60', + orange: 'text-orange-500/60 decoration-orange-400/60', + amber: 'text-amber-500/60 decoration-amber-400/60', + emerald: 'text-emerald-500/60 decoration-emerald-400/60', } @@ -34,7 +34,7 @@ const colorVariants = { :name="`i-logos:${icon}`" /> diff --git a/app/components/home/Activity.vue b/app/components/home/Activity.vue index 63d8777..1b68580 100644 --- a/app/components/home/Activity.vue +++ b/app/components/home/Activity.vue @@ -3,16 +3,22 @@ import type { UseTimeAgoMessages } from '@vueuse/core' import type { Activity } from '~~/types' import { activityMessages, IDEs } from '~~/types' +const { t } = useI18n({ + useScope: 'local', +}) + const { data: activity, refresh } = await useAsyncData('activity', () => $fetch('/api/activity')) useIntervalFn(async () => await refresh(), 5000) const codingActivity = computed(() => { - const activities = activity.value!.data.activities.filter(activity => IDEs.some(ide => ide.name === activity.name)) - if (activities.length > 1) { - const randomIndex = Math.floor(Math.random() * activities.length) - return activities[randomIndex] - } - return activities[0] + const activities = activity.value!.data.activities.filter(activity => IDEs.some(ide => ide.name === activity.name)).map(activity => ({ + ...activity, + name: activity.assets?.small_text === 'Cursor' ? 'Cursor' : activity.name, + })) + + return activities.length > 1 + ? activities[Math.floor(Math.random() * activities.length)] + : activities[0] }) const { locale, locales } = useI18n() @@ -24,7 +30,7 @@ const isActive = computed(() => { const { name, details, state } = codingActivity.value - return name === 'Visual Studio Code' + return name === 'Visual Studio Code' || name === 'Cursor' ? !details.includes('Idling') : state.toLowerCase().includes('editing') }) @@ -44,7 +50,7 @@ const getActivity = computed(() => { .replace('Workspace:', '') .trim() : '' - const stateWord = state.split(' ')[1] + const stateWord = state.split(' ')[1] || t('secret') const ago = useTimeAgo(timestamps.start, { messages: activityMessages[locale.value] as UseTimeAgoMessages, }).value @@ -63,10 +69,6 @@ const getActivity = computed(() => { }, } }) - -const { t } = useI18n({ - useScope: 'local', -})