diff --git a/src/tangledGraph.ts b/src/tangledGraph.ts index ae0725a..cbf95a8 100644 --- a/src/tangledGraph.ts +++ b/src/tangledGraph.ts @@ -38,7 +38,8 @@ const HEADER_TEXT_X = 16; const HEADER_TITLE_Y = 53; const LOGO_WIDTH = 140; const LOGO_HEIGHT = 24; -const LOGO_URL = 'https://assets.tangled.network/tangled_logotype_black_on_trans.svg'; +const LOGO_URL_LIGHT = 'https://assets.tangled.network/tangled_logotype_black_on_trans.svg'; +const LOGO_URL_DARK = 'https://assets.tangled.network/tangled_logotype_white_on_trans.svg'; const MIN_CANVAS_WIDTH = 700; const HEADER_CHAR_WIDTH = 8.2; const SUMMARY_CHAR_WIDTH = 6.2; @@ -48,7 +49,6 @@ const WEEKDAY_LABELS = [ { label: 'Fri', row: 5 }, ]; const MONTH_LABELS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; -const HEATMAP_COLORS = ['#ebedf0', '#d1d5db', '#9ca3af', '#4b5563', '#111827'] as const; export function normalizeAccount(input: string | undefined): string | null { if (!input) { @@ -127,38 +127,87 @@ export function buildGraphSvg({ account, range, days, error }: GraphSvgOptions): .map((day) => { const x = LEFT_GUTTER + day.weekIndex * (CELL_SIZE + CELL_GAP); const y = graphStartY + day.weekdayIndex * (CELL_SIZE + CELL_GAP); - const fill = day.inRange ? HEATMAP_COLORS[day.level] : '#f8fafc'; - const stroke = day.inRange ? 'none' : '#e5e7eb'; + const cellClass = day.inRange ? `heat-${day.level}` : 'oor'; const tooltip = `${day.isoDate}: ${day.count} activit${day.count === 1 ? 'y' : 'ies'}`; - return `${escapeXml(tooltip)}`; + return `${escapeXml(tooltip)}`; }) .join(''); const weekdays = WEEKDAY_LABELS.map(({ label, row }) => { const y = graphStartY + row * (CELL_SIZE + CELL_GAP) + CELL_SIZE - 1; - return `${label}`; + return `${label}`; }).join(''); const months = monthLabels .map(({ label, weekIndex }) => { const x = LEFT_GUTTER + weekIndex * (CELL_SIZE + CELL_GAP); - return `${label}`; + return `${label}`; }) .join(''); const summary = error - ? `${escapeXml(error)}` - : `${escapeXml(summaryText)}`; + ? `${escapeXml(error)}` + : `${escapeXml(summaryText)}`; const accountUrl = `https://tangled.org/@${encodeURIComponent(account)}`; return ` ${escapeXml(headerText)} Calendar heatmap of Tangled activities for ${escapeXml(account)} + - - ${escapeXml(headerText)} + + ${escapeXml(headerText)} ${months} ${weekdays} @@ -281,7 +330,10 @@ function renderLogo(width: number, height: number): string { const x = width - RIGHT_GUTTER - LOGO_WIDTH; const y = height - FOOTER_HEIGHT + 1; - return ``; + return ( + `` + + `` + ); } function subtractUtcMonths(date: Date, months: number): Date {