diff --git a/package-lock.json b/package-lock.json index ad5e341..a16b594 100644 --- a/package-lock.json +++ b/package-lock.json @@ -170,6 +170,14 @@ "@types/react": "16.3.14" } }, + "@types/es6-promise": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@types/es6-promise/-/es6-promise-3.3.0.tgz", + "integrity": "sha512-ixCIAEkLUKv9movnHKCzx2rzAJgEnSALDXPrOSSwOjWwXFs0ssSZKan+O2e3FExPPCbX+DfA9NcKsbvLuyUlNA==", + "requires": { + "es6-promise": "4.2.4" + } + }, "@types/history": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/@types/history/-/history-4.6.2.tgz", @@ -4095,6 +4103,11 @@ "es6-symbol": "3.1.1" } }, + "es6-promise": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==" + }, "es6-symbol": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", diff --git a/package.json b/package.json index 7523faa..a297296 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/app/AsyncComponent.tsx b/src/app/AsyncComponent.tsx new file mode 100644 index 0000000..ebd7787 --- /dev/null +++ b/src/app/AsyncComponent.tsx @@ -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 { + 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 ( +
+ +
+ ); + } + + public render(): any { + const { Component } = this.state; + return Component ? : this.renderLoader(); + } +} + +export default withStyles(styles)(AsyncComponent); diff --git a/src/app/buttons/Buttons.tsx b/src/app/buttons/Buttons.tsx new file mode 100644 index 0000000..1b1a535 --- /dev/null +++ b/src/app/buttons/Buttons.tsx @@ -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 { + public renderButtons(headerText: string, buttonVariant: ButtonProps['variant']): any { + const { classes } = this.props; + return ( + + + + + + + + + + + + + + + + ); + } + public render(): React.ReactElement { + const { classes } = this.props; + + return ( +
+ + {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')} + +
+ ); + } +} + +export default withStyles(buttonStyles)(Buttons); diff --git a/src/app/buttons/IButtons.tsx b/src/app/buttons/IButtons.tsx new file mode 100644 index 0000000..8dd36bc --- /dev/null +++ b/src/app/buttons/IButtons.tsx @@ -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 { +} diff --git a/src/app/buttons/buttons.styles.tsx b/src/app/buttons/buttons.styles.tsx index 66d8efa..8642633 100644 --- a/src/app/buttons/buttons.styles.tsx +++ b/src/app/buttons/buttons.styles.tsx @@ -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', }, }); diff --git a/src/app/buttons/index.tsx b/src/app/buttons/index.tsx index eea5f4b..bdef67b 100644 --- a/src/app/buttons/index.tsx +++ b/src/app/buttons/index.tsx @@ -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 { - public render(): React.ReactElement { - const { classes } = this.props; - - return ( -
- - - - - - - - - - -
-
-
-
-
-
-
-
-
- ); - } -} - -export default withStyles(homeStyles)(Buttons); +export { default } from './Buttons'; diff --git a/src/app/components/panel/CollapsiblePanel/CollapsiblePanel.tsx b/src/app/components/panel/CollapsiblePanel/CollapsiblePanel.tsx index 6f8d770..0569246 100644 --- a/src/app/components/panel/CollapsiblePanel/CollapsiblePanel.tsx +++ b/src/app/components/panel/CollapsiblePanel/CollapsiblePanel.tsx @@ -41,7 +41,6 @@ class CollapsiblePanel extends React.Component { public render(): any { const { classes, header, customheader, className } = this.props; - console.log('cjeckdfd', this.props); return (
diff --git a/src/app/dashboard/Dashboard.tsx b/src/app/dashboard/Dashboard.tsx index 4f00260..2318e1b 100644 --- a/src/app/dashboard/Dashboard.tsx +++ b/src/app/dashboard/Dashboard.tsx @@ -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 { @@ -39,12 +43,13 @@ class Dashboard extends React.Component {
- - - - - - + } /> + } /> + } /> + } /> + } /> + } /> + } />
diff --git a/src/app/dashboard/SideBar/menuItems.tsx b/src/app/dashboard/SideBar/menuItems.tsx index fb02abf..35d416e 100644 --- a/src/app/dashboard/SideBar/menuItems.tsx +++ b/src/app/dashboard/SideBar/menuItems.tsx @@ -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 = [ { @@ -21,32 +18,32 @@ export const menuItems: Array = [ { id: 2, title: 'Widgets', - path: 'widgets', - icon: , + path: '/dashboard/widgets', + icon: , }, { id: 3, title: 'Charts', path: '/dashboard/charts', - icon: , + icon: , }, { id: 4, title: 'Buttons', path: '/dashboard/buttons', - icon: , + icon: , }, { id: 5, title: 'Icons', path: '/dashboard/icons', - icon: , + icon: , }, { id: 6, title: 'Form Elements', path: '', - icon: , + icon: , isOpen: false, children: [ { @@ -59,25 +56,25 @@ export const menuItems: Array = [ id: 62, title: 'Text Fields', path: '/dashboard/form-elements/text-fields', - icon: , + icon: , }, { id: 63, title: 'Selection Controls', path: '/dashboard/form-elements/selection-controls', - icon: , + icon: , }, { id: 64, title: 'Dropdown Select', path: '/dashboard/form-elements/forms', - icon: , + icon: , }, { id: 65, title: 'Date Time Pickers', path: '/dashboard/form-elements/forms', - icon: , + icon: , }, ], }, diff --git a/src/app/icons/Icons.tsx b/src/app/icons/Icons.tsx index 6154327..48a2e98 100644 --- a/src/app/icons/Icons.tsx +++ b/src/app/icons/Icons.tsx @@ -6,7 +6,6 @@ import { IIconsProps, IIconsState } from './IIcons'; import { Paper, Divider, Typography, CardContent } from '@material-ui/core'; import { CollapsiblePanel } from '../components'; import { colorVariantIcons } from './iconSet/colorVariantIcons'; -import { actionIcons } from './iconSet/actionIcons'; class Icons extends React.Component { public render(): React.ReactElement { @@ -21,7 +20,7 @@ class Icons extends React.Component { {colorVariantIcons && colorVariantIcons.map((colorVariantIcon, index) => ( - + {colorVariantIcon.icon} {colorVariantIcon.title} @@ -32,23 +31,6 @@ class Icons extends React.Component { - - - - - {actionIcons && actionIcons.map((actionIcon, index) => ( - - - {actionIcon.icon} - - {actionIcon.title} - - - ))} - - - -
); diff --git a/src/app/icons/iconSet/colorVariantIcons.tsx b/src/app/icons/iconSet/colorVariantIcons.tsx index 0037553..c226ced 100644 --- a/src/app/icons/iconSet/colorVariantIcons.tsx +++ b/src/app/icons/iconSet/colorVariantIcons.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { deepOrange } from '@material-ui/core/colors'; -import { Star } from '@material-ui/icons'; +import Star from '@material-ui/icons/Star'; import { iconStyle } from '../icons.styles'; export const colorVariantIcons = [ diff --git a/src/app/icons/iconSet/index.tsx b/src/app/icons/iconSet/index.tsx index 23b7537..61ec5a2 100644 --- a/src/app/icons/iconSet/index.tsx +++ b/src/app/icons/iconSet/index.tsx @@ -1,2 +1 @@ -export { actionIcons } from './actionIcons'; export { colorVariantIcons } from './colorVariantIcons'; diff --git a/src/app/index.tsx b/src/app/index.tsx index da931bb..56c9594 100644 --- a/src/app/index.tsx +++ b/src/app/index.tsx @@ -1,17 +1,21 @@ import * as React from 'react'; import { Route, Redirect, Switch } from 'react-router-dom'; -import Login from './login'; -import Dashboard from './dashboard'; +import AsyncComponent from './AsyncComponent'; +// import Login from './login'; +// import Dashboard from './dashboard'; const NoMatch = () =>

Page not found!

; +const login = () => import('./login'); +const dashboard = () => import('./dashboard'); + export class App extends React.Component { public render(): React.ReactElement { return (
- - + } /> + } /> diff --git a/src/app/text-fields/ITextFields.tsx b/src/app/text-fields/ITextFields.tsx new file mode 100644 index 0000000..cbff7e2 --- /dev/null +++ b/src/app/text-fields/ITextFields.tsx @@ -0,0 +1,17 @@ +import { Theme } from '@material-ui/core'; + +interface ITextFieldsOwnProps { + classes: any; +} +interface ITextFieldsStateProps { + theme: Theme; +} + +export type ITextFieldsProps = ITextFieldsOwnProps & ITextFieldsStateProps; + +export interface ITextFieldsState { + name: string; + age: string; + multiline: string; + currency: string; +} diff --git a/src/app/text-fields/TextFields.tsx b/src/app/text-fields/TextFields.tsx new file mode 100644 index 0000000..14196fe --- /dev/null +++ b/src/app/text-fields/TextFields.tsx @@ -0,0 +1,220 @@ +import * as React from 'react'; +import { withStyles } from '@material-ui/core/styles'; +import Grid from '@material-ui/core/Grid'; +import { textFieldStyles } from './textFields.styles'; +import { ITextFieldsProps, ITextFieldsState } from './ITextFields'; +import { CardContent, TextField, MenuItem } from '@material-ui/core'; +import { CollapsiblePanel } from '../components'; + +const currencies = [ + { + value: 'USD', + label: '$', + }, + { + value: 'EUR', + label: '€', + }, + { + value: 'BTC', + label: '฿', + }, + { + value: 'JPY', + label: '¥', + }, + ]; + +class TextFields extends React.Component { + constructor(props: ITextFieldsProps, context: any) { + super(props, context); + this.state = { + name: 'Cat in the Hat', + age: '', + multiline: 'Controlled', + currency: 'EUR', + }; + } + + public render(): React.ReactElement { + const { classes } = this.props; + + return ( +
+ + + + + +
+ + + + + + + + + + + + + + + {currencies.map(option => ( + + {option.label} + + ))} + + + {currencies.map(option => ( + + ))} + + + +
+
+
+
+
+
+ ); + } +} + +export default withStyles(textFieldStyles)(TextFields); diff --git a/src/app/text-fields/index.tsx b/src/app/text-fields/index.tsx new file mode 100644 index 0000000..ace9e51 --- /dev/null +++ b/src/app/text-fields/index.tsx @@ -0,0 +1 @@ +export { default } from './TextFields'; diff --git a/src/app/text-fields/textFields.styles.tsx b/src/app/text-fields/textFields.styles.tsx new file mode 100644 index 0000000..3957d17 --- /dev/null +++ b/src/app/text-fields/textFields.styles.tsx @@ -0,0 +1,24 @@ +import { Theme } from '@material-ui/core'; + +export const textFieldStyles = (theme: Theme): any => ({ + root: { + flexGrow: 1, + }, + gridContainer: { + justifyContent: 'center', + }, + container: { + display: 'flex', + flexWrap: 'wrap', + justifyContent: 'space-between', + }, + textField: { + marginLeft: theme.spacing.unit, + marginRight: theme.spacing.unit, + width: 200, + }, + menu: { + width: 200, + }, +}); + diff --git a/src/app/buttons/buttons.interface.tsx b/src/app/widgets/IWidgets.tsx similarity index 100% rename from src/app/buttons/buttons.interface.tsx rename to src/app/widgets/IWidgets.tsx diff --git a/src/app/widgets/index.tsx b/src/app/widgets/index.tsx new file mode 100644 index 0000000..ad60242 --- /dev/null +++ b/src/app/widgets/index.tsx @@ -0,0 +1 @@ +export { default } from './widgets'; diff --git a/src/app/widgets/widgets.styles.tsx b/src/app/widgets/widgets.styles.tsx new file mode 100644 index 0000000..d2ee4fc --- /dev/null +++ b/src/app/widgets/widgets.styles.tsx @@ -0,0 +1,17 @@ +import { Theme } from '@material-ui/core'; +import { ThemeConfig, defineColours } from '../../theme'; + +export const homeStyles = (theme: Theme): any => ({ + root: { + flexGrow: 1, + }, + paper: { + padding: theme.spacing.unit * 2, + textAlign: 'center', + color: theme.palette.text.secondary, + }, + panelHeader: { + background: defineColours(ThemeConfig.warningColor, true), + color: '#fff', + }, +}); diff --git a/src/app/widgets/widgets.tsx b/src/app/widgets/widgets.tsx new file mode 100644 index 0000000..024ef10 --- /dev/null +++ b/src/app/widgets/widgets.tsx @@ -0,0 +1,93 @@ +import * as React from 'react'; +import { withStyles } from '@material-ui/core/styles'; +import { Grid, CardContent, Typography } from '@material-ui/core'; +import { homeStyles } from './widgets.styles'; +import { IHomeProps, IHomeState } from './IWidgets'; +import { StatsWidget, CollapsiblePanel } from '../components'; +import StarIcon from '@material-ui/icons/Star'; +import InboxIcon from '@material-ui/icons/Inbox'; +import { defineColours, ThemeConfig } from '../../theme'; + +class Home extends React.Component { + public render(): React.ReactElement { + const { classes } = this.props; + + return ( +
+ + + } + value='32.5 C' + title='Temperature' + textColor={defineColours(ThemeConfig.primaryColor, true)} + backgroundColor={defineColours(ThemeConfig.primaryColor)} + /> + + + } + value='13486' + title='Visibility' + color='secondary' + backgroundColor={defineColours(ThemeConfig.secondaryColor)} + /> + + + } + value='87%' + title='Humidity' + textColor={defineColours(ThemeConfig.warningColor, true)} + backgroundColor={defineColours(ThemeConfig.warningColor)} + /> + + + } + value='2.1 m/s' + title='Wind Speed' + textColor={defineColours(ThemeConfig.dangerColor, true)} + backgroundColor={defineColours(ThemeConfig.dangerColor)} + /> + + + + + + + + Method: + + + Heat 1/2 cup of the broth in a pot until simmering, add saffron and set aside for 10 + minutes. + + + Heat oil in a (14- to 16-inch) paella pan or a large, deep skillet over medium-high + heat. Add chicken, shrimp and chorizo, and cook, stirring occasionally until lightly + browned, 6 to 8 minutes. Transfer shrimp to a large plate and set aside, leaving + chicken and chorizo in the pan. Add pimentón, bay leaves, garlic, tomatoes, onion, + salt and pepper, and cook, stirring often until thickened and fragrant, about 10 + minutes. Add saffron broth and remaining 4 1/2 cups chicken broth; bring to a boil. + + + Add rice and stir very gently to distribute. Top with artichokes and peppers, and + cook without stirring, until most of the liquid is absorbed, 15 to 18 minutes. + Reduce heat to medium-low, add reserved shrimp and mussels, tucking them down into + the rice, and cook again without stirring, until mussels have opened and rice is + just tender, 5 to 7 minutes more. (Discard any mussels that don’t open.) + + + Set aside off of the heat to let rest for 10 minutes, and then serve. + + + + + +
+ ); + } +} + +export default withStyles(homeStyles, {withTheme: true})(Home); diff --git a/tsconfig.json b/tsconfig.json index a4b046e..618059f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "strictNullChecks": true, "outDir": "build", "noUnusedLocals": true, + "lib": ["es2015", "dom"], }, "exclude": [ "build",