Actions
Cleanup #41552
openmgr/dashboard: remove color literals from typescript code
Status:
New
Priority:
Normal
Assignee:
-
Category:
General
Target version:
-
% Done:
0%
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:
Description
As they appear in, for example, src/app/shared/pipes/health-color.pipe.ts
.
- Component presentation/styling becomes interleaved with component logic, which is a basic coding anti-pattern.
- It results in failing unit-tests, as they explicitly look for literals which need to be explicitly set at both sides.
The above makes hard to use alternative styles (vendor/downstream specific).
Alternatives (from less to more optimal):- Using enums (as charts do) instead of literals. This enums are shared between code and tests. However, the above approach is still suboptimal (literal colors still apear in the code, while they should all come from SCSS).
- Ideally, components should rely on style classes (e.g: HealthPipe switches from
health-ok-color
tohealth-error-color
whenHEALTH_ERR
happens). This approach, however, would not work with some TS components that rely on 3rd parties (chartjs) requiring explicit colors/styles. In this case - An alternative would be to use CSS classes and make them available to code. Javascript allows for getting computed styles, and this tutorial provides a different approach
Updated by Ernesto Puerta about 3 years ago
- Project changed from mgr to Dashboard
- Category changed from 132 to General
Updated by Ernesto Puerta over 1 year ago
- Related to Tasks #50490: mgr/dashboard: native dependencies added
Actions