Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrutjes committed Mar 14, 2017
0 parents commit 8f630c2
Show file tree
Hide file tree
Showing 76 changed files with 3,041 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
packages/*/dist
packages/*/yarn-error.log
packages/vue
lerna-debug.log
npm-debug.log
node_modules
yarn.lock
26 changes: 26 additions & 0 deletions COMPONENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Component
---------

In this document, a few rules / guidelines to ensure maximum consistency & re-usability for custom components.

## Styles and Classes

* Prefix your classes with a short (max 4 chars) vendor name. We use `alg`, please use another one.
* Do not use [`scoped`](https://vue-loader.vuejs.org/en/features/scoped-css.html) styles, it makes it very hard to override them.
* Use [BEM notation](http://getbem.com/introduction/) with only one depth level.
* Unless you are trying to ship a very opinionated styled component, just add styles for the elements that helps understanding the behaviour. i.e. for a pagination component, you will want to put in bold the current page.

## Component good practices

* Use the `vue-algolia-component` mixin. This will make sure your component can resolve the `searchStore` if not provided. It ensures the `searchStore` prop is available in your component at any time.
* If you need mutate the `searchStore` multiple times, please use `searchStore.stop()` and `searchStore.start()`, so that other components don't update their rendering on every intermediary state mutation.
* Make sure that when the component is mounted, you catch up with the `searchStore`. You can optionally mutate the state of the `searchStore` at this stage.
* When a component is `unmounted` or `destroyed`, make sure that you leave the `searchStore` in a state that does not include things you might have added (facets / filters / etc.).
* Make sure your component gracefully handles any state of the `searchStore`.
* Suffix all faceting components with `Facet`

## Export UMD + ES2015

* Export your component as UMD and make the `.vue` file the default entry point.
* If you have more things you'd like to export (i.e. if you decide to break down your component in several mixins and you want to expose those), the please also provide users with an ES2015 build so that they can leverage tree shaking.

19 changes: 19 additions & 0 deletions build/rollup.cjs.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import vue from 'rollup-plugin-vue';
import buble from 'rollup-plugin-buble';
import filesize from 'rollup-plugin-filesize';
import fs from 'fs';
const pkg = JSON.parse(fs.readFileSync('package.json'));
const dependencies = Object.keys(pkg.dependencies || []);

export default {
entry: 'src/index.js',
external: dependencies,
plugins: [
vue({compileTemplate: true, css: false}),
buble(),
filesize()
],
targets: [
{ dest: `dist/${pkg.name}.common.js`, format: 'cjs' },
]
};
19 changes: 19 additions & 0 deletions build/rollup.es.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import vue from 'rollup-plugin-vue';
import buble from 'rollup-plugin-buble';
import filesize from 'rollup-plugin-filesize';
import fs from 'fs';
const pkg = JSON.parse(fs.readFileSync('package.json'));
const dependencies = Object.keys(pkg.dependencies || []);

export default {
entry: 'src/index.js',
external: dependencies,
plugins: [
vue({compileTemplate: true, css: false}),
buble(),
filesize()
],
targets: [
{ dest: `dist/${pkg.name}.esm.js`, format: 'es' },
]
};
36 changes: 36 additions & 0 deletions build/rollup.umd.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import vue from 'rollup-plugin-vue';
import buble from 'rollup-plugin-buble';
import filesize from 'rollup-plugin-filesize';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import replace from 'rollup-plugin-replace';
import camelize from 'camelize';
import fs from 'fs';
const pkg = JSON.parse(fs.readFileSync('package.json'));
let moduleName = camelize(pkg.name);
moduleName = moduleName.charAt(0).toUpperCase() + moduleName.slice(1);

export default {
entry: 'src/index.js',
moduleName: moduleName,
plugins: [
vue({compileTemplate: true, css: false}),
resolve({
browser: true,
preferBuiltins: false
}),
buble(),
commonjs(),
replace({
'process.env': JSON.stringify({
'NODE_ENV': 'production'
})
}),
uglify(),
filesize()
],
targets: [
{ dest: `dist/${pkg.name}.js`, format: 'umd' },
]
};
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"lerna": "2.0.0-beta.38",
"packages": [
"packages/*"
],
"npmClient": "yarn",
"version": "0.0.0"
}
24 changes: 24 additions & 0 deletions packages/algolia-search-store/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "algolia-search-store",
"version": "0.0.0",
"files": [
"dist"
],
"main": "dist/algolia-search-store.common.js",
"module": "dist/algolia-search-store.esm.js",
"jsnext:main": "dist/algolia-search-store.esm.js",
"unpkg": "dist/algolia-search-store.js",
"scripts": {
"build": "yarn build-umd && yarn build-es && yarn build-cjs",
"build-umd": "rollup -c ../../build/rollup.umd.config.js",
"build-es": "rollup -c ../../build/rollup.es.config.js",
"build-cjs": "rollup -c ../../build/rollup.cjs.config.js"
},
"dependencies": {
"algoliasearch": "^3.18.1",
"algoliasearch-helper": "^2.14.0"
},
"peerDependencies": {
"vue": "^2.2.2"
}
}
Loading

0 comments on commit 8f630c2

Please sign in to comment.