diff options
author | Tobias Urdin <tobias.urdin@binero.se> | 2023-03-15 23:36:45 +0000 |
---|---|---|
committer | Tobias Urdin <tobias.urdin@binero.se> | 2023-04-21 11:23:56 +0000 |
commit | 59cd5de78baa31150958e6d0d6733407c0e95805 (patch) | |
tree | ed72bd938cc5d40a04de612e30547a78ea9c53cf /web/src/pages/Build.jsx | |
parent | de9dfa2bc416d9b1bb6159ed39a014fbba267db5 (diff) | |
download | zuul-59cd5de78baa31150958e6d0d6733407c0e95805.tar.gz |
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
Diffstat (limited to 'web/src/pages/Build.jsx')
-rw-r--r-- | web/src/pages/Build.jsx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/web/src/pages/Build.jsx b/web/src/pages/Build.jsx index 0386f8eef..c66af1060 100644 --- a/web/src/pages/Build.jsx +++ b/web/src/pages/Build.jsx @@ -65,6 +65,7 @@ class BuildPage extends React.Component { activeTab: PropTypes.string.isRequired, location: PropTypes.object.isRequired, history: PropTypes.object.isRequired, + preferences: PropTypes.object, } state = { @@ -250,10 +251,10 @@ class BuildPage extends React.Component { return ( <> - <PageSection variant={PageSectionVariants.light}> + <PageSection variant={this.props.preferences.darkMode ? PageSectionVariants.dark : PageSectionVariants.light}> <Build build={build} active={activeTab} hash={hash} /> </PageSection> - <PageSection variant={PageSectionVariants.light}> + <PageSection variant={this.props.preferences.darkMode ? PageSectionVariants.dark : PageSectionVariants.light}> <Tabs isFilled activeKey={activeTab} @@ -314,7 +315,7 @@ class BuildPage extends React.Component { </Tabs> </PageSection> {!this.state.topOfPageVisible && ( - <PageSection variant={PageSectionVariants.light}> + <PageSection variant={this.props.preferences.darkMode ? PageSectionVariants.dark : PageSectionVariants.light}> <Button onClick={scrollToTop} variant="primary" style={{position: 'fixed', bottom: 20, right: 20, zIndex: 1}}> Go to top of page <ArrowUpIcon/> </Button> @@ -362,6 +363,7 @@ function mapStateToProps(state, ownProps) { isFetchingManifest: state.build.isFetchingManifest, isFetchingOutput: state.build.isFetchingOutput, isFetchingLogfile: state.logfile.isFetching, + preferences: state.preferences, } } |