refactor(svg): centralize GHOST_HEIGHT_PX and other layout constants …#651
refactor(svg): centralize GHOST_HEIGHT_PX and other layout constants …#651Ixotic27 wants to merge 1 commit into
Conversation
|
@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. |
|
👋 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:
Once you've updated the PR description the check will re-run automatically. 🙌 |
There was a problem hiding this comment.
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.tsintolib/svg/constants.ts - Moved SVG dimensions and
FONT_MAPfromlib/svg/generator.tsintolib/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.
| 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', | ||
| }; |
| export const FONT_MAP: Record<string, string> = { | ||
| jetbrains: '"JetBrains Mono", monospace', | ||
| fira: '"Fira Code", monospace', | ||
| roboto: '"Roboto", sans-serif', | ||
| }; |
|
👋 Hey @Ixotic27, it looks like you didn't use our PR template! The section Please update your PR description to include all required sections so we can review this properly:
You can find the full template in CONTRIBUTING.md. Just edit your PR description and the |
|
address the copilot comments please |
yeah doing that |
it's in .github folder brother |
|
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-leaseOnce resolved, the |
1 similar comment
|
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-leaseOnce resolved, the |
8105877 to
5ff1a42
Compare
|
I have rebased the PR against main and resolved the merge conflicts in lib/svg/generator.ts. It's ready for review! |
5ff1a42 to
5e4e96b
Compare
| 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'; |
| 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; |
| 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; |
|
@Ixotic27 look for copilot suggestions |
Description
Centralized
GHOST_HEIGHT_PXand other layout constants (SVG_WIDTH,SVG_HEIGHT,FONT_MAP, scale multipliers) inlib/svg/constants.tsby extracting them fromgenerator.tsandlayout.ts.Fixes #310
Pillar
Visual Preview
N/A
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.