Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
Add custom SVG cursor that matches theme accent color (#166)
Jacob Beckerman6ed385f33c68
diff --git a/js/app/packages/app/component/settings/Appearance.tsx b/js/app/packages/app/component/settings/Appearance.tsxindex 2ab1ecee24..567ef16e01 100644--- a/js/app/packages/app/component/settings/Appearance.tsx+++ b/js/app/packages/app/component/settings/Appearance.tsx@@ -1,13 +1,27 @@// import { ComputeTokens } from '../../../block-theme/ComputeTokens';+import { ToggleSwitch } from '@core/component/FormControls/ToggleSwitch';import { TabContent } from '@core/component/TabContent';import { isMobileWidth } from '@core/mobile/mobileWidth';+import { createEffect, createSignal } from 'solid-js';import { ThemeEditorAdvanced } from '../../../block-theme/components/ThemeEditorAdvanced';import { ThemeEditorBasic } from '../../../block-theme/components/ThemeEditorBasic';import ThemeList from '../../../block-theme/components/ThemeList';import ThemeTools from '../../../block-theme/components/ThemeTools';+import {+ getCustomCursorEnabled,+ setCustomCursorEnabled,+} from '../../util/cursor';export function Appearance() {+ const [cursorEnabled, setCursorEnabled] = createSignal(+ getCustomCursorEnabled()+ );++ createEffect(() => {+ setCustomCursorEnabled(cursorEnabled());+ });+return (<TabContent title="Appearance"><div@@ -17,6 +31,25 @@ export function Appearance() {gap: '8px',}}>+ <div+ style={{+ 'font-family': 'var(--font-mono)',+ border: '1px solid var(--b4)',+ 'box-sizing': 'border-box',+ padding: '12px 20px',+ display: 'flex',+ 'align-items': 'center',+ 'justify-content': 'space-between',+ 'font-size': '14px',+ }}+ >+ <span>Themed cursor</span>+ <ToggleSwitch+ checked={cursorEnabled()}+ onChange={(enabled) => setCursorEnabled(enabled)}+ />+ </div>+<ThemeTools /><divdiff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.cssindex 84a05b99ee..57e1b13f9b 100644--- a/js/app/packages/app/index.css+++ b/js/app/packages/app/index.css@@ -545,6 +545,8 @@overscroll-behavior: none;}+ /* Custom cursor is set via JavaScript in index.tsx to match theme accent color */+body {@apply overflow-clip overscroll-none relative m-0 p-0 font-sans optical-auto;diff --git a/js/app/packages/app/index.tsx b/js/app/packages/app/index.tsxindex ce804cc813..7089489dbd 100644--- a/js/app/packages/app/index.tsx+++ b/js/app/packages/app/index.tsx@@ -9,9 +9,94 @@ import { ErrorBoundary, render } from 'solid-js/web';import { FatalError } from './component/FatalError';import { ReactiveFavicon } from './component/ReactiveFavicon';import { Root } from './component/Root';+import { getCustomCursorEnabled } from './util/cursor';initializeLexical();+let cursorStyleEl: HTMLStyleElement | null = null;++function updateCursor() {+ if (!document.body || !document.head) return;++ const enabled = getCustomCursorEnabled();+ if (!enabled) {+ if (cursorStyleEl) {+ cursorStyleEl.textContent = '';+ }+ return;+ }++ const accentColor = getComputedStyle(document.documentElement)+ .getPropertyValue('--color-accent')+ .trim();+ if (!accentColor) return;++ // Convert CSS color (oklch/rgb/etc) to hex using canvas+ const canvas = document.createElement('canvas');+ canvas.width = canvas.height = 1;+ const ctx = canvas.getContext('2d');+ if (!ctx) return;++ ctx.fillStyle = accentColor;+ ctx.fillRect(0, 0, 1, 1);+ const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;+ const hexColor =+ '#' + [r, g, b].map((x) => x.toString(16).padStart(2, '0')).join('');++ // Create SVG cursor with accent color (scaled 10% larger)+ const encodedColor = hexColor.replace('#', '%23');+ const svgCursor = `url('data:image/svg+xml;utf8,<svg width="15" height="13" viewBox="0 0 14 12" fill="none" xmlns="http://www.w3.org/2000/svg"><g transform="translate(7 6) rotate(-45) scale(1.1) translate(-7 -6)"><path d="M13.0244 11.2764L6.51465 7.74316L0 11.2793L6.5127 0L13.0244 11.2764Z" fill="${encodedColor}"/></g></svg>') 7.7 0, auto`;++ if (!cursorStyleEl) {+ cursorStyleEl = document.createElement('style');+ cursorStyleEl.id = 'custom-cursor-style';+ document.head.appendChild(cursorStyleEl);+ }++ cursorStyleEl.textContent = `* { cursor: ${svgCursor} !important; }`;+}++// Initialize cursor+function initCursor() {+ if (!document.body || !document.head) {+ requestAnimationFrame(initCursor);+ return;+ }+ setTimeout(updateCursor, 0);+}++if (document.readyState === 'loading') {+ document.addEventListener('DOMContentLoaded', initCursor);+} else {+ initCursor();+}++// Watch for theme changes and preference changes+let lastAccentColor = '';+let lastCursorEnabled = getCustomCursorEnabled();+setInterval(() => {+ if (!document.body) return;+ const currentAccentColor = getComputedStyle(document.documentElement)+ .getPropertyValue('--color-accent')+ .trim();+ const currentCursorEnabled = getCustomCursorEnabled();++ if (+ (currentAccentColor && currentAccentColor !== lastAccentColor) ||+ currentCursorEnabled !== lastCursorEnabled+ ) {+ lastAccentColor = currentAccentColor;+ lastCursorEnabled = currentCursorEnabled;+ updateCursor();+ }+}, 100);++// Listen for immediate preference changes+window.addEventListener('cursor-preference-changed', () => {+ lastCursorEnabled = getCustomCursorEnabled();+ updateCursor();+});+const renderApp = () => {const root = document.getElementById('root');if (!root) return console.error('Root element not found');diff --git a/js/app/packages/app/util/cursor.ts b/js/app/packages/app/util/cursor.tsnew file mode 100644index 0000000000..c0e1bdf696--- /dev/null+++ b/js/app/packages/app/util/cursor.ts@@ -0,0 +1,12 @@+const CURSOR_ENABLED_KEY = 'custom-cursor-enabled';++export function getCustomCursorEnabled(): boolean {+ const stored = localStorage.getItem(CURSOR_ENABLED_KEY);+ return stored === null ? true : stored === 'true';+}++export function setCustomCursorEnabled(enabled: boolean) {+ localStorage.setItem(CURSOR_ENABLED_KEY, String(enabled));+ // Dispatch event to notify cursor code of preference change+ window.dispatchEvent(new CustomEvent('cursor-preference-changed'));+}