Skip to content

refactor(svg): centralize GHOST_HEIGHT_PX and other layout constants …#651

Open
Ixotic27 wants to merge 1 commit into
JhaSourav07:mainfrom
Ixotic27:refactor/svg-constants
Open

refactor(svg): centralize GHOST_HEIGHT_PX and other layout constants …#651
Ixotic27 wants to merge 1 commit into
JhaSourav07:mainfrom
Ixotic27:refactor/svg-constants

Conversation

@Ixotic27
Copy link
Copy Markdown
Contributor

@Ixotic27 Ixotic27 commented May 27, 2026

Description

Centralized GHOST_HEIGHT_PX and other layout constants (SVG_WIDTH, SVG_HEIGHT, FONT_MAP, scale multipliers) in lib/svg/constants.ts by extracting them from generator.ts and layout.ts.

Fixes #310

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

Copilot AI review requested due to automatic review settings May 27, 2026 15:37
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 27, 2026

@Ixotic27 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

👋 Hey @Ixotic27! Thanks for your contribution! 🎉

It looks like this PR isn't linked to any issue yet.

Please edit your PR description and add a closing keyword so we can track this properly, for example:

Fixes #<issue-number>

💡 You can link multiple issues if needed (e.g. Fixes #12, Closes #34).
If you're working on something that doesn't have an issue yet, please open one first and then link it here.

Once you've updated the PR description the check will re-run automatically. 🙌

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR centralizes previously inlined SVG/layout constants into a shared constants.ts module to reduce duplication and keep configuration values consistent.

Changes:

  • Moved layout scaling constants from lib/svg/layout.ts into lib/svg/constants.ts
  • Moved SVG dimensions and FONT_MAP from lib/svg/generator.ts into lib/svg/constants.ts
  • Updated imports to reference the new constants module

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/svg/layout.ts Replaces local layout constants with imports from shared constants module
lib/svg/generator.ts Replaces local SVG dimension/font constants with imports from shared constants module
lib/svg/constants.ts Introduces a shared constants module used by generator and layout

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/svg/constants.ts
Comment on lines +1 to +14
export const SVG_WIDTH = 600;
export const SVG_HEIGHT = 420;

export const GHOST_HEIGHT_PX = 4;
export const LOG_SCALE_MULTIPLIER = 12;
export const LINEAR_SCALE_MULTIPLIER = 5;
export const MAX_LOG_HEIGHT = 80;
export const MAX_LINEAR_HEIGHT = 50;

export const FONT_MAP: Record<string, string> = {
jetbrains: '"JetBrains Mono", monospace',
fira: '"Fira Code", monospace',
roboto: '"Roboto", sans-serif',
};
Comment thread lib/svg/constants.ts
Comment on lines +10 to +14
export const FONT_MAP: Record<string, string> = {
jetbrains: '"JetBrains Mono", monospace',
fira: '"Fira Code", monospace',
roboto: '"Roboto", sans-serif',
};
@github-actions github-actions Bot added the needs-details This PR is missing required description details. label May 27, 2026
@github-actions
Copy link
Copy Markdown

👋 Hey @Ixotic27, it looks like you didn't use our PR template!

The section ## Description is missing from your PR description.

Please update your PR description to include all required sections so we can review this properly:

  • ## Description — What does this PR do? Which issue does it fix?
  • ## Pillar — Which contribution pillar does this fall under?
  • ## Checklist — Have you ticked off the quality checklist?

You can find the full template in CONTRIBUTING.md. Just edit your PR description and the needs-details label will be removed automatically. 🙌

@github-actions github-actions Bot removed the needs-details This PR is missing required description details. label May 27, 2026
@JhaSourav07
Copy link
Copy Markdown
Owner

address the copilot comments please

@Ixotic27
Copy link
Copy Markdown
Contributor Author

address the copilot comments please

yeah doing that
in the mean time can you tell me your github actions script so that i can implement the same for my project also
please it would be of great help

@github-actions github-actions Bot added the type:refactor Code changes that neither fix a bug nor add a feature label May 27, 2026
@JhaSourav07
Copy link
Copy Markdown
Owner

address the copilot comments please

yeah doing that in the mean time can you tell me your github actions script so that i can implement the same for my project also please it would be of great help

it's in .github folder brother

@github-actions github-actions Bot added the needs-rebase This PR has merge conflicts and needs a rebase. label May 27, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Hey @Ixotic27, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

1 similar comment
@github-actions
Copy link
Copy Markdown

⚠️ Hey @Ixotic27, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@Ixotic27 Ixotic27 force-pushed the refactor/svg-constants branch from 8105877 to 5ff1a42 Compare May 28, 2026 03:25
@Ixotic27
Copy link
Copy Markdown
Contributor Author

I have rebased the PR against main and resolved the merge conflicts in lib/svg/generator.ts. It's ready for review!

@github-actions github-actions Bot removed the needs-rebase This PR has merge conflicts and needs a rebase. label May 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread lib/svg/generator.ts
import { sanitizeFont, sanitizeHexColor, sanitizeRadius, sanitizeGoogleFontUrl } from './sanitizer';

import { SVG_WIDTH, SVG_HEIGHT, FONT_MAP } from './constants';
import { SVG_WIDTH, SVG_HEIGHT, FONT_MAP, isFontKey } from './generatorConstants';
Comment thread lib/svg/layout.ts
MAX_LOG_HEIGHT,
MAX_LINEAR_HEIGHT,
} from './constants';
} from './layoutConstants';
export type FontKey = keyof typeof FONT_MAP;

export function isFontKey(font: string): font is FontKey {
return font in FONT_MAP;
Comment on lines +1 to +5
export const GHOST_HEIGHT_PX = 4;
export const LOG_SCALE_MULTIPLIER = 12;
export const LINEAR_SCALE_MULTIPLIER = 5;
export const MAX_LOG_HEIGHT = 80;
export const MAX_LINEAR_HEIGHT = 50;
@Aamod007
Copy link
Copy Markdown
Collaborator

@Ixotic27 look for copilot suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:refactor Code changes that neither fix a bug nor add a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(svg): centralize GHOST_HEIGHT_PX and other layout constants in lib/svg/constants.ts

4 participants