-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure title and subtitle use custom color also for dark background
- Loading branch information
1 parent
6122203
commit b886121
Showing
6 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
.../adapters/dhis_highcharts/customSVGOptions/singleValue/config/getSingleValueTitleColor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { colors } from '@dhis2/ui' | ||
import { LEGEND_DISPLAY_STYLE_FILL } from '../../../../../../../modules/legends.js' | ||
import { getSingleValueLegendColor } from './getSingleValueLegendColor.js' | ||
import { shouldUseContrastColor } from './shouldUseContrastColor.js' | ||
|
||
export function getSingleValueTitleColor( | ||
customColor, | ||
defaultColor, | ||
value, | ||
legendOptions, | ||
legendSets | ||
) { | ||
// Never override custom color | ||
if (customColor) { | ||
return customColor | ||
} | ||
|
||
const isUsingLegendBackground = | ||
legendOptions?.style === LEGEND_DISPLAY_STYLE_FILL | ||
|
||
// If not using legend background, always return default color | ||
if (!isUsingLegendBackground) { | ||
return defaultColor | ||
} | ||
|
||
const legendColor = getSingleValueLegendColor( | ||
legendOptions, | ||
legendSets, | ||
value | ||
) | ||
|
||
// Return default color or contrasting color when using legend background and default color | ||
return shouldUseContrastColor(legendColor) ? colors.white : defaultColor | ||
} |
2 changes: 1 addition & 1 deletion
2
src/visualizations/config/adapters/dhis_highcharts/customSVGOptions/singleValue/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { getSingleValueCustomSVGOptions } from './config/getSingleValueCustomSVGOptions.js' | ||
export { getSingleValueBackgroundColor } from './config/getSingleValueBackgroundColor.js' | ||
export { getSingleValueTextColor } from './config/getSingleValueTextColor.js' | ||
export { getSingleValueTitleColor } from './config/getSingleValueTitleColor.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/visualizations/config/adapters/dhis_highcharts/subtitle/singleValue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/visualizations/config/adapters/dhis_highcharts/title/singleValue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters