Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"extends": "eslint-config-airbnb",
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"meteor": true,
"browser": true,
"jasmine": true
},
"rules": {
"prefer-const": 0
"no-console": 0,
"prefer-template": 0,
"import/no-unresolved": 0
}
}
15 changes: 8 additions & 7 deletions app/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
/* global ReactMeteorData */
import React, {Component} from 'react';
import React, { Component } from 'react';
import reactMixin from 'react-mixin';
import BlazeTemplate from './BlazeTemplate';
import {Users, Posts} from 'collections';
import { Users, Posts } from 'collections';
import './App.css';

Meteor.call('sayHello', function(err, res) {
Meteor.call('sayHello', (err, res) => {
console.log(res);
});

@reactMixin.decorate(ReactMeteorData)
export default class App extends Component {
getMeteorData() {
return {
users: Users.find().fetch()
usersCount: Users.find().fetch().length,
postsCount: Posts.find().fetch().length
};
}

render() {
let userCount = Users.find().fetch().length;
let postsCount = Posts.find().fetch().length;
const { usersCount, postsCount } = this.data;

return (
<div className="App">
{Meteor.isClient && <BlazeTemplate template={Template.loginButtons} />}
<h1>Hello Webpack!</h1>
<p>There are {userCount} users in the Minimongo (login to change)</p>
<p>There are {usersCount} users in the Minimongo (login to change)</p>
<p>There are {postsCount} posts in the Minimongo (autopublish removed)</p>
</div>
);
Expand Down
16 changes: 8 additions & 8 deletions app/components/BlazeTemplate.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/* global Blaze */
import React, {component} from 'react';
import React, { Component } from 'react';
import ReactDOM from 'react-dom';

export default class BlazeTemplate extends React.Component {
export default class BlazeTemplate extends Component {
static propTypes = {
template: React.PropTypes.any.isRequired,
component: React.PropTypes.any,
}
static defaultProps = {
component: 'div',
}
// we don't want to re-render this component if parent changes
shouldComponentUpdate() {
return false;
}
componentDidMount() {
let {template} = this.props;
const { template } = this.props;
this.view = Blaze.render(template, ReactDOM.findDOMNode(this.refs.root));
}
shouldComponentUpdate() {
return false;
}
componentWillUnmount() {
Blaze.remove(this.view);
}
render() {
let {component, ...props} = this.props;
const { component } = this.props;
let { ...props } = this.props;
props.ref = 'root';
return React.createElement(component, props);
}
Expand Down
35 changes: 19 additions & 16 deletions app/components/__tests__/client/unit/AppSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@
// data and then the children can be very easily tested with
// just props and state. We'll use a local component for an example

import React, {Component} from 'react';
import {mount} from 'enzyme';
import React, { Component, PropTypes } from 'react';
import { mount } from 'enzyme';

class Post extends Component {
state = {
isVisible: true
};
static defaultProps = {
title: 'Default Post Name'
title: 'Default Post Name',
};
static propTypes = {
title: PropTypes.string,
};
state = {
isVisible: true,
};
handleHide = () => {
this.setState({isVisible: false});
this.setState({ isVisible: false });
};
render() {
let visibleClass = (this.state.isVisible) ? 'block' : 'hidden';
const visibleClass = (this.state.isVisible) ? 'block' : 'hidden';
return (
<div className='Post' style={{display: visibleClass}}>
<div className="Post" style={{ display: visibleClass }}>
<h1>{this.props.title}</h1>
<article>
How now brown cow
Expand All @@ -34,22 +37,22 @@ class Post extends Component {

describe('Sample post component', () => {
it('renders default post name without props', () => {
let comp = mount(<Post/>);
const comp = mount(<Post />);
expect(comp.find('h1').text()).toEqual('Default Post Name');
});

it('renders correct post name with a name prop', () => {
let comp = mount(<Post title="Webpack is awesome!"/>);
expect(comp.find('h1').text()).toEqual("Webpack is awesome!");
const comp = mount(<Post title="Webpack is awesome!" />);
expect(comp.find('h1').text()).toEqual('Webpack is awesome!');
});

it("should have a default state of visible", () => {
let comp = mount(<Post/>);
it('should have a default state of visible', () => {
const comp = mount(<Post />);
expect(comp.find('.Post').prop('style').display).toEqual('block');
});

it("should hide when hide button is clicked", () => {
let comp = mount(<Post/>);
it('should hide when hide button is clicked', () => {
const comp = mount(<Post />);
comp.find('button').simulate('click');
expect(comp.find('.Post').prop('style').display).toEqual('hidden');
});
Expand Down
6 changes: 3 additions & 3 deletions app/fixtures.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* global Accounts */
import {Posts} from './collections';
import { Posts } from './collections';

export function createPosts() {
console.log('Creating fake posts');
[1, 2, 3, 4].forEach(function(count) {
[1, 2, 3, 4].forEach(count => {
Posts.insert({
name: 'Test post # ' + count,
desc: 'How now brown cow',
Expand All @@ -13,7 +13,7 @@ export function createPosts() {

export function createUsers() {
console.log('Creating fake users');
['Bob', 'Jane', 'Max'].forEach(function(name) {
['Bob', 'Jane', 'Max'].forEach(name => {
Accounts.createUser({
username: name,
password: 'password',
Expand Down
2 changes: 1 addition & 1 deletion app/main_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Accounts.ui.config({
console.log('Running on client only');

Meteor.startup(() => {
ReactDOM.render(<App/>, document.getElementById('root'));
ReactDOM.render(<App />, document.getElementById('root'));
});
8 changes: 3 additions & 5 deletions app/main_server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';
import App from './components/App.jsx';
import {Posts} from './collections';
import {createPosts, createUsers} from './fixtures';
import { Posts } from './collections';
import { createPosts, createUsers } from './fixtures';
// we don't call this so we're just importing to initialize file
import './method_example';

Expand All @@ -16,5 +14,5 @@ console.log('\n\nRunning on server only');
console.log('There are # posts:', Posts.find().fetch().length);

Meteor.startup(() => {
console.log('React SSR:', React.renderToString(<App/>));

});
2 changes: 1 addition & 1 deletion core-js-custom-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var path = require('path');
dirs.lib = path.join(dirs.webpack, 'lib');
if (!fs.existsSync(dirs.lib)) mkdir(dirs.lib);

var coreJsVersion = JSON.parse(fs.readFileSync('node_modules/core-js/package.json')).version;
var coreJsVersion = JSON.parse(fs.readFileSync('node_modules/core-js-builder/node_modules/core-js/package.json')).version;
var targetFileName = 'core-js-no-number.js';
var currentFileExist = fs.existsSync(path.join(dirs.lib, targetFileName));
var currentFileFewLines = currentFileExist ?
Expand Down
1 change: 1 addition & 0 deletions meteor_core/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ notices-for-facebook-graph-api-2
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
13 changes: 6 additions & 7 deletions meteor_core/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

accounts-ui
meteor-base
accounts-password
react-meteor-data
babel-runtime
meteor-base
mobile-experience
mongo
blaze-html-templates
session
jquery
tracker
logging
reload
random
ejson
spacebars
check
mindfront:why-reminify

accounts-ui
mobile-experience
blaze-html-templates
spacebars
2 changes: 1 addition & 1 deletion meteor_core/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@1.2.0.2
METEOR@1.3.2.4
Loading