From 59cd5de78baa31150958e6d0d6733407c0e95805 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Wed, 15 Mar 2023 23:36:45 +0000 Subject: web: add dark mode and theme selection This adds a theme selection in the preferences in the config modal and adds a new dark theme. Removes the line.png image and instead uses CSS linear-gradient that is available in all browsers since around 2018, also fixes the 15 pixels spacing issue that is there today. You can select between three different themes. Auto will use your system preference to choose either the light or dark theme, changes dynamically based on your system preference. Light is the current theme. Dark is the theme added by this patch series. The UX this changes is that if somebody has their system preferences set to dark, for example in Mac OS X that is in System Settings -> Appearance -> Dark the user will get the Zuul web UI in dark by default and same for the opposite. This uses a poor man's dark mode for swagger-ui as per the comment in [1]. [1] https://github.com/swagger-api/swagger-ui/issues/5327#issuecomment-742375520 Change-Id: I01cf32f3decdb885307a76eb79d644667bbbf9a3 --- web/src/containers/charts/GanttChart.jsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'web/src/containers/charts/GanttChart.jsx') diff --git a/web/src/containers/charts/GanttChart.jsx b/web/src/containers/charts/GanttChart.jsx index 5ac065fce..f677d83b8 100644 --- a/web/src/containers/charts/GanttChart.jsx +++ b/web/src/containers/charts/GanttChart.jsx @@ -26,7 +26,7 @@ import { buildResultLegendData, buildsBarStyle } from './Misc' function BuildsetGanttChart(props) { - const { builds, timezone } = props + const { builds, timezone, preferences } = props const sortedByStartTime = builds.sort((a, b) => { if (a.start_time > b.start_time) { return -1 @@ -64,6 +64,10 @@ function BuildsetGanttChart(props) { const chartLegend = buildResultLegendData.filter((legend) => { return uniqueResults.indexOf(legend.name) > -1 }) + let horizontalLegendTextColor = '#000' + if (preferences.darkMode) { + horizontalLegendTextColor = '#ccc' + } return (
@@ -81,10 +85,9 @@ function BuildsetGanttChart(props) { legendOrientation='horizontal' legendPosition='top' legendData={legendData} - legendComponent={} - + legendComponent={} > - + + style={{ tickLabels: { angle: -25, padding: 1, verticalAnchor: 'middle', textAnchor: 'end', fill: horizontalLegendTextColor } }} + /> } + } labels={({ datum }) => `${datum.result}\nStarted ${datum.started}\nEnded ${datum.ended}`} /> - +
) @@ -120,8 +124,10 @@ function BuildsetGanttChart(props) { BuildsetGanttChart.propTypes = { builds: PropTypes.array.isRequired, timezone: PropTypes.string, + preferences: PropTypes.object, } export default connect((state) => ({ timezone: state.timezone, -}))(BuildsetGanttChart) \ No newline at end of file + preferences: state.preferences, +}))(BuildsetGanttChart) -- cgit v1.2.1