| @@ -0,0 +1,15 @@ | ||
| import {createApp} from 'mantra-core'; | ||
| import initContext from './configs/context'; | ||
|
|
||
| // modules | ||
| import coreModule from './modules/core'; | ||
| import react_utilsModule from './modules/react_utils'; | ||
|
|
||
| // init context | ||
| const context = initContext(); | ||
|
|
||
| // create app | ||
| const app = createApp(context); | ||
| app.loadModule(coreModule); | ||
| app.loadModule(react_utilsModule); | ||
| app.init(); |
| @@ -0,0 +1,7 @@ | ||
| import products from './products'; | ||
| import nav from './nav'; | ||
|
|
||
| export default { | ||
| products, | ||
| nav | ||
| }; |
| @@ -0,0 +1,3 @@ | ||
| export default { | ||
|
|
||
| } |
| @@ -0,0 +1,3 @@ | ||
| export default { | ||
|
|
||
| } |
| @@ -0,0 +1,9 @@ | ||
| import React from 'react'; | ||
|
|
||
| const Front = () => ( | ||
| <div> | ||
| Front | ||
| </div> | ||
| ); | ||
|
|
||
| export default Front; |
| @@ -0,0 +1,20 @@ | ||
| import React from 'react'; | ||
|
|
||
| const Home = () => ( | ||
| <div> | ||
| <h1>Mantra</h1> | ||
| <p> | ||
| Welcome to Mantra 0.2.0. | ||
| </p> | ||
| <ul> | ||
| <li> | ||
| Read <a target="_blank" href="https://kadirahq.github.io/mantra/">spec</a> | ||
| </li> | ||
| <li> | ||
| Learn <a target="_blank" href="https://github.com/sungwoncho/mantra-cli#commands">CLI</a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| ); | ||
|
|
||
| export default Home; |
| @@ -0,0 +1,11 @@ | ||
| import React from 'react'; | ||
|
|
||
| const Layout = ({content = () => null }) => ( | ||
| <div> | ||
| <div> | ||
| {content()} | ||
| </div> | ||
| </div> | ||
| ); | ||
|
|
||
| export default Layout; |
| @@ -0,0 +1,9 @@ | ||
| import React from 'react'; | ||
|
|
||
| const Nav = () => ( | ||
| <div> | ||
| Nav | ||
| </div> | ||
| ); | ||
|
|
||
| export default Nav; |
| @@ -0,0 +1,13 @@ | ||
| import React from 'react'; | ||
|
|
||
| class Product extends React.Component { | ||
| render() { | ||
| return ( | ||
| <div> | ||
| Product | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default Product; |
| @@ -0,0 +1,9 @@ | ||
| import React from 'react'; | ||
|
|
||
| const ProductList = () => ( | ||
| <div> | ||
| ProductList | ||
| </div> | ||
| ); | ||
|
|
||
| export default ProductList; |
| @@ -0,0 +1,18 @@ | ||
| import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core'; | ||
|
|
||
| import Front from '../components/front.jsx'; | ||
|
|
||
| export const composer = ({context}, onData) => { | ||
| const {Meteor, Collections} = context(); | ||
|
|
||
| onData(null, {}); | ||
| }; | ||
|
|
||
| export const depsMapper = (context, actions) => ({ | ||
| context: () => context | ||
| }); | ||
|
|
||
| export default composeAll( | ||
| composeWithTracker(composer), | ||
| useDeps(depsMapper) | ||
| )(Front); |
| @@ -0,0 +1,18 @@ | ||
| import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core'; | ||
|
|
||
| import Nav from '../components/nav.jsx'; | ||
|
|
||
| export const composer = ({context}, onData) => { | ||
| const {Meteor, Collections} = context(); | ||
|
|
||
| onData(null, {}); | ||
| }; | ||
|
|
||
| export const depsMapper = (context, actions) => ({ | ||
| context: () => context | ||
| }); | ||
|
|
||
| export default composeAll( | ||
| composeWithTracker(composer), | ||
| useDeps(depsMapper) | ||
| )(Nav); |
| @@ -0,0 +1,18 @@ | ||
| import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core'; | ||
|
|
||
| import Product from '../components/product.jsx'; | ||
|
|
||
| export const composer = ({context}, onData) => { | ||
| const {Meteor, Collections} = context(); | ||
|
|
||
| onData(null, {}); | ||
| }; | ||
|
|
||
| export const depsMapper = (context, actions) => ({ | ||
| context: () => context | ||
| }); | ||
|
|
||
| export default composeAll( | ||
| composeWithTracker(composer), | ||
| useDeps(depsMapper) | ||
| )(Product); |
| @@ -0,0 +1,18 @@ | ||
| import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core'; | ||
|
|
||
| import ProductList from '../components/product_list.jsx'; | ||
|
|
||
| export const composer = ({context}, onData) => { | ||
| const {Meteor, Collections} = context(); | ||
|
|
||
| onData(null, {}); | ||
| }; | ||
|
|
||
| export const depsMapper = (context, actions) => ({ | ||
| context: () => context | ||
| }); | ||
|
|
||
| export default composeAll( | ||
| composeWithTracker(composer), | ||
| useDeps(depsMapper) | ||
| )(ProductList); |
| @@ -0,0 +1,10 @@ | ||
| import actions from './actions'; | ||
| import routes from './routes.jsx'; | ||
|
|
||
| export default { | ||
| routes, | ||
| actions, | ||
| load(context) { | ||
|
|
||
| } | ||
| }; |
| @@ -0,0 +1,18 @@ | ||
| import React from 'react'; | ||
| import {mount} from 'react-mounter'; | ||
|
|
||
| import MainLayout from '/client/modules/core/components/main_layout.jsx' | ||
| import Home from './components/home.jsx' | ||
|
|
||
| export default function (injectDeps, {FlowRouter}) { | ||
| const MainLayoutCtx = injectDeps(MainLayout); | ||
|
|
||
| FlowRouter.route('/', { | ||
| name: 'main', | ||
| action() { | ||
| mount(MainLayoutCtx, { | ||
| content: () => (<Home />) | ||
| }); | ||
| } | ||
| }); | ||
| } |
| @@ -0,0 +1,2 @@ | ||
| export default { | ||
| }; |
| @@ -0,0 +1,16 @@ | ||
| import React from 'react' | ||
| import invariant from 'invariant' | ||
| import _ from 'lodash' | ||
|
|
||
| class BaseComponent extends React.Component { | ||
| bindHandlers(...handlers) { | ||
| handlers.map((handler) => { | ||
| invariant(this[handler], `cannot bind non-existant handler: ${handler}`) | ||
| invariant(_.isFunction(this[handler]), `cannot bind non-function handler: ${handler}`) | ||
|
|
||
| this[handler] = this[handler].bind(this) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| export default BaseComponent |
| @@ -0,0 +1,10 @@ | ||
| import actions from './actions'; | ||
| import routes from './routes.jsx'; | ||
|
|
||
| export default { | ||
| routes, | ||
| actions, | ||
| load(context) { | ||
|
|
||
| } | ||
| }; |
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import {mount} from 'react-mounter'; | ||
|
|
||
| import MainLayout from '/client/modules/core/components/main_layout.jsx'; | ||
|
|
||
| export default function (injectDeps, {FlowRouter}) { | ||
| const MainLayoutCtx = injectDeps(MainLayout); | ||
|
|
||
| // FlowRouter.route('', { | ||
| // name: '', | ||
| // action() { | ||
| // mount(MainLayoutCtx, { | ||
| // content: () => (< />) | ||
| // }); | ||
| // } | ||
| // }); | ||
| } |
| @@ -0,0 +1,2 @@ | ||
| $color-primary: $palette-blue-500 !default; | ||
| $color-primary-dark: $palette-blue-700 !default; |
| @@ -0,0 +1,9 @@ | ||
| import Products from './products'; | ||
| import Manufacturers from './manufacturers'; | ||
| import Vendors from './vendors'; | ||
|
|
||
| export { | ||
| Products, | ||
| Manufacturers, | ||
| Vendors | ||
| }; |
| @@ -0,0 +1,6 @@ | ||
| import {Mongo} from 'meteor/mongo'; | ||
|
|
||
|
|
||
| const Manufacturers = new Mongo.Collection('manufacturers'); | ||
|
|
||
| export default Manufacturers; |
| @@ -0,0 +1,6 @@ | ||
| import {Mongo} from 'meteor/mongo'; | ||
|
|
||
|
|
||
| const Products = new Mongo.Collection('products'); | ||
|
|
||
| export default Products; |
| @@ -0,0 +1,6 @@ | ||
| import {Mongo} from 'meteor/mongo'; | ||
|
|
||
|
|
||
| const Vendors = new Mongo.Collection('vendors'); | ||
|
|
||
| export default Vendors; |
| @@ -0,0 +1,50 @@ | ||
| { | ||
| "name": "arrow-react-toolbox", | ||
| "private": "true", | ||
| "version": "0.1.0", | ||
| "description": "arrow-react-toolbox", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "start": "meteor run" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/username/reponame.git" | ||
| }, | ||
| "author": "", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "eslint": "1.10.x", | ||
| "eslint-plugin-react": "3.15.x", | ||
| "invariant": "2.2.1", | ||
| "lodash": "4.10.0", | ||
| "mantra-core": "^1.5.0", | ||
| "meteor-node-stubs": "~0.2.0", | ||
| "normalize.css": "4.1.1", | ||
| "react": "^15.0.0", | ||
| "react-addons-css-transition-group": "15.0.1", | ||
| "react-dom": "^15.0.0", | ||
| "react-komposer": "^1.8.0", | ||
| "react-mounter": "^1.2.0", | ||
| "react-simple-di": "^1.2.0", | ||
| "react-toolbox": "^0.16.2" | ||
| }, | ||
| "cssModules": { | ||
| "extensions": [ | ||
| "scss" | ||
| ], | ||
| "globalVariables": [ | ||
| "node_modules/react-toolbox/lib/_colors.scss", | ||
| { | ||
| "theme-building": true | ||
| }, | ||
| "client/toolbox-theme.scss" | ||
| ], | ||
| "outputJsFilePath": { | ||
| ".*node_modules/.*": "{dirname}/{basename}.js" | ||
| }, | ||
| "explicitIncludes": [ | ||
| "node_modules/react-toolbox" | ||
| ] | ||
| } | ||
| } |
| @@ -0,0 +1,17 @@ | ||
| #### Toolchain | ||
|
|
||
| - Meteor 1.3 | ||
| - latest Mantra Architecture packages | ||
| - ESLint 2 | ||
| - React-Toolbox | ||
| - CSS Modules (nathantreid:css-modules) | ||
| - Flow Router | ||
| - Komposer | ||
| - Reactive-Dict | ||
| - Lodash | ||
| - Invariant | ||
|
|
||
| ##### Coming soon | ||
|
|
||
| - Test runner + framework | ||
| - Mantra Storybook (component sandbox) |
| @@ -0,0 +1,11 @@ | ||
| import Products from '/lib/collections/products'; | ||
|
|
||
| //export default function () { | ||
| if (!Products.findOne()) { | ||
| for (let lc = 1; lc <= 5; lc++) { | ||
| const name = `This is the product name: ${lc}`; | ||
| const vendor = `${lc}'s vendor`; | ||
| Products.insert({name, vendor}); | ||
| } | ||
| } | ||
| // } |
| @@ -0,0 +1,10 @@ | ||
| import publications from './publications'; | ||
|
|
||
| publications(); | ||
|
|
||
|
|
||
| // Be sure to import meteor methods | ||
|
|
||
| import methods from './methods' | ||
|
|
||
| methods() |
| @@ -0,0 +1,5 @@ | ||
| import products from './products'; | ||
|
|
||
| export default function () { | ||
| products(); | ||
| } |
| @@ -0,0 +1,20 @@ | ||
| import { Products } from '/lib/collections'; | ||
| import { Meteor } from 'meteor/meteor'; | ||
| import { check } from 'meteor/check'; | ||
|
|
||
| export default function () { | ||
| Meteor.methods({ | ||
| 'product.create'(name, vendor) { | ||
| const createdAt = new Date(); | ||
| const product = {name, vendor, createdAt}; | ||
| check(name, String) | ||
| check(vendor, String) | ||
|
|
||
| const insertProduct = Products.insert(product); | ||
|
|
||
| console.log(`Added ${name} to Products`) | ||
|
|
||
| return insertProduct | ||
| } | ||
| }); | ||
| } |
| @@ -0,0 +1,5 @@ | ||
| import products from './products'; | ||
|
|
||
| export default function () { | ||
| products(); | ||
| } |
| @@ -0,0 +1,9 @@ | ||
| import {Products} from '/lib/collections'; | ||
| import {Meteor} from 'meteor/meteor'; | ||
| import {check} from 'meteor/check'; | ||
|
|
||
| export default function () { | ||
| Meteor.publish('products', function (productsId) { | ||
| return Products.find(productsId); | ||
| }); | ||
| } |