From: Artur Janicki Date: Tue, 3 Jul 2018 12:40:16 +0000 (+0200) Subject: #13704: add custom theme and clean code X-Git-Tag: 1.2.0~60^2~3 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/5844264e8def16755e8da6e7e57a716e69a130ff #13704: add custom theme and clean code Feature #13704 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- diff --git a/src/common/custom-theme.ts b/src/common/custom-theme.ts new file mode 100644 index 00000000..e78185dd --- /dev/null +++ b/src/common/custom-theme.ts @@ -0,0 +1,61 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { createMuiTheme } from '@material-ui/core/styles'; +import { ThemeOptions, Theme } from '@material-ui/core/styles/createMuiTheme'; +import purple from '@material-ui/core/colors/purple'; +import blue from '@material-ui/core/colors/blue'; +import grey from '@material-ui/core/colors/grey'; + +interface ArvadosThemeOptions extends ThemeOptions { + customs: any; +} + +export interface ArvadosTheme extends Theme { + customs: any; +} + +const purple900 = purple["900"]; +const grey600 = grey["600"]; +const themeOptions: ArvadosThemeOptions = { + customs: { + colors: { + + } + }, + overrides: { + MuiAppBar: { + colorPrimary: { + backgroundColor: purple900 + } + }, + MuiTabs: { + root: { + color: grey600 + }, + indicator: { + backgroundColor: purple900 + } + }, + MuiTab: { + selected: { + fontWeight: 700, + color: purple900 + } + } + }, + mixins: { + toolbar: { + minHeight: '48px' + } + }, + palette: { + primary: { + main: '#06C', + dark: blue.A100 + } + } +}; + +export const CustomTheme = createMuiTheme(themeOptions); \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 58048784..21ecdab1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -15,6 +15,8 @@ import ApiToken from "./views-components/api-token/api-token"; import authActions from "./store/auth/auth-action"; import { authService } from "./services/services"; import { getProjectList } from "./store/project/project-action"; +import { MuiThemeProvider } from '@material-ui/core/styles'; +import { CustomTheme } from './common/custom-theme'; const history = createBrowserHistory(); @@ -25,14 +27,16 @@ const rootUuid = authService.getRootUuid(); store.dispatch(getProjectList(rootUuid)); const App = () => - - -
- - -
-
-
; + + + +
+ + +
+
+
+
; ReactDOM.render( , diff --git a/src/views-components/details-panel/details-panel.tsx b/src/views-components/details-panel/details-panel.tsx index b63266a0..a864d507 100644 --- a/src/views-components/details-panel/details-panel.tsx +++ b/src/views-components/details-panel/details-panel.tsx @@ -6,7 +6,8 @@ import * as React from 'react'; import Drawer from '@material-ui/core/Drawer'; import IconButton from "@material-ui/core/IconButton"; import CloseIcon from '@material-ui/icons/Close'; -import { StyleRulesCallback, WithStyles, withStyles, Theme } from "@material-ui/core/styles"; +import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles'; +import { ArvadosTheme } from '../../common/custom-theme'; import Tabs from '@material-ui/core/Tabs'; import Tab from '@material-ui/core/Tab'; import Typography from '@material-ui/core/Typography'; @@ -14,7 +15,7 @@ import Grid from '@material-ui/core/Grid'; import * as classnames from "classnames"; export interface DetailsPanelProps { - closeDrawer: () => void; + onCloseDrawer: () => void; isOpened: boolean; } @@ -27,16 +28,13 @@ class DetailsPanel extends React.Component) => { - return ( - - {children} - - ); - } + renderTabContainer = (children: React.ReactElement) => + + {children} + render() { - const { classes, closeDrawer, isOpened } = this.props; + const { classes, onCloseDrawer, isOpened } = this.props; const { tabsValue } = this.state; return (
@@ -46,21 +44,14 @@ class DetailsPanel extends React.Component Tutorial pipeline - + - - - + + + {tabsValue === 0 && this.renderTabContainer( @@ -102,15 +93,10 @@ class DetailsPanel extends React.Component = (theme: Theme) => ({ +const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ container: { width: 0, position: 'relative', @@ -126,25 +112,15 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ width: drawerWidth }, headerContainer: { - color: colorLightGray, + color: theme.palette.grey["600"], margin: `${theme.spacing.unit}px 0` }, - tabsIndicator: { - backgroundColor: colorPurple - }, - tabRoot: { - color: colorGray, - '&$tabSelected': { - fontWeight: 700, - color: colorPurple - } - }, tabContainer: { padding: theme.spacing.unit * 3 }, tabSelected: {}, gridLabel: { - color: colorVeryLightGray, + color: theme.palette.grey["500"] } }); diff --git a/src/views-components/main-app-bar/main-app-bar.tsx b/src/views-components/main-app-bar/main-app-bar.tsx index 135e1219..1230e3b7 100644 --- a/src/views-components/main-app-bar/main-app-bar.tsx +++ b/src/views-components/main-app-bar/main-app-bar.tsx @@ -3,7 +3,7 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from "react"; -import { AppBar, Toolbar, Typography, Grid, IconButton, Badge, StyleRulesCallback, withStyles, WithStyles, Button, MenuItem } from "@material-ui/core"; +import { AppBar, Toolbar, Typography, Grid, IconButton, Badge, Button, MenuItem } from "@material-ui/core"; import NotificationsIcon from "@material-ui/icons/Notifications"; import PersonIcon from "@material-ui/icons/Person"; import HelpIcon from "@material-ui/icons/Help"; @@ -38,15 +38,12 @@ export interface MainAppBarActionProps { onDetailsPanelToggle: () => void; } -type MainAppBarProps = MainAppBarDataProps & MainAppBarActionProps & WithStyles; +type MainAppBarProps = MainAppBarDataProps & MainAppBarActionProps; export const MainAppBar: React.SFC = (props) => { - return - - + return + + Arvados @@ -120,15 +117,4 @@ const renderMenuItems = (menuItems: MainAppBarMenuItem[], onMenuItemClick: (menu )); }; -type CssRules = "appBar" | "toolbar"; - -const styles: StyleRulesCallback = theme => ({ - appBar: { - backgroundColor: "#692498" - }, - toolbar: { - minHeight: '48px' - } -}); - -export default withStyles(styles)(MainAppBar); +export default MainAppBar; diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 2cca921c..8cc5fc22 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -3,7 +3,7 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles'; +import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles'; import Drawer from '@material-ui/core/Drawer'; import { connect, DispatchProp } from "react-redux"; import { Route, Switch, RouteComponentProps, withRouter } from "react-router"; @@ -29,13 +29,14 @@ import projectActions from "../../store/project/project-action"; import ProjectPanel from "../project-panel/project-panel"; import { sidePanelData } from '../../store/side-panel/side-panel-reducer'; import DetailsPanel from '../../views-components/details-panel/details-panel'; +import { ArvadosTheme } from '../../common/custom-theme'; const drawerWidth = 240; -const appBarHeight = 116; +const appBarHeight = 100; type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'contentWrapper' | 'toolbar'; -const styles: StyleRulesCallback = (theme: Theme) => ({ +const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { flexGrow: 1, zIndex: 1, @@ -47,7 +48,6 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ }, appBar: { zIndex: theme.zIndex.drawer + 1, - backgroundColor: '#692498', position: "absolute", width: "100%" }, @@ -65,7 +65,7 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ paddingTop: appBarHeight }, content: { - padding: theme.spacing.unit * 3, + padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3}px`, overflowY: "auto", flexGrow: 1 }, @@ -204,7 +204,7 @@ class Workbench extends React.Component {
+ onCloseDrawer={this.mainAppBarActions.onDetailsPanelToggle} /> );