Skip to content

Commit

Permalink
Merge pull request #19 from ranjithprabhuk/development
Browse files Browse the repository at this point in the history
Development -> Master
  • Loading branch information
ranjithprabhuk authored Jul 8, 2018
2 parents d7c495e + c418760 commit 09d519d
Show file tree
Hide file tree
Showing 23 changed files with 579 additions and 99 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@material-ui/core": "^1.3.0",
"@material-ui/icons": "^2.0.0-beta.1",
"@types/classnames": "^2.2.4",
"@types/es6-promise": "^3.3.0",
"@types/recharts": "^1.0.21",
"html-loader": "^0.5.4",
"lodash": "^4.17.4",
Expand Down
61 changes: 61 additions & 0 deletions src/app/AsyncComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import * as React from 'react';
import { Theme, withStyles, CircularProgress } from '@material-ui/core';

interface IAsyncComponentOwnProps {
moduleProvider: any;
classes: any;
}

interface IAsyncComponentState {
Component: any;
}

interface IAsyncComponentStateProps {
theme?: Theme;
}

type IAsyncComponentProps = IAsyncComponentOwnProps & IAsyncComponentStateProps;

export const styles = (theme: Theme): any => ({
loader: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: '100vw',
height: '100vh',
},
progress: {
margin: theme.spacing.unit * 2,
},
});

class AsyncComponent extends React.PureComponent<IAsyncComponentProps, IAsyncComponentState> {
constructor(props: IAsyncComponentProps) {
super(props);
this.state = {
Component: null,
};
}

public componentWillMount(): any {
if (!this.state.Component) {
this.props.moduleProvider().then((data: any) => this.setState({ Component: data.default }));
}
}

public renderLoader(): any {
const {classes} = this.props;
return (
<div className={classes.loader}>
<CircularProgress className={classes.progress} />
</div>
);
}

public render(): any {
const { Component } = this.state;
return Component ? <Component /> : this.renderLoader();
}
}

export default withStyles(styles)(AsyncComponent);
61 changes: 61 additions & 0 deletions src/app/buttons/Buttons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
import { buttonStyles } from './buttons.styles';
import { IButtonProps, IButtonState } from './IButtons';
import { Button, CardContent } from '@material-ui/core';
import { CollapsiblePanel } from '../components';
import { ButtonProps } from '@material-ui/core/Button';

class Buttons extends React.Component<IButtonProps, IButtonState> {
public renderButtons(headerText: string, buttonVariant: ButtonProps['variant']): any {
const { classes } = this.props;
return (
<Grid item xs={12}>
<CollapsiblePanel className={classes.panelHeader} header={headerText} autoOpen>
<CardContent style={{ paddingBottom: 0 }}>
<Grid container className={classes.gridContainer}>
<Button variant={buttonVariant} className={classes.button}>Default</Button>
<Button color='primary' className={classes.button}>
Primary
</Button>
<Button variant={buttonVariant} color='secondary' className={classes.button}>
Secondary
</Button>
<Button variant={buttonVariant} disabled className={classes.button}>
Disabled
</Button>
<Button variant={buttonVariant} href='/#/dashboard' className={classes.button}>
Link
</Button>
<input accept='image/*' className={classes.input} id='flat-button-file' multiple type='file' />
<label htmlFor='flat-button-file'>
<Button variant={buttonVariant} component='span' className={classes.button}>
Upload
</Button>
</label>
</Grid>
</CardContent>
</CollapsiblePanel>
</Grid>
);
}
public render(): React.ReactElement<Buttons> {
const { classes } = this.props;

return (
<div className={classes.root}>
<Grid container spacing={8}>
{this.renderButtons('Text Buttons', 'text')}
{this.renderButtons('Outline Buttons', 'outlined')}
{this.renderButtons('Contained Buttons', 'contained')}
{this.renderButtons('Raised Buttons', 'raised')}
{this.renderButtons('Raised Buttons', 'flat')}
{this.renderButtons('Raised Buttons', 'fab')}
</Grid>
</div>
);
}
}

export default withStyles(buttonStyles)(Buttons);
13 changes: 13 additions & 0 deletions src/app/buttons/IButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Theme } from '@material-ui/core';

interface IButtonOwnProps {
classes: any;
}
interface IButtonStateProps {
theme: Theme;
}

export type IButtonProps = IButtonOwnProps & IButtonStateProps;

export interface IButtonState {
}
17 changes: 12 additions & 5 deletions src/app/buttons/buttons.styles.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { Theme } from '@material-ui/core';

export const homeStyles = (theme: Theme): any => ({
export const buttonStyles = (theme: Theme): any => ({
root: {
flexGrow: 1,
},
paper: {
padding: theme.spacing.unit * 2,
textAlign: 'center',
color: theme.palette.text.secondary,
gridContainer: {
justifyContent: 'center',
},
panelHeader: {
backgroundColor: theme.palette.grey[200],
},
button: {
margin: theme.spacing.unit,
},
input: {
display: 'none',
},
});
38 changes: 1 addition & 37 deletions src/app/buttons/index.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
import { homeStyles } from './buttons.styles';
import { IHomeProps, IHomeState } from './buttons.interface';
import { Card, Button } from '@material-ui/core';

class Buttons extends React.Component<IHomeProps, IHomeState> {
public render(): React.ReactElement<Buttons> {
const { classes } = this.props;

return (
<div className={classes.root}>
<Grid container spacing={8}>
<Grid item sm={12} md={6}>
<Card>
<Button color='primary'>Primary</Button>
<Button color='default'>Default</Button>
<Button color='secondary'>Secondary</Button>
</Card>
</Grid>
<Grid item sm={12} md={6}>
<Card>
<div><Button variant='flat'>Flat Button</Button></div>
<div><Button variant='contained' color='primary'>Contained Button</Button></div>
<div><Button variant='flat' color='primary'>Contained Button</Button></div>
<div><Button variant='raised'>Raised Button</Button></div>
<div><Button variant='fab'>Fab Button</Button></div>
</Card>
</Grid>
</Grid>
</div >
);
}
}

export default withStyles(homeStyles)(Buttons);
export { default } from './Buttons';
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class CollapsiblePanel extends React.Component<any, any> {

public render(): any {
const { classes, header, customheader, className } = this.props;
console.log('cjeckdfd', this.props);

return (
<div>
Expand Down
27 changes: 16 additions & 11 deletions src/app/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import { dashboardStyles } from './dashboard.styles';
import { IDashboardProps, IDashboardState } from './IDashboard';
import Home from '../home';
import Charts from '../charts';
import Buttons from '../buttons';
import Icons from '../icons';
import Forms from '../forms';
import { Route, Switch, Redirect } from 'react-router-dom';
import Sidebar from './SideBar';
import Header from './Header';
import AsyncComponent from '../AsyncComponent';

const home = () => import('../home');
const widgets = () => import('../widgets');
const charts = () => import('../charts');
const buttons = () => import('../buttons');
const icons = () => import('../icons');
const forms = () => import('../forms');
const textFields = () => import('../text-fields');


class Dashboard extends React.Component<IDashboardProps, IDashboardState> {
Expand Down Expand Up @@ -39,12 +43,13 @@ class Dashboard extends React.Component<IDashboardProps, IDashboardState> {
<div className={classes.toolbar}>
<div style={{ width: '100%' }}>
<Switch>
<Route exact path='/dashboard/home' component={Home} />
<Route exact path='/dashboard/charts' component={Charts} />
<Route exact path='/dashboard/buttons' component={Buttons} />
<Route exact path='/dashboard/icons' component={Icons} />
<Route exact path='/dashboard/widgets' component={Home} />
<Route exact path='/dashboard/form-elements/forms' component={Forms} />
<Route exact path='/dashboard/home' component={() => <AsyncComponent moduleProvider={home} />} />
<Route exact path='/dashboard/widgets' component={() => <AsyncComponent moduleProvider={widgets} />} />
<Route exact path='/dashboard/charts' component={() => <AsyncComponent moduleProvider={charts} />} />
<Route exact path='/dashboard/buttons' component={() => <AsyncComponent moduleProvider={buttons} />} />
<Route exact path='/dashboard/icons' component={() => <AsyncComponent moduleProvider={icons} />} />
<Route exact path='/dashboard/form-elements/forms' component={() => <AsyncComponent moduleProvider={forms} />} />
<Route exact path='/dashboard/form-elements/text-fields' component={() => <AsyncComponent moduleProvider={textFields} />} />
<Redirect path='/dashboard' to='/dashboard/home' />
</Switch>
</div>
Expand Down
37 changes: 17 additions & 20 deletions src/app/dashboard/SideBar/menuItems.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import * as React from 'react';
import { IMenuItems } from './ISideBar';
import {
Drafts,
Inbox,
Report,
SentimentVerySatisfied,
Star,
TextFields,
Dashboard,
PermContactCalendar,
} from '@material-ui/icons';
import Drafts from '@material-ui/icons/Drafts';
import Dashboard from '@material-ui/icons/Dashboard';
import TagFaces from '@material-ui/icons/TagFaces';
import PieChart from '@material-ui/icons/PieChart';
import Widgets from '@material-ui/icons/Widgets';
import Crop169 from '@material-ui/icons/Crop169';
import Description from '@material-ui/icons/Description';

export const menuItems: Array<IMenuItems> = [
{
Expand All @@ -21,32 +18,32 @@ export const menuItems: Array<IMenuItems> = [
{
id: 2,
title: 'Widgets',
path: 'widgets',
icon: <Star />,
path: '/dashboard/widgets',
icon: <Widgets />,
},
{
id: 3,
title: 'Charts',
path: '/dashboard/charts',
icon: <Report />,
icon: <PieChart />,
},
{
id: 4,
title: 'Buttons',
path: '/dashboard/buttons',
icon: <Inbox />,
icon: <Crop169 />,
},
{
id: 5,
title: 'Icons',
path: '/dashboard/icons',
icon: <SentimentVerySatisfied />,
icon: <TagFaces />,
},
{
id: 6,
title: 'Form Elements',
path: '',
icon: <TextFields />,
icon: <Description />,
isOpen: false,
children: [
{
Expand All @@ -59,25 +56,25 @@ export const menuItems: Array<IMenuItems> = [
id: 62,
title: 'Text Fields',
path: '/dashboard/form-elements/text-fields',
icon: <TextFields />,
icon: <Dashboard />,
},
{
id: 63,
title: 'Selection Controls',
path: '/dashboard/form-elements/selection-controls',
icon: <TextFields />,
icon: <Dashboard />,
},
{
id: 64,
title: 'Dropdown Select',
path: '/dashboard/form-elements/forms',
icon: <TextFields />,
icon: <Dashboard />,
},
{
id: 65,
title: 'Date Time Pickers',
path: '/dashboard/form-elements/forms',
icon: <PermContactCalendar />,
icon: <Dashboard />,
},
],
},
Expand Down
Loading

0 comments on commit 09d519d

Please sign in to comment.