-
Notifications
You must be signed in to change notification settings - Fork 39
#566 Export LINE_WIDTH constant #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: thekingofcity <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR centralizes line width management by exporting a LINE_WIDTH = 5 constant from src/constants/lines.ts and updating 23 line style components to use it. This enables automatic recalculation of all line width-related values if the constant changes in the future, improving maintainability.
Key Changes:
- Exported
LINE_WIDTHconstant for centralized line width management - Updated strokeWidth attributes from hardcoded
"5"to{LINE_WIDTH} - Updated derived values (e.g.,
"2.5"→{LINE_WIDTH / 2}) - Removed duplicate local
LINE_WIDTHconstant fromjr-east-single-color-pattern.tsx
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/constants/lines.ts | Exports LINE_WIDTH = 5 constant for centralized line width management |
| src/components/svgs/lines/styles/single-color.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/shanghai-suburban-railway.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/mtr-race-day.tsx | Replaced strokeWidth="5" with LINE_WIDTH and updated strokeDasharray to use LINE_WIDTH |
| src/components/svgs/lines/styles/mtr-light-rail.tsx | Replaced strokeWidth="2.5" with LINE_WIDTH / 2 |
| src/components/svgs/lines/styles/mrt-under-construction.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/mrt-tape-out.tsx | Updated strokeWidth, marker dimensions, and polygon points to use LINE_WIDTH |
| src/components/svgs/lines/styles/mrt-sentosa-express.tsx | Replaced strokeWidth="5" with LINE_WIDTH and updated strokeDasharray calculations |
| src/components/svgs/lines/styles/london-tube-terminal.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/london-tube-internal-int.tsx | Replaced strokeWidth="2.5" with LINE_WIDTH / 2 |
| src/components/svgs/lines/styles/london-tube-10-min-walk.tsx | Replaced strokeWidth="5" with LINE_WIDTH and updated strokeDasharray |
| src/components/svgs/lines/styles/london-sandwich.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/london-rail.tsx | Updated multiple strokeWidth values to use LINE_WIDTH with appropriate multipliers |
| src/components/svgs/lines/styles/london-ifs-could-cable-car.tsx | Replaced all three strokeWidth values with LINE_WIDTH-based expressions |
| src/components/svgs/lines/styles/london-DART.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/jr-east-single-color.tsx | Replaced strokeWidth values with LINE_WIDTH + 0.1 and LINE_WIDTH - 0.1 |
| src/components/svgs/lines/styles/jr-east-single-color-pattern.tsx | Removed duplicate local LINE_WIDTH constant, now uses imported constant |
| src/components/svgs/lines/styles/guangdong-intercity-railway.tsx | Replaced strokeWidth="5" with LINE_WIDTH and strokeWidth="2.5" with LINE_WIDTH / 2 |
| src/components/svgs/lines/styles/dual-color.tsx | Replaced both strokeWidth="2.5" occurrences with LINE_WIDTH / 2 |
| src/components/svgs/lines/styles/china-railway.tsx | Replaced strokeWidth="5" with LINE_WIDTH and updated dependent calculation |
| src/components/svgs/lines/styles/chengdurt-outside-fare-gates.tsx | Replaced strokeWidth="5" with LINE_WIDTH and updated strokeDasharray |
| src/components/svgs/lines/styles/bjsubway-tram.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/bjsubway-single-color.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
| src/components/svgs/lines/styles/bjsubway-dotted.tsx | Replaced hardcoded strokeWidth="5" with LINE_WIDTH |
Comments suppressed due to low confidence (1)
src/components/svgs/lines/styles/london-DART.tsx:35
- The hardcoded
strokeWidth="3"should be expressed in terms of LINE_WIDTH for consistency. This is 0.6 times LINE_WIDTH, so it should bestrokeWidth={LINE_WIDTH * 0.6}orstrokeWidth={(LINE_WIDTH / 5) * 3}.
<path
d={path}
fill="none"
stroke={color[3]}
strokeWidth="3"
strokeLinecap="round"
strokeDasharray="0.001 6"
thekingofcity
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Line width values were hardcoded as
5throughout line style components, preventing centralized adjustments.Changes
LINE_WIDTH = 5constant fromsrc/constants/lines.tsstrokeWidth="5"→strokeWidth={LINE_WIDTH}strokeWidth="2.5"→strokeWidth={LINE_WIDTH / 2}strokeDasharray, marker dimensionsjr-east-single-color-pattern.tsxExample
All line width calculations now derive from a single source, enabling automatic recalculation across the application.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.