Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2stack specificStack: react
reactsvgiconsdry
Make one configurable SVG component instead of near-duplicate icons
Render a single SVG React component whose fill/stroke and rotation are driven by props/CSS instead of creating separate icons for each state.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const DownVoted = (props) => (<svg {...props}><path fill="#CA2B3D" d="..." /></svg>); |
| 2 | const UpVoted = (props) => (<svg {...props}><path fill="#CA2B3D" d="..." /></svg>); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const Vote = ({ active, ...props }) => ( |
| 2 | <svg {...props}> |
| 3 | <path fill={active ? '#CA2B3D' : 'transparent'} d="..." /> |
| 4 | </svg> |
| 5 | ); |
Explanation (EN)
Objašnjenje (HR)