Skip to content

Commit

Permalink
update for bach-material-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Gretz committed May 29, 2019
1 parent 35d0eba commit acbd01b
Show file tree
Hide file tree
Showing 9 changed files with 381 additions and 14 deletions.
20 changes: 17 additions & 3 deletions app/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@ import React from 'react';
import {Provider} from 'react-redux';
import {ConnectedRouter} from 'connected-react-router';
import {hot} from 'react-hot-loader';
import {ThemeProvider} from '@material-ui/styles';
import {createMuiTheme} from '@material-ui/core/styles';
import purple from '@material-ui/core/colors/purple';

import App from './App';

const theme = createMuiTheme({
palette: {
primary: purple,
secondary: {
main: '#f44336',
},
},
});

const Root = ({store, history}) => (
<Provider store={store}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
<ThemeProvider theme={theme}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</ThemeProvider>
</Provider>
);

Expand Down
1 change: 1 addition & 0 deletions app/features/bachMaterialUI/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default as WithStyles} from './withStyles';
41 changes: 41 additions & 0 deletions app/features/bachMaterialUI/components/withStyles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import {compose, withState, withCallback} from '@truefit/bach';
import {withStyles} from '@truefit/bach-material-ui';

const WithStyles = ({classes, fontSize, increase}) => (
<div className={classes.container}>
<h1 className={classes.h1}>withStyles</h1>
<h2 className={classes.h2}>Font Size: {fontSize}</h2>
<button className={classes.button} onClick={increase}>
^ Increase ^
</button>
</div>
);

export default compose(
withState('fontSize', 'setFontSize', 12),
withCallback('increase', ({fontSize, setFontSize}) => () => {
setFontSize(fontSize + 1);
}),
withStyles(theme => ({
container: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '100%',
flexDirection: 'column',
},
h1: {
color: theme.palette.primary.main,
},
h2: {
color: theme.palette.secondary.main,
fontSize: ({fontSize}) => fontSize,
},
button: {
height: 50,
width: 100,
borderRadius: 8,
},
})),
)(WithStyles);
15 changes: 15 additions & 0 deletions app/features/shared/components/bachMaterialUIDirectory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import Menu from './controls/menu';

const simple = ['withStyles'];

const combined = [];

export default () => (
<Menu
title="@truefit/bach-material-ui"
root="bachmaterialui"
simple={simple}
combined={combined}
/>
);
21 changes: 14 additions & 7 deletions app/features/shared/components/controls/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ const Menu = ({title, root, links}) => (
</>
);

export default ({title, root, simple, combined}) => (
<>
<h1>{title}</h1>
<Menu title="Simple" root={root} links={simple} />
<Menu title="Combined" root={root} links={combined} />
</>
);
export default ({title, root, simple, combined}) => {
const combinedMenu =
combined?.length > 0 ? (
<Menu title="Combined" root={root} links={combined} />
) : null;

return (
<>
<h1>{title}</h1>
<Menu title="Simple" root={root} links={simple} />
{combinedMenu}
</>
);
};
2 changes: 2 additions & 0 deletions app/features/shared/components/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import React from 'react';
import BachDirectory from './bachDirectory';
import BachRecomposeDirectory from './bachRecomposeDirectory.js';
import BachReduxDirectory from './bachReduxDirectory';
import BachMaterialUi from './bachMaterialUIDirectory.js';

export default () => (
<>
<BachDirectory />
<BachRecomposeDirectory />
<BachReduxDirectory />
<BachMaterialUi />
</>
);
6 changes: 6 additions & 0 deletions app/features/shared/components/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
WithActionsAndSelector,
} from '../../bachRedux/components';

import {WithStyles} from '../../bachMaterialUI/components';

import Directory from './directory';
import NotFound from './notFound';

Expand Down Expand Up @@ -74,6 +76,10 @@ export default () => (
/>
</Route>

<Route path="/bachmaterialui">
<Route path="*/withStyles" component={WithStyles} />
</Route>

<Route component={NotFound} />
</Switch>
);
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
},
"license": "MIT",
"dependencies": {
"@material-ui/core": "^4.0.1",
"@truefit/bach": "^0.1.18",
"@truefit/bach-material-ui": "^0.1.0",
"@truefit/bach-recompose": "^0.0.4",
"@truefit/bach-redux": "^0.1.0",
"@truefit/http-utils": "^1.0.8",
Expand Down
Loading

0 comments on commit acbd01b

Please sign in to comment.