Skip to content

Commit e29c6d9

Browse files
committed
Initial commit
0 parents  commit e29c6d9

30 files changed

+1642
-0
lines changed

.babelrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"targets": {
7+
"browsers": [
8+
"last 2 versions"
9+
]
10+
}
11+
}
12+
]
13+
],
14+
"plugins": [
15+
"transform-vue-jsx",
16+
"transform-object-rest-spread"
17+
],
18+
"env": {
19+
"test": {
20+
"plugins": [
21+
"istanbul"
22+
]
23+
}
24+
}
25+
}

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/*.js

.eslintrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
root: true,
3+
parser: 'babel-eslint',
4+
parserOptions: {
5+
sourceType: 'module'
6+
},
7+
extends: 'vue',
8+
// add your custom rules here
9+
'rules': {
10+
// allow async-await
11+
'generator-star-spacing': 0,
12+
// allow debugger during development
13+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
14+
},
15+
globals: {
16+
requestAnimationFrame: true,
17+
performance: true
18+
}
19+
}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
node_modules/
3+
npm-debug.log
4+
test/coverage
5+
dist
6+
yarn-error.log
7+
reports

.stylelintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"processors": ["stylelint-processor-html"],
3+
"extends": "stylelint-config-standard",
4+
"rules": {
5+
"no-empty-source": null
6+
}
7+
}

CONTRIBUTING.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
We accept contributions via Pull Requests on [Github](https://github.com/havban/vue-rangedate-picker).
6+
7+
8+
## Pull Requests
9+
10+
- **Keep the same style** - eslint will automatically be ran before committing
11+
12+
- **Tip** to pass lint tests easier use the `npm run lint:fix` command
13+
14+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
15+
16+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
17+
18+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
19+
20+
- **Create feature branches** - Don't ask us to pull from your master branch.
21+
22+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
23+
24+
- **Send coherent history** - Make sure your commits message means something
25+
26+
27+
## Running Tests
28+
29+
Launch visual tests and watch the components at the same time
30+
31+
``` bash
32+
$ npm run dev
33+
```
34+
35+
36+
**Happy coding**!

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 hidayat.febiansyah
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# VueRangedatePicker
2+
3+
[![npm](https://img.shields.io/npm/v/vue-rangedate-picker.svg)](https://www.npmjs.com/package/vue-rangedate-picker) [![vue2](https://img.shields.io/badge/vue-2.x-brightgreen.svg)](https://vuejs.org/)
4+
5+
> Date picker with range selection
6+
7+
## Installation
8+
9+
```bash
10+
npm install --save vue-rangedate-picker
11+
```
12+
13+
## Usage
14+
15+
### Bundler (Webpack, Rollup)
16+
17+
```js
18+
import Vue from 'vue'
19+
import VueRangedatePicker from 'vue-rangedate-picker'
20+
// You need a specific loader for CSS files like https://github.com/webpack/css-loader
21+
import 'vue-rangedate-picker/dist/vue-rangedate-picker.css'
22+
23+
Vue.use(VueRangedatePicker)
24+
```
25+
26+
### Browser
27+
28+
```html
29+
<!-- Include after Vue -->
30+
<!-- Local files -->
31+
<link rel="stylesheet" href="vue-rangedate-picker/dist/vue-rangedate-picker.css"></link>
32+
<script src="vue-rangedate-picker/dist/vue-rangedate-picker.js"></script>
33+
34+
<!-- From CDN -->
35+
<link rel="stylesheet" href="https://unpkg.com/vue-rangedate-picker/dist/vue-rangedate-picker.css"></link>
36+
<script src="https://unpkg.com/vue-rangedate-picker"></script>
37+
```
38+
39+
## Development
40+
41+
### Launch visual tests
42+
43+
```bash
44+
npm run dev
45+
```
46+
47+
### Launch Karma with coverage
48+
49+
```bash
50+
npm run dev:coverage
51+
```
52+
53+
### Build
54+
55+
Bundle the js and css of to the `dist` folder:
56+
57+
```bash
58+
npm run build
59+
```
60+
61+
62+
## Publishing
63+
64+
The `prepublish` hook will ensure dist files are created before publishing. This
65+
way you don't need to commit them in your repository.
66+
67+
```bash
68+
# Bump the version first
69+
# It'll also commit it and create a tag
70+
npm version
71+
# Push the bumped package and tags
72+
git push --follow-tags
73+
# Ship it 🚀
74+
npm publish
75+
```
76+
77+
## License
78+
79+
[MIT](http://opensource.org/licenses/MIT)

build/build.js

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
const mkdirp = require('mkdirp')
2+
const rollup = require('rollup').rollup
3+
const vue = require('rollup-plugin-vue')
4+
const jsx = require('rollup-plugin-jsx')
5+
const buble = require('rollup-plugin-buble')
6+
const replace = require('rollup-plugin-replace')
7+
const cjs = require('rollup-plugin-commonjs')
8+
const node = require('rollup-plugin-node-resolve')
9+
const sass = require('rollup-plugin-sass')
10+
const uglify = require('uglify-js')
11+
const CleanCSS = require('clean-css')
12+
13+
// Make sure dist dir exists
14+
mkdirp('dist')
15+
16+
const {
17+
logError,
18+
write,
19+
banner,
20+
name,
21+
moduleName,
22+
version,
23+
processStyle
24+
} = require('./utils')
25+
26+
function rollupBundle ({ env }) {
27+
return rollup({
28+
entry: 'src/index.js',
29+
plugins: [
30+
node({
31+
extensions: ['.js', '.jsx', '.vue']
32+
}),
33+
cjs(),
34+
vue({
35+
compileTemplate: true,
36+
css (styles, stylesNodes) {
37+
// Only generate the styles once
38+
if (env['process.env.NODE_ENV'] === '"production"') {
39+
Promise.all(
40+
stylesNodes.map(processStyle)
41+
).then(css => {
42+
const result = css.map(c => c.css).join('')
43+
// write the css for every component
44+
// TODO add it back if we extract all components to individual js
45+
// files too
46+
// css.forEach(writeCss)
47+
write(`dist/${name}.css`, result)
48+
write(`dist/${name}.min.css`, new CleanCSS().minify(result).styles)
49+
}).catch(logError)
50+
}
51+
}
52+
}),
53+
jsx({ factory: 'h' }),
54+
replace(Object.assign({
55+
__VERSION__: version
56+
}, env)),
57+
buble({
58+
objectAssign: 'Object.assign'
59+
}),
60+
sass()
61+
]
62+
})
63+
}
64+
65+
const bundleOptions = {
66+
banner,
67+
exports: 'named',
68+
format: 'umd',
69+
moduleName
70+
}
71+
72+
function createBundle ({ name, env, format }) {
73+
return rollupBundle({
74+
env
75+
}).then(function (bundle) {
76+
const options = Object.assign({}, bundleOptions)
77+
if (format) options.format = format
78+
const code = bundle.generate(options).code
79+
if (/min$/.test(name)) {
80+
const minified = uglify.minify(code, {
81+
output: {
82+
preamble: banner,
83+
ascii_only: true // eslint-disable-line camelcase
84+
}
85+
}).code
86+
return write(`dist/${name}.js`, minified)
87+
} else {
88+
return write(`dist/${name}.js`, code)
89+
}
90+
}).catch(logError)
91+
}
92+
93+
// Browser bundle (can be used with script)
94+
createBundle({
95+
name: `${name}`,
96+
env: {
97+
'process.env.NODE_ENV': '"development"'
98+
}
99+
})
100+
101+
// Commonjs bundle (preserves process.env.NODE_ENV) so
102+
// the user can replace it in dev and prod mode
103+
createBundle({
104+
name: `${name}.common`,
105+
env: {},
106+
format: 'cjs'
107+
})
108+
109+
// uses export and import syntax. Should be used with modern bundlers
110+
// like rollup and webpack 2
111+
createBundle({
112+
name: `${name}.esm`,
113+
env: {},
114+
format: 'es'
115+
})
116+
117+
// Minified version for browser
118+
createBundle({
119+
name: `${name}.min`,
120+
env: {
121+
'process.env.NODE_ENV': '"production"'
122+
}
123+
})

0 commit comments

Comments
 (0)