Skip to content

Commit 9ddc58e

Browse files
author
Scott Prue
committed
Update material example to use material-ui v1, react 16.3, and firebase 5.0.0
1 parent 13549e9 commit 9ddc58e

File tree

76 files changed

+8453
-836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+8453
-836
lines changed

examples/complete/material/.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
coverage/**
1+
**/coverage/**
22
**/node_modules/**
33
dist/**
44
src/index.html

examples/complete/material/.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rules:
2525
jsx-quotes: ['error', 'prefer-double']
2626
prettier/prettier: ['error', {
2727
singleQuote: true,
28-
trailingComma: 'es6',
28+
trailingComma: 'none',
2929
semi: false,
3030
bracketSpacing: true,
3131
jsxBracketSameLine: true,

examples/complete/material/LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 David Zukowski
3+
Copyright (c) 2017 testuser
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const logger = require('../lib/logger')
2+
const config = require('../../project.config')
23

34
logger.info('Starting server...')
4-
require('../../server/main').listen(3000, () => {
5-
logger.success('Server is running at http://localhost:3000')
5+
require('../../server/main').listen(config.port, () => {
6+
logger.success(`Server is running at http://localhost:${config.port}`)
67
})

examples/complete/material/build/webpack.config.js

+22-11
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,23 @@ config.module.rules.push({
5959
test: /\.(js|jsx)$/,
6060
exclude: [
6161
/node_modules/,
62-
/react-redux-firebase\/es/,
6362
/redux-firestore\/es/,
63+
/react-redux-firebase\/es/
64+
// Add other packages that you are npm linking here
6465
],
6566
use: [
6667
{
6768
loader: 'babel-loader',
6869
query: {
6970
cacheDirectory: true,
70-
// Ignore .babelrc file (prevents issue with global babelrc)
71+
// ignore root .babelrc (Check issue #59 for more details)
7172
babelrc: false,
7273
plugins: [
7374
'lodash',
7475
'transform-decorators-legacy',
75-
'transform-export-extensions',
7676
'babel-plugin-transform-class-properties',
7777
'babel-plugin-syntax-dynamic-import',
78+
'babel-plugin-transform-export-extensions',
7879
[
7980
'babel-plugin-transform-runtime',
8081
{
@@ -159,13 +160,22 @@ config.plugins.push(extractStyles)
159160

160161
// Images
161162
// ------------------------------------
162-
config.module.rules.push({
163-
test: /\.(png|jpg|gif)$/,
164-
loader: 'url-loader',
165-
options: {
166-
limit: 8192
163+
config.module.rules.push(
164+
{
165+
test: /\.(png|jpg|gif)$/,
166+
loader: 'url-loader',
167+
options: {
168+
limit: 8192
169+
}
170+
},
171+
{
172+
test: /octicons\.css$/,
173+
loader: 'url-loader',
174+
options: {
175+
limit: 8192
176+
}
167177
}
168-
})
178+
)
169179

170180
// Fonts
171181
// ------------------------------------
@@ -207,8 +217,9 @@ config.plugins.push(
207217
// ------------------------------------
208218
if (__DEV__) {
209219
config.entry.main.push(
210-
`webpack-hot-middleware/client.js?path=${config.output
211-
.publicPath}__webpack_hmr`
220+
`webpack-hot-middleware/client.js?path=${
221+
config.output.publicPath
222+
}__webpack_hmr`
212223
)
213224
config.plugins.push(
214225
new webpack.HotModuleReplacementPlugin(),

examples/complete/material/config/webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const APP_ENTRY = project.paths.client('main.js')
2929
webpackConfig.entry = {
3030
app: __DEV__
3131
? [APP_ENTRY].concat(
32-
`webpack-hot-middleware/client?path=${project.compiler_public_path}__webpack_hmr`
32+
`webpack-hot-middleware/client?path=${
33+
project.compiler_public_path
34+
}__webpack_hmr`
3335
)
3436
: [APP_ENTRY],
3537
vendor: project.compiler_vendors

examples/complete/material/database.rules.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"$uid": {
77
".write": "auth !== null && $uid === auth.uid"
88
}
9+
},
10+
"projects": {
11+
".indexOn": ["createdBy"]
912
}
1013
}
1114
}

examples/complete/material/firebase.json

+5
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@
1313
"destination": "/index.html"
1414
}
1515
]
16+
},
17+
"functions": {
18+
"predeploy": [
19+
"npm --prefix \"$RESOURCE_DIR\" run build"
20+
]
1621
}
1722
}

examples/complete/material/package.json

+21-16
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,40 @@
1212
"start:simple": "cross-env NODE_ENV=development node build/scripts/start",
1313
"lint": "eslint .",
1414
"lint:fix": "npm run lint -- --fix",
15-
"format": "prettier --single-quote --no-semi --trailing-comma none --write \"src/**/*.js\""
15+
"format": "prettier --single-quote --no-semi --trailing-comma none --write \"src/**/*.js\"",
16+
"prepush": "npm run lint"
1617
},
1718
"repository": {
1819
"type": "git",
1920
"url": "git+https://github.com/testuser/material.git"
2021
},
22+
"engines": {
23+
"node": ">=6.11.5"
24+
},
2125
"author": "testuser (https://github.com/testuser)",
2226
"license": "MIT",
2327
"dependencies": {
24-
"firebase": "^5.0.1",
25-
"lodash": "^4.17.4",
26-
"material-ui": "^0.19.1",
28+
"@material-ui/core": "1.0.0",
29+
"@material-ui/icons": "1.0.0",
30+
"firebase": "^5.0.3",
31+
"lodash": "^4.17.10",
32+
"material-ui": "next",
2733
"normalize.css": "^7.0.0",
2834
"object-assign": "^4.1.1",
2935
"promise": "^7.1.1",
30-
"prop-types": "^15.6.1",
31-
"react": "^15.5.4",
32-
"react-dom": "^15.5.4",
36+
"prop-types": "^15.5.10",
37+
"react": "^16.3.0",
38+
"react-dom": "^16.3.0",
3339
"react-google-button": "^0.3.0",
34-
"react-redux": "^5.0.4",
40+
"react-redux": "^5.0.7",
3541
"react-redux-firebase": "*",
3642
"react-router": "^3.0.0",
37-
"react-tap-event-plugin": "^2.0.1",
38-
"recompose": "^0.26.0",
43+
"recompose": "^0.27.1",
3944
"redbox-react": "^1.3.6",
40-
"redux": "^3.6.0",
45+
"redux": "^4.0.0",
4146
"redux-auth-wrapper": "^1.0.0",
42-
"redux-form": "^6.6.1",
43-
"redux-form-material-ui": "^4.2.0",
47+
"redux-form": "^7.3.0",
48+
"redux-form-material-ui": "next",
4449
"redux-thunk": "^2.2.0",
4550
"whatwg-fetch": "^2.0.3"
4651
},
@@ -75,20 +80,20 @@
7580
"eslint-plugin-react": "^7.0.1",
7681
"eslint-plugin-standard": "^3.0.1",
7782
"express": "^4.14.0",
78-
"extract-text-webpack-plugin": "^2.1.0",
83+
"extract-text-webpack-plugin": "^3.0.0",
7984
"figures": "^2.0.0",
8085
"file-loader": "^0.11.1",
8186
"fs-extra": "^3.0.1",
8287
"html-webpack-plugin": "^2.29.0",
8388
"husky": "^0.14.3",
8489
"ip": "^1.1.5",
8590
"node-sass": "^4.5.3",
86-
"prettier": "^1.5.3",
91+
"prettier": "^1.12.1",
8792
"rimraf": "^2.6.1",
8893
"sass-loader": "^6.0.5",
8994
"style-loader": "^0.17.0",
9095
"url-loader": "^0.5.8",
91-
"webpack": "^2.5.1",
96+
"webpack": "^3.6.0",
9297
"webpack-dashboard": "^0.4.0",
9398
"webpack-dev-middleware": "^1.11.0",
9499
"webpack-hot-middleware": "^2.13.2",
+6-34
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
const ip = require('ip')
22
const NODE_ENV = process.env.NODE_ENV || 'development'
3+
const PORT = 3000
34

45
module.exports = {
56
/** The environment to use when building the project */
67
env: NODE_ENV,
8+
/** The port that is used for local development */
9+
port: PORT,
710
/** The full path to the project's root directory */
811
basePath: __dirname,
912
/** The name of the directory containing the application source code */
@@ -13,7 +16,8 @@ module.exports = {
1316
/** The name of the directory in which to emit compiled assets */
1417
outDir: 'dist',
1518
/** The base path for all projects assets (relative to the website root) */
16-
publicPath: NODE_ENV === 'development' ? `http://${ip.address()}:3000/` : '/',
19+
publicPath:
20+
NODE_ENV === 'development' ? `http://${ip.address()}:${PORT}/` : '/',
1721
/** Whether to generate sourcemaps */
1822
sourcemaps: true,
1923
/** A hash map of keys that the compiler should treat as external to the project */
@@ -32,37 +36,5 @@ module.exports = {
3236
'react-router',
3337
'react-redux-firebase',
3438
'material-ui'
35-
],
36-
/**
37-
* Settings used to create src/config.js using firebase-ci
38-
* in ci environment. If you are running locally, go to src/config.js.
39-
*/
40-
ci: {
41-
development: {
42-
firebase: {
43-
apiKey: 'AIzaSyCTUERDM-Pchn_UDTsfhVPiwM4TtNIxots',
44-
authDomain: 'redux-firebasev3.firebaseapp.com',
45-
databaseURL: 'https://redux-firebasev3.firebaseio.com',
46-
storageBucket: 'redux-firebasev3.appspot.com'
47-
},
48-
reduxFirebase: {
49-
userProfile: 'users', // root that user profiles are written to
50-
enableLogging: false, // enable/disable Firebase Database Logging
51-
updateProfileOnLogin: false // enable/disable updating of profile on login
52-
}
53-
},
54-
production: {
55-
firebase: {
56-
apiKey: 'AIzaSyCTUERDM-Pchn_UDTsfhVPiwM4TtNIxots',
57-
authDomain: 'redux-firebasev3.firebaseapp.com',
58-
databaseURL: 'https://redux-firebasev3.firebaseio.com',
59-
storageBucket: 'redux-firebasev3.appspot.com'
60-
},
61-
reduxFirebase: {
62-
userProfile: 'users',
63-
enableLogging: false,
64-
updateProfileOnLogin: false
65-
}
66-
}
67-
}
39+
]
6840
}

examples/complete/material/src/components/LoadingSpinner/LoadingSpinner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import CircularProgress from 'material-ui/CircularProgress'
3+
import CircularProgress from '@material-ui/core/CircularProgress'
44
import classes from './LoadingSpinner.scss'
55

66
export const LoadingSpinner = ({ size }) => (
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
1-
import React, { Component } from 'react'
1+
import React from 'react'
22
import PropTypes from 'prop-types'
33
import { browserHistory, Router } from 'react-router'
4+
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles'
45
import { Provider } from 'react-redux'
5-
import { Notifications } from 'modules/notification'
6+
import ThemeSettings from 'theme'
67

7-
// Themeing/Styling
8-
import Theme from 'theme'
9-
import getMuiTheme from 'material-ui/styles/getMuiTheme'
8+
const theme = createMuiTheme(ThemeSettings)
109

11-
export default class AppContainer extends Component {
12-
static childContextTypes = {
13-
muiTheme: PropTypes.object
14-
}
10+
const App = ({ routes, store }) => (
11+
<MuiThemeProvider theme={theme}>
12+
<Provider store={store}>
13+
<Router history={browserHistory}>{routes}</Router>
14+
</Provider>
15+
</MuiThemeProvider>
16+
)
1517

16-
static propTypes = {
17-
routes: PropTypes.object.isRequired,
18-
store: PropTypes.object.isRequired
19-
}
20-
21-
getChildContext = () => ({
22-
muiTheme: getMuiTheme(Theme)
23-
})
24-
25-
render() {
26-
const { routes, store } = this.props
27-
return (
28-
<Provider store={store}>
29-
<div>
30-
<Router history={browserHistory}>{routes}</Router>
31-
<Notifications />
32-
</div>
33-
</Provider>
34-
)
35-
}
18+
App.propTypes = {
19+
routes: PropTypes.object.isRequired,
20+
store: PropTypes.object.isRequired
3621
}
22+
23+
export default App
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import Menu from '@material-ui/core/Menu'
4+
import MenuItem from '@material-ui/core/MenuItem'
5+
import IconButton from '@material-ui/core/IconButton'
6+
import AccountCircle from '@material-ui/icons/AccountCircle'
7+
import { withStyles } from '@material-ui/core/styles'
8+
9+
const styles = {
10+
buttonRoot: {
11+
color: 'white'
12+
}
13+
}
14+
15+
export const AccountMenu = ({
16+
avatarUrl,
17+
displayName,
18+
goToAccount,
19+
onLogoutClick,
20+
closeAccountMenu,
21+
anchorEl,
22+
handleMenu,
23+
classes
24+
}) => (
25+
<div>
26+
<IconButton
27+
aria-owns={anchorEl ? 'menu-appbar' : null}
28+
aria-haspopup="true"
29+
onClick={handleMenu}
30+
classes={{ root: classes.buttonRoot }}>
31+
<AccountCircle />
32+
</IconButton>
33+
<Menu
34+
id="menu-appbar"
35+
anchorEl={anchorEl}
36+
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
37+
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
38+
open={Boolean(anchorEl)}
39+
onClose={closeAccountMenu}>
40+
<MenuItem onClick={goToAccount}>Account</MenuItem>
41+
<MenuItem onClick={onLogoutClick}>Sign Out</MenuItem>
42+
</Menu>
43+
</div>
44+
)
45+
46+
AccountMenu.propTypes = {
47+
displayName: PropTypes.string,
48+
avatarUrl: PropTypes.string,
49+
goToAccount: PropTypes.func.isRequired,
50+
onLogoutClick: PropTypes.func.isRequired,
51+
anchorEl: PropTypes.object,
52+
closeAccountMenu: PropTypes.func.isRequired,
53+
handleMenu: PropTypes.func.isRequired,
54+
classes: PropTypes.object.isRequired // from withStyles
55+
}
56+
57+
export default withStyles(styles)(AccountMenu)

0 commit comments

Comments
 (0)